use of org.nhindirect.common.mail.dsn.DSNStandard.MtaNameType in project nhin-d by DirectProject.
the class DSNGenerator method createDeliveryStatus.
/**
* Creates the deliver status section of the message
* @param recipientDSNHeaders
* @param messageDSNHeaders
* @return
* @throws MessagingException
*/
protected DeliveryStatus createDeliveryStatus(List<DSNRecipientHeaders> recipientDSNHeaders, DSNMessageHeaders messageDSNHeaders) throws MessagingException {
final DeliveryStatus deliveryStatus = new DeliveryStatus();
for (DSNRecipientHeaders dsnHeaders : recipientDSNHeaders) {
final InternetHeaders recipHeaders = new InternetHeaders();
final DSNAction dsnAction = dsnHeaders.getAction();
recipHeaders.addHeader(DSNStandard.Headers.Action, "" + dsnAction);
final Address finalRecipient = dsnHeaders.getFinalRecipient();
if (finalRecipient != null) {
recipHeaders.addHeader(DSNStandard.Headers.FinalRecipient, finalRecipient.getType() + ";" + finalRecipient.toString());
}
String status = dsnHeaders.getStatus();
recipHeaders.addHeader(DSNStandard.Headers.Status, status);
deliveryStatus.addRecipientDSN(recipHeaders);
}
final InternetHeaders messageHeaders = new InternetHeaders();
final MtaNameType mtaNameType = messageDSNHeaders.getMtaNameType();
final String reportingMta = messageDSNHeaders.getReportingMta();
messageHeaders.addHeader(DSNStandard.Headers.ReportingMTA, mtaNameType + ";" + reportingMta);
// add a custom header with original message id
final String originalMessageId = messageDSNHeaders.getOriginalMessageId();
messageHeaders.addHeader(DSNStandard.Headers.OriginalMessageID, originalMessageId);
deliveryStatus.setMessageDSN(messageHeaders);
return deliveryStatus;
}
Aggregations