use of org.nhindirect.common.tx.impl.DefaultTxDetailParser 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.impl.DefaultTxDetailParser in project nhin-d by DirectProject.
the class MockTxsResource method supressNotification.
@Path("suppressNotification")
@TypeHint(Boolean.class)
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response supressNotification(Tx notificationMessage) {
Boolean retEntity = Boolean.TRUE;
final String originalMessageId = SuppressNotificationRequest.getOriginalMessageId(notificationMessage, new DefaultTxDetailParser());
if (originalMessageId.isEmpty() || originalMessageId.equals("NotNotification")) {
retEntity = Boolean.FALSE;
}
return Response.ok(retEntity).build();
}
use of org.nhindirect.common.tx.impl.DefaultTxDetailParser in project nhin-d by DirectProject.
the class DSNMessageGenerator_generateDSNFailureMessageTest method testGenerateDSNFailureMessage_assertMessageCreated_noCopiedSubject.
@Test
public void testGenerateDSNFailureMessage_assertMessageCreated_noCopiedSubject() throws Exception {
Exchange exchange = new DefaultExchange(mock(CamelContext.class));
String message = TestUtils.readMessageFromFile("MessageWithAttachment.txt");
DefaultTxDetailParser parser = new DefaultTxDetailParser();
InputStream str = IOUtils.toInputStream(message);
try {
// send original message
final MimeMessage mimeMessage = new MimeMessage(null, str);
mimeMessage.setHeader(MailStandard.Headers.Subject, "");
// change the message id
mimeMessage.saveChanges();
Map<String, TxDetail> details = parser.getMessageDetails(mimeMessage);
Tx originalMessage = new Tx(TxMessageType.IMF, details);
Collection<Tx> txs = new ArrayList<Tx>();
txs.add(originalMessage);
DSNMessageGenerator generator = createGenerator();
generator.generateDSNFailureMessage(txs, exchange);
MimeMessage dsnMessage = (MimeMessage) exchange.getIn().getBody();
assertNotNull(dsnMessage);
// check the subject
String newSubject = MailStandard.getHeader(dsnMessage, MailStandard.Headers.Subject);
assertEquals("Not Delivered:", newSubject);
} finally {
IOUtils.closeQuietly(str);
}
}
use of org.nhindirect.common.tx.impl.DefaultTxDetailParser in project nhin-d by DirectProject.
the class TestNonReliableMessageMonitorRoute method testSingleRecipMDNReceived_readFromMessages_assertConditionComplete.
@Test
public void testSingleRecipMDNReceived_readFromMessages_assertConditionComplete() throws Exception {
final DefaultTxDetailParser parser = new DefaultTxDetailParser();
final Map<String, TxDetail> imfDetails = parser.getMessageDetails(TestUtils.readMimeMessageFromFile("MessageFromCernerToAthena.txt"));
final Map<String, TxDetail> mdnDetails = parser.getMessageDetails(TestUtils.readMimeMessageFromFile("MDNFromAthenaToCerner"));
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
Tx originalMessage = new Tx(TxMessageType.IMF, imfDetails);
template.sendBody("direct:start", originalMessage);
// send MDN to original message
Tx mdnMessage = new Tx(TxMessageType.MDN, mdnDetails);
template.sendBody("direct:start", mdnMessage);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
}
use of org.nhindirect.common.tx.impl.DefaultTxDetailParser in project nhin-d by DirectProject.
the class DSNMessageGenerator_generateDSNFailureMessageTest method testGenerateDSNFailureMessage_assertMessageCreated.
@Test
public void testGenerateDSNFailureMessage_assertMessageCreated() throws Exception {
Exchange exchange = new DefaultExchange(mock(CamelContext.class));
String message = TestUtils.readMessageFromFile("MessageWithAttachment.txt");
DefaultTxDetailParser parser = new DefaultTxDetailParser();
InputStream str = IOUtils.toInputStream(message);
try {
// send original message
final MimeMessage mimeMessage = new MimeMessage(null, str);
// change the message id
mimeMessage.saveChanges();
Map<String, TxDetail> details = parser.getMessageDetails(mimeMessage);
Tx originalMessage = new Tx(TxMessageType.IMF, details);
Collection<Tx> txs = new ArrayList<Tx>();
txs.add(originalMessage);
DSNMessageGenerator generator = createGenerator();
generator.generateDSNFailureMessage(txs, exchange);
MimeMessage dsnMessage = (MimeMessage) exchange.getIn().getBody();
assertNotNull(dsnMessage);
// check the subject
String newSubject = MailStandard.getHeader(dsnMessage, MailStandard.Headers.Subject);
assertTrue(newSubject.contains(MailStandard.getHeader(mimeMessage, MailStandard.Headers.Subject)));
// check for the original message id in the in-reply-to
String originalMessageId = MailStandard.getHeader(dsnMessage, MailStandard.Headers.InReplyTo);
assertEquals(MailStandard.getHeader(mimeMessage, MailStandard.Headers.MessageID), originalMessageId);
} finally {
IOUtils.closeQuietly(str);
}
}
Aggregations