All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kaleidofoundry.mail.MailingDispatcherReport Maven / Gradle / Ivy

The newest version!
package org.kaleidofoundry.mail;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.kaleidofoundry.core.util.ThrowableHelper;

/**
 * Report of a mailing send
 * 
    *
  • invalid addresses
  • *
* * @author jraduget */ public class MailingDispatcherReport implements Serializable { private static final long serialVersionUID = -5533039526120133759L; private Map> invalidAddresses; private Map mailExceptions; public MailingDispatcherReport() { invalidAddresses = new HashMap>(); mailExceptions = new HashMap(); } public Map> getInvalidAddresses() { return invalidAddresses; } public Map getMailExceptions() { return mailExceptions; } public void put(MailMessage message, List invalidAddresses) { this.invalidAddresses.put(message, invalidAddresses); } public void put(MailMessage message, MailException me) { this.mailExceptions.put(message, me); if (me instanceof InvalidMailAddressException && !"mail.service.message.fromaddress.none".equals(me.getCode()) && !"mail.service.message.address.none".equals(me.getCode())) { put(message, ((InvalidMailAddressException) me).getInvalidAddresses()); } } public void put(MailMessage message, List invalidAddresses, MailException me) { put(message, invalidAddresses); put(message, me); } public boolean isEmpty() { return invalidAddresses.isEmpty() && mailExceptions.isEmpty(); } @Override public String toString() { StringBuilder str = new StringBuilder(); str.append("MailingDispatcherReport ["); str.append("invalidAddresses=" + invalidAddresses.values()); str.append(", mailExceptions="); for (Entry mre : mailExceptions.entrySet()) { str.append(ThrowableHelper.getStackTrace(mre.getValue())).append("\n"); } str.append("]"); return str.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy