Package com.vdoc.sdk.commons.freemarker
Class FreemarkerUtils
java.lang.Object
com.vdoc.sdk.commons.freemarker.FreemarkerUtils
Freemarker utility class
Created by famaridon on 12/08/2015.
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.mail.internet.MimeMessageBuild aMimeMessage: body is build with freemarker template and parameters FROM field is set with the server configuration. mime type is set to text/htmlstatic jakarta.mail.internet.MimeMessageevaluateMessage(String subject, String templateName, String mimeType, Map<String, Object> parameters) Build aMimeMessage: body is build with freemarker template and parameters FROM field is set with the server configuration.static StringgetTemplateContent(String relativePath, String template, freemarker.template.ObjectWrapper objectWrapper, Map<String, Object> parameters) Get template contentstatic StringGet template content
-
Method Details
-
getTemplateContent
public static String getTemplateContent(String relativePath, String template, Map<String, Object> parameters) throws IOException, freemarker.template.TemplateExceptionGet template content- Parameters:
relativePath- relative folder path (relative to /custom/)template- the .flt file nameparameters- all template input param- Returns:
- the freemarker result
- Throws:
IOException- on errorfreemarker.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.TemplateExceptionGet template content- Parameters:
relativePath- relative folder path (relative to /custom/)template- the .flt file nameobjectWrapper- you can use it to customize the default object wrapper.parameters- all template input param- Returns:
- the freemarker result
- Throws:
IOException- on errorfreemarker.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.MessagingExceptionBuild aMimeMessage:- 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 subjecttemplateName- 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 readfreemarker.template.TemplateException- if the .ftl contain errorjakarta.mail.MessagingException- on errorjakarta.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.MessagingExceptionBuild aMimeMessage:- body is build with freemarker template and parameters
- FROM field is set with the server configuration.
- Parameters:
subject- the mail subjecttemplateName- the .ftl file name under the '/custom/configuration/freemarker/mail/' folder.mimeType- the mime typeparameters- freemarker data.- Returns:
- the completed mime message
- Throws:
IOException- if the .ftl can't be readfreemarker.template.TemplateException- if the .ftl contain errorjakarta.mail.MessagingException- on errorjakarta.mail.internet.AddressException- on error
-