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.base.trait.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 Details

    • m_aPMode

      protected IPMode m_aPMode
    • m_sServiceType

      protected String m_sServiceType
    • m_sService

      protected String m_sService
    • m_sAction

      protected String m_sAction
    • m_sAgreementRef

      protected String m_sAgreementRef
    • m_sAgreementType

      protected String m_sAgreementType
    • m_sPModeID

      protected String m_sPModeID
    • m_sFromPartyIDType

      protected String m_sFromPartyIDType
    • m_sFromPartyID

      protected String m_sFromPartyID
    • m_sFromRole

      protected String m_sFromRole
    • m_sToPartyIDType

      protected String m_sToPartyIDType
    • m_sToPartyID

      protected String m_sToPartyID
    • m_sToRole

      protected String m_sToRole
    • m_sConversationID

      protected String m_sConversationID
    • m_aMessageProperties

      protected final com.helger.collection.commons.ICommonsList<MessageProperty> m_aMessageProperties
    • m_sEndpointURL

      protected String m_sEndpointURL
    • m_aAttachments

      protected final com.helger.collection.commons.ICommonsList<AS4OutgoingAttachment> m_aAttachments
    • m_bForceMimeMessage

      protected boolean m_bForceMimeMessage
    • m_aSignalMsgConsumer

      protected IAS4SignalMessageConsumer m_aSignalMsgConsumer
    • m_aSignalMsgValidationResultHdl

      protected IAS4SignalMessageValidationResultHandler m_aSignalMsgValidationResultHdl
  • Constructor Details

    • AbstractAS4UserMessageBuilder

      protected AbstractAS4UserMessageBuilder()
      Create a new builder
  • Method Details

    • pmode

      public final @Nullable IPMode pmode()
      Returns:
      The currently set P-Mode. May be null.
    • pmode

      public final @NonNull IMPLTYPE pmode(@Nullable IPMode aPMode)
      Set the PMode to be used. By default a generic PMode is used.
      Parameters:
      aPMode - The PMode to be used. May be null.
      Returns:
      this for chaining
    • serviceType

      public final @Nullable String serviceType()
      Returns:
      The optional "Service" type. May be null.
      Since:
      3.0.0
    • service

      public final @Nullable String service()
      Returns:
      The "Service" value. May be null.
      Since:
      3.0.0
    • service

      public final @NonNull IMPLTYPE service(@Nullable String sServiceValue)
      Set the "Service" value only, leaving the type null.
      Parameters:
      sServiceValue - Service value. May be null.
      Returns:
      this for chaining.
    • service

      public final @NonNull 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 be null.
      sServiceValue - Service value. May be null.
      Returns:
      this for chaining.
    • action

      public final @Nullable String action()
      Returns:
      The "Action" value. May be null.
      Since:
      3.0.0
    • action

      public final @NonNull IMPLTYPE action(@Nullable String sAction)
      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 be null.
      Returns:
      this for chaining.
    • agreementRef

      public final @Nullable String agreementRef()
      Returns:
      The "AgreementRef" value. May be null.
      Since:
      3.0.0
    • agreementRef

      public final @NonNull IMPLTYPE agreementRef(@Nullable String sAgreementRef)
      Set the "AgreementRef" value. It's optional.
      Parameters:
      sAgreementRef - Agreement reference. May be null.
      Returns:
      this for chaining.
    • agreementType

      public final @Nullable String agreementType()
      Returns:
      The "AgreementRef type" value. May be null.
      Since:
      3.0.0
    • agreementType

      public final @Nullable IMPLTYPE agreementType(@Nullable String sAgreementType)
      Set the "AgreementRef type" value. It's optional.
      Parameters:
      sAgreementType - Agreement reference type. May be null.
      Returns:
      this for chaining.
      Since:
      2.7.8
    • pmodeID

      public final @Nullable String pmodeID()
      Returns:
      the current PMode ID. May be null.
      See Also:
    • pmodeID

      public final @NonNull IMPLTYPE pmodeID(@Nullable String s)
      Set the optional PMode ID for packaging in the user message.
      Parameters:
      s - PMode ID. May be null.
      Returns:
      this for chaining
    • fromPartyIDType

      public final @Nullable String fromPartyIDType()
      Returns:
      The "from party ID type". May be null.
      Since:
      3.0.0
    • fromPartyIDType

      public final @NonNull IMPLTYPE fromPartyIDType(@Nullable String sFromPartyIDType)
      Set the "from party ID type".
      Parameters:
      sFromPartyIDType - The from party ID.
      Returns:
      this for chaining
    • fromPartyID

      public final @Nullable String fromPartyID()
      Returns:
      The "from party ID". May be null.
      Since:
      3.0.0
    • fromPartyID

      public final @NonNull IMPLTYPE fromPartyID(@Nullable String sFromPartyID)
      Set the "from party ID".
      Parameters:
      sFromPartyID - The from party ID.
      Returns:
      this for chaining
    • fromRole

      public final @Nullable String fromRole()
      Returns:
      The "from party role". May be null.
      Since:
      3.0.0
    • fromRole

      public final @NonNull IMPLTYPE fromRole(@Nullable String sFromRole)
      Set the "from party role". This is optional
      Parameters:
      sFromRole - The from role. May be null.
      Returns:
      this for chaining
    • toPartyIDType

      public final @Nullable String toPartyIDType()
      Returns:
      The "to party ID type". May be null.
      Since:
      3.0.0
    • toPartyIDType

      public final @NonNull IMPLTYPE toPartyIDType(@Nullable String sToPartyIDType)
      Set the "to party ID type".
      Parameters:
      sToPartyIDType - The to party ID.
      Returns:
      this for chaining
    • toPartyID

      public final @Nullable String toPartyID()
      Returns:
      The "to party ID". May be null.
      Since:
      3.0.0
    • toPartyID

      public final @NonNull IMPLTYPE toPartyID(@Nullable String sToPartyID)
      Set the "to party ID".
      Parameters:
      sToPartyID - The to party ID.
      Returns:
      this for chaining
    • toRole

      public final @Nullable String toRole()
      Returns:
      The "to party role". May be null.
      Since:
      3.0.0
    • toRole

      public final @NonNull IMPLTYPE toRole(@Nullable String sToRole)
      Set the "to party role". This is optional
      Parameters:
      sToRole - The to role. May be null.
      Returns:
      this for chaining
    • conversationID

      public final @Nullable String conversationID()
      Returns:
      The optional AS4 conversation ID. May be null.
      Since:
      3.0.0
    • conversationID

      public final @NonNull IMPLTYPE conversationID(@Nullable String sConversationID)
      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 be null.
      Returns:
      this for chaining
    • messageProperties

      @ReturnsMutableObject public final @NonNull com.helger.collection.commons.ICommonsList<MessageProperty> messageProperties()
    • getAllMessageProperties

      @ReturnsMutableCopy public final @NonNull com.helger.collection.commons.ICommonsList<MessageProperty> getAllMessageProperties()
    • addEbmsProperties

      public final @NonNull IMPLTYPE addEbmsProperties(@Nullable Iterable<? extends Ebms3Property> a)
    • addMessageProperty

      public final @NonNull IMPLTYPE addMessageProperty(@Nullable Ebms3Property a)
    • addMessageProperty

      public final @NonNull IMPLTYPE addMessageProperty(@Nullable MessageProperty.Builder a)
    • addMessageProperty

      public final @NonNull IMPLTYPE addMessageProperty(@Nullable MessageProperty a)
    • messageProperty

      public final @NonNull IMPLTYPE messageProperty(@Nullable Ebms3Property a)
    • messageProperty

      public final @NonNull IMPLTYPE messageProperty(@Nullable MessageProperty.Builder a)
    • messageProperty

      public final @NonNull IMPLTYPE messageProperty(@Nullable MessageProperty a)
    • messageProperties

      public final @NonNull IMPLTYPE messageProperties(@Nullable MessageProperty... a)
    • messageProperties

      public final @NonNull IMPLTYPE messageProperties(@Nullable Iterable<? extends MessageProperty> a)
    • receiverCertificate

      public final @NonNull IMPLTYPE receiverCertificate(@Nullable X509Certificate aCertificate)
      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 be null.
      Returns:
      this for chaining
      See Also:
    • receiverCertificateAlias

      public final @NonNull IMPLTYPE receiverCertificateAlias(@Nullable String sAlias)
      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 be null.
      Returns:
      this for chaining
      Since:
      2.1.4
      See Also:
    • endpointURL

      public final @Nullable String endpointURL()
      Returns:
      The receiver AS4 endpoint URL. May be null.
      Since:
      3.0.0
    • endpointURL

      public final @NonNull IMPLTYPE endpointURL(@Nullable String sEndointURL)
      Set an receiver AS4 endpoint URL, independent of its usability.
      Parameters:
      sEndointURL - The endpoint URL to be used. May be null.
      Returns:
      this for chaining
    • attachments

      @ReturnsMutableObject public final @NonNull com.helger.collection.commons.ICommonsList<AS4OutgoingAttachment> attachments()
    • getAllAttachments

      @ReturnsMutableCopy public final @NonNull com.helger.collection.commons.ICommonsList<AS4OutgoingAttachment> getAllAttachments()
    • addAttachment

      public final @NonNull IMPLTYPE addAttachment(@Nullable AS4OutgoingAttachment.Builder a)
      Add an optional attachment
      Parameters:
      a - The attachment to be added. May be null.
      Returns:
      this for chaining
    • addAttachment

      public final @NonNull IMPLTYPE addAttachment(@Nullable AS4OutgoingAttachment a)
      Add an optional attachment
      Parameters:
      a - The attachment to be added. May be null.
      Returns:
      this for chaining
    • attachment

      public final @NonNull IMPLTYPE attachment(@Nullable AS4OutgoingAttachment.Builder a)
      Set optional attachment. All existing attachments are overridden.
      Parameters:
      a - The attachment to be set. May be null.
      Returns:
      this for chaining
    • attachment

      public final @NonNull IMPLTYPE attachment(@Nullable AS4OutgoingAttachment a)
      Set optional attachment. All existing attachments are overridden.
      Parameters:
      a - The attachment to be set. May be null.
      Returns:
      this for chaining
    • attachments

      public final @NonNull IMPLTYPE attachments(@Nullable AS4OutgoingAttachment... a)
      Set optional attachments. All existing attachments are overridden.
      Parameters:
      a - The attachment to be set. May be null.
      Returns:
      this for chaining
    • attachments

      public final @NonNull IMPLTYPE attachments(@Nullable Iterable<? extends AS4OutgoingAttachment> a)
      Set optional attachments. All existing attachments are overridden.
      Parameters:
      a - The attachment to be set. May be null.
      Returns:
      this for chaining
    • forceMimeMessage

      public final boolean forceMimeMessage()
      Returns:
      true if the message is forced into the MIME format, false otherwise.
      Since:
      3.0.0
    • forceMimeMessage

      public final @NonNull IMPLTYPE forceMimeMessage(boolean b)
      Enable the enforcement of packaging the AS4 user message in a MIME message.
      Parameters:
      b - true to enforce it, false to make it dynamic.
      Returns:
      this for chaining
      Since:
      2.5.1
    • signalMsgConsumer

      public final @Nullable IAS4SignalMessageConsumer signalMsgConsumer()
      Returns:
      The optional Ebms3 Signal Message Consumer. May be null.
      Since:
      3.0.0
    • signalMsgConsumer

      public final @NonNull 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 be null.
      Returns:
      this for chaining
    • signalMsgValidationResultHdl

      public final @Nullable IAS4SignalMessageValidationResultHandler signalMsgValidationResultHdl()
      Returns:
      The optional Ebms3 Signal Message validation result handled. May be null.
      Since:
      3.0.1
    • signalMsgValidationResultHdl

      public final @NonNull 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 be null.
      Returns:
      this for chaining
      Since:
      3.0.1
    • finishFields

      @OverridingMethodsMustInvokeSuper protected @NonNull com.helger.base.state.ESuccess finishFields(@NonNull AS4ResourceHelper aResHelper) throws Phase4Exception
      Description copied from class: AbstractAS4MessageBuilder
      Internal 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 before AbstractAS4MessageBuilder.isEveryRequiredFieldSet()
      Overrides:
      finishFields in class AbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>
      Parameters:
      aResHelper - The AS4 resource helper to use. Never null.
      Returns:
      ESuccess - never null. Returning failure here stops sending the message.
      Throws:
      Phase4Exception - if something goes wrong
    • isEveryRequiredFieldSet

      @OverridingMethodsMustInvokeSuper public boolean isEveryRequiredFieldSet()
      Description copied from class: AbstractAS4MessageBuilder
      Check if all mandatory fields are set. This method is called after AbstractAS4MessageBuilder.finishFields(AS4ResourceHelper) and before AbstractAS4MessageBuilder.customizeBeforeSending()
      Overrides:
      isEveryRequiredFieldSet in class AbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4UserMessageBuilder<IMPLTYPE>>
      Returns:
      true if 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 be null.
    • sendMessageAndCheckForReceipt

      public final @NonNull EAS4UserMessageSendResult 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.SUCCESS only if all parameters are correct, HTTP transmission was successful and if a positive AS4 Receipt was returned. Never null.
      Since:
      0.13.0
    • sendMessageAndCheckForReceipt

      public final @NonNull 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 thrown Phase4Exception. May be null.
      Returns:
      EAS4UserMessageSendResult.SUCCESS only if all parameters are correct, HTTP transmission was successful and if a positive AS4 Receipt was returned. Never null.
      Since:
      1.0.0-rc1