Search in sources :

Example 1 with AddressSource

use of org.nhindirect.stagent.AddressSource in project nhin-d by DirectProject.

the class AbstractNotificationAwareMailet method getMailRecipients.

/**
	 * Get the recipients of Mail message by retrieving the recipient list from the SMTP envelope first, then falling back to the recipients
	 * in the message if the recipients cannot be retrieved from the SMTP envelope.
	 * @param mail The mail object that contains information from the SMTP envelope.
	 * @return Collection of message recipients.
	 * @throws MessagingException
	 */
@SuppressWarnings("unchecked")
protected NHINDAddressCollection getMailRecipients(Mail mail) throws MessagingException {
    final NHINDAddressCollection recipients = new NHINDAddressCollection();
    // uses the RCPT TO commands
    final Collection<MailAddress> recips = mail.getRecipients();
    if (recips == null || recips.size() == 0) {
        // fall back to the mime message list of recipients
        final Address[] recipsAddr = mail.getMessage().getAllRecipients();
        for (Address addr : recipsAddr) {
            recipients.add(new NHINDAddress(addr.toString(), (AddressSource) null));
        }
    } else {
        for (MailAddress addr : recips) {
            recipients.add(new NHINDAddress(addr.toString(), (AddressSource) null));
        }
    }
    return recipients;
}
Also used : NHINDAddress(org.nhindirect.stagent.NHINDAddress) MailAddress(org.apache.mailet.MailAddress) AddressSource(org.nhindirect.stagent.AddressSource) Address(javax.mail.Address) MailAddress(org.apache.mailet.MailAddress) InternetAddress(javax.mail.internet.InternetAddress) NHINDAddress(org.nhindirect.stagent.NHINDAddress) NHINDAddressCollection(org.nhindirect.stagent.NHINDAddressCollection)

Example 2 with AddressSource

use of org.nhindirect.stagent.AddressSource in project nhin-d by DirectProject.

the class ReliableDispatchedNotificationProducer_produceTest method getMailRecipients.

protected NHINDAddressCollection getMailRecipients(MimeMessage mail) throws MessagingException {
    final NHINDAddressCollection recipients = new NHINDAddressCollection();
    final Address[] recipsAddr = mail.getAllRecipients();
    for (Address addr : recipsAddr) {
        recipients.add(new NHINDAddress(addr.toString(), (AddressSource) null));
    }
    return recipients;
}
Also used : NHINDAddress(org.nhindirect.stagent.NHINDAddress) AddressSource(org.nhindirect.stagent.AddressSource) Address(javax.mail.Address) InternetAddress(javax.mail.internet.InternetAddress) NHINDAddress(org.nhindirect.stagent.NHINDAddress) NHINDAddressCollection(org.nhindirect.stagent.NHINDAddressCollection)

Aggregations

Address (javax.mail.Address)2 InternetAddress (javax.mail.internet.InternetAddress)2 AddressSource (org.nhindirect.stagent.AddressSource)2 NHINDAddress (org.nhindirect.stagent.NHINDAddress)2 NHINDAddressCollection (org.nhindirect.stagent.NHINDAddressCollection)2 MailAddress (org.apache.mailet.MailAddress)1