Search in sources :

Example 1 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class TxUtil method isReliableAndTimelyRequested.

/**
	 * Determines if the message is requesting timely and reliable delivery.  This is determined by 
     * the existence of the X-DIRECT-FINAL-DESTINATION-DELIVERY message disposition option on the original message.
	 * @param msg The message that is being inspected for timely and reliable messaging.
	 * @return true if the original message indicates that it requires timely and reliable delivery; false otherwise
	 */
public static boolean isReliableAndTimelyRequested(MimeMessage msg) {
    if (msg == null)
        return false;
    final TxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    final Tx tx = new Tx(getMessageType(msg), details);
    return isReliableAndTimelyRequested(tx);
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) DefaultTxDetailParser(org.nhindirect.common.tx.impl.DefaultTxDetailParser) DefaultTxDetailParser(org.nhindirect.common.tx.impl.DefaultTxDetailParser)

Example 2 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class DefaultTxDetailParser method getMessageDetails.

public Map<String, TxDetail> getMessageDetails(InputStream stream) {
    Map<String, TxDetail> retVal = null;
    if (stream == null)
        throw new IllegalArgumentException("Input stream cannot be null");
    try {
        // convert into a MimeMessage
        final MimeMessage msg = new MimeMessage(null, stream);
        retVal = getMessageDetails(msg);
    }///CLOVER:OFF		
     catch (MessagingException e) {
        LOGGER.warn("Failed to translate input stream into MimeMessage.", e);
    }
    return retVal;
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) MessagingException(javax.mail.MessagingException) TxDetail(org.nhindirect.common.tx.model.TxDetail)

Example 3 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class SuppressNotificationRequest method getOriginalMessageId.

public static String getOriginalMessageId(Tx tx, TxDetailParser parser) {
    ///CLOVER:OFF
    if (tx == null) {
        throw new IllegalArgumentException("Invalid parameter received. Tx cannot be null.");
    }
    ///CLOVER:ON
    final TxMessageType type = tx.getMsgType();
    if (type != TxMessageType.DSN && type != TxMessageType.MDN)
        return "";
    final TxDetail detail = tx.getDetail(TxDetailType.PARENT_MSG_ID);
    return (detail != null && !detail.getDetailValue().isEmpty()) ? detail.getDetailValue() : "";
}
Also used : TxDetail(org.nhindirect.common.tx.model.TxDetail) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Example 4 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_noFullHeaders.

@Test
public void testGetMessageDetails_noFullHeaders() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser() {

        @Override
        public String getHeadersAsStringInternal(MimeMessage msg) {
            return "";
        }
    };
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull(details.get(TxDetailType.MSG_FULL_HEADERS.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 5 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_MDNOptionForTimely_assertTrue.

@Test
public void testIsTimelyAndRequired_MDNOptionForTimely_assertTrue() {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, MDNStandard.DispositionOption_TimelyAndReliable));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertTrue(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

TxDetail (org.nhindirect.common.tx.model.TxDetail)70 Test (org.junit.Test)50 Tx (org.nhindirect.common.tx.model.Tx)35 MimeMessage (javax.mail.internet.MimeMessage)32 HashMap (java.util.HashMap)20 Exchange (org.apache.camel.Exchange)10 CamelContext (org.apache.camel.CamelContext)9 DefaultExchange (org.apache.camel.impl.DefaultExchange)9 ArrayList (java.util.ArrayList)7 TxMessageType (org.nhindirect.common.tx.model.TxMessageType)6 NotificationDAOException (org.nhindirect.monitor.dao.NotificationDAOException)5 InputStream (java.io.InputStream)4 Address (javax.mail.Address)4 InternetAddress (javax.mail.internet.InternetAddress)4 DefaultTxDetailParser (org.nhindirect.common.tx.impl.DefaultTxDetailParser)4 TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)4 Header (javax.mail.Header)3 MessagingException (javax.mail.MessagingException)3 MimeBodyPart (javax.mail.internet.MimeBodyPart)3 DSNMessageHeaders (org.nhindirect.common.mail.dsn.DSNMessageHeaders)3