Class MessageHelperMethods

java.lang.Object
com.helger.phase4.messaging.domain.MessageHelperMethods

@Immutable public final class MessageHelperMethods extends Object
This class contains every method, static variables which are used by more than one message creating classes in this package.
Author:
bayerlma, Philip Helger
  • Field Details

  • Method Details

    • createRandomConversationID

      @Nonnull @Nonempty public static String createRandomConversationID()
    • getCustomMessageIDSuffix

      @Nullable public static String getCustomMessageIDSuffix()
      Returns:
      The custom message ID suffix to be used. May be null.
      Since:
      1.1.1
    • setCustomMessageIDSuffix

      public static void setCustomMessageIDSuffix(@Nullable String sSuffix)
      Set a custom message ID suffix to be used in createRandomMessageID(). If a string is provided, any eventually present leading dot is cut. This
      Parameters:
      sSuffix - The suffix to be used. May be null. If present it must match the MESSAGE_ID_SUFFIX_REGEX regular expression.
      Since:
      1.1.1
    • createRandomMessageID

      @Nonnull @Nonempty public static String createRandomMessageID()
      Create a new random AS4 Message ID. Every call results in a new unique message ID. The layout of a created message ID is like this: UUID@phase4[.customSuffix] where UUID is a random UID, "@phase4" is a constant, non-changeable value and customSuffix is the optional suffix to be set via setCustomMessageIDSuffix(String).
      Returns:
      A new random AS4 Message ID. Neither null nor empty.
    • createRandomContentID

      @Nonnull @Nonempty public static String createRandomContentID()
      Returns:
      A random Content-ID that adheres to RFC 822. Neither null nor empty.
    • createRandomMessagingID

      @Nonnull @Nonempty public static String createRandomMessagingID()
    • createRandomWSUID

      @Nonnull @Nonempty public static String createRandomWSUID()
    • createEbms3MessageInfo

      @Nonnull public static Ebms3MessageInfo createEbms3MessageInfo()
      Create a new message info with a UUID as message ID.
      Returns:
      Never null.
    • createEbms3MessageInfo

      @Nonnull public static Ebms3MessageInfo createEbms3MessageInfo(@Nullable String sRefToMessageID)
      Create a new message info with a UUID as message ID and a reference to the previous message.
      Parameters:
      sRefToMessageID - The message ID of the referenced message. May be null.
      Returns:
      Never null.
    • createEbms3MessageInfo

      @Nonnull public static Ebms3MessageInfo createEbms3MessageInfo(@Nonnull @Nonempty String sMessageID, @Nullable String sRefToMessageID)
      Create a new message info.
      Parameters:
      sMessageID - The message ID. May neither be null nor empty.
      sRefToMessageID - to set the reference to the previous message needed for two way exchanges
      Returns:
      Never null.
    • createEbms3MessageInfo

      @Nonnull public static Ebms3MessageInfo createEbms3MessageInfo(@Nonnull @Nonempty String sMessageID, @Nullable String sRefToMessageID, @Nonnull OffsetDateTime aDateTime)
      Create a new message info.
      Parameters:
      sMessageID - The message ID. May neither be null nor empty.
      sRefToMessageID - to set the reference to the previous message needed for two way exchanges
      aDateTime - Date and time. May not be null.
      Returns:
      Never null.
      Since:
      0.12.0
    • createEbms3Description

      @Nonnull @ReturnsMutableCopy public static Ebms3Description createEbms3Description(@Nonnull Locale aLocale, @Nonnull String sText)
    • createEbms3Property

      @Nonnull public static Ebms3Property createEbms3Property(@Nonnull @Nonempty String sName, @Nonnull String sValue)
    • createEbms3Property

      @Nonnull public static Ebms3Property createEbms3Property(@Nonnull @Nonempty String sName, @Nullable String sType, @Nonnull String sValue)
    • createEbms3PartyId

      @Nonnull public static Ebms3PartyId createEbms3PartyId(@Nonnull @Nonempty String sValue)
    • createEbms3PartyId

      @Nonnull public static Ebms3PartyId createEbms3PartyId(@Nullable String sType, @Nonnull @Nonempty String sValue)
    • createEbms3ReversePartyInfo

      @Nonnull public static Ebms3PartyInfo createEbms3ReversePartyInfo(@Nonnull Ebms3PartyInfo aOrigPartyInfo)
    • createEbms3PartyInfo

      @Nonnull public static Ebms3PartyInfo createEbms3PartyInfo(@Nonnull @Nonempty String sFromRole, @Nonnull @Nonempty String sFromPartyID, @Nonnull @Nonempty String sToRole, @Nonnull @Nonempty String sToPartyID)
    • createEbms3PartyInfo

      @Nonnull public static Ebms3PartyInfo createEbms3PartyInfo(@Nonnull @Nonempty String sFromRole, @Nullable String sFromPartyIDType, @Nonnull @Nonempty String sFromPartyID, @Nonnull @Nonempty String sToRole, @Nullable String sToPartyIDType, @Nonnull @Nonempty String sToPartyID)
    • createEbms3MessageProperties

      @Nullable public static Ebms3MessageProperties createEbms3MessageProperties(@Nullable List<Ebms3Property> aEbms3Properties)
    • createEbms3CollaborationInfo

      @Nonnull public static Ebms3CollaborationInfo createEbms3CollaborationInfo(@Nullable String sAgreementRefPMode, @Nullable String sAgreementRefValue, @Nullable String sServiceType, @Nonnull @Nonempty String sServiceValue, @Nonnull @Nonempty String sAction, @Nonnull String sConversationID)
    • createEbms3PartInfo

      @Nullable public static Ebms3PartInfo createEbms3PartInfo(@Nullable IAS4Attachment aAttachment)
    • createEbms3PayloadInfo

      @Nullable public static Ebms3PayloadInfo createEbms3PayloadInfo(boolean bHasSoapPayload, @Nullable com.helger.commons.collection.impl.ICommonsList<? extends IAS4Attachment> aAttachments)
      Add payload info if attachments are present.
      Parameters:
      bHasSoapPayload - true if SOAP payload is present. This must be false when using MIME message layout!
      aAttachments - Used attachments
      Returns:
      null if no attachments are present.
    • forEachHeaderAndRemoveAfterwards

      public static void forEachHeaderAndRemoveAfterwards(@Nonnull jakarta.mail.internet.MimeMessage aMimeMsg, @Nonnull BiConsumer<String,String> aConsumer, boolean bUnifyValues) throws jakarta.mail.MessagingException
      Take all headers from the MIME message and pass them to the provided consumer. Afterwards remove all headers from the MIME message itself.
      Parameters:
      aMimeMsg - The message to use. May not be null.
      aConsumer - The consumer to be invoked. May not be null.
      bUnifyValues - true to unify the HTTP header values before passing them to the consumer.
      Throws:
      jakarta.mail.MessagingException - In case of MIME message processing problems
    • getAndRemoveAllHeaders

      @Nonnull @ReturnsMutableCopy public static com.helger.commons.http.HttpHeaderMap getAndRemoveAllHeaders(@Nonnull jakarta.mail.internet.MimeMessage aMimeMsg) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException