Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.util
Class EmailTemplateUtil

java.lang.Object
  extended by com.jivesoftware.base.util.EmailTemplateUtil

public final class EmailTemplateUtil
extends java.lang.Object

Used for doing transformations on email template content, and storing customized versions of email templates.

XML Configuration files must be in the file format

      <email-templates>
          <template name="" country="" language="">
              <![CDATA[template content]]>
          </template>
      </email-templates>
 

Since:
5.0

Method Summary
static void addConfiguration(java.io.Reader reader)
          Adds an additional *-email-templates.xml configuration file to this class.
static java.lang.String applyFreemarkerTemplate(java.util.Map properties, java.lang.String templateName, java.util.Locale locale)
          Assumes that the template is a freemarker template and applies a freemarker transformation to it.
static java.lang.String applyFreemarkerTemplateSrc(java.util.Map properties, java.lang.String templateSrc)
          Assumes that the template is a freemarker template and applies a freemarker transformation to it.
static void deleteCustomEmailTemplate(java.lang.String templateName, java.util.Locale locale)
          Deletes a customized template
static void destroy()
          Removes all template content
static java.lang.String getEmailTemplate(java.lang.String templateName, java.util.Locale locale)
          Get the raw email template source for a specific template templateName.
static java.util.List getEmailTemplateLocales(java.lang.String templateName)
          Returns a list of locales for the given template name.
static java.lang.String getHtmlEscapedEmailTemplate(java.lang.String templateName, java.util.Locale locale)
          Returns an HTML escaped template String.
static void setEmailTemplate(java.lang.String templateName, java.lang.String templateSource, java.util.Locale locale)
          This method can be used to override the default source for a template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addConfiguration

public static void addConfiguration(java.io.Reader reader)
Adds an additional *-email-templates.xml configuration file to this class. This is generally used for things like integrated where you will be loading templates from various products.

Parameters:
reader - Reader for an email template xml file

destroy

public static void destroy()
Removes all template content


applyFreemarkerTemplate

public static java.lang.String applyFreemarkerTemplate(java.util.Map properties,
                                                       java.lang.String templateName,
                                                       java.util.Locale locale)
Assumes that the template is a freemarker template and applies a freemarker transformation to it.

Parameters:
properties - Used for the freemarker context
templateName - Name of the template (from properties)
locale - Used to choose which language of template to use
Returns:
the transformed content

applyFreemarkerTemplateSrc

public static java.lang.String applyFreemarkerTemplateSrc(java.util.Map properties,
                                                          java.lang.String templateSrc)
Assumes that the template is a freemarker template and applies a freemarker transformation to it.

Parameters:
properties - Used for the freemarker context
templateSrc - Freemarker template source
Returns:
the transformed content

getEmailTemplate

public static java.lang.String getEmailTemplate(java.lang.String templateName,
                                                java.util.Locale locale)
Get the raw email template source for a specific template templateName. This method will first check to see if a template has been overriden with JiveGlobals using JiveGlobals.getLocalizedJiveProperty(String, java.util.Locale). If no overriden version is found then the default template will be pulled from the XML content added to this class via addConfiguration(java.io.Reader).

Parameters:
templateName - The email template templateName
locale - Which localized version of the email template to grab
Returns:
The string source of the email template

getHtmlEscapedEmailTemplate

public static java.lang.String getHtmlEscapedEmailTemplate(java.lang.String templateName,
                                                           java.util.Locale locale)
Returns an HTML escaped template String. Escapes the template returned from getEmailTemplate(String, Locale).

Parameters:
templateName - The email template templateName
locale - Which localized version of the email template to grab
Returns:
The HTML escaped string source of the email template

setEmailTemplate

public static void setEmailTemplate(java.lang.String templateName,
                                    java.lang.String templateSource,
                                    java.util.Locale locale)
This method can be used to override the default source for a template. This method will use JiveGlobals.setLocalizedJiveProperty(String, String, java.util.Locale) to set the template source inside the jive properties. If null is passed in for a templateSource value then the jive property for the template source will be deleted and the default template source will be used.

Parameters:
templateName - The name of the template
templateSource - source of the template to override
locale - which locale version of the source to override

deleteCustomEmailTemplate

public static void deleteCustomEmailTemplate(java.lang.String templateName,
                                             java.util.Locale locale)
Deletes a customized template

Parameters:
templateName - The name of the template to delete
locale - which locale to delete the template for

getEmailTemplateLocales

public static java.util.List getEmailTemplateLocales(java.lang.String templateName)
Returns a list of locales for the given template name. This can be used to list currently installed locales for a given template. This method returns an empty list if no templates are found.

Parameters:
templateName - the name of the template.
Returns:
a list of locales for the given template name or an empty list of none exist.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.