Friday 23 March 2018

OIM API - Code Snippet to Read OIM Notification Template Data.

public void getTemplateDataFromOIM(String templateName)
                            throws TemplateNotFoundException, MultipleTemplateException,
                            NotificationManagementException {
        final String logp = CN + " :: getTemplateDataFromOIM() - ";
        logger.log(Level.INFO, logp + "START");
        String subject = "";
        String body = "";
                  
        //get notification service
        NotificationService notificationService = Platform.getService(NotificationService.class);
       
        Locale defaultLocale = Locale.getDefault();
        NotificationTemplate temp = notificationService.lookupTemplate(templateName, defaultLocale);

        if (temp == null) {
            logger.severe(logp + "Template name not found : " + templateName);
            return;
        }

        subject = temp.getLocaltemplateCollection().get(defaultLocale.toString()).getSubject();
        logger.info(logp + "Email Subject is : " + subject);

        body = temp.getLocaltemplateCollection().get(defaultLocale.toString()).getLongmessage();
        logger.info(logp + "Email body is : " + body);

        logger.log(Level.INFO,logp + "END");
 }


Happy Learning!!!

No comments:

Post a Comment