Package com.helger.phase4.sender
Class AbstractAS4UserMessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>
java.lang.Object
com.helger.phase4.sender.AbstractAS4MessageBuilder<IMPLTYPE>
com.helger.phase4.sender.AbstractAS4UserMessageBuilder<IMPLTYPE>
- Type Parameters:
IMPLTYPE- The implementation type
- All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
- Direct Known Subclasses:
AbstractAS4UserMessageBuilderMIMEPayload
@NotThreadSafe
public abstract class AbstractAS4UserMessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>
extends AbstractAS4MessageBuilder<IMPLTYPE>
Abstract builder base class for a user message.
- Since:
- 0.10.0
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> protected final com.helger.commons.collection.impl.ICommonsList<MessageProperty> protected IPModeprotected IAS4SignalMessageConsumerprotected IAS4SignalMessageValidationResultHandlerprotected booleanprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected StringFields inherited from class com.helger.phase4.sender.AbstractAS4MessageBuilder
DEFAULT_LOCALE, m_aBuildMessageCallback, m_aCryptoFactoryCrypt, m_aCryptoFactorySign, m_aCryptParams, m_aCustomHttpPoster, m_aDecryptParameterModifier, m_aHttpClientFactory, m_aHttpRetrySettings, m_aIncomingDumper, m_aLocale, m_aOutgoingDumper, m_aResponseConsumer, m_aRetryCallback, m_aSendingDateTime, m_aSendingDTConsumer, m_aSigningParams, m_eSoapVersion, m_sAS4ProfileID, m_sMessageID, m_sRefToMessageID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Stringaction()final IMPLTYPESet the "Action" value.final IMPLTYPEAdd an optional attachmentfinal IMPLTYPEAdd an optional attachmentfinal IMPLTYPEfinal IMPLTYPEfinal IMPLTYPEfinal Stringfinal IMPLTYPEagreementRef(String sAgreementRef) Set the "AgreementRef" value.final Stringfinal IMPLTYPEagreementType(String sAgreementType) Set the "AgreementRef type" value.protected voidapplyToUserMessage(AS4ClientUserMessage aUserMsg) This method applies all builder parameters onto the user message, except the attachments.final IMPLTYPESet optional attachment.final IMPLTYPESet optional attachment.final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> final IMPLTYPESet optional attachments.final IMPLTYPEattachments(Iterable<? extends AS4OutgoingAttachment> a) Set optional attachments.final Stringfinal IMPLTYPEconversationID(String sConversationID) Set the optional AS4 conversation ID.final Stringfinal IMPLTYPEendpointURL(String sEndointURL) Set an receiver AS4 endpoint URL, independent of its usability.protected com.helger.commons.state.ESuccessInternal method that is invoked before the required field check is performed.final booleanfinal IMPLTYPEforceMimeMessage(boolean b) Enable the enforcement of packaging the AS4 user message in a MIME message.final Stringfinal IMPLTYPEfromPartyID(String sFromPartyID) Set the "from party ID".final Stringfinal IMPLTYPEfromPartyIDType(String sFromPartyIDType) Set the "from party ID type".final StringfromRole()final IMPLTYPESet the "from party role".final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> final com.helger.commons.collection.impl.ICommonsList<MessageProperty> booleanCheck if all mandatory fields are set.final com.helger.commons.collection.impl.ICommonsList<MessageProperty> final IMPLTYPEfinal IMPLTYPEmessageProperties(Iterable<? extends MessageProperty> a) final IMPLTYPEfinal IMPLTYPEfinal IMPLTYPEfinal IPModepmode()final IMPLTYPESet the PMode to be used.final StringpmodeID()final IMPLTYPESet the optional PMode ID for packaging in the user message.final IMPLTYPEreceiverCertificate(X509Certificate aCertificate) Set the receiver certificate used to encrypt the message with.final IMPLTYPEreceiverCertificateAlias(String sAlias) Set the receiver certificate alias into the CryptoFactory keystore used to encrypt the message with.This is a sanity method that encapsulates all the sending checks that are necessary to determine overall sending success or error.
Note: this method is not thread-safe, because it changes the signal message consumer internally.sendMessageAndCheckForReceipt(Consumer<? super Phase4Exception> aExceptionConsumer) This is a sanity method that encapsulates all the sending checks that are necessary to determine overall sending success or error.
Note: this method is not thread-safe, because it changes the signal message consumer internally.final Stringservice()final IMPLTYPESet the "Service" value only, leaving the typenull.final IMPLTYPESet the "Service" value consisting of type and value.final Stringfinal IMPLTYPEsignalMsgConsumer(IAS4SignalMessageConsumer aSignalMsgConsumer) Set an optional Ebms3 Signal Message Consumer.final IMPLTYPEsignalMsgValidationResultHdl(IAS4SignalMessageValidationResultHandler aSignalMsgValidationResultHdl) Set an optional Ebms3 Signal Message validation result handler.final Stringfinal IMPLTYPESet the "to party ID".final Stringfinal IMPLTYPEtoPartyIDType(String sToPartyIDType) Set the "to party ID type".final StringtoRole()final IMPLTYPESet the "to party role".Methods inherited from class com.helger.phase4.sender.AbstractAS4MessageBuilder
afterSuccessfulSending, as4ProfileID, as4ProfileID, buildMessageCallback, buildMessageCallback, cryptoFactory, cryptoFactoryCrypt, cryptoFactoryCrypt, cryptoFactorySign, cryptoFactorySign, cryptParams, customHttpPoster, customHttpPoster, customizeBeforeSending, decryptRequestDataModifier, decryptRequestDataModifier, httpClientFactory, httpClientFactory, httpClientFactory, httpRetrySettings, httpRetrySettings, incomingAttachmentFactory, incomingAttachmentFactory, incomingDumper, incomingDumper, incomingProfileSelector, incomingProfileSelector, locale, locale, mainSendMessage, messageID, messageID, outgoingDumper, outgoingDumper, pmodeResolver, pmodeResolver, rawResponseConsumer, rawResponseConsumer, refToMessageID, refToMessageID, retryCallback, retryCallback, senderInterrupt, senderInterrupt, sendingDateTime, sendingDateTime, sendingDateTimeConsumer, sendingDateTimeConsumer, sendMessage, signingParams, soapVersion, soapVersion, withCryptParams, withSigningParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Field Details
-
m_aPMode
-
m_sServiceType
-
m_sService
-
m_sAction
-
m_sAgreementRef
-
m_sAgreementType
-
m_sPModeID
-
m_sFromPartyIDType
-
m_sFromPartyID
-
m_sFromRole
-
m_sToPartyIDType
-
m_sToPartyID
-
m_sToRole
-
m_sConversationID
-
m_aMessageProperties
protected final com.helger.commons.collection.impl.ICommonsList<MessageProperty> m_aMessageProperties -
m_sEndpointURL
-
m_aAttachments
protected final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> m_aAttachments -
m_bForceMimeMessage
protected boolean m_bForceMimeMessage -
m_aSignalMsgConsumer
-
m_aSignalMsgValidationResultHdl
-
-
Constructor Details
-
AbstractAS4UserMessageBuilder
protected AbstractAS4UserMessageBuilder()Create a new builder
-
-
Method Details
-
pmode
- Returns:
- The currently set P-Mode. May be
null.
-
pmode
Set the PMode to be used. By default a generic PMode is used.- Parameters:
aPMode- The PMode to be used. May benull.- Returns:
- this for chaining
-
serviceType
- Returns:
- The optional "Service" type. May be
null. - Since:
- 3.0.0
-
service
- Returns:
- The "Service" value. May be
null. - Since:
- 3.0.0
-
service
Set the "Service" value only, leaving the typenull.- Parameters:
sServiceValue- Service value. May benull.- Returns:
- this for chaining.
-
service
@Nonnull public final IMPLTYPE service(@Nullable String sServiceType, @Nullable String sServiceValue) Set the "Service" value consisting of type and value. It's optional. If the "Service" value is not set, it the "service type" defaults to the "process identifier scheme" and the "service value" defaults to the "process identifier value".- Parameters:
sServiceType- Service type. May benull.sServiceValue- Service value. May benull.- Returns:
- this for chaining.
-
action
- Returns:
- The "Action" value. May be
null. - Since:
- 3.0.0
-
action
Set the "Action" value. It's optional. If the "Action" value is not set, it defaults to the "document type identifier value" (URI encoded).- Parameters:
sAction- Action value. May benull.- Returns:
- this for chaining.
-
agreementRef
- Returns:
- The "AgreementRef" value. May be
null. - Since:
- 3.0.0
-
agreementRef
Set the "AgreementRef" value. It's optional.- Parameters:
sAgreementRef- Agreement reference. May benull.- Returns:
- this for chaining.
-
agreementType
- Returns:
- The "AgreementRef type" value. May be
null. - Since:
- 3.0.0
-
agreementType
Set the "AgreementRef type" value. It's optional.- Parameters:
sAgreementType- Agreement reference type. May benull.- Returns:
- this for chaining.
- Since:
- 2.7.8
-
pmodeID
- Returns:
- the current PMode ID. May be
null. - See Also:
-
pmodeID
Set the optional PMode ID for packaging in the user message.- Parameters:
s- PMode ID. May benull.- Returns:
- this for chaining
-
fromPartyIDType
- Returns:
- The "from party ID type". May be
null. - Since:
- 3.0.0
-
fromPartyIDType
Set the "from party ID type".- Parameters:
sFromPartyIDType- The from party ID.- Returns:
- this for chaining
-
fromPartyID
- Returns:
- The "from party ID". May be
null. - Since:
- 3.0.0
-
fromPartyID
Set the "from party ID".- Parameters:
sFromPartyID- The from party ID.- Returns:
- this for chaining
-
fromRole
- Returns:
- The "from party role". May be
null. - Since:
- 3.0.0
-
fromRole
Set the "from party role". This is optional- Parameters:
sFromRole- The from role. May benull.- Returns:
- this for chaining
-
toPartyIDType
- Returns:
- The "to party ID type". May be
null. - Since:
- 3.0.0
-
toPartyIDType
Set the "to party ID type".- Parameters:
sToPartyIDType- The to party ID.- Returns:
- this for chaining
-
toPartyID
- Returns:
- The "to party ID". May be
null. - Since:
- 3.0.0
-
toPartyID
Set the "to party ID".- Parameters:
sToPartyID- The to party ID.- Returns:
- this for chaining
-
toRole
- Returns:
- The "to party role". May be
null. - Since:
- 3.0.0
-
toRole
Set the "to party role". This is optional- Parameters:
sToRole- The to role. May benull.- Returns:
- this for chaining
-
conversationID
- Returns:
- The optional AS4 conversation ID. May be
null. - Since:
- 3.0.0
-
conversationID
Set the optional AS4 conversation ID. If this field is not set, a random conversation ID is created.- Parameters:
sConversationID- The optional AS4 conversation ID to be used. May benull.- Returns:
- this for chaining
-
messageProperties
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsList<MessageProperty> messageProperties() -
getAllMessageProperties
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<MessageProperty> getAllMessageProperties() -
addMessageProperty
-
addMessageProperty
-
addMessageProperty
-
messageProperty
-
messageProperty
-
messageProperty
-
messageProperties
-
messageProperties
-
receiverCertificate
Set the receiver certificate used to encrypt the message with. This is the full certificate. This method overwrites any receiver certificate alias configuration (the later call "wins").- Parameters:
aCertificate- The certificate of the receiver to be used. May benull.- Returns:
- this for chaining
- See Also:
-
receiverCertificateAlias
Set the receiver certificate alias into the CryptoFactory keystore used to encrypt the message with. This is only the alias or name of the entry. This method overwrites any receiver certificate configuration (the later call "wins").- Parameters:
sAlias- The certificate alias of the receiver to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.1.4
- See Also:
-
endpointURL
- Returns:
- The receiver AS4 endpoint URL. May be
null. - Since:
- 3.0.0
-
endpointURL
Set an receiver AS4 endpoint URL, independent of its usability.- Parameters:
sEndointURL- The endpoint URL to be used. May benull.- Returns:
- this for chaining
-
attachments
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> attachments() -
getAllAttachments
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<AS4OutgoingAttachment> getAllAttachments() -
addAttachment
Add an optional attachment- Parameters:
a- The attachment to be added. May benull.- Returns:
- this for chaining
-
addAttachment
Add an optional attachment- Parameters:
a- The attachment to be added. May benull.- Returns:
- this for chaining
-
attachment
Set optional attachment. All existing attachments are overridden.- Parameters:
a- The attachment to be set. May benull.- Returns:
- this for chaining
-
attachment
Set optional attachment. All existing attachments are overridden.- Parameters:
a- The attachment to be set. May benull.- Returns:
- this for chaining
-
attachments
Set optional attachments. All existing attachments are overridden.- Parameters:
a- The attachment to be set. May benull.- Returns:
- this for chaining
-
attachments
Set optional attachments. All existing attachments are overridden.- Parameters:
a- The attachment to be set. May benull.- Returns:
- this for chaining
-
forceMimeMessage
- Returns:
trueif the message is forced into the MIME format,falseotherwise.- Since:
- 3.0.0
-
forceMimeMessage
Enable the enforcement of packaging the AS4 user message in a MIME message.- Parameters:
b-trueto enforce it,falseto make it dynamic.- Returns:
- this for chaining
- Since:
- 2.5.1
-
signalMsgConsumer
- Returns:
- The optional Ebms3 Signal Message Consumer. May be
null. - Since:
- 3.0.0
-
signalMsgConsumer
@Nonnull public final IMPLTYPE signalMsgConsumer(@Nullable IAS4SignalMessageConsumer aSignalMsgConsumer) Set an optional Ebms3 Signal Message Consumer. If this consumer is set, the response is trying to be parsed as a Signal Message. This method is optional and must not be called prior to sending.- Parameters:
aSignalMsgConsumer- The optional signal message consumer. May benull.- Returns:
- this for chaining
-
signalMsgValidationResultHdl
- Returns:
- The optional Ebms3 Signal Message validation result handled. May be
null. - Since:
- 3.0.1
-
signalMsgValidationResultHdl
@Nonnull public final IMPLTYPE signalMsgValidationResultHdl(@Nullable IAS4SignalMessageValidationResultHandler aSignalMsgValidationResultHdl) Set an optional Ebms3 Signal Message validation result handler. This handler is invoked, after the synchronous signal message references were evaluated. This handler cannot modify any message flow - it is an informational callback only.- Parameters:
aSignalMsgValidationResultHdl- The optional signal message consumer. May benull.- Returns:
- this for chaining
- Since:
- 3.0.1
-
finishFields
@Nonnull @OverridingMethodsMustInvokeSuper protected com.helger.commons.state.ESuccess finishFields() throws Phase4ExceptionDescription copied from class:AbstractAS4MessageBuilderInternal method that is invoked before the required field check is performed. Override to set additional dynamically created fields if necessary.
Don't add message properties in here, because if the required fields check fails than this method would be called again.
This is called beforeAbstractAS4MessageBuilder.isEveryRequiredFieldSet()- Overrides:
finishFieldsin classAbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>- Returns:
ESuccess- nevernull. Returning failure here stops sending the message.- Throws:
Phase4Exception- if something goes wrong
-
isEveryRequiredFieldSet
Description copied from class:AbstractAS4MessageBuilderCheck if all mandatory fields are set. This method is called afterAbstractAS4MessageBuilder.finishFields()and beforeAbstractAS4MessageBuilder.customizeBeforeSending()- Overrides:
isEveryRequiredFieldSetin classAbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>- Returns:
trueif all mandatory fields are set, and sending can continue.
-
applyToUserMessage
@OverridingMethodsMustInvokeSuper protected void applyToUserMessage(@Nonnull AS4ClientUserMessage aUserMsg) This method applies all builder parameters onto the user message, except the attachments.- Parameters:
aUserMsg- The user message the parameters should be applied to. May not benull.
-
sendMessageAndCheckForReceipt
This is a sanity method that encapsulates all the sending checks that are necessary to determine overall sending success or error.
Note: this method is not thread-safe, because it changes the signal message consumer internally.- Returns:
EAS4UserMessageSendResult.SUCCESSonly if all parameters are correct, HTTP transmission was successful and if a positive AS4 Receipt was returned. Nevernull.- Since:
- 0.13.0
-
sendMessageAndCheckForReceipt
@Nonnull public final EAS4UserMessageSendResult sendMessageAndCheckForReceipt(@Nullable Consumer<? super Phase4Exception> aExceptionConsumer) This is a sanity method that encapsulates all the sending checks that are necessary to determine overall sending success or error.
Note: this method is not thread-safe, because it changes the signal message consumer internally.- Parameters:
aExceptionConsumer- An optional Consumer that takes an eventually thrownPhase4Exception. May benull.- Returns:
EAS4UserMessageSendResult.SUCCESSonly if all parameters are correct, HTTP transmission was successful and if a positive AS4 Receipt was returned. Nevernull.- Since:
- 1.0.0-rc1
-