Package com.helger.peppol.xhe.read
Class DBNAllianceXHEDataReader
java.lang.Object
com.helger.peppol.xhe.read.DBNAllianceXHEDataReader
Main class to read exchange header envelope and extract the DBNAlliance required data out of it.
- Author:
- Robinson Garcia, Philip Helger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDBNAllianceXHEDataReader(com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.helger.xhe.v10.XHE10MarshallerCreate a new XHE10 marshaller used for reading XHE documents.extractData(com.helger.commons.io.resource.IReadableResource aExchangeHeaderEnvelope) Extract the document data from the Exchange Header Envelope represents by the passed parameter.extractData(com.helger.xhe.v10.XHE10XHEType aExchangeHeaderEnvelope) Extract the document data from the Exchange Header Envelope represents by the passed parameter.extractData(com.helger.xhe.v10.XHE10XHEType aXHE, com.helger.xhe.v10.cac.XHE10PayloadsType aPayloads) Extract the document data from the Standard Business Document represents by the passed parameter.extractData(InputStream aExchangeHeaderEnvelope) Extract the document data from the Exchange Header Envelope represents by the passed parameter.extractData(Node aExchangeHeaderEnvelope) Extract the document data from the Exchange Header Envelope represents by the passed parameter.extractDataUnchecked(com.helger.xhe.v10.XHE10XHEType aXHE, 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.final com.helger.peppolid.factory.IIdentifierFactoryprotected booleanisInstanceHashValueExist(String sInstanceHashValue) The Instance Hash Value MUST NOT be included in the envelope.final booleanprotected booleanisValidBusinessMessage(Element aBusinessMessage) Check if the passed business message is valid or not.protected booleanisValidContentTypeCodeListID(String sListID) Check if the passed list id is valid or not.protected booleanisValidContentTypeCodeValue(String sListID, String sValue) Check if the passed content type code value is valid or not.protected booleanisValidCreationDateTime(com.helger.commons.datetime.XMLOffsetDateTime aCreationDateTime) Check if the passed document identification creation date time is valid or not.protected booleanisValidCustomizationID(String sCustomizationID) Check if the passed customization id is valid or not.protected booleanisValidCustomizationIDSchemaID(String sSchemaID) Check if the passed customization id schema is valid or not.protected booleanisValidFromPartySchemaID(String sFromPartySchemaID) Check if the passed from party schema is is valid or not.protected booleanisValidFromPartyValue(String sFromPartySchemaID, String sFromPartyValue) Check if the passed from party value is valid or not.protected booleanisValidHeaderID(String sHeaderID) Check if the passed header id is valid or not.protected booleanisValidInstanceEncryptionIndicatorValue(boolean bInstanceEncryptionIndicator) Check if the passed instance encryption indicator value is valid or not.protected booleanisValidPayloadIDValue(String sPayloadID) Check if the passed payload id is valid or not.protected booleanisValidProfileID(String sProfileID) Check if the passed profile id is valid or not.protected booleanisValidToPartySchemaID(String sToPartySchemaID) Check if the passed to party schema is valid or not.protected booleanisValidToPartyValue(String sToPartySchemaID, String sToPartyValue) Check if the passed to party value is valid or not.protected booleanisValidXHEVersionID(String sXHEVersionID) Check if the passed XHE version is valid or not.final DBNAllianceXHEDataReadersetPerformValueChecks(boolean b) Enable or disable the performing of value checks on data extraction.voidvalidateData(com.helger.xhe.v10.XHE10XHEType aXHE, com.helger.xhe.v10.cac.XHE10PayloadsType aPayloads, 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.
-
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
- Returns:
- The identifier provided in the constructor. Never
null.
-
isPerformValueChecks
public final boolean isPerformValueChecks()- Returns:
trueif value checks on data extraction are enabled,falseif not. By default checks are enabled - seeDEFAULT_PERFORM_VALUE_CHECKS.
-
setPerformValueChecks
Enable or disable the performing of value checks on data extraction.- Parameters:
b-trueto enable checks,falseto disable them.- Returns:
- this for chaining
-
isValidXHEVersionID
Check if the passed XHE version is valid or not. By default is must matchCDBNAllianceXHE.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 benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidCustomizationIDSchemaID
Check if the passed customization id schema is valid or not. By default is must matchCDBNAllianceXHE.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 attributeXHE/CustomizationID/@schemeID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidCustomizationID
Check if the passed customization id is valid or not. By default is must matchCDBNAllianceXHE.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 attributeXHE/CustomizationID/. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidProfileID
Check if the passed profile id is valid or not. By default is must matchCDBNAllianceXHE.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 attributeXHE/ProfileID/. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidHeaderID
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 ofXHE/Header/ID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
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 benull. 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 nevernull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidFromPartySchemaID
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 attributeXHE/Header/FromParty/PartyIdentification/ID/@schemaID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
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 attributeXHE/Header/FromParty/PartyIdentification/ID/@schemaID. May benull.sFromPartyValue- The value to be checked. This conforms to the XML element value ofXHE/Header/FromParty/PartyIdentification/ID/. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidToPartySchemaID
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 attributeXHE/Header/ToParty/PartyIdentification/ID/@schemaID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
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 attributeXHE/Header/ToParty/PartyIdentification/ID/@schemaID. May benull.sToPartyValue- The value to be checked. This conforms to the XML element value ofXHE/Header/ToParty/PartyIdentification/ID/. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidPayloadIDValue
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 fieldXHE/Payloads/Payload/ID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
isValidContentTypeCodeListID
Check if the passed list id is valid or not.- Parameters:
sListID- The value to be checked. This is the content of the XML attributeXHE/Payloads/Payload/ContentTypeCode/@listID. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
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 attributeXHE/Payloads/Payload/ContentTypeCode/@listID. May benull.sValue- The value to be checked. This corresponds to the fieldXHE/Payloads/Payload/ContentTypeCode. May benull.- Returns:
trueif the value is valid,falseotherwise.
-
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 benull. 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 nevernull.- Returns:
trueif the value is valid,falseotherwise.
-
isInstanceHashValueExist
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 alwaysnull.- Returns:
trueif the field does not exist,falseotherwise.
-
isValidBusinessMessage
Check if the passed business message is valid or not. By default this method always returnstruesince the element is nevernulland no UBL specific checks are performed. Override this method to perform further or other checks.- Parameters:
aBusinessMessage- The business message element to check against. Nevernull.- Returns:
trueif the value is valid,falseotherwise.
-
createXHEMarshaller
Create a new XHE10 marshaller used for reading XHE documents. Override this method to customize reading.- Returns:
- An instance of the
XHE10Marshallerand nevernull.
-
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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.aPayloads- The Payloads list to be validated (this does NOT mean Schematron validation). Must not benull.aErrorList- The error list to be filled. Must not benull.
-
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 ifisPerformValueChecks()istrue.- Parameters:
aXHE- The xhe object to read from. May not benull.aPayloads- The list of DBNAlliance payload to extract data from. May not benull.- 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 benull.aPayloads- The list of DBNAlliance payload to extract data from. May not benull.- Returns:
- The document data and never
null.
-