use of com.helger.peppol.sbdh.read.PeppolSBDHDocumentReader in project as2-peppol-servlet by phax.
the class AS2ServletSBDModule method handle.
public void handle(@Nonnull final String sAction, @Nonnull final IMessage aMsg, @Nullable final Map<String, Object> aOptions) throws OpenAS2Exception {
try {
// Interpret content as SBD
final StandardBusinessDocument aSBD = new SBDMarshaller().read(aMsg.getData().getInputStream());
if (aSBD == null)
throw new IllegalArgumentException("Failed to interpret the passed document as a Standard Business Document!");
if (AS2PeppolServletConfiguration.isReceiverCheckEnabled()) {
final PeppolSBDHDocument aDD = new PeppolSBDHDocumentReader().extractData(aSBD);
final String sMessageID = aDD.getInstanceIdentifier();
// Get the endpoint information required from the recipient
final EndpointType aReceiverEndpoint = _getReceiverEndpoint(aDD.getReceiverAsIdentifier(), aDD.getDocumentTypeAsIdentifier(), aDD.getProcessAsIdentifier(), sMessageID);
if (aReceiverEndpoint == null) {
throw new OpenAS2Exception(sMessageID + " Failed to resolve endpoint for provided receiver/documentType/process - not handling document");
}
// Check if the message is for us
_checkIfReceiverEndpointURLMatches(aReceiverEndpoint, sMessageID);
// Get the recipient certificate from the SMP
_checkIfEndpointCertificateMatches(aReceiverEndpoint, sMessageID);
} else {
s_aLogger.info("Endpoint checks for the AS2 AP are disabled");
}
// Handle incoming document via SPI
for (final IAS2IncomingSBDHandlerSPI aHandler : m_aHandlers) aHandler.handleIncomingSBD(aSBD);
} catch (final Exception ex) {
// Something went wrong
throw WrappedOpenAS2Exception.wrap(ex);
}
}
Aggregations