Class PeppolSBDHData

java.lang.Object
com.helger.peppol.sbdh.PeppolSBDHData

@NotThreadSafe public class PeppolSBDHData extends Object
This class contains all the Peppol data per SBDH document in a syntax neutral way. This class maps to the requirements of the Peppol Business Message Envelope 2.0 specification.
Since:
9.2.0 - was previously called "PeppolSBDHDocument"
Author:
Philip Helger
  • Constructor Details

    • PeppolSBDHData

      public PeppolSBDHData(@Nonnull com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory)
      Constructor
      Parameters:
      aIdentifierFactory - Identifier factory to be used. May not be null.
  • Method Details

    • getSenderScheme

      @Nullable public String getSenderScheme()
      Returns:
      The sender participant identifier scheme. May be null if not initialized. This field is mapped to StandardBusinessDocumentHeader/Sender/Identifier/@Authority .
    • getSenderValue

      @Nullable public String getSenderValue()
      Returns:
      The sender participant identifier value. May be null if not initialized. This field is mapped to StandardBusinessDocumentHeader/Sender/Identifier/.
    • getSenderAsIdentifier

      @Nullable public com.helger.peppolid.IParticipantIdentifier getSenderAsIdentifier()
      Returns:
      The sender participant identifier as a participant identifier or null if certain information are missing or are invalid.
    • setSender

      @Nonnull public PeppolSBDHData setSender(@Nonnull @Nonempty String sScheme, @Nonnull @Nonempty String sValue)
      Set the sender participant identifier.
      Parameters:
      sScheme - The Peppol identifier scheme. This is usually always PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Sender/Identifier/@Authority .
      sValue - The sender identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Sender/Identifier/.
      Returns:
      this
    • setSender

      @Nonnull public PeppolSBDHData setSender(@Nonnull com.helger.peppolid.IParticipantIdentifier aSenderID)
      Set the sender participant identifier.
      Parameters:
      aSenderID - The participant identifier to use. May not be null.
      Returns:
      this
      Since:
      8.6.1
    • setSenderWithDefaultScheme

      @Nonnull public PeppolSBDHData setSenderWithDefaultScheme(@Nonnull @Nonempty String sValue)
      Set the sender participant identifier value using the default identifier scheme/authority PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME.
      Parameters:
      sValue - The sender identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Sender/Identifier/.
      Returns:
      this
    • getReceiverScheme

      @Nullable public String getReceiverScheme()
      Returns:
      The receiver participant identifier scheme. May be null if not initialized. This field is mapped to StandardBusinessDocumentHeader/Receiver/Identifier/@Authority .
    • getReceiverValue

      @Nullable public String getReceiverValue()
      Returns:
      The receiver participant identifier value. May be null if not initialized. This field is mapped to StandardBusinessDocumentHeader/Receiver/Identifier/.
    • getReceiverAsIdentifier

      @Nullable public com.helger.peppolid.IParticipantIdentifier getReceiverAsIdentifier()
      Returns:
      The receiver participant identifier as a participant identifier or null if certain information are missing or are invalid.
    • setReceiver

      @Nonnull public PeppolSBDHData setReceiver(@Nonnull @Nonempty String sScheme, @Nonnull @Nonempty String sValue)
      Set the receiver participant identifier.
      Parameters:
      sScheme - The Peppol identifier scheme. This is usually always PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME . May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Receiver/Identifier/@Authority .
      sValue - The receiver identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Receiver/Identifier/.
      Returns:
      this
    • setReceiver

      @Nonnull public PeppolSBDHData setReceiver(@Nonnull com.helger.peppolid.IParticipantIdentifier aReceiverID)
      Set the receiver participant identifier.
      Parameters:
      aReceiverID - The participant identifier to use. May not be null.
      Returns:
      this
      Since:
      8.6.1
    • setReceiverWithDefaultScheme

      @Nonnull public PeppolSBDHData setReceiverWithDefaultScheme(@Nonnull @Nonempty String sValue)
      Set the receiver participant identifier value using the default identifier scheme/authority PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME.
      Parameters:
      sValue - The sender identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/Receiver/Identifier/.
      Returns:
      this
    • getDocumentTypeScheme

      @Nullable public String getDocumentTypeScheme()
      Returns:
      The document type identifier scheme. May be null if not initialized yet. This field is currently not mapped.
    • getDocumentTypeValue

      @Nullable public String getDocumentTypeValue()
      Returns:
      The document type identifier value. May be null if not initialized yet. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="DOCUMENTID"]/InstanceIdentifier .
    • getDocumentTypeAsIdentifier

      @Nullable public com.helger.peppolid.IDocumentTypeIdentifier getDocumentTypeAsIdentifier()
      Returns:
      The document type identifier as an object or null if certain information are missing or are invalid.
    • setDocumentType

      @Nonnull public PeppolSBDHData setDocumentType(@Nonnull @Nonempty String sScheme, @Nonnull @Nonempty String sValue)
      Set the document type identifier.
      Parameters:
      sScheme - The document type identifier scheme. May neither be null nor empty.
      sValue - The document type identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="DOCUMENTID"]/InstanceIdentifier .
      Returns:
      this
    • setDocumentType

      @Nonnull public PeppolSBDHData setDocumentType(@Nonnull com.helger.peppolid.IDocumentTypeIdentifier aDocTypeID)
      Set the document type identifier.
      Parameters:
      aDocTypeID - The document type identifier to use. May not be null.
      Returns:
      this
      Since:
      8.6.1
    • setDocumentTypeWithBusdoxDocidQns

      @Nonnull public PeppolSBDHData setDocumentTypeWithBusdoxDocidQns(@Nonnull @Nonempty String sValue)
      Set the document type identifier using the default identifier scheme/authority PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS .
      Parameters:
      sValue - The document type identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="DOCUMENTID"]/InstanceIdentifier .
      Returns:
      this
      Since:
      8.3.1
    • setDocumentTypeWithPeppolDoctypeWildcard

      @Nonnull public PeppolSBDHData setDocumentTypeWithPeppolDoctypeWildcard(@Nonnull @Nonempty String sValue)
      Set the document type identifier using the default identifier scheme/authority PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_PEPPOL_DOCTYPE_WILDCARD .
      Parameters:
      sValue - The document type identifier value. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="DOCUMENTID"]/InstanceIdentifier .
      Returns:
      this
      Since:
      8.3.1
    • getProcessScheme

      @Nullable public String getProcessScheme()
      Returns:
      The process identifier scheme. May be null if not initialized yet. This field is currently not mapped.
    • getProcessValue

      @Nullable public String getProcessValue()
      Returns:
      The process identifier value. May be null if not initialized yet. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="PROCESSID"]/InstanceIdentifier .
    • getProcessAsIdentifier

      @Nullable public com.helger.peppolid.IProcessIdentifier getProcessAsIdentifier()
      Returns:
      The process identifier as an object or null if certain information are missing or are invalid.
    • setProcess

      @Nonnull public PeppolSBDHData setProcess(@Nonnull @Nonempty String sScheme, @Nonnull @Nonempty String sValue)
      Set the process identifier.
      Parameters:
      sScheme - The process identifier scheme. May neither be null nor empty.
      sValue - The process identifier. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="PROCESSID"]/InstanceIdentifier .
      Returns:
      this
    • setProcess

      @Nonnull public PeppolSBDHData setProcess(@Nonnull com.helger.peppolid.IProcessIdentifier aProcessID)
      Set the process identifier.
      Parameters:
      aProcessID - The process identifier to use. May not be null.
      Returns:
      this
      Since:
      8.6.1
    • setProcessWithDefaultScheme

      @Nonnull public PeppolSBDHData setProcessWithDefaultScheme(@Nonnull @Nonempty String sValue)
      Set the document type identifier using the default identifier scheme/authority PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME.
      Parameters:
      sValue - The process identifier. May neither be null nor empty. This field is mapped to StandardBusinessDocumentHeader/BusinessScope/Scope[Type/text()="PROCESSID"]/InstanceIdentifier .
      Returns:
      this
    • getCountryC1

      @Nullable public String getCountryC1()
      Get the country code of C1. This is a new mandatory field, introduced by the Peppol Business Message Envelope 2.0 specification. It is mapped inside the BusinessScope area.
      Returns:
      The country code of C1. May be null.
      Since:
      9.0.5
      See Also:
    • hasCountryC1

      public boolean hasCountryC1()
      Check if the country code of C1 is present or not.
      Returns:
      true if the country code of C1 is present, false if not.
      Since:
      9.0.5
      See Also:
    • setCountryC1

      @Nonnull public PeppolSBDHData setCountryC1(@Nonnull @Nonempty String sCountryC1)
      Set the country code of C1 to be used.
      Parameters:
      sCountryC1 - The country code of C1 to be used. May be null.
      Returns:
      this for chaining
      Since:
      9.0.5
      See Also:
    • additionalAttributes

      @Nonnull @ReturnsMutableObject public com.helger.commons.collection.attr.StringMap additionalAttributes()
      Returns:
      The mutable attribute map where all additional attributes according to Spec v1.1, chapter 1.6.1 were added.
      Since:
      6.1.4
    • setDocumentIdentification

      @Nonnull public PeppolSBDHData setDocumentIdentification(@Nonnull @Nonempty String sStandard, @Nonnull @Nonempty String sTypeVersion, @Nonnull @Nonempty String sType, @Nonnull @Nonempty String sInstanceIdentifier, @Nonnull com.helger.commons.datetime.XMLOffsetDateTime aCreationDateAndTime)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      sStandard - The standard of the enveloped business message, normally described by use of the XML namespace of the business message root element (such as urn:oasis:names:specification: ubl:schema:xsd:Order-2). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Standard .
      sTypeVersion - The version number of the enveloped business message (such as the value "2.1" for OASIS UBL 2.1). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/TypeVersion .
      sType - Message type - mandatory in SBDH. XML local element name of the root-element in the business message. May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Type .
      sInstanceIdentifier - An informative unique ID created by the issuer of the envelope. The InstanceIdentifier MUST be unique for each Business Message Envelope being created. This ID is not the same as the ID of the business message (such as the Invoice Number). It is not the same as a transmission Message ID generated by the application sending the message (as defined in AS4).
      The InstanceIdentifier MUST be globally unique and it is RECOMMENDED to use UUID (such as 118e3040-51d2-11e3-8f96-0800200c9a66). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/InstanceIdentifier .
      aCreationDateAndTime - The date and time for when this envelope was created. It is NOT necessarily the same as the issue date of the business document (such as the invoice) being enveloped. It is NOT necessarily the date time for transmission.
      The format of the value of this MUST include timezone information. May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/CreationDateAndTime .
      Returns:
      this
      See Also:
    • getStandard

      @Nullable public String getStandard()
      The standard of the enveloped business message, normally described by use of the XML namespace of the business message root element (such as urn:oasis:names:specification:ubl:schema:xsd:Order-2). This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Standard .
      Returns:
      The standard value. May be null.
    • hasStandard

      public boolean hasStandard()
      Returns:
      true if a standard is present, false if not.
      Since:
      7.0.0
    • setStandard

      @Nonnull public PeppolSBDHData setStandard(@Nonnull @Nonempty String sStandard)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      sStandard - The standard of the enveloped business message, normally described by use of the XML namespace of the business message root element (such as urn:oasis:names:specification: ubl:schema:xsd:Order-2). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Standard .
      Returns:
      this
      Since:
      8.3.1
      See Also:
    • getTypeVersion

      @Nullable public String getTypeVersion()
      The version number of the enveloped business message (such as the value "2.1" for OASIS UBL 2.1 or "2.2" for OASIS UBL 2.2). This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/TypeVersion .
      Returns:
      The type version. May be null.
    • hasTypeVersion

      public boolean hasTypeVersion()
      Returns:
      true if a type version is present, false if not.
      Since:
      7.0.0
    • setTypeVersion

      @Nonnull public PeppolSBDHData setTypeVersion(@Nonnull @Nonempty String sTypeVersion)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      sTypeVersion - The version number of the enveloped business message (such as the value "2.1" for OASIS UBL 2.1). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/TypeVersion .
      Returns:
      this
      Since:
      8.3.1
      See Also:
    • getType

      @Nullable public String getType()
      Message type - mandatory in SBDH. XML local element name of the root-element in the business message. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Type.
      Returns:
      Type value. May be null.
    • hasType

      public boolean hasType()
      Returns:
      true if a type is present, false if not.
      Since:
      7.0.0
    • setType

      @Nonnull public PeppolSBDHData setType(@Nonnull @Nonempty String sType)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      sType - Message type - mandatory in SBDH. XML local element name of the root-element in the business message. May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/Type .
      Returns:
      this
      Since:
      8.3.1
      See Also:
    • getInstanceIdentifier

      @Nullable public String getInstanceIdentifier()
      An informative unique ID created by the issuer of the envelope. The InstanceIdentifier MUST be unique for each Business Message Envelope being created. This ID is not the same as the ID of the business message (such as the Invoice Number). It is not the same as a transmission Message ID generated by the application sending the message (as defined in AS2 or START).
      The InstanceIdentifier MUST be globally unique and it is RECOMMENDED to use UUID (such as 118e3040-51d2-11e3-8f96-0800200c9a66). This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/InstanceIdentifier .
      Returns:
      The instance identifier. May be null.
    • hasInstanceIdentifier

      public boolean hasInstanceIdentifier()
      Returns:
      true if an instance identifier is present, false if not.
      Since:
      7.0.0
    • setInstanceIdentifier

      @Nonnull public PeppolSBDHData setInstanceIdentifier(@Nonnull @Nonempty String sInstanceIdentifier)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      sInstanceIdentifier - An informative unique ID created by the issuer of the envelope. The InstanceIdentifier MUST be unique for each Business Message Envelope being created. This ID is not the same as the ID of the business message (such as the Invoice Number). It is not the same as a transmission Message ID generated by the application sending the message (as defined in AS4).
      The InstanceIdentifier MUST be globally unique and it is RECOMMENDED to use UUID (such as 118e3040-51d2-11e3-8f96-0800200c9a66). May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/InstanceIdentifier .
      Returns:
      this
      Since:
      8.3.1
      See Also:
    • getCreationDateAndTime

      @Nullable public com.helger.commons.datetime.XMLOffsetDateTime getCreationDateAndTime()
      The date and time for when this envelope was created. It is NOT necessarily the same as the issue date of the business document (such as the invoice) being enveloped. It is NOT necessarily the date time for transmission.
      The format of the value of this MUST include timezone information. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/CreationDateAndTime .
      Returns:
      The creation date time. May be null.
    • hasCreationDateAndTime

      public boolean hasCreationDateAndTime()
      Returns:
      true if creation date and time is present, false if not.
      Since:
      7.0.0
    • setCreationDateAndTime

      @Nonnull public PeppolSBDHData setCreationDateAndTime(@Nonnull com.helger.commons.datetime.XMLOffsetDateTime aCreationDateAndTime)
      Set the content of the fields that are mapped to StandardBusinessDocumentHeader/DocumentIdentification.
      Parameters:
      aCreationDateAndTime - The date and time for when this envelope was created. It is NOT necessarily the same as the issue date of the business document (such as the invoice) being enveloped. It is NOT necessarily the date time for transmission.
      The format of the value of this MUST include timezone information. May not be null. This field is mapped to StandardBusinessDocumentHeader/DocumentIdentification/CreationDateAndTime .
      Returns:
      this
      Since:
      8.3.1
      See Also:
    • getBusinessMessage

      @Nullable @ReturnsMutableCopy public Element getBusinessMessage()
      Get the contained business message.
      Returns:
      null if no business message is present. A clone (deep copy) of the business message otherwise.
      See Also:
    • getBusinessMessageNoClone

      @Nullable @ReturnsMutableObject public Element getBusinessMessageNoClone()
      Get the contained business message without cloning it.
      Returns:
      null if no business message is present.
      Since:
      8.6.1
      See Also:
    • hasBusinessMessage

      public boolean hasBusinessMessage()
      Check if a business message is present without having the need to explicitly call getBusinessMessage() which returns a cloned node and is therefore an expensive operation.
      Returns:
      true if a business message is present, false otherwise.
    • getBusinessMessageAsBinaryContent

      @Nullable public BinaryContentType getBusinessMessageAsBinaryContent()
      Parse the existing business message as a special Peppol "BinaryContent" element.
      Returns:
      The parsed payload as a Peppol SBDH "BinaryContent" or null if the existing Business Message is not a valid binary content.
      Since:
      8.2.4
      See Also:
    • getBusinessMessageAsTextContent

      @Nullable public TextContentType getBusinessMessageAsTextContent()
      Parse the existing business message as a special Peppol SBDH "TextContent" element.
      Returns:
      The parsed payload as a Peppol "TextContent" or null if the existing Business Message is not a valid text content.
      Since:
      8.2.4
      See Also:
    • setBusinessMessage

      @Nonnull public PeppolSBDHData setBusinessMessage(@Nonnull Element aBusinessMessage)
      Set the main business message that should be transmitted together with the SBDH. The DOM element is cloned internally to avoid outside modification
      Parameters:
      aBusinessMessage - The business message to be set. May not be null. Internally the passed element is cloned, so that further modifications outside of this method have no impact on the business message inside this object.
      Returns:
      this
      See Also:
    • setBusinessMessageNoClone

      @Nonnull public PeppolSBDHData setBusinessMessageNoClone(@Nonnull Element aBusinessMessage)
      Set the main business message that should be transmitted together with the SBDH. The DOM element is not cloned / copied internally.
      Parameters:
      aBusinessMessage - The business message to be set. May not be null. Internally the passed element is cloned, so that further modifications outside of this method have no impact on the business message inside this object.
      Returns:
      this
      Since:
      8.8.1
      See Also:
    • setBusinessMessageBinaryOnly

      @Nonnull public PeppolSBDHData setBusinessMessageBinaryOnly(@Nonnull byte[] aBinaryPayload, @Nonnull com.helger.commons.mime.IMimeType aMimeType, @Nullable Charset aCharset)
      Set a business message with binary payload. Based on the Peppol SBDH v1.2 binary payload specification. This is wrapper for creating the Peppol SBDH "BinaryContent" element.
      Parameters:
      aBinaryPayload - The bytes to be wrapped. May not be null.
      aMimeType - The MIME type to use. May not be null.
      aCharset - The character set to be used, if the MIME type is text based. May be null.
      Returns:
      this for chaining
      Since:
      6.2.4
      See Also:
    • setBusinessMessageTextOnly

      @Nonnull public PeppolSBDHData setBusinessMessageTextOnly(@Nonnull String sTextPayload, @Nonnull com.helger.commons.mime.IMimeType aMimeType)
      Set a business message with text payload. Based on the Peppol SBDH v1.2 text payload specification. Note: the character set of the wrapped text must be identical to the character set of the SBDH surrounding it. In case the payload requires a specific character set, it is suggested to use the binary message. This is wrapper for creating the Peppol SBDH "TextContent" element.
      Parameters:
      sTextPayload - The text to be wrapped. May not be null.
      aMimeType - The MIME type to use. May not be null.
      Returns:
      this for chaining
      Since:
      6.2.4
      See Also:
    • areAllFieldsSet

      public boolean areAllFieldsSet(boolean bLogMissing)
      Check if all mandatory fields are set in the SBDH data.
      Parameters:
      bLogMissing - true if log messages should be emitted, false if not
      Returns:
      true if all mandatory fields required for creating an SBDH are present, false if at least one field is not set.
    • areAllFieldsSet

      public boolean areAllFieldsSet(@Nonnull Consumer<String> aMissingFieldConsumer)
      Check if all mandatory fields are set in the SBDH data.
      Parameters:
      aMissingFieldConsumer - The consumer to be invoked for each missing field. May not be null
      Returns:
      true if all mandatory fields required for creating an SBDH are present, false if at least one field is not set.
      Since:
      9.6.1
    • areAllFieldsSet

      public boolean areAllFieldsSet()
      Returns:
      true if all mandatory fields required for creating an SBDH are present, false if at least one field is not set.
    • areAllAdditionalAttributesValid

      public boolean areAllAdditionalAttributesValid()
      Check if all additional attributes contain non-reserved names.
      Returns:
      true if no additional attributes are present or if all additional attributes contain valid names.
    • getAsStandardBusinessDocument

      @Nonnull public org.unece.cefact.namespaces.sbdh.StandardBusinessDocument getAsStandardBusinessDocument()
      Returns:
      A generic JAXB SBD document of this data. Never null.
      Since:
      9.2.0
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createUBL21

      @Nonnull public static PeppolSBDHData createUBL21(@Nonnull Element aBusinessMessage, @Nonnull com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory)
      Create a new PeppolSBDHData object for a business message assuming it is UBL 2.1. The resulting object has all required fields set, except for:
      • sender ID
      • receiver ID
      • document type ID
      • and process ID
      Parameters:
      aBusinessMessage - The XML business message. May not be null.
      aIdentifierFactory - Identifier factory to be used. May not be null.
      Returns:
      A pre-filled PeppolSBDHData object with some information still missing.
      Since:
      8.3.1
      See Also: