Search in sources :

Example 16 with Ebms3Error

use of com.helger.phase4.ebms3header.Ebms3Error in project phase4 by phax.

the class MockMessageProcessorCheckingStreamsSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nonnull final IPMode aPmode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    final Ebms3PullRequest aPR = aSignalMessage.getPullRequest();
    if (aPR != null && aPR.getMpc().equals("TWO-SPI")) {
        final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
        // Add properties
        final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
        final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
        final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
        final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
        final Ebms3CollaborationInfo aEbms3CollaborationInfo;
        final Ebms3PartyInfo aEbms3PartyInfo;
        aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
        aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
        final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
        final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
        aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
        aUserMessage.setMessageInfo(aEbms3MessageInfo);
        aUserMessage.setMessageProperties(aEbms3MessageProperties);
        aUserMessage.setPartyInfo(aEbms3PartyInfo);
        aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
        aUserMessage.setMpc(aSignalMessage.getPullRequest().getMpc());
        return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
    }
    return AS4SignalMessageProcessorResult.createSuccess();
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 17 with Ebms3Error

use of com.helger.phase4.ebms3header.Ebms3Error in project phase4 by phax.

the class MockMessageProcessorSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nullable final IPMode aPMode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    // Must be a pull-request
    final Ebms3PullRequest aPullRequest = aSignalMessage.getPullRequest();
    if (aPullRequest != null) {
        if (aPullRequest.getMpc().equals(MPC_FAILURE)) {
            return AS4SignalMessageProcessorResult.createFailure("Error in creating the usermessage - mock MPC 'failure' was used!");
        }
        // Empty MPC
        if (aPullRequest.getMpc().equals(MPC_EMPTY)) {
            return AS4SignalMessageProcessorResult.createSuccess();
        }
    }
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    final Ebms3PartyInfo aEbms3PartyInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
    final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aUserMessage.setMessageInfo(aEbms3MessageInfo);
    aUserMessage.setMessageProperties(aEbms3MessageProperties);
    aUserMessage.setPartyInfo(aEbms3PartyInfo);
    aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
    if (aPullRequest != null)
        aUserMessage.setMpc(aPullRequest.getMpc());
    return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)13 Ebms3Error (com.helger.phase4.ebms3header.Ebms3Error)9 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)9 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)8 Phase4Exception (com.helger.phase4.util.Phase4Exception)8 Node (org.w3c.dom.Node)8 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)7 IOException (java.io.IOException)7 AS4DecompressException (com.helger.phase4.attachment.AS4DecompressException)6 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)6 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)6 IPMode (com.helger.phase4.model.pmode.IPMode)6 MessagingException (javax.mail.MessagingException)6 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)6 HttpHeaderMap (com.helger.commons.http.HttpHeaderMap)5 Ebms3PullRequest (com.helger.phase4.ebms3header.Ebms3PullRequest)5 PModeLeg (com.helger.phase4.model.pmode.leg.PModeLeg)5 Locale (java.util.Locale)5 Document (org.w3c.dom.Document)5 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4