Class FreemarkerUtils

java.lang.Object
com.vdoc.sdk.commons.freemarker.FreemarkerUtils

public class FreemarkerUtils extends Object
Freemarker utility class Created by famaridon on 12/08/2015.
  • Method Details

    • getTemplateContent

      public static String getTemplateContent(String relativePath, String template, Map<String,Object> parameters) throws IOException, freemarker.template.TemplateException
      Get template content
      Parameters:
      relativePath - relative folder path (relative to /custom/)
      template - the .flt file name
      parameters - all template input param
      Returns:
      the freemarker result
      Throws:
      IOException - on error
      freemarker.template.TemplateException - on error
    • getTemplateContent

      public static String getTemplateContent(String relativePath, String template, freemarker.template.ObjectWrapper objectWrapper, Map<String,Object> parameters) throws IOException, freemarker.template.TemplateException
      Get template content
      Parameters:
      relativePath - relative folder path (relative to /custom/)
      template - the .flt file name
      objectWrapper - you can use it to customize the default object wrapper.
      parameters - all template input param
      Returns:
      the freemarker result
      Throws:
      IOException - on error
      freemarker.template.TemplateException - on error
    • evaluateHtmlMessage

      public static jakarta.mail.internet.MimeMessage evaluateHtmlMessage(String subject, String templateName, Map<String,Object> parameters) throws IOException, freemarker.template.TemplateException, jakarta.mail.MessagingException
      Build a MimeMessage :
      • body is build with freemarker template and parameters
      • FROM field is set with the server configuration.
      • mime type is set to text/html
      Parameters:
      subject - the mail subject
      templateName - the .ftl file name under the '/custom/configuration/freemarker/mail/ folder.
      parameters - freemarker data.
      Returns:
      the completed mime message
      Throws:
      IOException - if the .ftl can't be read
      freemarker.template.TemplateException - if the .ftl contain error
      jakarta.mail.MessagingException - on error
      jakarta.mail.internet.AddressException - on error
    • evaluateMessage

      public static jakarta.mail.internet.MimeMessage evaluateMessage(String subject, String templateName, String mimeType, Map<String,Object> parameters) throws IOException, freemarker.template.TemplateException, jakarta.mail.MessagingException
      Build a MimeMessage :
      • body is build with freemarker template and parameters
      • FROM field is set with the server configuration.
      Parameters:
      subject - the mail subject
      templateName - the .ftl file name under the '/custom/configuration/freemarker/mail/' folder.
      mimeType - the mime type
      parameters - freemarker data.
      Returns:
      the completed mime message
      Throws:
      IOException - if the .ftl can't be read
      freemarker.template.TemplateException - if the .ftl contain error
      jakarta.mail.MessagingException - on error
      jakarta.mail.internet.AddressException - on error