View Javadoc
1   /* 
2   Copyright (c) 2010, NHIN Direct Project
3   All rights reserved.
4   
5   Authors:
6      Greg Meyer      gm2552@cerner.com
7    
8   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9   
10  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
12  in the documentation and/or other materials provided with the distribution.  Neither the name of the The NHIN Direct Project (nhindirect.org). 
13  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
15  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 
16  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
17  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
18  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
19  THE POSSIBILITY OF SUCH DAMAGE.
20  */
21  
22  package org.nhindirect.gateway.smtp.dsn;
23  
24  import java.util.Collection;
25  
26  import javax.mail.MessagingException;
27  import javax.mail.internet.MimeMessage;
28  
29  import org.nhindirect.common.tx.model.Tx;
30  import org.nhindirect.stagent.NHINDAddressCollection;
31  
32  /**
33   * Interface definition for creating DSN failure messages based on a Tx object a list of failed recipients.
34   * @author Greg Meyer
35   * @since 2.0
36   */
37  public interface DSNCreator 
38  {
39  	/**
40  	 * Creates a DSN messages using message information from a Tx object a list of failed recipients. 
41  	 * @param tx Tx object containing information on the message that failed to be send or delivered.
42  	 * @param failedRecipeints List of intended recipients that did not receive the original message. 
43  	 * @return A MimeMessages representing the full DSN message.
44  	 * @throws MessagingException
45  	 * @deprecated As of 2.0.1.  This method does not correctly determine the domain of the postmaster for incoming messages.
46  	 * Use {@link #createDSNFailure(Tx, NHINDAddressCollection, boolean)}.  
47  	 */
48  	public MimeMessage createDSNFailure(Tx tx, NHINDAddressCollection failedRecipeints) throws MessagingException;
49  	
50  	/**
51  	 * Creates a collection of DSN messages using message information from a Tx object a list of failed recipients.  A DSN message is created
52  	 * for each unique postmaster domain. <b><b>
53  	 * @param tx Tx object containing information on the message that failed to be send or delivered.
54  	 * @param failedRecipeints List of intended recipients that did not receive the original message. 
55  	 * @param useSenderDomainForPostmaster Indicates if the original sender or the recipients should be used to determine the postmaster domain.  
56  	 * Generally for rejected outgoing messages, the sender's domain is used, and for incoming messages the recipients' domains are used.
57  	 * @return A collection of MimeMessages representing the full DSN messages.
58  	 * @throws MessagingException
59  	 */
60  	public Collection<MimeMessage> createDSNFailure(Tx tx, NHINDAddressCollection failedRecipeints, boolean useSenderDomainForPostmaster) throws MessagingException;
61  }