MessageRecipients bccList,
MessageRecipient replyTo)
throws MessageException {
if (toList == null && ccList == null && bccList == null) {
throw new MessageException(
localizer.format("recipient-lists-null-invalid"));
}
MessageRecipientsStatusContainer container;
MessageRecipients failures = new MessageRecipients();
MessageRecipients recipients = new MessageRecipients();
// We need to build one big recipient list with the correct
// RecipientType
try {
if (toList != null) {
container = validateRecipients(toList,
RecipientInternals.TO_RECIPIENT);
RecipientInternals.addRecipients(recipients,
container.getSuccesses());
RecipientInternals.addRecipients(failures,
container.getFailures());
}
if (ccList != null) {
container = validateRecipients(ccList,
RecipientInternals.CC_RECIPIENT);
RecipientInternals.addRecipients(recipients,
container.getSuccesses());
RecipientInternals.addRecipients(failures,
container.getFailures());
}
if (bccList != null) {
container = validateRecipients(bccList,
RecipientInternals.BCC_RECIPIENT);
RecipientInternals.addRecipients(recipients,
container.getSuccesses());
RecipientInternals.addRecipients(failures,
container.getFailures());
}
} catch (RecipientException e) {
throw new MessageException(e);
}
MessageRecipients sendFailures =
sendToChannelAdapters(message, recipients, replyTo);
try {
if (sendFailures != null) {
RecipientInternals.addRecipients(failures, sendFailures);
}
} catch (RecipientException e) {
throw new MessageException(e);
}
return failures;
}