Search in sources :

Example 1 with ChannelFreemarkerTemplatingService

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);
    }
}
Also used : HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) ChannelFreemarkerTemplatingService(com.blackducksoftware.integration.hub.alert.channel.ChannelFreemarkerTemplatingService) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException)

Aggregations

ChannelFreemarkerTemplatingService (com.blackducksoftware.integration.hub.alert.channel.ChannelFreemarkerTemplatingService)1 JsonObject (com.google.gson.JsonObject)1 TemplateException (freemarker.template.TemplateException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1