//Make sure all the objects are MailAddress objects
verifyMailAddresses(recipients);
}
} catch (MessagingException me) {
// look in the matcher's mailet's init attributes
MailetConfig mailetConfig = ((Mailet) mailets.get(i)).getMailetConfig();
String onMatchException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMatchException");
if (onMatchException == null) {
onMatchException = Mail.ERROR;
} else {
onMatchException = onMatchException.trim().toLowerCase(Locale.US);
}
if (onMatchException.compareTo("nomatch") == 0) {
//In case the matcher returned null, create an empty Collection
recipients = new ArrayList(0);
} else if (onMatchException.compareTo("matchall") == 0) {
recipients = mail.getRecipients();
// no need to verify addresses
} else {
handleException(me, mail, matcher.getMatcherConfig().getMatcherName(), onMatchException);
}
}
// Split the recipients into two pools. notRecipients will contain the
// recipients on the message that the matcher did not return.
Collection notRecipients;
if (recipients == mail.getRecipients() || recipients.size() == 0) {
notRecipients = new ArrayList(0);
} else {
notRecipients = new ArrayList(mail.getRecipients());
notRecipients.removeAll(recipients);
}
if (recipients.size() == 0) {
//Everything was not a match... store it in the next spot in the array
unprocessed[i + 1].add(mail);
continue;
}
if (notRecipients.size() != 0) {
// There are a mix of recipients and not recipients.
// We need to clone this message, put the notRecipients on the clone
// and store it in the next spot
Mail notMail = new MailImpl(mail,newName(mail));
notMail.setRecipients(notRecipients);
// set the state to the current processor
notMail.setState(originalState);
unprocessed[i + 1].add(notMail);
//We have to set the reduce possible recipients on the old message
mail.setRecipients(recipients);
}
// We have messages that need to process... time to run the mailet.
Mailet mailet = (Mailet) mailets.get(i);
if (getLogger().isDebugEnabled()) {
logMessageBuffer =
new StringBuffer(128)
.append("Servicing ")
.append(mail.getName())
.append(" by ")
.append(mailet.getMailetInfo());
getLogger().debug(logMessageBuffer.toString());
}
try {
mailet.service(mail);
// Make sure all the recipients are still MailAddress objects
verifyMailAddresses(mail.getRecipients());
} catch (MessagingException me) {
MailetConfig mailetConfig = mailet.getMailetConfig();
String onMailetException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMailetException");
if (onMailetException == null) {
onMailetException = Mail.ERROR;
} else {
onMailetException = onMailetException.trim().toLowerCase(Locale.US);