Skip to content

Commit

Permalink
Added parseUserOrSignalMessage for #239
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jun 18, 2024
1 parent 4414431 commit 469c2e1
Showing 1 changed file with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.helger.commons.lang.ServiceLoaderHelper;
import com.helger.commons.mime.IMimeType;
import com.helger.commons.mime.MimeTypeParser;
import com.helger.commons.state.ESuccess;
import com.helger.commons.string.StringHelper;
import com.helger.commons.wrapper.Wrapper;
import com.helger.phase4.attachment.AS4DecompressException;
Expand Down Expand Up @@ -171,8 +172,8 @@ public static void parseAS4Message (@Nonnull final IAS4IncomingAttachmentFactory
final IMimeType aPlainContentType = aContentType.getCopyWithoutParameters ();

// Fallback to global dumper if none is provided
final IAS4IncomingDumper aRealIncomingDumper = aIncomingDumper != null ? aIncomingDumper
: AS4DumpManager.getIncomingDumper ();
final IAS4IncomingDumper aRealIncomingDumper = aIncomingDumper != null ? aIncomingDumper : AS4DumpManager
.getIncomingDumper ();

Document aSoapDocument = null;
ESoapVersion eSoapVersion = null;
Expand Down Expand Up @@ -467,8 +468,7 @@ private static void _processSoapHeaderElements (@Nonnull final SOAPHeaderElement
aHeader.getNode (),
aIncomingAttachments,
aState,
aProcessingErrorMessagesTarget)
.isSuccess ())
aProcessingErrorMessagesTarget).isSuccess ())
{
// Mark header as processed (for mustUnderstand check)
aHeader.setProcessed (true);
Expand Down Expand Up @@ -990,4 +990,62 @@ public static Ebms3UserMessage parseUserMessage (@Nonnull final IAS4CryptoFactor
}
return ret;
}

@Nonnull
public static ESuccess parseUserOrSignalMessage (@Nonnull final IAS4CryptoFactory aCryptoFactorySign,
@Nonnull final IAS4CryptoFactory aCryptoFactoryCrypt,
@Nonnull final IPModeResolver aPModeResolver,
@Nonnull final IAS4IncomingAttachmentFactory aIAF,
@Nonnull final IAS4IncomingProfileSelector aAS4ProfileSelector,
@Nonnull @WillNotClose final AS4ResourceHelper aResHelper,
@Nullable final IPMode aSendingPMode,
@Nonnull final Locale aLocale,
@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata,
@Nonnull final HttpResponse aHttpResponse,
@Nonnull final byte [] aResponsePayload,
@Nullable final IAS4IncomingDumper aIncomingDumper,
@Nonnull final IAS4IncomingSecurityConfiguration aIncomingSecurityConfiguration,
@Nullable final IAS4UserMessageConsumer aUserMsgConsumer,
@Nullable final IAS4SignalMessageConsumer aSignalMsgConsumer) throws Phase4Exception
{
final IAS4MessageState aState = _parseMessage (aCryptoFactorySign,
aCryptoFactoryCrypt,
aPModeResolver,
aIAF,
aAS4ProfileSelector,
aResHelper,
aSendingPMode,
aLocale,
aMessageMetadata,
aHttpResponse,
aResponsePayload,
aIncomingDumper,
aIncomingSecurityConfiguration);
if (aState == null)
{
// Error message was already logged
return ESuccess.FAILURE;
}

final Ebms3UserMessage aUserMsg = aState.getEbmsUserMessage ();
if (aUserMsg != null)
{
// Invoke consumer here, because we have the state
if (aUserMsgConsumer != null)
aUserMsgConsumer.handleUserMessage (aUserMsg, aMessageMetadata, aState);
}
else
{
final Ebms3SignalMessage aSignalMsg = aState.getEbmsSignalMessage ();
if (aSignalMsg != null)
{
// Invoke consumer here, because we have the state
if (aSignalMsgConsumer != null)
aSignalMsgConsumer.handleSignalMessage (aSignalMsg, aMessageMetadata, aState);
}
else
LOGGER.warn ("A Message state is present, but it contains neither a SignalMessage nor a UserMessage.");
}
return ESuccess.SUCCESS;
}
}

0 comments on commit 469c2e1

Please sign in to comment.