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;
23  
24  import java.util.Arrays;
25  
26  import javax.mail.internet.InternetAddress;
27  
28  import org.nhindirect.common.mail.MDNStandard;
29  import org.nhindirect.stagent.NHINDAddress;
30  import org.nhindirect.stagent.mail.notifications.Notification;
31  import org.nhindirect.stagent.mail.notifications.NotificationType;
32  import org.nhindirect.stagent.mail.notifications.ReportingUserAgent;
33  
34  /**
35   * Notification producer for creating MDN dispatched messages.
36   * @author Greg Meyer
37   * @since 2.0
38   */
39  public class ReliableDispatchedNotificationProducer extends NotificationProducer
40  {
41  	/**
42  	 * Constructor
43  	 * @param settings Notification specific settings
44  	 */
45  	public ReliableDispatchedNotificationProducer(NotificationSettings settings)
46  	{
47  		super(settings);
48  	}
49  	
50  	/**
51  	 * {@inheritDoc}
52  	 */
53      protected Notification createAck(InternetAddress address)
54      {
55          Notification notification = new Notification(NotificationType.Dispatched);
56          if (settings.hasText())
57          {
58              notification.setExplanation(settings.getText());
59          }
60                  
61          notification.setReportingAgent(new ReportingUserAgent(NHINDAddress.getHost(address), settings.getProductName()));        
62          notification.setExtensions(Arrays.asList(MDNStandard.DispositionOption_TimelyAndReliable));
63          return notification;
64      }
65  }