{
try
{
GregorianCalendar timestamp = null;
EbMSStatusRequest request = (EbMSStatusRequest)message.getPayload();
EbMSMessageStatus status = EbMSMessageStatus.get((String)message.getProperty(Constants.EBMS_MESSAGE_STATUS));
if (status == null)
{
MessageHeader messageHeader = ebMSDAO.getMessageHeader(request.getStatusRequest().getRefToMessageId());
if (messageHeader == null || messageHeader.getService().getValue().equals(Constants.EBMS_SERVICE_URI))
status = EbMSMessageStatus.NOT_RECOGNIZED;
else if (messageHeader.getCPAId().equals(request.getMessageHeader().getCPAId()))
status = EbMSMessageStatus.UNAUTHORIZED;
else
{
status = ebMSDAO.getMessageStatus(request.getStatusRequest().getRefToMessageId());
if (MessageStatusType.RECEIVED.equals(status.statusCode()) || MessageStatusType.PROCESSED.equals(status.statusCode()) || MessageStatusType.FORWARDED.equals(status.statusCode()))
timestamp = messageHeader.getMessageData().getTimestamp().toGregorianCalendar();
}
}
message.setPayload(EbMSMessageUtils.ebMSStatusRequestToEbMSStatusResponse(request,hostname,status,timestamp));
return message;