@Override
protected void fillRecipients(Execution execution, Message email) throws MessagingException {
try {
ExecutionImpl exe = (ExecutionImpl) execution;
SortedSet<String> emails = new TreeSet<String>();
AddressTemplate addressTemplate = getTemplate().getTo();
String s = "";
if (addressTemplate != null) {
s = addressTemplate.getUsers();
if (!"".equals(s)) {
if ("assignable".equals(s)) {
emails.addAll(getAssignables(exe, s));
} else {
emails.add(evaluateExpression(execution, s));
}
for (String m : emails) {
if (m != null && !"".equals(m)) {
try {
InternetAddress address = new InternetAddress(m);
address.validate();
email.addRecipient(Message.RecipientType.TO, address);
} catch (MessagingException e) {
logger.debug(e.getMessage(), e);
}
}
}
emails.clear();
}
}
if (!"".equals(s)) {
addressTemplate = getTemplate().getCc();
if (addressTemplate != null) {
s = addressTemplate.getUsers();
if ("assignable".equals(s)) {
emails.addAll(getAssignables(exe, s));
} else {
emails.add(evaluateExpression(execution, s));
}
for (String m : emails) {
if (m != null && !"".equals(m)) {
try {
InternetAddress address = new InternetAddress(m);
address.validate();
email.addRecipient(Message.RecipientType.CC, address);
} catch (MessagingException e) {
logger.debug(e.getMessage(), e);
}
}
}
}
addressTemplate = getTemplate().getBcc();
if (addressTemplate != null) {
s = addressTemplate.getUsers();
if ("assignable".equals(s)) {
emails.addAll(getAssignables(exe, s));
} else {
emails.add(evaluateExpression(execution, s));
}