diff --git a/dbnalliance-xhe/findbugs-exclude.xml b/dbnalliance-xhe/findbugs-exclude.xml new file mode 100644 index 00000000..7c8fe95d --- /dev/null +++ b/dbnalliance-xhe/findbugs-exclude.xml @@ -0,0 +1,21 @@ + + + + diff --git a/dbnalliance-xhe/pom.xml b/dbnalliance-xhe/pom.xml index 9caab864..886e3e37 100644 --- a/dbnalliance-xhe/pom.xml +++ b/dbnalliance-xhe/pom.xml @@ -1,22 +1,35 @@ + 4.0.0 - peppol-commons-parent-pom com.helger.peppol + peppol-commons-parent-pom 9.4.1-SNAPSHOT - - com.helger.peppol dbnalliance-xhe - 9.4.1-SNAPSHOT bundle - dbnalliance-xhe + https://github.com/phax/peppol-commons/dbnalliance-xhe + 2024 Library for reading and writing OASIS Exchange Header Envelope (XHE) Version 1.0 documents conforming to the DBNAlliance specifications - - UTF-8 - @@ -32,6 +45,10 @@ + + robinsongarciax + Robinson Garcia + philip Philip Helger @@ -56,7 +73,7 @@ com.helger ph-xhe - 4.0.1 + ${ph-xhe.version} com.helger.peppol @@ -66,13 +83,6 @@ com.helger.peppol peppol-id - - - com.github.spotbugs - spotbugs-annotations - compile - true - com.helger.peppol diff --git a/dbnalliance-xhe/src/etc/javadoc.css b/dbnalliance-xhe/src/etc/javadoc.css new file mode 100644 index 00000000..9e5f5c68 --- /dev/null +++ b/dbnalliance-xhe/src/etc/javadoc.css @@ -0,0 +1,583 @@ +/** + * Copyright (C) 2024 Philip Helger + * philip[at]helger[dot]com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * based on phloc javadoc CSS. + * (c) 2011-2014 phloc systems. + * Derived from the original javadoc CSS from Sun JDK + */ + +body { + background-color: #FFFFFF; + color: #353833; + font-family: Arial, Helvetica, sans-serif; + font-size: 76%; + margin: 0; +} + +a:link,a:visited { + color: #880000; + text-decoration: none; +} + +a:hover,a:focus { + color: #BB2222; + text-decoration: none; +} + +a:active { + color: #4C6B87; + text-decoration: none; +} + +a[name] { + color: #353833; +} + +a[name]:hover { + color: #353833; + text-decoration: none; +} + +pre { + font-size: 1.3em; +} + +h1 { + font-size: 1.8em; +} + +h2 { + font-size: 1.5em; +} + +h3 { + font-size: 1.4em; +} + +h4 { + font-size: 1.3em; +} + +h5 { + font-size: 1.2em; +} + +h6 { + font-size: 1.1em; +} + +ul { + list-style-type: disc; +} + +code,tt { + font-size: 1.2em; +} + +dt code { + font-size: 1.2em; +} + +table tr td dt code { + font-size: 1.2em; + vertical-align: top; +} + +sup { + font-size: 0.6em; +} + +.clear { + clear: both; + height: 0; + overflow: hidden; +} + +.aboutLanguage { + float: right; + font-size: 0.8em; + margin-top: -7px; + padding: 0 21px; + z-index: 200; +} + +.legalCopy { + margin-left: 0.5em; +} + +.bar a,.bar a:link,.bar a:visited,.bar a:active { + color: #FFFFFF; + text-decoration: none; +} + +.bar a:hover,.bar a:focus { + color: #BB7A2A; +} + +.tab { + background-color: #0066FF; + background-image: url("resources/titlebar.gif"); + background-position: left top; + background-repeat: no-repeat; + color: #FFFFFF; + font-weight: bold; + padding: 8px; + width: 5em; +} + +.bar { + background-image: url("resources/background.gif"); + background-repeat: repeat-x; + color: #FFFFFF; + font-size: 1em; + height: auto; + margin: 0; + padding: 0.8em 0.5em 0.4em 0.8em; +} + +.topNav { + background-image: url("resources/background.gif"); + background-repeat: repeat-x; + clear: right; + color: #FFFFFF; + float: left; + height: 2.8em; + overflow: hidden; + padding: 10px 0 0; + width: 100%; +} + +.bottomNav { + background-image: url("resources/background.gif"); + background-repeat: repeat-x; + clear: right; + color: #FFFFFF; + float: left; + height: 2.8em; + margin-top: 10px; + overflow: hidden; + padding: 10px 0 0; + width: 100%; +} + +.subNav { + background-color: #DEE3E9; + border-bottom: 1px solid #9EADC0; + float: left; + overflow: hidden; + width: 100%; +} + +.subNav div { + clear: left; + float: left; + padding: 0 0 5px 6px; +} + +ul.navList,ul.subNavList { + float: left; + margin: 0 25px 0 0; + padding: 0; +} + +ul.navList li { + float: left; + list-style: none outside none; + padding: 3px 6px; +} + +ul.subNavList li { + float: left; + font-size: 90%; + list-style: none outside none; +} + +.topNav a:link,.topNav a:active,.topNav a:visited,.bottomNav a:link,.bottomNav a:active,.bottomNav a:visited + { + color: #FFFFFF; + text-decoration: none; +} + +.topNav a:hover,.bottomNav a:hover { + color: #BB7A2A; + text-decoration: none; +} + +.navBarCell1Rev { + background-color: #A88834; + background-image: url("resources/tab.gif"); + border: 1px solid #C9AA44; + color: #FFFFFF; + margin: auto 5px; +} + +.header,.footer { + clear: both; + margin: 0 20px; + padding: 5px 0 0; +} + +.indexHeader { + margin: 10px; + position: relative; +} + +.indexHeader h1 { + font-size: 1.3em; +} + +.title { + color: #880000; + margin: 10px 0; +} + +.subTitle { + margin: 5px 0 0; +} + +.header ul { + margin: 0 0 25px; + padding: 0; +} + +.footer ul { + margin: 20px 0 5px; +} + +.header ul li,.footer ul li { + font-size: 1.2em; + list-style: none outside none; +} + +div.details ul.blockList ul.blockList ul.blockList li.blockList h4,div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 + { + background-color: #DEE3E9; + border-bottom: 1px solid #9EADC0; + border-top: 1px solid #9EADC0; + margin: 0 0 6px -8px; + padding: 2px 5px; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color: #DEE3E9; + border-bottom: 1px solid #9EADC0; + border-top: 1px solid #9EADC0; + margin: 0 0 6px -8px; + padding: 2px 5px; +} + +ul.blockList ul.blockList li.blockList h3 { + margin: 15px 0; + padding: 0; +} + +ul.blockList li.blockList h2 { + padding: 0 0 20px; +} + +.contentContainer,.sourceContainer,.classUseContainer,.serializedFormContainer,.constantValuesContainer + { + clear: both; + padding: 10px 20px; + position: relative; +} + +.indexContainer { + font-size: 1em; + margin: 10px; + position: relative; +} + +.indexContainer h2 { + font-size: 1.1em; + padding: 0 0 3px; +} + +.indexContainer ul { + margin: 0; + padding: 0; +} + +.indexContainer ul li { + list-style: none outside none; +} + +.contentContainer .description dl dt,.contentContainer .details dl dt,.serializedFormContainer dl dt + { + color: #4E4E4E; + font-size: 1.1em; + font-weight: bold; + margin: 10px 0 0; +} + +.contentContainer .description dl dd,.contentContainer .details dl dd,.serializedFormContainer dl dd + { + margin: 10px 0 10px 20px; +} + +.serializedFormContainer dl.nameValue dt { + display: inline; + font-size: 1.1em; + font-weight: bold; + margin-left: 1px; +} + +.serializedFormContainer dl.nameValue dd { + display: inline; + font-size: 1.1em; +} + +ul.horizontal li { + display: inline; + font-size: 0.9em; +} + +ul.inheritance { + margin: 0; + padding: 0; +} + +ul.inheritance li { + display: inline; + list-style: none outside none; +} + +ul.inheritance li ul.inheritance { + margin-left: 15px; + padding-left: 15px; + padding-top: 1px; +} + +ul.blockList,ul.blockListLast { + margin: 10px 0; + padding: 0; +} + +ul.blockList li.blockList,ul.blockListLast li.blockList { + list-style: none outside none; + margin-bottom: 25px; +} + +ul.blockList ul.blockList li.blockList,ul.blockList ul.blockListLast li.blockList + { + background-color: #F9F9F9; + border: 1px solid #9EADC0; + padding: 0 20px 5px 10px; +} + +ul.blockList ul.blockList ul.blockList li.blockList,ul.blockList ul.blockList ul.blockListLast li.blockList + { + -moz-border-bottom-colors: none; + -moz-border-left-colors: none; + -moz-border-right-colors: none; + -moz-border-top-colors: none; + background-color: #FFFFFF; + border-color: currentColor #9EADC0 #9EADC0; + border-image: none; + border-right: 1px solid #9EADC0; + border-style: none solid solid; + border-width: medium 1px 1px; + padding: 0 0 5px 8px; +} + +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + -moz-border-bottom-colors: none; + -moz-border-left-colors: none; + -moz-border-right-colors: none; + -moz-border-top-colors: none; + border-color: currentColor currentColor #9EADC0; + border-image: none; + border-style: none none solid; + border-width: medium medium 1px; + margin-left: 0; + padding-bottom: 15px; + padding-left: 0; +} + +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + border-bottom: medium none; + list-style: none outside none; + padding-bottom: 0; +} + +table tr td dl,table tr td dl dt,table tr td dl dd { + margin-bottom: 1px; + margin-top: 0; +} + +.contentContainer table,.classUseContainer table,.constantValuesContainer table + { + border-bottom: 1px solid #9EADC0; + width: 100%; +} + +.contentContainer ul li table,.classUseContainer ul li table,.constantValuesContainer ul li table + { + width: 100%; +} + +.contentContainer .description table,.contentContainer .details table { + border-bottom: medium none; +} + +.contentContainer ul li table th.colOne,.contentContainer ul li table th.colFirst,.contentContainer ul li table th.colLast,.classUseContainer ul li table th,.constantValuesContainer ul li table th,.contentContainer ul li table td.colOne,.contentContainer ul li table td.colFirst,.contentContainer ul li table td.colLast,.classUseContainer ul li table td,.constantValuesContainer ul li table td + { + padding-right: 20px; + vertical-align: top; +} + +.contentContainer ul li table th.colLast,.classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,.contentContainer ul li table td.colLast,.classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,.contentContainer ul li table th.colOne,.classUseContainer ul li table th.colOne,.contentContainer ul li table td.colOne,.classUseContainer ul li table td.colOne + { + padding-right: 3px; +} + +.overviewSummary caption,.packageSummary caption,.contentContainer ul.blockList li.blockList caption,.summary caption,.classUseContainer caption,.constantValuesContainer caption + { + background-repeat: no-repeat; + clear: none; + color: #FFFFFF; + font-weight: bold; + margin: 0; + overflow: hidden; + padding: 0; + position: relative; + text-align: left; +} + +caption a:link,caption a:hover,caption a:active,caption a:visited { + color: #FFFFFF; +} + +.overviewSummary caption span,.packageSummary caption span,.contentContainer ul.blockList li.blockList caption span,.summary caption span,.classUseContainer caption span,.constantValuesContainer caption span + { + background-image: url("resources/titlebar.gif"); + display: block; + float: left; + height: 18px; + padding-left: 8px; + padding-top: 8px; + white-space: nowrap; +} + +.overviewSummary .tabEnd,.packageSummary .tabEnd,.contentContainer ul.blockList li.blockList .tabEnd,.summary .tabEnd,.classUseContainer .tabEnd,.constantValuesContainer .tabEnd + { + background-image: url("resources/titlebar_end.gif"); + background-position: right top; + background-repeat: no-repeat; + float: left; + position: relative; + width: 10px; +} + +ul.blockList ul.blockList li.blockList table { + margin: 0 0 12px; + width: 100%; +} + +.tableSubHeadingColor { + background-color: #EEEEFF; +} + +.altColor { + background-color: #EEEEEF; +} + +.rowColor { + background-color: #FFFFFF; +} + +.overviewSummary td,.packageSummary td,.contentContainer ul.blockList li.blockList td,.summary td,.classUseContainer td,.constantValuesContainer td + { + padding: 3px 3px 3px 7px; + text-align: left; +} + +th.colFirst,th.colLast,th.colOne,.constantValuesContainer th { + background: none repeat scroll 0 0 #DEE3E9; + border-bottom: 1px solid #9EADC0; + border-top: 1px solid #9EADC0; + padding: 3px 3px 3px 7px; + text-align: left; +} + +td.colOne a:link,td.colOne a:active,td.colOne a:visited,td.colOne a:hover,td.colFirst a:link,td.colFirst a:active,td.colFirst a:visited,td.colFirst a:hover,td.colLast a:link,td.colLast a:active,td.colLast a:visited,td.colLast a:hover,.constantValuesContainer td a:link,.constantValuesContainer td a:active,.constantValuesContainer td a:visited,.constantValuesContainer td a:hover + { + font-weight: bold; +} + +td.colFirst,th.colFirst { + border-left: 1px solid #9EADC0; + white-space: nowrap; +} + +td.colLast,th.colLast { + border-right: 1px solid #9EADC0; +} + +td.colOne,th.colOne { + border-left: 1px solid #9EADC0; + border-right: 1px solid #9EADC0; +} + +table.overviewSummary { + margin-left: 0; + padding: 0; +} + +table.overviewSummary td.colFirst,table.overviewSummary th.colFirst,table.overviewSummary td.colOne,table.overviewSummary th.colOne + { + vertical-align: middle; + width: 25%; +} + +table.packageSummary td.colFirst,table.overviewSummary th.colFirst { + vertical-align: middle; + width: 25%; +} + +.description pre { + margin-top: 0; +} + +.deprecatedContent { + margin: 0; + padding: 10px 0; +} + +.docSummary { + padding: 0; +} + +.sourceLineNo { + color: #008000; + padding: 0 30px 0 0; +} + +h1.hidden { + font-size: 0.9em; + overflow: hidden; + visibility: hidden; +} + +.block { + display: block; + margin: 3px 0 0; +} + +.strong { + font-weight: bold; +} diff --git a/dbnalliance-xhe/src/etc/license-template.txt b/dbnalliance-xhe/src/etc/license-template.txt new file mode 100644 index 00000000..14f84602 --- /dev/null +++ b/dbnalliance-xhe/src/etc/license-template.txt @@ -0,0 +1,14 @@ +Copyright (C) 2024 Philip Helger +philip[at]helger[dot]com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/CDBNAllianceXHE.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/CDBNAllianceXHE.java index f4290ff8..8e755322 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/CDBNAllianceXHE.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/CDBNAllianceXHE.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,6 @@ import javax.annotation.concurrent.Immutable; - /** * Constants for the usage of XHE in DBNAlliance. * @@ -38,5 +37,7 @@ public final class CDBNAllianceXHE /** Constant for the reference to the DBNAlliance specification */ public static final String PROFILE_ID = "dbnalliance-envelope-1.0"; - + + private CDBNAllianceXHE () + {} } diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAlliancePayload.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAlliancePayload.java index c9b6b497..c7f96a5f 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAlliancePayload.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAlliancePayload.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,12 @@ */ package com.helger.peppol.xhe; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.concurrent.NotThreadSafe; + +import org.w3c.dom.Element; + import com.helger.commons.ValueEnforcer; import com.helger.commons.annotation.Nonempty; import com.helger.commons.annotation.ReturnsMutableCopy; @@ -24,24 +30,21 @@ import com.helger.peppolid.IDocumentTypeIdentifier; import com.helger.peppolid.IProcessIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.NotThreadSafe; -import org.w3c.dom.Element; /** - * This class contains all the DBNAlliance data per Payload instance, - * such as a single invoice in a syntax neutral way. - * This class maps to the requirements of the Exchange Header - * Envelope (XHE) Version 1.0 specification. + * This class contains all the DBNAlliance data per Payload instance, such as a + * single invoice in a syntax neutral way. This class maps to the requirements + * of the Exchange Header Envelope (XHE) Version 1.0 specification. * * @author Robinson Garcia */ @NotThreadSafe -public class DBNAlliancePayload { - +public class DBNAlliancePayload +{ + public static final boolean DEFAULT_INSTANCE_ENCRYPTION_INDICATOR = false; + private final IIdentifierFactory m_aIdentifierFactory; - + private String m_sDescription; private String m_sContentTypeCodeListID; private String m_sContentTypeCodeValue; @@ -49,25 +52,25 @@ public class DBNAlliancePayload { private String m_sCustomizationIDValue; private String m_sProfileIDScheme; private String m_sProfileIDValue; - private boolean m_bInstanceEncryptionIndicator = false; + private boolean m_bInstanceEncryptionIndicator = DEFAULT_INSTANCE_ENCRYPTION_INDICATOR; private String m_sInstanceEncryptionMethod; // PayloadContent private Element m_aPayloadContent; - + /** * Constructor * * @param aIdentifierFactory * Identifier factory to be used. May not be null. */ - public DBNAlliancePayload (@Nonnull final IIdentifierFactory aIdentifierFactory) { + public DBNAlliancePayload (@Nonnull final IIdentifierFactory aIdentifierFactory) + { m_aIdentifierFactory = ValueEnforcer.notNull (aIdentifierFactory, "IdentifierFactory"); } - + /** - * Description - An OPTIONAL human readable description of the payload. - * This field is mapped to - * XHE/Payloads/Payload/Description. + * Description - An OPTIONAL human readable description of the payload. This + * field is mapped to XHE/Payloads/Payload/Description. * * @return Description value. May be null. */ @@ -78,7 +81,8 @@ public String getDescription () } /** - * @return true if a description is present, false if not. + * @return true if a description is present, false + * if not. */ public boolean hasDescription () { @@ -92,8 +96,7 @@ public boolean hasDescription () * @param sDescription * Description - An OPTIONAL human readable description of the payload. * This field is mapped to - * XHE/Payloads/Payload/Description - * . + * XHE/Payloads/Payload/Description . * @return this */ @Nonnull @@ -104,12 +107,11 @@ public DBNAlliancePayload setDescription (@Nonnull @Nonempty final String sDescr m_sDescription = sDescription; return this; } - + /** - * @return The content type code list id. May be null - * if not initialized. This field is mapped to - * XHE/Payloads/Payload/ContentTypeCode/@listID - * . + * @return The content type code list id. May be null if not + * initialized. This field is mapped to + * XHE/Payloads/Payload/ContentTypeCode/@listID . */ @Nullable public String getContentTypeCodeListID () @@ -118,8 +120,8 @@ public String getContentTypeCodeListID () } /** - * @return The content type code value. May be null - * if not initialized. This field is mapped to + * @return The content type code value. May be null if not + * initialized. This field is mapped to * XHE/Payloads/Payload/ContentTypeCode/. */ @Nullable @@ -132,18 +134,17 @@ public String getContentTypeCodeValue () * Set the content type code. * * @param slistID - * The DBNAlliance identifier scheme. May neither be null + * The DBNAlliance identifier scheme. May neither be null * nor empty. This field is mapped to - * XHE/Payloads/Payload/ContentTypeCode/@listID - * . + * XHE/Payloads/Payload/ContentTypeCode/@listID . * @param sValue - * The from party identifier value. May neither be null nor - * empty. This field is mapped to + * The from party identifier value. May neither be null + * nor empty. This field is mapped to * XHE/Payloads/Payload/ContentTypeCode/. * @return this */ @Nonnull - public DBNAlliancePayload setContentTypeCode(@Nullable final String slistID, @Nonnull @Nonempty final String sValue) + public DBNAlliancePayload setContentTypeCode (@Nullable final String slistID, @Nonnull @Nonempty final String sValue) { ValueEnforcer.notEmpty (sValue, "Value"); @@ -151,12 +152,11 @@ public DBNAlliancePayload setContentTypeCode(@Nullable final String slistID, @No m_sContentTypeCodeValue = sValue; return this; } - + /** - * @return The customization id scheme that applies to the payload instance. - * May be null if not initialized. - * This field is mapped to - * XHE/Payloads/Payload/CustomizationID/@schemeID. + * @return The customization id scheme that applies to the payload instance. + * May be null if not initialized. This field is mapped + * to XHE/Payloads/Payload/CustomizationID/@schemeID. */ @Nullable public String getCustomizationIDScheme () @@ -165,10 +165,9 @@ public String getCustomizationIDScheme () } /** - * @return The customization id value that applies to the payload instance. - * May be null if not initialized. - * This field is mapped to - * XHE/Payloads/Payload/CustomizationID/. + * @return The customization id value that applies to the payload instance. + * May be null if not initialized. This field is mapped + * to XHE/Payloads/Payload/CustomizationID/. */ @Nullable public String getCustomizationIDValue () @@ -177,28 +176,26 @@ public String getCustomizationIDValue () } /** - * @return The from party participant identifier as a participant identifier or - * null if certain information are missing or are + * @return The from party participant identifier as a participant identifier + * or null if certain information are missing or are * invalid. */ @Nullable public IDocumentTypeIdentifier getCustomizationIDAsIdentifier () { - return m_aIdentifierFactory.createDocumentTypeIdentifier(m_sCustomizationIDScheme, m_sCustomizationIDValue); + return m_aIdentifierFactory.createDocumentTypeIdentifier (m_sCustomizationIDScheme, m_sCustomizationIDValue); } /** * Set the customization identifier. * * @param sScheme - * The customization id scheme that applies to the payload instance. - * May be null if not initialized. - * This field is mapped to + * The customization id scheme that applies to the payload instance. + * May be null if not initialized. This field is mapped to * XHE/Payloads/Payload/CustomizationID/@schemeID. * @param sValue - * The customization id value that applies to the payload instance. - * May be null if not initialized. - * This field is mapped to + * The customization id value that applies to the payload instance. May + * be null if not initialized. This field is mapped to * XHE/Payloads/Payload/CustomizationID/. * @return this */ @@ -211,7 +208,7 @@ public DBNAlliancePayload setCustomizationID (@Nullable final String sScheme, @N m_sCustomizationIDValue = sValue; return this; } - + /** * Set the customization identifier. * @@ -226,11 +223,10 @@ public DBNAlliancePayload setCustomizationID (@Nonnull final IDocumentTypeIdenti return setCustomizationID (aCustomizationID.getScheme (), aCustomizationID.getValue ()); } - + /** - * @return The profile id scheme that the payload instance is part of. - * May be null if not initialized. - * This field is mapped to + * @return The profile id scheme that the payload instance is part of. May be + * null if not initialized. This field is mapped to * XHE/Payloads/Payload/ProfileID/@schemeID. */ @Nullable @@ -240,9 +236,8 @@ public String getProfileIDScheme () } /** - * @return The profile id value that the payload instance is part of. - * May be null if not initialized. - * This field is mapped to + * @return The profile id value that the payload instance is part of. May be + * null if not initialized. This field is mapped to * XHE/Payloads/Payload/ProfileID/. */ @Nullable @@ -252,28 +247,26 @@ public String getProfileIDValue () } /** - * @return The from party participant identifier as a participant identifier or - * null if certain information are missing or are + * @return The from party participant identifier as a participant identifier + * or null if certain information are missing or are * invalid. */ @Nullable public IProcessIdentifier getProfileIDAsIdentifier () { - return m_aIdentifierFactory.createProcessIdentifier(m_sProfileIDScheme, m_sProfileIDValue); + return m_aIdentifierFactory.createProcessIdentifier (m_sProfileIDScheme, m_sProfileIDValue); } /** * Set the profile identifier. * * @param sScheme - * The profile id scheme that the payload instance is part of. - * May be null if not initialized. - * This field is mapped to + * The profile id scheme that the payload instance is part of. May be + * null if not initialized. This field is mapped to * XHE/Payloads/Payload/ProfileID/@schemeID. * @param sValue - * The profile id value that the payload instance is part of. - * May be null if not initialized. - * This field is mapped to + * The profile id value that the payload instance is part of. May be + * null if not initialized. This field is mapped to * XHE/Payloads/Payload/ProfileID/. * @return this */ @@ -286,7 +279,7 @@ public DBNAlliancePayload setProfileID (@Nullable final String sScheme, @Nonnull m_sCustomizationIDValue = sValue; return this; } - + /** * Set the profile identifier. * @@ -301,16 +294,15 @@ public DBNAlliancePayload setProfileID (@Nonnull final IProcessIdentifier aProfi return setCustomizationID (aProfileID.getScheme (), aProfileID.getValue ()); } - + /** - * InstanceEncryptionIndicator - Indicator to state whether the payload instance is encrypted or not. - * This field is mapped to + * InstanceEncryptionIndicator - Indicator to state whether the payload + * instance is encrypted or not. This field is mapped to * XHE/Payloads/Payload/InstanceEncryptionIndicator. * * @return InstanceEncryptionIndicator value. Default value is false. */ - @Nullable - public boolean getInstanceEncryptionIndicator () + public boolean isInstanceEncryptionIndicator () { return m_bInstanceEncryptionIndicator; } @@ -322,19 +314,16 @@ public boolean getInstanceEncryptionIndicator () * @param bInstanceEncryptionIndicator * Indicator to state whether the payload instance is encrypted or not. * This field is mapped to - * XHE/Payloads/Payload/InstanceEncryptionIndicator - * . + * XHE/Payloads/Payload/InstanceEncryptionIndicator . * @return this */ @Nonnull - public DBNAlliancePayload setInstanceEncryptionIndicator (@Nonnull final boolean bInstanceEncryptionIndicator) + public DBNAlliancePayload setInstanceEncryptionIndicator (final boolean bInstanceEncryptionIndicator) { - ValueEnforcer.notNull(bInstanceEncryptionIndicator, "InstanceEncryptionIndicator"); - m_bInstanceEncryptionIndicator = bInstanceEncryptionIndicator; return this; } - + /** * InstanceEncryptionMethod - Method used to encrypt the payload instance. * This field is mapped to @@ -349,7 +338,8 @@ public String getInstanceEncryptionMethod () } /** - * @return true if a InstanceEncryptionMethod is present, false if not. + * @return true if a InstanceEncryptionMethod is present, + * false if not. */ public boolean hasInstanceEncryptionMethod () { @@ -361,21 +351,19 @@ public boolean hasInstanceEncryptionMethod () * XHE/Payloads/Payload/InstanceEncryptionMethod. * * @param sInstanceEncryptionMethod - * Method used to encrypt the payload instance. - * This field is mapped to - * XHE/Payloads/Payload/InstanceEncryptionMethod - * . + * Method used to encrypt the payload instance. This field is mapped to + * XHE/Payloads/Payload/InstanceEncryptionMethod . * @return this */ @Nonnull public DBNAlliancePayload setInstanceEncryptionMethod (@Nonnull @Nonempty final String sInstanceEncryptionMethod) { - ValueEnforcer.notNull(sInstanceEncryptionMethod, "InstanceEncryptionMethod"); + ValueEnforcer.notEmpty (sInstanceEncryptionMethod, "InstanceEncryptionMethod"); m_sInstanceEncryptionMethod = sInstanceEncryptionMethod; return this; } - + /** * Get the contained payload content. * @@ -389,7 +377,7 @@ public Element getPayloadContent () { return m_aPayloadContent == null ? null : (Element) m_aPayloadContent.cloneNode (true); } - + /** * Get the contained payload content without cloning it. * @@ -404,9 +392,9 @@ public Element getPayloadContentNoClone () } /** - * Check if a payload content is present without having the need to - * explicitly call {@link #getPayloadContent()} which returns a cloned node - * and is therefore an expensive operation. + * Check if a payload content is present without having the need to explicitly + * call {@link #getPayloadContent()} which returns a cloned node and is + * therefore an expensive operation. * * @return true if a payload content is present, * false otherwise. diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAllianceXHEData.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAllianceXHEData.java index cf7f1946..8d6ad989 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAllianceXHEData.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/DBNAllianceXHEData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,16 @@ */ package com.helger.peppol.xhe; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.concurrent.NotThreadSafe; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.helger.commons.ValueEnforcer; import com.helger.commons.annotation.Nonempty; import com.helger.commons.datetime.PDTFactory; @@ -26,24 +36,18 @@ import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; import com.helger.xhe.v10.XHE10XHEType; -import java.util.ArrayList; -import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.NotThreadSafe; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * This class contains all the DBNAlliance data per XHE document in a syntax - * neutral way. This class maps to the requirements of the Exchange Header + * This class contains all the DBNAlliance data per XHE document in a syntax + * neutral way. This class maps to the requirements of the Exchange Header * Envelope (XHE) Version 1.0 specification. * * @author Robinson Garcia */ @NotThreadSafe -public class DBNAllianceXHEData { - +public class DBNAllianceXHEData +{ + private static final Logger LOGGER = LoggerFactory.getLogger (DBNAllianceXHEData.class); private final IIdentifierFactory m_aIdentifierFactory; @@ -56,30 +60,28 @@ public class DBNAllianceXHEData { private String m_sToPartyScheme; private String m_sToPartyValue; // Payloads - private List m_aPayloads = new ArrayList<>(); - + private List m_aPayloads = new ArrayList <> (); + /** * Constructor * * @param aIdentifierFactory * Identifier factory to be used. May not be null. */ - public DBNAllianceXHEData (@Nonnull final IIdentifierFactory aIdentifierFactory) { + public DBNAllianceXHEData (@Nonnull final IIdentifierFactory aIdentifierFactory) + { m_aIdentifierFactory = ValueEnforcer.notNull (aIdentifierFactory, "IdentifierFactory"); } - + /** - * An informative unique ID created by the issuer of the envelope. The - * ID MUST be unique for each Exchange Header 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).
+ * An informative unique ID created by the issuer of the envelope. The ID MUST + * be unique for each Exchange Header 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 - * XHE/Header/ID - * . + * to XHE/Header/ID . * * @return The instance identifier. May be null. */ @@ -104,16 +106,15 @@ public boolean hasID () * * @param sID * An informative unique ID created by the issuer of the envelope. The - * ID 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).
+ * ID 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 - * XHE/Header/ID - * . + * XHE/Header/ID . * @return this */ @Nonnull @@ -130,9 +131,7 @@ public DBNAllianceXHEData setInstanceIdentifier (@Nonnull @Nonempty final String * 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 - * XHE/Header/CreationDateTime - * . + * field is mapped to XHE/Header/CreationDateTime . * * @return The creation date time. May be null. */ @@ -163,8 +162,7 @@ public boolean hasCreationDateTime () * date time for transmission.
* The format of the value of this MUST include timezone information. * May not be null. This field is mapped to - * XHE/Header/CreationDateTime - * . + * XHE/Header/CreationDateTime . * @return this */ @Nonnull @@ -176,10 +174,10 @@ public DBNAllianceXHEData setCreationDateAndTime (@Nonnull final XMLOffsetDateTi m_aCreationDateTime = PDTFactory.getWithMillisOnly (aCreationDateTime); return this; } - + /** - * @return The from party participant identifier scheme. May be null - * if not initialized. This field is mapped to + * @return The from party participant identifier scheme. May be + * null if not initialized. This field is mapped to * XHE/Header/FromParty/PartyIdentification/ID/@schemeID * . */ @@ -190,8 +188,8 @@ public String getFromPartyScheme () } /** - * @return The from party participant identifier value. May be null - * if not initialized. This field is mapped to + * @return The from party participant identifier value. May be + * null if not initialized. This field is mapped to * XHE/Header/FromParty/PartyIdentification/ID/. */ @Nullable @@ -201,8 +199,8 @@ public String getFromPartyValue () } /** - * @return The from party participant identifier as a participant identifier or - * null if certain information are missing or are + * @return The from party participant identifier as a participant identifier + * or null if certain information are missing or are * invalid. */ @Nullable @@ -215,18 +213,18 @@ public IParticipantIdentifier getFromPartyAsIdentifier () * Set the sender participant identifier. * * @param sScheme - * The DBNAlliance identifier scheme. May neither be null + * The DBNAlliance identifier scheme. May neither be null * nor empty. This field is mapped to - * XHE/Header/FromParty/PartyIdentification/ID/@schemeID - * . + * XHE/Header/FromParty/PartyIdentification/ID/@schemeID . * @param sValue - * The from party identifier value. May neither be null nor - * empty. This field is mapped to + * The from party identifier value. May neither be null + * nor empty. This field is mapped to * XHE/Header/FromParty/PartyIdentification/ID/. * @return this */ @Nonnull - public DBNAllianceXHEData setFromParty (@Nonnull @Nonempty final String sScheme, @Nonnull @Nonempty final String sValue) + public DBNAllianceXHEData setFromParty (@Nonnull @Nonempty final String sScheme, + @Nonnull @Nonempty final String sValue) { ValueEnforcer.notEmpty (sScheme, "Scheme"); ValueEnforcer.notEmpty (sValue, "Value"); @@ -235,7 +233,7 @@ public DBNAllianceXHEData setFromParty (@Nonnull @Nonempty final String sScheme, m_sFromPartyValue = sValue; return this; } - + /** * Set the from party participant identifier. * @@ -250,12 +248,11 @@ public DBNAllianceXHEData setFromParty (@Nonnull final IParticipantIdentifier aF return setFromParty (aFromPartyID.getScheme (), aFromPartyID.getValue ()); } - + /** * @return The to party participant identifier scheme. May be * null if not initialized. This field is mapped to - * XHE/Header/ToParty/PartyIdentification/ID/@schemeID - * . + * XHE/Header/ToParty/PartyIdentification/ID/@schemeID . */ @Nullable public String getToPartyScheme () @@ -289,10 +286,9 @@ public IParticipantIdentifier getToPartyAsIdentifier () * Set the to party participant identifier. * * @param sScheme - * The DBNAlliance identifier scheme. May neither be null + * The DBNAlliance identifier scheme. May neither be null * nor empty. This field is mapped to - * XHE/Header/ToParty/PartyIdentification/ID/@schemeID - * . + * XHE/Header/ToParty/PartyIdentification/ID/@schemeID . * @param sValue * The to party identifier value. May neither be null nor * empty. This field is mapped to @@ -324,21 +320,19 @@ public DBNAllianceXHEData setToParty (@Nonnull final IParticipantIdentifier aToP return setToParty (aToPartyID.getScheme (), aToPartyID.getValue ()); } - + /** - * Get the list of payloads of the exchange header envelope. - * This field is mapped to - * XHE/Payloads - * . + * Get the list of payloads of the exchange header envelope. This field is + * mapped to XHE/Payloads . * * @return The payloads list . */ @Nullable - public List getPayloads() + public List getPayloads () { return m_aPayloads; } - + /** * Set the list of payloads of the exchange header envelope (XHE). * @@ -347,20 +341,20 @@ public List getPayloads() * @return this */ @Nonnull - public DBNAllianceXHEData setPayloads (@Nonnull final List aPayloads) + public DBNAllianceXHEData setPayloads (@Nonnull final List aPayloads) { ValueEnforcer.notNull (aPayloads, "Payloads"); m_aPayloads = aPayloads; return this; } - + /** * Set an individual payload. * * @param aPayload - * An individual payload to be added to the list of payloads. - * May not be null. + * An individual payload to be added to the list of payloads. May not + * be null. * @return this */ @Nonnull @@ -368,10 +362,10 @@ public DBNAllianceXHEData addPayload (@Nonnull final DBNAlliancePayload aPayload { ValueEnforcer.notNull (aPayload, "Payload"); - m_aPayloads.add(aPayload); + m_aPayloads.add (aPayload); return this; } - + /** * @param bLogMissing * true if log messages should be emitted, @@ -388,13 +382,13 @@ public boolean areAllFieldsSet (final boolean bLogMissing) aCondLog.info ("DBNAlliance XHE data - ID Value is missing"); return false; } - + if (m_aCreationDateTime == null) { aCondLog.info ("DBNAlliance XHE data - Creation Date Time Value is missing"); return false; } - + if (StringHelper.hasNoText (m_sFromPartyScheme)) { aCondLog.info ("DBNAlliance XHE data - From Party Scheme is missing"); @@ -417,7 +411,7 @@ public boolean areAllFieldsSet (final boolean bLogMissing) return false; } - if (m_aPayloads.isEmpty()) + if (m_aPayloads.isEmpty ()) { aCondLog.info ("DBNAlliance XHE data - An envelope MUST contain at least one business document."); return false; @@ -435,7 +429,7 @@ public boolean areAllFieldsSet () { return areAllFieldsSet (false); } - + /** * @return A generic JAXB XHE document of this data. Never null. * @see DBNAllianceXHEDocumentWriter for the main logic diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReadException.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReadException.java index 3e7e5b52..104fea51 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReadException.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReadException.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,11 +23,12 @@ * * @author Robinson Garcia */ -public class DBNAllianceXHEDocumentReadException extends Exception { +public class DBNAllianceXHEDocumentReadException extends Exception +{ private final EDBNAllianceXHEDocumentReadError m_eErrorCode; DBNAllianceXHEDocumentReadException (@Nonnull final String sErrorMsg, - @Nonnull final EDBNAllianceXHEDocumentReadError eErrorCode) + @Nonnull final EDBNAllianceXHEDocumentReadError eErrorCode) { super (sErrorMsg); m_eErrorCode = eErrorCode; diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReader.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReader.java index 621a816b..3c28c817 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReader.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/DBNAllianceXHEDocumentReader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,18 @@ */ package com.helger.peppol.xhe.read; +import java.io.InputStream; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.WillClose; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + import com.helger.commons.ValueEnforcer; import com.helger.commons.annotation.OverrideOnDemand; import com.helger.commons.datetime.XMLOffsetDateTime; @@ -45,25 +57,15 @@ import com.helger.xhe.v10.cbc.XHE10InstanceEncryptionIndicatorType; import com.helger.xhe.v10.cbc.XHE10InstanceEncryptionMethodType; import com.helger.xhe.v10.cbc.XHE10ProfileIDType; -import java.io.InputStream; -import java.util.List; -import java.util.Locale; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.WillClose; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Element; -import org.w3c.dom.Node; /** - * Main class to read exchange header envelope and extract the DBNAllance + * Main class to read exchange header envelope and extract the DBNAlliance * required data out of it. * * @author Robinson Garcia */ -public class DBNAllianceXHEDocumentReader { - +public class DBNAllianceXHEDocumentReader +{ public static final boolean DEFAULT_PERFORM_VALUE_CHECKS = true; private static final Logger LOGGER = LoggerFactory.getLogger (DBNAllianceXHEDocumentReader.class); @@ -114,9 +116,9 @@ public final DBNAllianceXHEDocumentReader setPerformValueChecks (final boolean b } /** - * Check if the passed XHE version is valid or not. By default is must - * match {@link CDBNAllianceXHE#XHE_VERSION_ID}. Override this method to - * allow for other schemes as well. + * Check if the passed XHE version is valid or not. By default is must match + * {@link CDBNAllianceXHE#XHE_VERSION_ID}. Override this method to allow for + * other schemes as well. * * @param sXHEVersionID * The value to be checked. This is the content of the XML element @@ -131,13 +133,14 @@ protected boolean isValidXHEVersionID (@Nullable final String sXHEVersionID) } /** - * Check if the passed customization id schema is valid or not. By default is must - * match {@link CDBNAllianceXHE#CUSTOMIZATION_SCHEMA_ID}. Override - * this method to allow for other schemes as well. + * Check if the passed customization id schema is valid or not. By default is + * must match {@link CDBNAllianceXHE#CUSTOMIZATION_SCHEMA_ID}. Override this + * method to allow for other schemes as well. * * @param sSchemaID * The value to be checked. This is the content of the XML attribute - * XHE/CustomizationID/@schemeID. May be null. + * XHE/CustomizationID/@schemeID. May be + * null. * @return true if the value is valid, false * otherwise. */ @@ -146,11 +149,11 @@ protected boolean isValidCustomizationIDSchemaID (@Nullable final String sSchema { return CDBNAllianceXHE.CUSTOMIZATION_SCHEMA_ID.equals (sSchemaID); } - + /** * Check if the passed customization id is valid or not. By default is must - * match {@link CDBNAllianceXHE#CUSTOMIZATION_ID}. Override - * this method to allow for other schemes as well. + * match {@link CDBNAllianceXHE#CUSTOMIZATION_ID}. Override this method to + * allow for other schemes as well. * * @param sCustomizationID * The value to be checked. This is the content of the XML attribute @@ -165,9 +168,9 @@ protected boolean isValidCustomizationID (@Nullable final String sCustomizationI } /** - * Check if the passed profile id is valid or not. By default is must - * match {@link CDBNAllianceXHE#PROFILE_ID}. Override - * this method to allow for other schemes as well. + * Check if the passed profile id is valid or not. By default is must match + * {@link CDBNAllianceXHE#PROFILE_ID}. Override this method to allow for other + * schemes as well. * * @param sProfileID * The value to be checked. This is the content of the XML attribute @@ -182,21 +185,21 @@ protected boolean isValidProfileID (@Nullable final String sProfileID) } /** - * Check if the passed header id is valid or not. By default is must - * not be empty. Override this method to perform further checks. + * Check if the passed header id is valid or not. By default is must not be + * empty. Override this method to perform further checks. * * @param sHeaderID * The value to be checked. This conforms to the XML element value of * XHE/Header/ID. May be null. - * @return true if the value is valid, false - * otherwise. + * @return true if the value is valid, false + * otherwise. */ @OverrideOnDemand protected boolean isValidHeaderID (@Nullable final String sHeaderID) { return StringHelper.hasText (sHeaderID); } - + /** * Check if the passed document identification creation date time is valid or * not. By default all values are valid as they cannot be null. @@ -204,8 +207,7 @@ protected boolean isValidHeaderID (@Nullable final String sHeaderID) * * @param aCreationDateTime * The value to be checked. This corresponds to the field - * "XHE/Header/CreationDateTime". Is never - * null . + * "XHE/Header/CreationDateTime". Is never null . * @return true if the value is valid, false * otherwise. */ @@ -214,14 +216,14 @@ protected boolean isValidCreationDateTime (@Nonnull final XMLOffsetDateTime aCre { return true; } - + /** - * Check if the passed from party schema is is valid or not. By default is + * Check if the passed from party schema is is valid or not. By default is * must not be empty. * * @param sFromPartySchemaID * The value to be checked. This is the content of the XML attribute - * XHE/Header/FromParty/PartyIdentification/ID/@schemaID. + * XHE/Header/FromParty/PartyIdentification/ID/@schemaID. * May be null. * @return true if the value is valid, false * otherwise. @@ -238,29 +240,29 @@ protected boolean isValidFromPartySchemaID (@Nullable final String sFromPartySch * * @param sFromPartySchemaID * The value to be checked. This is the content of the XML attribute - * XHE/Header/FromParty/PartyIdentification/ID/@schemaID. + * XHE/Header/FromParty/PartyIdentification/ID/@schemaID. * May be null. * @param sFromPartyValue * The value to be checked. This conforms to the XML element value of - * XHE/Header/FromParty/PartyIdentification/ID/. - * May be null. + * XHE/Header/FromParty/PartyIdentification/ID/. May be + * null. * @return true if the value is valid, false - * otherwise. + * otherwise. */ @OverrideOnDemand protected boolean isValidFromPartyValue (@Nullable final String sFromPartySchemaID, - @Nullable final String sFromPartyValue) + @Nullable final String sFromPartyValue) { return StringHelper.hasText (sFromPartyValue); } - + /** - * Check if the passed to party schema is valid or not. By default is - * must not be empty. + * Check if the passed to party schema is valid or not. By default is must not + * be empty. * * @param sToPartySchemaID * The value to be checked. This is the content of the XML attribute - * XHE/Header/ToParty/PartyIdentification/ID/@schemaID. + * XHE/Header/ToParty/PartyIdentification/ID/@schemaID. * May be null. * @return true if the value is valid, false * otherwise. @@ -272,88 +274,85 @@ protected boolean isValidToPartySchemaID (@Nullable final String sToPartySchemaI } /** - * 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. + * 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. * * @param sToPartySchemaID * The value to be checked. This is the content of the XML attribute - * XHE/Header/ToParty/PartyIdentification/ID/@schemaID. + * XHE/Header/ToParty/PartyIdentification/ID/@schemaID. * May be null. * @param sToPartyValue * The value to be checked. This conforms to the XML element value of - * XHE/Header/ToParty/PartyIdentification/ID/. - * May be null. + * XHE/Header/ToParty/PartyIdentification/ID/. May be + * null. * @return true if the value is valid, false - * otherwise. + * otherwise. */ @OverrideOnDemand - protected boolean isValidToPartyValue (@Nullable final String sToPartySchemaID, - @Nullable final String sToPartyValue) + protected boolean isValidToPartyValue (@Nullable final String sToPartySchemaID, @Nullable final String sToPartyValue) { return StringHelper.hasText (sToPartyValue); } // Payloads validations - + /** - * Check if the passed payload id is valid or not. By default is - * must not be empty. + * Check if the passed payload id is valid or not. By default is must not be + * empty. * * @param sPayloadID * The value to be checked. This corresponds to the field - * XHE/Payloads/Payload/ID. - * May be null. + * XHE/Payloads/Payload/ID. May be null. * @return true if the value is valid, false * otherwise. */ @OverrideOnDemand protected boolean isValidPayloadIDValue (@Nullable final String sPayloadID) { - return StringHelper.hasText(sPayloadID); + return StringHelper.hasText (sPayloadID); } - + /** * Check if the passed list id is valid or not. * * @param sListID * The value to be checked. This is the content of the XML attribute - * XHE/Payloads/Payload/ContentTypeCode/@listID. - * May be null. + * XHE/Payloads/Payload/ContentTypeCode/@listID. May be + * null. * @return true if the value is valid, false * otherwise. */ @OverrideOnDemand protected boolean isValidContentTypeCodeListID (@Nullable final String sListID) { - return "MIME".equals(sListID); + return "MIME".equals (sListID); } - + /** - * Check if the passed content type code value is valid or not. By default is + * Check if the passed content type code value is valid or not. By default is * must not be empty. * * @param sListID * The value to be checked. This is the content of the XML attribute - * XHE/Payloads/Payload/ContentTypeCode/@listID. - * May be null. + * XHE/Payloads/Payload/ContentTypeCode/@listID. May be + * null. * @param sValue * The value to be checked. This corresponds to the field - * XHE/Payloads/Payload/ContentTypeCode. - * May be null. + * XHE/Payloads/Payload/ContentTypeCode. May be + * null. * @return true if the value is valid, false * otherwise. */ @OverrideOnDemand - protected boolean isValidContentTypeCodeValue (@Nullable final String sListID, - @Nullable final String sValue) + protected boolean isValidContentTypeCodeValue (@Nullable final String sListID, @Nullable final String sValue) { - return "application/xml".equals(sValue); + return "application/xml".equals (sValue); } - + /** - * 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. + * 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. * * @param bInstanceEncryptionIndicator * The value to be checked. This corresponds to the field @@ -367,11 +366,11 @@ protected boolean isValidInstanceEncryptionIndicatorValue (@Nullable final boole { return true; } - + /** - * 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. + * 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. * * @param sInstanceHashValue * The value to be checked. This corresponds to the field @@ -385,7 +384,7 @@ protected boolean isInstanceHashValueExist (@Nullable final String sInstanceHash { return sInstanceHashValue == null; } - + /** * Check if the passed business message is valid or not. By default this * method always returns true since the element is never @@ -403,8 +402,7 @@ protected boolean isValidBusinessMessage (@Nonnull final Element aBusinessMessag { return true; } - - + /** * Create a new XHE10 marshaller used for reading XHE documents. Override this * method to customize reading. @@ -421,7 +419,7 @@ protected XHE10Marshaller createXHEMarshaller () ret.setValidationEventHandler (null); return ret; } - + /** * Extract the document data from the Exchange Header Envelope represents by * the passed parameter. @@ -431,8 +429,8 @@ protected XHE10Marshaller createXHEMarshaller () * not be null. * @return The document data and never null. * @throws DBNAllianceXHEDocumentReadException - * In case the passed Exchange Header Envelope does not conform to - * the DBNAlliance rules. + * In case the passed Exchange Header Envelope does not conform to the + * DBNAlliance rules. */ @Nonnull public DBNAllianceXHEData extractData (@Nonnull @WillClose final InputStream aExchangeHeaderEnvelope) throws DBNAllianceXHEDocumentReadException @@ -462,8 +460,8 @@ public DBNAllianceXHEData extractData (@Nonnull @WillClose final InputStream aEx * The resource to read from. May not be null. * @return The document data and never null. * @throws DBNAllianceXHEDocumentReadException - * In case the passed Exchange Header Envelope does not conform to - * the DBNAlliance rules. + * In case the passed Exchange Header Envelope does not conform to the + * DBNAlliance rules. */ @Nonnull public DBNAllianceXHEData extractData (@Nonnull final IReadableResource aExchangeHeaderEnvelope) throws DBNAllianceXHEDocumentReadException @@ -486,8 +484,8 @@ public DBNAllianceXHEData extractData (@Nonnull final IReadableResource aExchang * The DOM node to read from. May not be null. * @return The document data and never null. * @throws DBNAllianceXHEDocumentReadException - * In case the passed Exchange Header Envelope does not conform to - * the DBNAlliance rules. + * In case the passed Exchange Header Envelope does not conform to the + * DBNAlliance rules. */ @Nonnull public DBNAllianceXHEData extractData (@Nonnull final Node aExchangeHeaderEnvelope) throws DBNAllianceXHEDocumentReadException @@ -510,8 +508,8 @@ public DBNAllianceXHEData extractData (@Nonnull final Node aExchangeHeaderEnvelo * The domain object to read from. May not be null. * @return The document data and never null. * @throws DBNAllianceXHEDocumentReadException - * In case the passed Exchange Header Envelope does not conform to - * the DBNAlliance rules. + * In case the passed Exchange Header Envelope does not conform to the + * DBNAlliance rules. */ @Nonnull public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aExchangeHeaderEnvelope) throws DBNAllianceXHEDocumentReadException @@ -519,13 +517,13 @@ public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aExchangeHead ValueEnforcer.notNull (aExchangeHeaderEnvelope, "ExchangeHeaderEnvelope"); // Grab the payloads - final XHE10PayloadsType aPayloads = aExchangeHeaderEnvelope.getPayloads(); + final XHE10PayloadsType aPayloads = aExchangeHeaderEnvelope.getPayloads (); if (aPayloads == null || aPayloads.getPayload ().isEmpty ()) throw new DBNAllianceXHEDocumentReadException (EDBNAllianceXHEDocumentReadError.MISSING_PAYLOADS_PAYLOAD); return extractData (aExchangeHeaderEnvelope, aPayloads); } - + @Nonnull private static IError _toError (@Nullable final String sErrorField, @Nonnull final EDBNAllianceXHEDocumentReadError e, @@ -563,22 +561,23 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, aErrorList.add (_toError ("XHE/XHEVersionID", EDBNAllianceXHEDocumentReadError.INVALID_XHE_VERSION_ID, aXHE.getXHEVersionIDValue ())); - + // Check CustomizationID { final XHE10CustomizationIDType aCustomizationID = aXHE.getCustomizationID (); - if (aCustomizationID == null) { - aErrorList.add (_toError ("XHE/CustomizationID", - EDBNAllianceXHEDocumentReadError.CUSTOMIZATION_ID_MISSING)); + if (aCustomizationID == null) + { + aErrorList.add (_toError ("XHE/CustomizationID", EDBNAllianceXHEDocumentReadError.CUSTOMIZATION_ID_MISSING)); } - else { + else + { // schemaID is mandatory final String sCustomizationIDSchemaID = aCustomizationID.getSchemeID (); if (!isValidCustomizationIDSchemaID (sCustomizationIDSchemaID)) aErrorList.add (_toError ("XHE/CustomizationID/SchemaID", EDBNAllianceXHEDocumentReadError.INVALID_CUSTOMIZATION_ID_SCHEMA_ID, sCustomizationIDSchemaID)); - + final String sCustomizationIDValue = aCustomizationID.getValue (); if (!isValidCustomizationID (sCustomizationIDValue)) aErrorList.add (_toError ("XHE/CustomizationID/Value", @@ -586,15 +585,16 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, sCustomizationIDValue)); } } - + // Check ProfileID { final XHE10ProfileIDType aProfileID = aXHE.getProfileID (); - if (aProfileID == null) { - aErrorList.add (_toError ("XHE/ProfileID", - EDBNAllianceXHEDocumentReadError.PROFILE_ID_MISSING)); + if (aProfileID == null) + { + aErrorList.add (_toError ("XHE/ProfileID", EDBNAllianceXHEDocumentReadError.PROFILE_ID_MISSING)); } - else { + else + { final String sProfileIDValue = aProfileID.getValue (); if (!isValidProfileID (sProfileIDValue)) aErrorList.add (_toError ("XHE/ProfileID/Value", @@ -602,14 +602,13 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, sProfileIDValue)); } } - + // Check Header { - final XHE10HeaderType aHeader = aXHE.getHeader(); + final XHE10HeaderType aHeader = aXHE.getHeader (); if (aHeader == null) { - aErrorList.add (_toError ("XHE/Header", - EDBNAllianceXHEDocumentReadError.HEADER_MISSING)); + aErrorList.add (_toError ("XHE/Header", EDBNAllianceXHEDocumentReadError.HEADER_MISSING)); } else { @@ -617,9 +616,7 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, final String sHeaderID = aHeader.getIDValue (); if (!isValidHeaderID (sHeaderID)) { - aErrorList.add (_toError ("XHE/Header/ID", - EDBNAllianceXHEDocumentReadError.INVALID_HEADER_ID, - sHeaderID)); + aErrorList.add (_toError ("XHE/Header/ID", EDBNAllianceXHEDocumentReadError.INVALID_HEADER_ID, sHeaderID)); } // Header creation date time is mandatory final XMLOffsetDateTime aCreationDateTime = aHeader.getCreationDateTimeValue (); @@ -629,17 +626,17 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, EDBNAllianceXHEDocumentReadError.INVALID_CREATION_DATE_TIME, sHeaderID)); } - + // Check from party final XHE10PartyType aFromParty = aHeader.getFromParty (); if (aFromParty != null) { - final int nFromPartyCount = aFromParty.getPartyIdentificationCount(); + final int nFromPartyCount = aFromParty.getPartyIdentificationCount (); if (nFromPartyCount != 1) aErrorList.add (_toError ("XHE/Header/FromParty/PartyIdentification", - EDBNAllianceXHEDocumentReadError.INVALID_FROM_PARTY_COUNT, - Integer.toString (nFromPartyCount))); - + EDBNAllianceXHEDocumentReadError.INVALID_FROM_PARTY_COUNT, + Integer.toString (nFromPartyCount))); + if (nFromPartyCount > 0) { final XHE10IDType aFromPartyID = aFromParty.getPartyIdentificationAtIndex (0).getID (); @@ -669,26 +666,26 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, } } } - + // Check to party final int nToPartyCount = aHeader.getToPartyCount (); if (nToPartyCount != 1) aErrorList.add (_toError ("XHE/Header/ToParty", - EDBNAllianceXHEDocumentReadError.INVALID_TO_PARTY_COUNT, - Integer.toString (nToPartyCount))); - + EDBNAllianceXHEDocumentReadError.INVALID_TO_PARTY_COUNT, + Integer.toString (nToPartyCount))); + if (nToPartyCount > 0) { - XHE10PartyType nToParty = aHeader.getToPartyAtIndex (0); - int nFromPartyIdentificationCount = nToParty.getPartyIdentificationCount (); + final XHE10PartyType nToParty = aHeader.getToPartyAtIndex (0); + final int nFromPartyIdentificationCount = nToParty.getPartyIdentificationCount (); if (nFromPartyIdentificationCount != 1) aErrorList.add (_toError ("XHE/Header/ToParty/PartyIdentification", - EDBNAllianceXHEDocumentReadError.INVALID_TO_PARTY_IDENTIFICATION_COUNT, - Integer.toString (nFromPartyIdentificationCount))); - + EDBNAllianceXHEDocumentReadError.INVALID_TO_PARTY_IDENTIFICATION_COUNT, + Integer.toString (nFromPartyIdentificationCount))); + if (nFromPartyIdentificationCount > 0) { - XHE10IDType aToPartyID = nToParty.getPartyIdentificationAtIndex (0).getID (); + final XHE10IDType aToPartyID = nToParty.getPartyIdentificationAtIndex (0).getID (); final String sScheme = aToPartyID.getSchemeID (); if (!isValidToPartySchemaID (sScheme)) { @@ -719,48 +716,49 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, } // Check Payloads - List aPayloadList = aPayloads.getPayload (); + final List aPayloadList = aPayloads.getPayload (); int nPayload = 1; - for (XHE10PayloadType aPayload : aPayloadList) + for (final XHE10PayloadType aPayload : aPayloadList) { - + // ID is mandatory final String sPayloadID = aPayload.getIDValue (); if (!isValidPayloadIDValue (sPayloadID)) aErrorList.add (_toError ("XHE/Payloads/Payload[" + nPayload + "]/ID", - EDBNAllianceXHEDocumentReadError.INVALID_PAYLOAD_ID_VALUE, - sPayloadID)); - + EDBNAllianceXHEDocumentReadError.INVALID_PAYLOAD_ID_VALUE, + sPayloadID)); + // Check content type code { final XHE10ContentTypeCodeType aContentTypeCode = aPayload.getContentTypeCode (); - + final String sContentTypeCodeListID = aContentTypeCode.getListID (); if (sContentTypeCodeListID != null && !isValidContentTypeCodeListID (sContentTypeCodeListID)) aErrorList.add (_toError ("XHE/Payloads/Payload[" + nPayload + "]/ContentTypeCode/listID", - EDBNAllianceXHEDocumentReadError.INVALID_CONTENT_TYPE_CODE_LIST_ID, - sContentTypeCodeListID)); - + EDBNAllianceXHEDocumentReadError.INVALID_CONTENT_TYPE_CODE_LIST_ID, + sContentTypeCodeListID)); + // Content type code values is mandatory final String sContentTypeCodeValue = aContentTypeCode.getValue (); if (!isValidContentTypeCodeValue (sContentTypeCodeListID, sContentTypeCodeValue)) aErrorList.add (_toError ("XHE/Payloads/Payload[" + nPayload + "]/ContentTypeCode", - EDBNAllianceXHEDocumentReadError.INVALID_CONTENT_TYPE_CODE_VALUE, - sContentTypeCodeValue)); + EDBNAllianceXHEDocumentReadError.INVALID_CONTENT_TYPE_CODE_VALUE, + sContentTypeCodeValue)); } - + // Check instance encription indicator final XHE10InstanceEncryptionIndicatorType aInstanceEncryptionIndicator = aPayload.getInstanceEncryptionIndicator (); if (aInstanceEncryptionIndicator == null) aErrorList.add (_toError ("XHE/Payloads/Payload[" + nPayload + "]/InstanceEncryptionIndicator", EDBNAllianceXHEDocumentReadError.INSTANCE_ENCRYPTION_INDICATOR_MISSING)); - - // Extract the payload content (business message) - cannot be null and must be an + + // Extract the payload content (business message) - cannot be null and + // must be an // Element! final Element aPayloadContent = (Element) aPayload.getPayloadContent (); if (!isValidBusinessMessage (aPayloadContent)) aErrorList.add (_toError (null, EDBNAllianceXHEDocumentReadError.INVALID_BUSINESS_MESSAGE)); - + nPayload++; } } @@ -773,16 +771,16 @@ public void validateData (@Nonnull final XHE10XHEType aXHE, * @param aXHE * The xhe object to read from. May not be null. * @param aPayloads - * The list of DBNAlliance payload to extract data from. May - * not be null. + * The list of DBNAlliance payload to extract data from. May not be + * null. * @return The document data and never null. * @throws DBNAllianceXHEDocumentReadException - * In case the passed Exchange Header Envelope does not conform to - * the DBNAlliance rules. + * In case the passed Exchange Header Envelope does not conform to the + * DBNAlliance rules. */ @Nonnull public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aXHE, - @Nonnull final XHE10PayloadsType aPayloads) throws DBNAllianceXHEDocumentReadException + @Nonnull final XHE10PayloadsType aPayloads) throws DBNAllianceXHEDocumentReadException { ValueEnforcer.notNull (aXHE, "ExchangeHeaderEnvelope"); ValueEnforcer.notNull (aPayloads, "Payloads"); @@ -801,7 +799,7 @@ public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aXHE, aErrorList.forEach (x -> { if (x.isError ()) { - final String sMsg = x.getAsString (Locale.US); + final String sMsg = x.getAsStringLocaleIndepdent (); LOGGER.error ("DBNAlliance XHE validation " + sMsg); if (aErrorMsgSB.length () > 0) aErrorMsgSB.append ('\n'); @@ -812,7 +810,7 @@ public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aXHE, // Find an error code final IError aFirst = aErrorList.findFirst (IHasErrorLevel::isError); final EDBNAllianceXHEDocumentReadError eError = EDBNAllianceXHEDocumentReadError.getFromIDOrDefault (aFirst.getErrorID (), - EDBNAllianceXHEDocumentReadError.GENERIC_XHE_ERROR); + EDBNAllianceXHEDocumentReadError.GENERIC_XHE_ERROR); throw new DBNAllianceXHEDocumentReadException (aErrorMsgSB.toString (), eError); } } @@ -828,18 +826,18 @@ public DBNAllianceXHEData extractData (@Nonnull final XHE10XHEType aXHE, * @param aXHE * The header object to read from. May not be null. * @param aPayloads - * The list of DBNAlliance payload to extract data from. May - * not be null. + * The list of DBNAlliance payload to extract data from. May not be + * null. * @return The document data and never null. */ @Nonnull public DBNAllianceXHEData extractDataUnchecked (@Nonnull final XHE10XHEType aXHE, - @Nonnull final XHE10PayloadsType aPayloads) + @Nonnull final XHE10PayloadsType aPayloads) { ValueEnforcer.notNull (aXHE, "ExchangeHeaderEnvelope"); ValueEnforcer.notNull (aPayloads, "Payloads"); final DBNAllianceXHEData ret = new DBNAllianceXHEData (m_aIdentifierFactory); - + // Check Header { final XHE10HeaderType aHeader = aXHE.getHeader (); @@ -847,7 +845,7 @@ public DBNAllianceXHEData extractDataUnchecked (@Nonnull final XHE10XHEType aXHE { ret.setInstanceIdentifier (aHeader.getIDValue ()); ret.setCreationDateAndTime (aHeader.getCreationDateTimeValue ()); - + // From Party { final XHE10PartyType aFromParty = aHeader.getFromParty (); @@ -857,7 +855,7 @@ public DBNAllianceXHEData extractDataUnchecked (@Nonnull final XHE10XHEType aXHE ret.setFromParty (aFromPartyID.getSchemeID (), aFromPartyID.getValue ()); } } - + // To Party { if (aHeader.hasToPartyEntries ()) @@ -872,45 +870,45 @@ public DBNAllianceXHEData extractDataUnchecked (@Nonnull final XHE10XHEType aXHE } } } - + // Check Payloads { - final List aXHEPayloads = aPayloads.getPayload(); - for (XHE10PayloadType aXHEPayload : aXHEPayloads) + final List aXHEPayloads = aPayloads.getPayload (); + for (final XHE10PayloadType aXHEPayload : aXHEPayloads) { - DBNAlliancePayload aPayload = new DBNAlliancePayload (m_aIdentifierFactory); - if (aXHEPayload.hasDescriptionEntries()) + final DBNAlliancePayload aPayload = new DBNAlliancePayload (m_aIdentifierFactory); + if (aXHEPayload.hasDescriptionEntries ()) aPayload.setDescription (aXHEPayload.getDescriptionAtIndex (0).getValue ()); - + // Check content type code - final XHE10ContentTypeCodeType aContentTypeCode = aXHEPayload.getContentTypeCode(); + final XHE10ContentTypeCodeType aContentTypeCode = aXHEPayload.getContentTypeCode (); if (aContentTypeCode != null) aPayload.setContentTypeCode (aContentTypeCode.getListID (), aContentTypeCode.getValue ()); - + // Check customization id - final XHE10CustomizationIDType aCustomizationID = aXHEPayload.getCustomizationID(); + final XHE10CustomizationIDType aCustomizationID = aXHEPayload.getCustomizationID (); if (aCustomizationID != null) aPayload.setCustomizationID (aCustomizationID.getSchemeID (), aCustomizationID.getValue ()); - + // Check profile id - final XHE10ProfileIDType aProfileID = aXHEPayload.getProfileID(); + final XHE10ProfileIDType aProfileID = aXHEPayload.getProfileID (); if (aProfileID != null) aPayload.setProfileID (aProfileID.getSchemeID (), aProfileID.getValue ()); - + final XHE10InstanceEncryptionIndicatorType aInstanceEncryptionIndicator = aXHEPayload.getInstanceEncryptionIndicator (); if (aInstanceEncryptionIndicator != null) aPayload.setInstanceEncryptionIndicator (aInstanceEncryptionIndicator.isValue ()); - - final XHE10InstanceEncryptionMethodType aInstanceEncryptionMethod = aXHEPayload.getInstanceEncryptionMethod(); + + final XHE10InstanceEncryptionMethodType aInstanceEncryptionMethod = aXHEPayload.getInstanceEncryptionMethod (); if (aInstanceEncryptionMethod != null) - aPayload.setInstanceEncryptionMethod (aInstanceEncryptionMethod.getValue()); - - final XHE10PayloadContentType aPayloadContent = aXHEPayload.getPayloadContent(); + aPayload.setInstanceEncryptionMethod (aInstanceEncryptionMethod.getValue ()); + + final XHE10PayloadContentType aPayloadContent = aXHEPayload.getPayloadContent (); if (aPayloadContent != null) - aPayload.setPayloadContent ((Element) aPayloadContent); - - ret.addPayload(aPayload); - + aPayload.setPayloadContent ((Element) aPayloadContent); + + ret.addPayload (aPayload); + } } diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/EDBNAllianceXHEDocumentReadError.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/EDBNAllianceXHEDocumentReadError.java index 33575f87..651a7d47 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/EDBNAllianceXHEDocumentReadError.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/read/EDBNAllianceXHEDocumentReadError.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,19 +16,20 @@ */ package com.helger.peppol.xhe.read; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import com.helger.commons.annotation.Nonempty; import com.helger.commons.id.IHasID; import com.helger.commons.lang.EnumHelper; import com.helger.commons.text.util.TextHelper; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * This enum contains all the errors that can occur during XHE reading * * @author Robinson Garcia */ -public enum EDBNAllianceXHEDocumentReadError implements IHasID +public enum EDBNAllianceXHEDocumentReadError implements IHasID { /** Failed to interpret ExchangeHeaderEnvelope as XML */ INVALID_XHE_XML ("invalid-xhe-xml", "Failed to interpret ExchangeHeaderEnvelope as XML."), @@ -38,10 +39,10 @@ public enum EDBNAllianceXHEDocumentReadError implements IHasID /** The "HeaderVersion" element has an illegal value */ INVALID_XHE_VERSION_ID ("invalid-xhe-version-id", "The ''VersionID'' element has the illegal value ''{0}''."), - + /** The "XHE/CustomizationID" element is missing */ CUSTOMIZATION_ID_MISSING ("customization-id-missing", "The ''XHE/CustomizationID'' element is missing."), - + /** The "XHE/CustomizationID/schemaID" attribute has an invalid value */ INVALID_CUSTOMIZATION_ID_SCHEMA_ID ("invalid-customization-id-schema-id", "The ''XHE/CustomizationID/schemaID'' attribute has the invalid value ''{0}''."), @@ -49,77 +50,83 @@ public enum EDBNAllianceXHEDocumentReadError implements IHasID /** The "XHE/CustomizationID" has an invalid value */ INVALID_CUSTOMIZATION_ID_VALUE ("invalid-customization-id-value", "The ''XHE/CustomizationID'' has the invalid value ''{0}''."), - + /** The "XHE/ProfileID" element is missing */ PROFILE_ID_MISSING ("profile-id-missing", "The ''XHE/ProfileID'' element is missing."), - + /** The "XHE/ProfileID/schemaID" attribute has an invalid value */ INVALID_PROFILE_ID_SCHEMA_ID ("invalid-profile-id-schema-id", - "The ''XHE/ProfileID/schemaID'' attribute has the invalid value ''{0}''."), + "The ''XHE/ProfileID/schemaID'' attribute has the invalid value ''{0}''."), /** The "XHE/ProfileID" has an invalid value */ - INVALID_PROFILE_ID_VALUE ("invalid-profile-id-value", - "The ''XHE/ProfileID'' has the invalid value ''{0}''."), - + INVALID_PROFILE_ID_VALUE ("invalid-profile-id-value", "The ''XHE/ProfileID'' has the invalid value ''{0}''."), + /** The "XHE/Header" element is missing */ HEADER_MISSING ("xhe-header-missing", "The ''XHE/Header'' element is missing."), - + /** The "XHE/Header/ID" has an invalid value */ - INVALID_HEADER_ID ("invalid-header-id-value", - "The ''XHE/Header/ID'' has the invalid value ''{0}''."), - + INVALID_HEADER_ID ("invalid-header-id-value", "The ''XHE/Header/ID'' has the invalid value ''{0}''."), + /** The value of the "XHE/Header/CreationDateAndTime" element is invalid */ INVALID_CREATION_DATE_TIME ("invalid-creation-date-time", "The ''XHE/Header/CreationDateAndTime'' element has the invalid value ''{0}'' according to the defined rules."), /** Not exactly one "XHE/Header/FromParty" element is present */ - INVALID_FROM_PARTY_COUNT ("invalid-from-party-count", - "Not exactly one ''FromParty'' element is present but {0}."), + INVALID_FROM_PARTY_COUNT ("invalid-from-party-count", "Not exactly one ''FromParty'' element is present but {0}."), - /** The "XHE/Header/FromParty/PartyIdentification/ID/schemaID" attribute has an invalid value */ + /** + * The "XHE/Header/FromParty/PartyIdentification/ID/schemaID" attribute has an + * invalid value + */ INVALID_FROM_PARTY_SCHEMA_ID ("invalid-from-party-schema-id", "The ''XHE/Header/FromParty/PartyIdentification/ID/schemaID'' attribute has the invalid value ''{0}''."), /** The "XHE/Header/FromParty/PartyIdentification/ID" has an invalid value */ - INVALID_FROM_PARTY_VALUE ("invalid-from-party-value", + INVALID_FROM_PARTY_VALUE ("invalid-from-party-value", "The ''XHE/Header/FromParty/PartyIdentification/ID'' has the invalid value ''{0}''."), - + /** Not exactly one "XHE/Header/ToParty" element is present */ - INVALID_TO_PARTY_COUNT ("invalid-to-party-count", - "Not exactly one ''ToParty'' element is present but {0}."), - + INVALID_TO_PARTY_COUNT ("invalid-to-party-count", "Not exactly one ''ToParty'' element is present but {0}."), + /** Not exactly one "XHE/Header/ToParty" element is present */ - INVALID_TO_PARTY_IDENTIFICATION_COUNT ("invalid-to-party-identification-count", + INVALID_TO_PARTY_IDENTIFICATION_COUNT ("invalid-to-party-identification-count", "Not exactly one ''ToParty/PartyIdentification'' element is present but {0}."), - /** The "XHE/Header/ToParty/PartyIdentification/ID/schemaID" attribute has an invalid value */ + /** + * The "XHE/Header/ToParty/PartyIdentification/ID/schemaID" attribute has an + * invalid value + */ INVALID_TO_PARTY_SCHEMA_ID ("invalid-to-party-schema-id", "The ''XHE/Header/ToParty/PartyIdentification/ID/schemaID'' attribute has the invalid value ''{0}''."), /** The "XHE/Header/FromParty/PartyIdentification/ID" has an invalid value */ - INVALID_TO_PARTY_VALUE ("invalid-from-party-value", + INVALID_TO_PARTY_VALUE ("invalid-from-party-value", "The ''XHE/Header/ToParty/PartyIdentification/ID'' has the invalid value ''{0}''."), - + /** The "XHE/Payloads/Payload/ID" has an invalid value */ - INVALID_PAYLOAD_ID_VALUE ("invalid-payload-id-value", + INVALID_PAYLOAD_ID_VALUE ("invalid-payload-id-value", "The ''XHE/Payloads/Payload/ID'' has the invalid value ''{0}''."), - + /** The "XHE/Payloads/Payload/ContentTypeCode/listID" has an invalid value */ - INVALID_CONTENT_TYPE_CODE_LIST_ID ("invalid-content-type-code-list-id", + INVALID_CONTENT_TYPE_CODE_LIST_ID ("invalid-content-type-code-list-id", "The ''XHE/Payloads/Payload/ContentTypeCode/listID'' has the invalid value ''{0}''."), - + /** The "XHE/Payloads/Payload/ContentTypeCode" has an invalid value */ - INVALID_CONTENT_TYPE_CODE_VALUE ("invalid-content-type-code-value", + INVALID_CONTENT_TYPE_CODE_VALUE ("invalid-content-type-code-value", "The ''XHE/Payloads/Payload/ContentTypeCode'' has the invalid value ''{0}''."), - - /** The "XHE/Payloads/Payload/InstanceEncryptionIndicator" has an invalid value */ - INVALID_INSTANCE_ENCRYPTION_INDICATOR_VALUE ("invalid-instance-encryption-indicator-value", + + /** + * The "XHE/Payloads/Payload/InstanceEncryptionIndicator" has an invalid value + */ + INVALID_INSTANCE_ENCRYPTION_INDICATOR_VALUE ("invalid-instance-encryption-indicator-value", "The ''XHE/Payloads/Payload/InstanceEncryptionIndicator'' has the invalid value ''{0}''."), - /** The "XHE/Payloads/Payload/InstanceEncryptionIndicator" has an invalid value */ - INSTANCE_ENCRYPTION_INDICATOR_MISSING ("instance-encryption-indicator-missing", + /** + * The "XHE/Payloads/Payload/InstanceEncryptionIndicator" has an invalid value + */ + INSTANCE_ENCRYPTION_INDICATOR_MISSING ("instance-encryption-indicator-missing", "The ''XHE/Payloads/Payload/InstanceEncryptionIndicator'' element is missing."), - + /** The main business message is invalid */ INVALID_BUSINESS_MESSAGE ("invalid-business-message", "The main business message is invalid according to the defined rules."), @@ -127,7 +134,6 @@ public enum EDBNAllianceXHEDocumentReadError implements IHasID /** * This is a fallback error code, in case the ID cannot be resolved to a * proper other error code. - * */ GENERIC_XHE_ERROR ("generic-xhe-error", "A generic error occurred."); @@ -178,7 +184,7 @@ public static EDBNAllianceXHEDocumentReadError getFromIDOrNull (@Nullable final @Nullable public static EDBNAllianceXHEDocumentReadError getFromIDOrDefault (@Nullable final String sID, - @Nullable final EDBNAllianceXHEDocumentReadError eDefault) + @Nullable final EDBNAllianceXHEDocumentReadError eDefault) { return EnumHelper.getFromIDOrDefault (EDBNAllianceXHEDocumentReadError.class, sID, eDefault); } diff --git a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/write/DBNAllianceXHEDocumentWriter.java b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/write/DBNAllianceXHEDocumentWriter.java index 3abc6443..5b682f78 100644 --- a/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/write/DBNAllianceXHEDocumentWriter.java +++ b/dbnalliance-xhe/src/main/java/com/helger/peppol/xhe/write/DBNAllianceXHEDocumentWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2024 Philip Helger + * Copyright (C) 2024 Philip Helger * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,10 @@ */ package com.helger.peppol.xhe.write; +import java.util.List; + +import javax.annotation.Nonnull; + import com.helger.commons.ValueEnforcer; import com.helger.peppol.xhe.CDBNAllianceXHE; import com.helger.peppol.xhe.DBNAlliancePayload; @@ -32,19 +36,17 @@ import com.helger.xhe.v10.cbc.XHE10DescriptionType; import com.helger.xhe.v10.cbc.XHE10IDType; import com.helger.xhe.v10.cbc.XHE10ProfileIDType; -import java.util.List; -import javax.annotation.Nonnull; /** * Convert a DBNAlliance XHE document to a regular XHE document * * @author Robinson Garcia */ -public class DBNAllianceXHEDocumentWriter { - +public class DBNAllianceXHEDocumentWriter +{ + /** - * Create a new {@link XHE} from the specified document - * data. + * Create a new {@link XHE10XHEType} from the specified document data. * * @param aData * The document data to be used. May not be null and @@ -62,7 +64,7 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED final XHE10XHEType aXHE = new XHE10XHEType (); aXHE.setXHEVersionID (CDBNAllianceXHE.XHE_VERSION_ID); - + // CustomizationID { final XHE10CustomizationIDType aCustomizationID = new XHE10CustomizationIDType (); @@ -70,16 +72,16 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED aCustomizationID.setValue (CDBNAllianceXHE.CUSTOMIZATION_ID); aXHE.setCustomizationID (aCustomizationID); } - + // ProfileID aXHE.setProfileID (CDBNAllianceXHE.PROFILE_ID); - + // Header data { final XHE10HeaderType aHeader = new XHE10HeaderType (); aHeader.setID (aData.getID ()); aHeader.setCreationDateTime (aData.getCreationDateTime ()); - + // From Party data { final XHE10PartyType aFromParty = new XHE10PartyType (); @@ -91,7 +93,7 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED aFromParty.addPartyIdentification (aPartyID); aHeader.setFromParty (aFromParty); } - + // To Party Data { final XHE10PartyType aToParty = new XHE10PartyType (); @@ -103,37 +105,37 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED aToParty.addPartyIdentification (aPartyID); aHeader.addToParty (aToParty); } - - aXHE.setHeader(aHeader); + + aXHE.setHeader (aHeader); } - + { final XHE10PayloadsType aPayloads = new XHE10PayloadsType (); - final List aDataPayloads = aData.getPayloads (); - int iID = 1; - for (DBNAlliancePayload aDataPayload : aDataPayloads) { - + final List aDataPayloads = aData.getPayloads (); + int nID = 1; + for (final DBNAlliancePayload aDataPayload : aDataPayloads) + { final XHE10PayloadType aPayload = new XHE10PayloadType (); - // payload IDs MUST be numbered sequen=ally star=ng with the number 1. - aPayload.setID (String.valueOf (iID++)); - aPayload.setInstanceEncryptionIndicator (aDataPayload.getInstanceEncryptionIndicator ()); + // payload IDs MUST be numbered sequentially starting with the number 1. + aPayload.setID (Integer.toString (nID++)); + aPayload.setInstanceEncryptionIndicator (aDataPayload.isInstanceEncryptionIndicator ()); aPayload.setInstanceEncryptionMethod (aDataPayload.getInstanceEncryptionMethod ()); - + // Description data { final XHE10DescriptionType aDescription = new XHE10DescriptionType (); aDescription.setValue (aDataPayload.getDescription ()); aPayload.addDescription (aDescription); } - + // Content Type data { final XHE10ContentTypeCodeType aContentTypeCode = new XHE10ContentTypeCodeType (); aContentTypeCode.setListID (aDataPayload.getContentTypeCodeListID ()); aContentTypeCode.setValue (aDataPayload.getContentTypeCodeValue ()); - aPayload.setContentTypeCode(aContentTypeCode); + aPayload.setContentTypeCode (aContentTypeCode); } - + // Customization ID data { final XHE10CustomizationIDType aCustomization = new XHE10CustomizationIDType (); @@ -141,7 +143,7 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED aCustomization.setValue (aDataPayload.getCustomizationIDValue ()); aPayload.setCustomizationID (aCustomization); } - + // Profile ID data { final XHE10ProfileIDType aProfile = new XHE10ProfileIDType (); @@ -149,13 +151,13 @@ public XHE10XHEType createExchangeHeaderEnvelope (@Nonnull final DBNAllianceXHED aProfile.setValue (aDataPayload.getProfileIDValue ()); aPayload.setProfileID (aProfile); } - + // Payload content data { final XHE10PayloadContentType aContent = new XHE10PayloadContentType (); - aContent.addContent(aDataPayload.getPayloadContentNoClone()); + aContent.addContent (aDataPayload.getPayloadContentNoClone ()); } - + aPayloads.addPayload (aPayload); } aXHE.setPayloads (aPayloads); diff --git a/pom.xml b/pom.xml index 6c5c530e..52b30c4e 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ 0.5.11 9.2.0 9.0.1 + 4.0.1 @@ -177,6 +178,11 @@ peppol-mlr ${project.version}
+ + com.helger.peppol + dbnalliance-xhe + ${project.version} + @@ -199,7 +205,6 @@ - dbnalliance-xhe peppol-id-datatypes peppol-id peppol-commons @@ -210,6 +215,7 @@ peppol-sml-client peppol-directory-businesscard peppol-mlr + dbnalliance-xhe