org.nhindirect.stagent.mail.notifications
Class NotificationHelper

java.lang.Object
  extended by org.nhindirect.stagent.mail.notifications.NotificationHelper

public class NotificationHelper
extends Object

Utility and extension methods for MDN specific message logic.

Author:
Greg Meyer, Umesh Madan

Constructor Summary
NotificationHelper()
           
 
Method Summary
static String asString(NotificationType type)
          Provides the appropriate Disposition header value for the type
static String asString(NotificationType type, boolean cap)
          Provides the appropriate Disposition header value for the type
static String asString(SendType type)
          Provides the appropriate Disposition header value for the type
static String asString(TriggerType type)
          Provides the appropriate Disposition header value for the type.
static NotificationMessage createNotificationMessage(Message message, javax.mail.internet.InternetAddress from, Notification notification)
          Creates an MDN Notification message for the given message
static Collection<NotificationMessage> createNotificationMessages(Message message, Collection<javax.mail.internet.InternetAddress> senders, NotificationCreator notificationCreator)
          Creates a notification message (MDN) for the given message to the senders.
static String getNotificationDestination(Message message)
          Gets the value of the Disposition-Notification-To header, which indicates where the original UA requested notification be sent.
static Collection<javax.mail.internet.InternetAddress> getNotificationDestinationAddresses(Message message)
          Gets the mail addresses contained in the Disposition-Notification-To header, which indicates where the original UA requested notification be sent.
static boolean hasNotificationRequest(Message message)
          Tests if this message has requested MDN notification.
static boolean isMDN(Message message)
          Tests if this message is an MDN
static void requestNotification(Message message)
          Sets the header values for this message to request message disposition notification.
static boolean shouldIssueNotification(Message message)
          Deprecated. as of version 1.1. The Direct Project model infers that a notification message should be sent regardless if a notification request is requested. The gateway agent model should now determine whether or not to send a notification based on the following criteria: 1) A preference in the gateway indicates that the agent/gateway should send notifications. 2) This message is not a MDN messages. This can be determined by calling isMDN(Message).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationHelper

public NotificationHelper()
Method Detail

hasNotificationRequest

public static boolean hasNotificationRequest(Message message)
Tests if this message has requested MDN notification.

The received message may be tested to see if it has a message disposition notification request, based on the Disposition-Notification-To header.

Parameters:
message - The message to test.
Returns:
true if this message has requested disposition notification. false otherwise

isMDN

public static boolean isMDN(Message message)
Tests if this message is an MDN

Parameters:
message - The message to test.
Returns:
true if this message in an MDN. false otherwise

shouldIssueNotification

public static boolean shouldIssueNotification(Message message)
Deprecated. as of version 1.1. The Direct Project model infers that a notification message should be sent regardless if a notification request is requested. The gateway agent model should now determine whether or not to send a notification based on the following criteria: 1) A preference in the gateway indicates that the agent/gateway should send notifications. 2) This message is not a MDN messages. This can be determined by calling isMDN(Message).

Returns true if the user agent should issue a notification for this message.

Tests the message to see if it has a message disposition notification request, based on the Disposition-Notification-To header Additionally, verifies that the message is NOT itself an MDN. As per RFC 3798, agents should never issue an MDN in response to an MDN

Parameters:
message - The message to test.
Returns:
true if the a notification should be issued. false otherwise

getNotificationDestination

public static String getNotificationDestination(Message message)
Gets the value of the Disposition-Notification-To header, which indicates where the original UA requested notification be sent. If the header is not present, then the From header is used.

Parameters:
message - The message to get the destination from.
Returns:
The value of the header (which will be a comma separated list of addresses)

getNotificationDestinationAddresses

public static Collection<javax.mail.internet.InternetAddress> getNotificationDestinationAddresses(Message message)
Gets the mail addresses contained in the Disposition-Notification-To header, which indicates where the original UA requested notification be sent.

Parameters:
message - The message to get the destination from.
Returns:
A collection of InternetAddresses, or an empty list if no header was found

requestNotification

public static void requestNotification(Message message)
Sets the header values for this message to request message disposition notification.

Parameters:
message - The message for which to set the disposition request headers.

createNotificationMessage

public static NotificationMessage createNotificationMessage(Message message,
                                                            javax.mail.internet.InternetAddress from,
                                                            Notification notification)
Creates an MDN Notification message for the given message

Parameters:
message - source message
from - Address this notification is from
notification - The notification to be embedded in the message
Returns:
Null if no notification should be issued

createNotificationMessages

public static Collection<NotificationMessage> createNotificationMessages(Message message,
                                                                         Collection<javax.mail.internet.InternetAddress> senders,
                                                                         NotificationCreator notificationCreator)
Creates a notification message (MDN) for the given message to the senders.

Parameters:
message - The message for which to send notification
senders - The message senders to which to send notification
notificationCreator - Interface for creating notification objects from addresses
Returns:
A collection of notification messages

asString

public static String asString(TriggerType type)
Provides the appropriate Disposition header value for the type.

Parameters:
type - The mode to translate
Returns:
A string representation suitable for inclusion in the action mode section of the Disposition header value

asString

public static String asString(SendType type)
Provides the appropriate Disposition header value for the type

Parameters:
type - The mode to translate
Returns:
A string representation suitable for inclusion in the sending mode section of the Disposition header value

asString

public static String asString(NotificationType type)
Provides the appropriate Disposition header value for the type

Parameters:
type - The type to translate
Returns:
A string representation suitable for inclusion in the disposition type section of the Disposition header value

asString

public static String asString(NotificationType type,
                              boolean cap)
Provides the appropriate Disposition header value for the type

Parameters:
type - The type to translate
Returns:
A string representation suitable for inclusion in the disposition type section of the Disposition header value


Copyright © 2010-2013 NHIN Direct. All Rights Reserved.