Search in sources :

Example 1 with EmailTarget

use of com.blackducksoftware.integration.hub.alert.channel.email.template.EmailTarget in project hub-alert by blackducksoftware.

the class EmailGroupChannel method sendMessage.

public void sendMessage(final List<String> emailAddresses, final EmailGroupEvent event, final String subjectLine) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, MessagingException, IOException, TemplateException {
    final EmailProperties emailProperties = new EmailProperties(getGlobalConfigEntity());
    final EmailMessagingService emailService = new EmailMessagingService(emailProperties);
    final ProjectData data = event.getProjectData();
    final HashMap<String, Object> model = new HashMap<>();
    model.put(EmailProperties.TEMPLATE_KEY_SUBJECT_LINE, subjectLine);
    model.put(EmailProperties.TEMPLATE_KEY_EMAIL_CATEGORY, data.getDigestType().getDisplayName());
    model.put(EmailProperties.TEMPLATE_KEY_HUB_SERVER_URL, StringUtils.trimToEmpty(globalProperties.getHubUrl()));
    model.put(EmailProperties.TEMPLATE_KEY_TOPIC, data);
    model.put(EmailProperties.TEMPLATE_KEY_START_DATE, String.valueOf(System.currentTimeMillis()));
    model.put(EmailProperties.TEMPLATE_KEY_END_DATE, String.valueOf(System.currentTimeMillis()));
    for (final String emailAddress : emailAddresses) {
        final EmailTarget emailTarget = new EmailTarget(emailAddress, "digest.ftl", model);
        emailService.sendEmailMessage(emailTarget);
    }
}
Also used : HashMap(java.util.HashMap) EmailTarget(com.blackducksoftware.integration.hub.alert.channel.email.template.EmailTarget) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)

Aggregations

EmailTarget (com.blackducksoftware.integration.hub.alert.channel.email.template.EmailTarget)1 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)1 HashMap (java.util.HashMap)1