Search in sources :

Example 1 with Ebms3Error

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

the class StoringServletMessageProcessorSPI method processAS4UserMessage.

@Nonnull
public AS4MessageProcessorResult processAS4UserMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3UserMessage aUserMessage, @Nonnull final IPMode aPMode, @Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aIncomingAttachments, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    LOGGER.info("Received AS4 user message");
    _dumpSoap(aMessageMetadata, aState);
    // Dump all incoming attachments (but only if they are repeatable)
    if (aIncomingAttachments != null) {
        int nAttachmentIndex = 0;
        for (final WSS4JAttachment aIncomingAttachment : aIncomingAttachments) {
            if (aIncomingAttachment.isRepeatable())
                _dumpIncomingAttachment(aMessageMetadata, aIncomingAttachment, nAttachmentIndex);
            nAttachmentIndex++;
        }
    }
    return AS4MessageProcessorResult.createSuccess();
}
Also used : WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Nonnull(javax.annotation.Nonnull)

Example 2 with Ebms3Error

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

the class ExampleReceiveMessageProcessorSPI method processAS4UserMessage.

@Nonnull
public AS4MessageProcessorResult processAS4UserMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3UserMessage aUserMessage, @Nonnull final IPMode aPMode, @Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aIncomingAttachments, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    LOGGER.info("Received AS4 user message");
    _dumpSoap(aMessageMetadata, aState);
    if (aIncomingAttachments != null) {
        int nIndex = 1;
        for (final WSS4JAttachment aIncomingAttachment : aIncomingAttachments) {
            final File aFile = StorageHelper.getStorageFile(aMessageMetadata, "-" + nIndex + ".payload");
            if (StreamHelper.copyInputStreamToOutputStream(aIncomingAttachment.getSourceStream(), FileHelper.getOutputStream(aFile)).isFailure())
                LOGGER.error("Failed to write incoming attachment [" + nIndex + "] to '" + aFile.getAbsolutePath() + "'");
            else
                LOGGER.info("Wrote incoming attachment [" + nIndex + "] to '" + aFile.getAbsolutePath() + "'");
            ++nIndex;
        }
    }
    return AS4MessageProcessorResult.createSuccess();
}
Also used : File(java.io.File) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Nonnull(javax.annotation.Nonnull)

Example 3 with Ebms3Error

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

the class MockClientMessages method createErrorMessageSigned.

@Nonnull
public static Document createErrorMessageSigned(@Nonnull final ESoapVersion eSoapVersion, @Nullable final ICommonsList<WSS4JAttachment> aAttachments, @Nonnull @WillNotClose final AS4ResourceHelper aResHelper) throws WSSecurityException {
    final ICommonsList<Ebms3Error> aEbms3ErrorList = new CommonsArrayList<>(EEbmsError.EBMS_INVALID_HEADER.getAsEbms3Error(Locale.US, null));
    final AS4ErrorMessage aErrorMsg = AS4ErrorMessage.create(eSoapVersion, "srcmsgid", aEbms3ErrorList).setMustUnderstand(true);
    final Document aSignedDoc = AS4Signer.createSignedMessage(AS4CryptoFactoryProperties.getDefaultInstance(), aErrorMsg.getAsSoapDocument(), eSoapVersion, aErrorMsg.getMessagingID(), aAttachments, aResHelper, false, AS4SigningParams.createDefault());
    return aSignedDoc;
}
Also used : Ebms3Error(com.helger.phase4.ebms3header.Ebms3Error) Document(org.w3c.dom.Document) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) AS4ErrorMessage(com.helger.phase4.messaging.domain.AS4ErrorMessage) Nonnull(javax.annotation.Nonnull)

Example 4 with Ebms3Error

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

the class AS4ErrorMessage method create.

@Nonnull
public static AS4ErrorMessage create(@Nonnull final ESoapVersion eSoapVersion, @Nonnull final Ebms3MessageInfo aEbms3MessageInfo, @Nonnull final ICommonsList<Ebms3Error> aErrorMessages) {
    final Ebms3SignalMessage aSignalMessage = new Ebms3SignalMessage();
    // Message Info
    aSignalMessage.setMessageInfo(aEbms3MessageInfo);
    // Error Message
    aSignalMessage.setError(aErrorMessages);
    return new AS4ErrorMessage(eSoapVersion, aSignalMessage);
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) Nonnull(javax.annotation.Nonnull)

Example 5 with Ebms3Error

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

the class IEbmsError method getAsEbms3Error.

@Nonnull
default Ebms3Error getAsEbms3Error(@Nonnull final Locale aContentLocale, @Nullable final String sRefToMessageInError, @Nullable final String sOrigin, @Nullable final Ebms3Description aEbmsDescription) {
    final Ebms3Error aEbms3Error = new Ebms3Error();
    // Default to shortDescription if none provided
    aEbms3Error.setDescription(aEbmsDescription != null ? aEbmsDescription : MessageHelperMethods.createEbms3Description(aContentLocale, getShortDescription()));
    aEbms3Error.setErrorDetail(getErrorDetail().getDisplayText(aContentLocale));
    aEbms3Error.setErrorCode(getErrorCode());
    aEbms3Error.setSeverity(getSeverity().getSeverity());
    aEbms3Error.setShortDescription(getShortDescription());
    aEbms3Error.setCategory(getCategory().getDisplayName());
    aEbms3Error.setRefToMessageInError(sRefToMessageInError);
    aEbms3Error.setOrigin(sOrigin);
    return aEbms3Error;
}
Also used : Ebms3Error(com.helger.phase4.ebms3header.Ebms3Error) 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