Class DBNAllianceXHEDataReader

java.lang.Object
com.helger.peppol.xhe.read.DBNAllianceXHEDataReader

public class DBNAllianceXHEDataReader extends Object
Main class to read exchange header envelope and extract the DBNAlliance required data out of it.
Author:
Robinson Garcia, Philip Helger
  • Field Details

    • DEFAULT_PERFORM_VALUE_CHECKS

      public static final boolean DEFAULT_PERFORM_VALUE_CHECKS
      See Also:
  • Constructor Details

    • DBNAllianceXHEDataReader

      public DBNAllianceXHEDataReader(@Nonnull com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory)
  • Method Details

    • getIdentifierFactory

      @Nonnull public final com.helger.peppolid.factory.IIdentifierFactory getIdentifierFactory()
      Returns:
      The identifier provided in the constructor. Never null.
    • isPerformValueChecks

      public final boolean isPerformValueChecks()
      Returns:
      true if value checks on data extraction are enabled, false if not. By default checks are enabled - see DEFAULT_PERFORM_VALUE_CHECKS.
    • setPerformValueChecks

      @Nonnull public final DBNAllianceXHEDataReader setPerformValueChecks(boolean b)
      Enable or disable the performing of value checks on data extraction.
      Parameters:
      b - true to enable checks, false to disable them.
      Returns:
      this for chaining
    • isValidXHEVersionID

      @OverrideOnDemand protected boolean isValidXHEVersionID(@Nullable String sXHEVersionID)
      Check if the passed XHE version is valid or not. By default is must match CDBNAllianceXHE.XHE_VERSION_ID. Override this method to allow for other schemes as well.
      Parameters:
      sXHEVersionID - The value to be checked. This is the content of the XML element /XHE/XHEVersionID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidCustomizationIDSchemaID

      @OverrideOnDemand protected boolean isValidCustomizationIDSchemaID(@Nullable String sSchemaID)
      Check if the passed customization id schema is valid or not. By default is must match CDBNAllianceXHE.CUSTOMIZATION_SCHEMA_ID. Override this method to allow for other schemes as well.
      Parameters:
      sSchemaID - The value to be checked. This is the content of the XML attribute XHE/CustomizationID/@schemeID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidCustomizationID

      @OverrideOnDemand protected boolean isValidCustomizationID(@Nullable String sCustomizationID)
      Check if the passed customization id is valid or not. By default is must match CDBNAllianceXHE.CUSTOMIZATION_ID. Override this method to allow for other schemes as well.
      Parameters:
      sCustomizationID - The value to be checked. This is the content of the XML attribute XHE/CustomizationID/. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidProfileID

      @OverrideOnDemand protected boolean isValidProfileID(@Nullable String sProfileID)
      Check if the passed profile id is valid or not. By default is must match CDBNAllianceXHE.PROFILE_ID. Override this method to allow for other schemes as well.
      Parameters:
      sProfileID - The value to be checked. This is the content of the XML attribute XHE/ProfileID/. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidHeaderID

      @OverrideOnDemand protected boolean isValidHeaderID(@Nullable String sHeaderID)
      Check if the passed header id is valid or not. By default is must not be empty. Override this method to perform further checks.
      Parameters:
      sHeaderID - The value to be checked. This conforms to the XML element value of XHE/Header/ID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidCreationDateTime

      @OverrideOnDemand protected boolean isValidCreationDateTime(@Nonnull com.helger.commons.datetime.XMLOffsetDateTime aCreationDateTime)
      Check if the passed document identification creation date time is valid or not. By default all values are valid as they cannot be null. Override this method to perform further or other checks.
      Parameters:
      aCreationDateTime - The value to be checked. This corresponds to the field "XHE/Header/CreationDateTime". Is never null .
      Returns:
      true if the value is valid, false otherwise.
    • isValidFromPartySchemaID

      @OverrideOnDemand protected boolean isValidFromPartySchemaID(@Nullable String sFromPartySchemaID)
      Check if the passed from party schema is is valid or not. By default is must not be empty.
      Parameters:
      sFromPartySchemaID - The value to be checked. This is the content of the XML attribute XHE/Header/FromParty/PartyIdentification/ID/@schemaID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidFromPartyValue

      @OverrideOnDemand protected boolean isValidFromPartyValue(@Nullable String sFromPartySchemaID, @Nullable String sFromPartyValue)
      Check if the passed from party value is valid or not. By default is must not be empty. Override this method to perform further checks.
      Parameters:
      sFromPartySchemaID - The value to be checked. This is the content of the XML attribute XHE/Header/FromParty/PartyIdentification/ID/@schemaID. May be null.
      sFromPartyValue - The value to be checked. This conforms to the XML element value of XHE/Header/FromParty/PartyIdentification/ID/. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidToPartySchemaID

      @OverrideOnDemand protected boolean isValidToPartySchemaID(@Nullable String sToPartySchemaID)
      Check if the passed to party schema is valid or not. By default is must not be empty.
      Parameters:
      sToPartySchemaID - The value to be checked. This is the content of the XML attribute XHE/Header/ToParty/PartyIdentification/ID/@schemaID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidToPartyValue

      @OverrideOnDemand protected boolean isValidToPartyValue(@Nullable String sToPartySchemaID, @Nullable String sToPartyValue)
      Check if the passed to party value is valid or not. By default is must not be empty. Override this method to perform further checks.
      Parameters:
      sToPartySchemaID - The value to be checked. This is the content of the XML attribute XHE/Header/ToParty/PartyIdentification/ID/@schemaID. May be null.
      sToPartyValue - The value to be checked. This conforms to the XML element value of XHE/Header/ToParty/PartyIdentification/ID/. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidPayloadIDValue

      @OverrideOnDemand protected boolean isValidPayloadIDValue(@Nullable String sPayloadID)
      Check if the passed payload id is valid or not. By default is must not be empty.
      Parameters:
      sPayloadID - The value to be checked. This corresponds to the field XHE/Payloads/Payload/ID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidContentTypeCodeListID

      @OverrideOnDemand protected boolean isValidContentTypeCodeListID(@Nullable String sListID)
      Check if the passed list id is valid or not.
      Parameters:
      sListID - The value to be checked. This is the content of the XML attribute XHE/Payloads/Payload/ContentTypeCode/@listID. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidContentTypeCodeValue

      @OverrideOnDemand protected boolean isValidContentTypeCodeValue(@Nullable String sListID, @Nullable String sValue)
      Check if the passed content type code value is valid or not. By default is must not be empty.
      Parameters:
      sListID - The value to be checked. This is the content of the XML attribute XHE/Payloads/Payload/ContentTypeCode/@listID. May be null.
      sValue - The value to be checked. This corresponds to the field XHE/Payloads/Payload/ContentTypeCode. May be null.
      Returns:
      true if the value is valid, false otherwise.
    • isValidInstanceEncryptionIndicatorValue

      @OverrideOnDemand protected boolean isValidInstanceEncryptionIndicatorValue(@Nullable boolean bInstanceEncryptionIndicator)
      Check if the passed instance encryption indicator value is valid or not. By default all values are valid as they cannot be null. Override this method to perform further or other checks.
      Parameters:
      bInstanceEncryptionIndicator - The value to be checked. This corresponds to the field "XHE/Payloads/Payload/InstanceEncryptionIndicator". Is never null .
      Returns:
      true if the value is valid, false otherwise.
    • isInstanceHashValueExist

      @OverrideOnDemand protected boolean isInstanceHashValueExist(@Nullable String sInstanceHashValue)
      The Instance Hash Value MUST NOT be included in the envelope. By default all values are invalid as they cannot be present. Override this method to perform further or other checks.
      Parameters:
      sInstanceHashValue - The value to be checked. This corresponds to the field "XHE/Payloads/Payload/InstanceHashValue". Is always null .
      Returns:
      true if the field does not exist, false otherwise.
    • isValidBusinessMessage

      @OverrideOnDemand protected boolean isValidBusinessMessage(@Nonnull Element aBusinessMessage)
      Check if the passed business message is valid or not. By default this method always returns true since the element is never null and no UBL specific checks are performed. Override this method to perform further or other checks.
      Parameters:
      aBusinessMessage - The business message element to check against. Never null.
      Returns:
      true if the value is valid, false otherwise.
    • createXHEMarshaller

      @Nonnull @OverrideOnDemand protected com.helger.xhe.v10.XHE10Marshaller createXHEMarshaller()
      Create a new XHE10 marshaller used for reading XHE documents. Override this method to customize reading.
      Returns:
      An instance of the XHE10Marshaller and never null.
    • extractData

      @Nonnull public DBNAllianceXHEData extractData(@Nonnull @WillClose InputStream aExchangeHeaderEnvelope) throws DBNAllianceXHEDataReadException
      Extract the document data from the Exchange Header Envelope represents by the passed parameter.
      Parameters:
      aExchangeHeaderEnvelope - The input stream to read from. Will be closed by this method. May not be null.
      Returns:
      The document data and never null.
      Throws:
      DBNAllianceXHEDataReadException - In case the passed Exchange Header Envelope does not conform to the DBNAlliance rules.
    • extractData

      @Nonnull public DBNAllianceXHEData extractData(@Nonnull com.helger.commons.io.resource.IReadableResource aExchangeHeaderEnvelope) throws DBNAllianceXHEDataReadException
      Extract the document data from the Exchange Header Envelope represents by the passed parameter.
      Parameters:
      aExchangeHeaderEnvelope - The resource to read from. May not be null.
      Returns:
      The document data and never null.
      Throws:
      DBNAllianceXHEDataReadException - In case the passed Exchange Header Envelope does not conform to the DBNAlliance rules.
    • extractData

      @Nonnull public DBNAllianceXHEData extractData(@Nonnull Node aExchangeHeaderEnvelope) throws DBNAllianceXHEDataReadException
      Extract the document data from the Exchange Header Envelope represents by the passed parameter.
      Parameters:
      aExchangeHeaderEnvelope - The DOM node to read from. May not be null.
      Returns:
      The document data and never null.
      Throws:
      DBNAllianceXHEDataReadException - In case the passed Exchange Header Envelope does not conform to the DBNAlliance rules.
    • extractData

      @Nonnull public DBNAllianceXHEData extractData(@Nonnull com.helger.xhe.v10.XHE10XHEType aExchangeHeaderEnvelope) throws DBNAllianceXHEDataReadException
      Extract the document data from the Exchange Header Envelope represents by the passed parameter.
      Parameters:
      aExchangeHeaderEnvelope - The domain object to read from. May not be null.
      Returns:
      The document data and never null.
      Throws:
      DBNAllianceXHEDataReadException - In case the passed Exchange Header Envelope does not conform to the DBNAlliance rules.
    • validateData

      public void validateData(@Nonnull com.helger.xhe.v10.XHE10XHEType aXHE, @Nonnull com.helger.xhe.v10.cac.XHE10PayloadsType aPayloads, @Nonnull com.helger.commons.error.list.ErrorList aErrorList)
      Validate the provided XHE and the Payloads according to the DBNAlliance rules and store the results in an Error List.
      Parameters:
      aXHE - The SBDH to be validated. Must not be null.
      aPayloads - The Payloads list to be validated (this does NOT mean Schematron validation). Must not be null.
      aErrorList - The error list to be filled. Must not be null.
    • extractData

      @Nonnull public DBNAllianceXHEData extractData(@Nonnull com.helger.xhe.v10.XHE10XHEType aXHE, @Nonnull com.helger.xhe.v10.cac.XHE10PayloadsType aPayloads) throws DBNAllianceXHEDataReadException
      Extract the document data from the Standard Business Document represents by the passed parameter. Eventually value checks are performed if isPerformValueChecks() is true.
      Parameters:
      aXHE - The xhe object to read from. May not be null.
      aPayloads - The list of DBNAlliance payload to extract data from. May not be null.
      Returns:
      The document data and never null.
      Throws:
      DBNAllianceXHEDataReadException - In case the passed Exchange Header Envelope does not conform to the DBNAlliance rules.
    • extractDataUnchecked

      @Nonnull public DBNAllianceXHEData extractDataUnchecked(@Nonnull com.helger.xhe.v10.XHE10XHEType aXHE, @Nonnull com.helger.xhe.v10.cac.XHE10PayloadsType aPayloads)
      Extract the document data from the Standard Business Document represents by the passed parameter without any value checks. This might be handy, if value checks were executed separately.
      Parameters:
      aXHE - The header object to read from. May not be null.
      aPayloads - The list of DBNAlliance payload to extract data from. May not be null.
      Returns:
      The document data and never null.