TextTemplate textTemplate;
try {
textTemplate = textTemplateFactory.getTemplate(name, locale);
} catch (TextTemplateException e) {
throw new SystemIntegrityException("Template [" + name + "] is not found", e);
}
// Prepare model
Map<String, Object> model = ImmutableMap.<String, Object>builder()
.put("locale", locale)
.put("timezone", timezone)
.putAll(attributes)
.build();
// Render template
String text;
try {
text = textTemplate.render(model);
} catch (TextTemplateException e) {
throw new SystemIntegrityException("Template [" + name + "] could not be rendered", e);
}
// Load subject
String defaultSubject = messageSourceAccessor.getMessage("mail.subject.default",
null, DEFAULT_SUBJECT, locale);