{
try
{
EbMSBaseMessage msg = (EbMSBaseMessage)message.getPayload();
Date now = new Date();
CollaborationProtocolAgreement cpa = ebMSDAO.getCPA(msg.getMessageHeader().getCPAId());
if (!StatusValueType.AGREED.equals(cpa.getStatus().getValue()))
{
message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader[@cpaid]",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"CPA not agreed."));
return false;
}
if (now.compareTo(cpa.getStart().toGregorianCalendar().getTime()) < 0 || now.compareTo(cpa.getEnd().toGregorianCalendar().getTime()) > 0)
{
message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader[@cpaid]",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"CPA invalid."));
return false;
}
return StatusValueType.AGREED.equals(cpa.getStatus().getValue())
&& now.compareTo(cpa.getStart().toGregorianCalendar().getTime()) >= 0
&& now.compareTo(cpa.getEnd().toGregorianCalendar().getTime()) <= 0
;
}
catch (DAOException e)
{
throw new RuntimeException(e);