use of com.blackducksoftware.integration.hub.alert.channel.ChannelFreemarkerTemplatingService in project hub-alert by blackducksoftware.
the class HipChatChannel method createHtmlMessage.
private String createHtmlMessage(final ProjectData projectData) {
try {
final String templatesDirectory = System.getenv("ALERT_TEMPLATES_DIR");
String templateDirectoryPath;
if (StringUtils.isNotBlank(templatesDirectory)) {
templateDirectoryPath = templatesDirectory + "/hipchat";
} else {
templateDirectoryPath = System.getProperties().getProperty("user.dir") + "/src/main/resources/hipchat/templates";
}
final ChannelFreemarkerTemplatingService freemarkerTemplatingService = new ChannelFreemarkerTemplatingService(templateDirectoryPath);
final HashMap<String, Object> model = new HashMap<>();
model.put("projectName", projectData.getProjectName());
model.put("projectVersion", projectData.getProjectVersion());
model.put("categoryMap", projectData.getCategoryMap());
return freemarkerTemplatingService.getResolvedTemplate(model, "notification.ftl");
} catch (final IOException | TemplateException e) {
throw new RuntimeException(e);
}
}
Aggregations