From 745b40eecfe8dbefa3ec1bf6d2e97960f794fb47 Mon Sep 17 00:00:00 2001 From: aaron-kumar Date: Sat, 26 Aug 2023 23:19:27 +0530 Subject: [PATCH] Added support for Peppol SBDH v2.0.1 and eDEC Code Lists v8.6 --- .../sniffer/PeppolStandardBusinessHeader.java | 23 ++++++++++++++++++- .../TransmissionRequestBuilder.java | 13 +++++++---- .../TransmissionRequestBuilderTest.java | 5 +++- .../identifier/CountryIdentifierExample.java | 15 ++++++++++++ pom.xml | 2 +- 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 oxalis-test/src/main/java/network/oxalis/test/identifier/CountryIdentifierExample.java diff --git a/oxalis-legacy/oxalis-document-sniffer/src/main/java/network/oxalis/sniffer/PeppolStandardBusinessHeader.java b/oxalis-legacy/oxalis-document-sniffer/src/main/java/network/oxalis/sniffer/PeppolStandardBusinessHeader.java index c4e4f3ba5..349c05ea1 100644 --- a/oxalis-legacy/oxalis-document-sniffer/src/main/java/network/oxalis/sniffer/PeppolStandardBusinessHeader.java +++ b/oxalis-legacy/oxalis-document-sniffer/src/main/java/network/oxalis/sniffer/PeppolStandardBusinessHeader.java @@ -57,10 +57,16 @@ public class PeppolStandardBusinessHeader { private DocumentTypeIdentifier peppolDocumentTypeId; /** - * The business process this document is a part of + * The business process */ private ProcessIdentifier profileTypeIdentifier; + /** + * The C1 Country code + */ + private C1CountryIdentifier c1CountryIdentifier; + + /** * Represents the unique identity of the message envelope. It is not the same as the ID of the * business message (such as the Invoice number). Nor is it the same as the transmission Message ID @@ -97,6 +103,7 @@ public PeppolStandardBusinessHeader(Header header) { creationDateAndTime = header.getCreationTimestamp(); peppolDocumentTypeId = header.getDocumentType(); profileTypeIdentifier = header.getProcess(); + c1CountryIdentifier = header.getC1CountryIdentifier(); instanceId = new InstanceId(header.getIdentifier().getIdentifier()); } @@ -108,6 +115,7 @@ public PeppolStandardBusinessHeader(PeppolStandardBusinessHeader peppolStandardB senderId = peppolStandardBusinessHeader.getSenderId(); peppolDocumentTypeId = peppolStandardBusinessHeader.getDocumentTypeIdentifier(); profileTypeIdentifier = peppolStandardBusinessHeader.getProfileTypeIdentifier(); + c1CountryIdentifier = peppolStandardBusinessHeader.getC1CountryIdentifier(); instanceId = peppolStandardBusinessHeader.getInstanceId(); creationDateAndTime = peppolStandardBusinessHeader.getCreationDateAndTime(); } @@ -122,6 +130,8 @@ public boolean isComplete() { (senderId != null) && (peppolDocumentTypeId != null) && (profileTypeIdentifier != null) && + // TODO: C1 Country is Not mandatory yet, uncomment once C1 country code will become mandatory + //(c1CountryIdentifier != null) && (instanceId != null) && (creationDateAndTime != null)); } @@ -137,6 +147,8 @@ public List listMissingProperties() { if (senderId == null) mhf.add("senderId"); if (peppolDocumentTypeId == null) mhf.add("peppolDocumentTypeId"); if (profileTypeIdentifier == null) mhf.add("profileTypeIdentifier"); + // TODO: C1 Country is Not mandatory yet, uncomment once C1 country code will become mandatory + //if (c1CountryIdentifier == null) mhf.add("c1CountryIdentifier"); if (instanceId == null) mhf.add("messageId"); if (creationDateAndTime == null) mhf.add("creationDateAndTime"); return mhf; @@ -195,6 +207,14 @@ public ProcessIdentifier getProfileTypeIdentifier() { return profileTypeIdentifier; } + public C1CountryIdentifier getC1CountryIdentifier() { + return c1CountryIdentifier; + } + + public void setC1CountryIdentifier(C1CountryIdentifier c1CountryIdentifier) { + this.c1CountryIdentifier = c1CountryIdentifier; + } + public Header toVefa() { PeppolDocumentTypeId documentTypeId = PeppolDocumentTypeId.valueOf(peppolDocumentTypeId.getIdentifier()); @@ -203,6 +223,7 @@ public Header toVefa() { recipientId, profileTypeIdentifier, peppolDocumentTypeId, + c1CountryIdentifier, instanceId == null ? InstanceIdentifier.generateUUID() : instanceId.toVefa(), InstanceType.of( documentTypeId.getRootNameSpace(), diff --git a/oxalis-outbound/src/main/java/network/oxalis/outbound/transmission/TransmissionRequestBuilder.java b/oxalis-outbound/src/main/java/network/oxalis/outbound/transmission/TransmissionRequestBuilder.java index 42aee3483..14f73d3fa 100644 --- a/oxalis-outbound/src/main/java/network/oxalis/outbound/transmission/TransmissionRequestBuilder.java +++ b/oxalis-outbound/src/main/java/network/oxalis/outbound/transmission/TransmissionRequestBuilder.java @@ -39,10 +39,7 @@ import network.oxalis.sniffer.PeppolStandardBusinessHeader; import network.oxalis.sniffer.identifier.InstanceId; import network.oxalis.sniffer.sbdh.SbdhWrapper; -import network.oxalis.vefa.peppol.common.model.DocumentTypeIdentifier; -import network.oxalis.vefa.peppol.common.model.Endpoint; -import network.oxalis.vefa.peppol.common.model.ParticipantIdentifier; -import network.oxalis.vefa.peppol.common.model.ProcessIdentifier; +import network.oxalis.vefa.peppol.common.model.*; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -149,6 +146,11 @@ public TransmissionRequestBuilder processType(ProcessIdentifier processTypeId) { return this; } + public TransmissionRequestBuilder c1CountryIdentifier(C1CountryIdentifier c1CountryIdentifier) { + suppliedHeaderFields.setC1CountryIdentifier(c1CountryIdentifier); + return this; + } + public TransmissionRequestBuilder instanceId(InstanceId instanceId) { suppliedHeaderFields.setInstanceId(instanceId); return this; @@ -298,6 +300,9 @@ protected PeppolStandardBusinessHeader createEffectiveHeader(final PeppolStandar if (supplied.getProfileTypeIdentifier() != null) { mergedHeaders.setProfileTypeIdentifier(supplied.getProfileTypeIdentifier()); } + if (supplied.getC1CountryIdentifier() != null) { + mergedHeaders.setC1CountryIdentifier(supplied.getC1CountryIdentifier()); + } // If instanceId was supplied by caller, use it otherwise, create new if (supplied.getInstanceId() != null) { diff --git a/oxalis-outbound/src/test/java/network/oxalis/outbound/transmission/TransmissionRequestBuilderTest.java b/oxalis-outbound/src/test/java/network/oxalis/outbound/transmission/TransmissionRequestBuilderTest.java index c3d1f13a2..57119e2f4 100644 --- a/oxalis-outbound/src/test/java/network/oxalis/outbound/transmission/TransmissionRequestBuilderTest.java +++ b/oxalis-outbound/src/test/java/network/oxalis/outbound/transmission/TransmissionRequestBuilderTest.java @@ -24,6 +24,7 @@ import com.google.inject.Inject; import com.google.inject.name.Named; +import network.oxalis.test.identifier.CountryIdentifierExample; import network.oxalis.test.identifier.PeppolDocumentTypeIdAcronym; import network.oxalis.test.identifier.PeppolProcessTypeIdAcronym; import network.oxalis.test.identifier.WellKnownParticipant; @@ -186,11 +187,12 @@ public void testOverrideEndPoint() throws Exception { public void testOverrideOfAllValues() throws Exception { TransmissionIdentifier transmissionIdentifier = TransmissionIdentifier.of("messageid"); TransmissionRequest request = transmissionRequestBuilder - .payLoad(inputStreamWithSBDH) + .payLoad(inputStreamWithSBDH) .sender(WellKnownParticipant.DIFI_TEST) .receiver(WellKnownParticipant.U4_TEST) .documentType(PeppolDocumentTypeIdAcronym.ORDER.toVefa()) .processType(PeppolProcessTypeIdAcronym.ORDER_ONLY.toVefa()) + .c1CountryIdentifier(CountryIdentifierExample.BE) .build(); Header header = request.getHeader(); @@ -198,6 +200,7 @@ public void testOverrideOfAllValues() throws Exception { assertEquals(header.getReceiver(), WellKnownParticipant.U4_TEST); assertEquals(header.getDocumentType(), PeppolDocumentTypeIdAcronym.ORDER.toVefa()); assertEquals(header.getProcess(), PeppolProcessTypeIdAcronym.ORDER_ONLY.toVefa()); + assertEquals(header.getC1CountryIdentifier(), CountryIdentifierExample.BE); assertNotEquals(header.getIdentifier().getIdentifier(), transmissionIdentifier.getIdentifier(), "The SBDH instanceId should not be equal to the AS2 transmission identifier"); } diff --git a/oxalis-test/src/main/java/network/oxalis/test/identifier/CountryIdentifierExample.java b/oxalis-test/src/main/java/network/oxalis/test/identifier/CountryIdentifierExample.java new file mode 100644 index 000000000..44bac4c0c --- /dev/null +++ b/oxalis-test/src/main/java/network/oxalis/test/identifier/CountryIdentifierExample.java @@ -0,0 +1,15 @@ +package network.oxalis.test.identifier; + +import network.oxalis.vefa.peppol.common.model.C1CountryIdentifier; + +public class CountryIdentifierExample { + // The value of the country code MUST be provided according to ISO-3166-1 in the Alpha-2 notation (e.g. “BE” representing Belgium). + public static final C1CountryIdentifier AU = C1CountryIdentifier.of("AU"); + public static final C1CountryIdentifier BE = C1CountryIdentifier.of("BE"); + public static final C1CountryIdentifier IN = C1CountryIdentifier.of("IN"); + public static final C1CountryIdentifier JP = C1CountryIdentifier.of("JP"); + public static final C1CountryIdentifier NO = C1CountryIdentifier.of("NO"); + public static final C1CountryIdentifier SE = C1CountryIdentifier.of("SE"); + public static final C1CountryIdentifier SG = C1CountryIdentifier.of("SG"); + +} diff --git a/pom.xml b/pom.xml index 7676b40ce..803c223b5 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ 1 2.9.0 1.70 - 3.1.0 + 3.2.0 4.0.1 1.6.7 1.2.2