recipientEmails.add(email);
recipientTOs.add(userDataBinder.getUserTO(recipient));
}
}
NotificationTask task = new NotificationTask();
task.setTraceLevel(notification.getTraceLevel());
task.setRecipients(recipientEmails);
task.setSender(notification.getSender());
task.setSubject(notification.getSubject());
final Map<String, Object> model = new HashMap<String, Object>();
model.put("user", userDataBinder.getUserTO(user));
model.put("syncopeConf", this.findAllSyncopeConfs());
model.put("recipients", recipientTOs);
model.put("events", notification.getEvents());
String htmlBody;
String textBody;
try {
htmlBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
+ notification.getTemplate() + ".html.vm", SyncopeConstants.DEFAULT_ENCODING, model);
textBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
+ notification.getTemplate() + ".txt.vm", SyncopeConstants.DEFAULT_ENCODING, model);
} catch (VelocityException e) {
LOG.error("Could not get mail body", e);
htmlBody = "";
textBody = "";
}
task.setTextBody(textBody);
task.setHtmlBody(htmlBody);
return task;
}