Class EmailHelper


  • public class EmailHelper
    extends java.lang.Object
    A helper class to provide email template related utility functions.
    Since:
    5.2.1
    Author:
    Jamal Kaabi-Mofrad
    • Constructor Detail

      • EmailHelper

        public EmailHelper()
    • Method Detail

      • setServiceRegistry

        public void setServiceRegistry​(ServiceRegistry serviceRegistry)
      • setPreferenceService

        public void setPreferenceService​(PreferenceService preferenceService)
      • setRepositoryHelper

        public void setRepositoryHelper​(Repository repositoryHelper)
      • setTemplateLoader

        public void setTemplateLoader​(freemarker.cache.TemplateLoader templateLoader)
      • setCompanyHomeChildName

        public void setCompanyHomeChildName​(java.lang.String companyHomeChildName)
      • init

        public void init()
      • getEmailTemplate

        public java.lang.String getEmailTemplate​(java.lang.String clientName,
                                                 java.lang.String emailTemplatePath,
                                                 java.lang.String fallbackTemplatePath)
        Gets the email template path or the given fallback template path.
        Parameters:
        clientName - optional client app name (used only for logging)
        emailTemplatePath - the email template xpath or class path
        fallbackTemplatePath - the fallback template
        Returns:
        • If emailTemplatePath is empty the fallback template is returned.
        • if the given emailTemplatePath is an xpath (i.e. starts with app:company_home), then an xpath search will be performed to find the NodeRef. If no nodeRef is found, the fallback template is returned.
        • If emailTemplatePath is a nodeRef and the node does not exist, the fallback template is returned, otherwise a string representation of the NodeRef is returned.
        • if emailTemplatePath is a class path which results in a template being found, then the emailTemplatePath is returned; otherwise, the fallback template is returned.
      • getLocalizedEmailTemplateNodeRef

        public org.alfresco.service.cmr.repository.NodeRef getLocalizedEmailTemplateNodeRef​(java.lang.String emailTemplateXPath)
        Gets the localized email template nodeRef.
        Parameters:
        emailTemplateXPath - the xpath of the template
        Returns:
        NodeRef of the localized template or null if no node is found
      • getUserLocaleOrDefault

        public java.util.Locale getUserLocaleOrDefault​(java.lang.String userId)
        Gets the user's locale.
        Parameters:
        userId - the user id
        Returns:
        the default locale or the user's preferred locale, if available