use of io.gravitee.rest.api.model.notification.NotificationTemplateEntity in project gravitee-management-rest-api by gravitee-io.
the class NotificationTemplateServiceImpl method loadEmailNotificationTemplateFromHook.
private NotificationTemplateEntity loadEmailNotificationTemplateFromHook(Hook hook) {
String templateName = hook.getTemplate() + "." + io.gravitee.rest.api.model.notification.NotificationTemplateType.EMAIL.name();
final EmailTemplate emailTemplate = EmailTemplate.fromHook(hook);
if (emailTemplate != null) {
File emailTemplateFile = new File(templatesPath + "/" + emailTemplate.getHtmlTemplate());
try {
String title = (emailTemplate == null ? "unused title" : emailTemplate.getSubject());
String content = new String(Files.readAllBytes(emailTemplateFile.toPath()));
return new NotificationTemplateEntity(hook.name(), hook.getScope().name(), templateName, hook.getLabel(), hook.getDescription(), title, content, io.gravitee.rest.api.model.notification.NotificationTemplateType.EMAIL);
} catch (IOException e) {
LOGGER.warn("Problem while getting freemarker template {} from file : {}", hook.getTemplate(), e.getMessage());
}
}
return null;
}
Aggregations