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() : "";
}
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;
}
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;
}
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;
}
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;
}
Aggregations