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