Search in sources :

Example 1 with TxMessageType

use of org.nhindirect.common.tx.model.TxMessageType 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 2 with TxMessageType

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

the class TimeoutDupStateManager method suppressNotification.

/**
	 * {@inheritDoc}
	 */
@Override
public boolean suppressNotification(Tx notificationMessage) throws DuplicateNotificationStateManagerException {
    boolean retVal = false;
    if (dao == null)
        throw new IllegalArgumentException("Dao cannot be null");
    if (notificationMessage == null)
        throw new IllegalArgumentException("Notification message cannot be null");
    final TxMessageType type = notificationMessage.getMsgType();
    if (type == TxMessageType.DSN || type == TxMessageType.MDN) {
        final TxDetail dispositionDetail = notificationMessage.getDetail(TxDetailType.DISPOSITION);
        // if it's an MDN displayed, then don't suppress it and let it go through
        if (type == TxMessageType.MDN && (dispositionDetail == null || dispositionDetail.getDetailValue().contains(MDNStandard.Disposition_Displayed)))
            return retVal;
        final TxDetail originalMessageIdDetail = notificationMessage.getDetail(TxDetailType.PARENT_MSG_ID);
        final TxDetail origRecips = notificationMessage.getDetail(TxDetailType.FINAL_RECIPIENTS);
        if (originalMessageIdDetail != null && origRecips != null) {
            final String[] recipsArray = origRecips.getDetailValue().split(",");
            for (int idx = 0; idx < recipsArray.length; ++idx) recipsArray[idx] = AbstractCompletionCondition.normalizeFinalRecip(recipsArray[idx]);
            final Collection<String> recips = Arrays.asList(recipsArray);
            try {
                // try by tabbular concatenation first... we need to make sure DSN messages
                // generated by the message monitor are not supressed... these messages
                // should be the only ones that use the tabbular format
                final String queryMsgId = originalMessageIdDetail.getDetailValue() + "\t" + notificationMessage.getDetail(TxDetailType.MSG_ID).getDetailValue();
                Set<String> alreadyReceivedNotifs = dao.getReceivedAddresses(queryMsgId, recips);
                if (!alreadyReceivedNotifs.isEmpty())
                    // this is from a DSN message generated by the monitor... don't suppress it
                    retVal = false;
                else {
                    // ok, so it's not in the tabular list... so just do the normal suppression test
                    alreadyReceivedNotifs = dao.getReceivedAddresses(originalMessageIdDetail.getDetailValue(), recips);
                    if (!alreadyReceivedNotifs.isEmpty())
                        retVal = true;
                }
            } catch (NotificationDAOException e) {
                throw new DuplicateNotificationStateManagerException(e);
            }
        }
    }
    return retVal;
}
Also used : TxDetail(org.nhindirect.common.tx.model.TxDetail) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) DuplicateNotificationStateManagerException(org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Example 3 with TxMessageType

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

the class MessageIdCorrelationExpression method evaluate.

/**
	 * {@inheritDoc}}
	 * This class specifically returns the message id or the parent message id based on the {@link Tx} type.
	 */
@SuppressWarnings({ "hiding", "unchecked" })
@Override
public <String> String evaluate(Exchange exchange, Class<String> type) {
    String retVal = null;
    final Tx tx = (Tx) exchange.getIn().getBody();
    final TxMessageType msgType = tx.getMsgType();
    final Map<java.lang.String, TxDetail> details = tx.getDetails();
    if (!details.isEmpty()) {
        // first check the type of message
        switch(msgType) {
            case IMF:
                {
                    final TxDetail msgIdDetail = details.get(TxDetailType.MSG_ID.getType());
                    if (msgIdDetail != null)
                        retVal = (String) msgIdDetail.getDetailValue().toString();
                    break;
                }
            case DSN:
            case MDN:
                {
                    final TxDetail msgIdDetail = details.get(TxDetailType.PARENT_MSG_ID.getType());
                    if (msgIdDetail != null)
                        retVal = (String) msgIdDetail.getDetailValue().toString();
                    break;
                }
        }
    }
    return retVal;
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Example 4 with TxMessageType

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

the class DefaultDuplicateNotificationStateManager method suppressNotification.

/**
	 * {@inheritDoc}
	 */
@Override
public boolean suppressNotification(Tx notificationMessage) throws DuplicateNotificationStateManagerException {
    boolean retVal = false;
    if (dao == null)
        throw new IllegalArgumentException("Dao cannot be null");
    if (notificationMessage == null)
        throw new IllegalArgumentException("Notification message cannot be null");
    final TxMessageType type = notificationMessage.getMsgType();
    if (type == TxMessageType.DSN || type == TxMessageType.MDN) {
        final TxDetail dispositionDetail = notificationMessage.getDetail(TxDetailType.DISPOSITION);
        // if it's an MDN displayed, then don't suppress it and let it go through
        if (type == TxMessageType.MDN && (dispositionDetail == null || dispositionDetail.getDetailValue().contains(MDNStandard.Disposition_Displayed)))
            return retVal;
        final TxDetail originalMessageIdDetail = notificationMessage.getDetail(TxDetailType.PARENT_MSG_ID);
        final TxDetail origRecips = notificationMessage.getDetail(TxDetailType.FINAL_RECIPIENTS);
        if (originalMessageIdDetail != null && origRecips != null) {
            Collection<String> recips = Arrays.asList(origRecips.getDetailValue().split(","));
            try {
                final Set<String> alreadyReceivedNotifs = dao.getReceivedAddresses(originalMessageIdDetail.getDetailValue(), recips);
                if (!alreadyReceivedNotifs.isEmpty())
                    retVal = true;
            } catch (NotificationDAOException e) {
                throw new DuplicateNotificationStateManagerException(e);
            }
        }
    }
    return retVal;
}
Also used : TxDetail(org.nhindirect.common.tx.model.TxDetail) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) DuplicateNotificationStateManagerException(org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Example 5 with TxMessageType

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

the class IsNotSMIMEEncrypted method match.

/**
	 * {@inheritDoc}
	 */
@SuppressWarnings("rawtypes")
public Collection match(Mail mail) throws MessagingException {
    if (mail == null)
        return null;
    MimeMessage message = mail.getMessage();
    if (message == null)
        return null;
    TxMessageType type = TxUtil.getMessageType(message);
    if (type != TxMessageType.SMIME) {
        return mail.getRecipients();
    } else
        return null;
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Aggregations

TxMessageType (org.nhindirect.common.tx.model.TxMessageType)9 TxDetail (org.nhindirect.common.tx.model.TxDetail)6 NotificationDAOException (org.nhindirect.monitor.dao.NotificationDAOException)3 DuplicateNotificationStateManagerException (org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException)3 MessagingException (javax.mail.MessagingException)2 MimeMessage (javax.mail.internet.MimeMessage)2 DeliveryStatus (com.sun.mail.dsn.DeliveryStatus)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Address (javax.mail.Address)1 InternetAddress (javax.mail.internet.InternetAddress)1 InternetHeaders (javax.mail.internet.InternetHeaders)1 Tx (org.nhindirect.common.tx.model.Tx)1 PolicyParseException (org.nhindirect.policy.PolicyParseException)1 PolicyProcessException (org.nhindirect.policy.PolicyProcessException)1 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)1 MimeException (org.nhindirect.stagent.mail.MimeException)1