Skip to content

Commit

Permalink
Added support for Peppol SBDH v2.0.1 and eDEC Code Lists v8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-kumar committed Aug 26, 2023
1 parent fcedae7 commit 745b40e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}

Expand All @@ -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();
}
Expand All @@ -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));
}
Expand All @@ -137,6 +147,8 @@ public List<String> 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;
Expand Down Expand Up @@ -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());

Expand All @@ -203,6 +223,7 @@ public Header toVefa() {
recipientId,
profileTypeIdentifier,
peppolDocumentTypeId,
c1CountryIdentifier,
instanceId == null ? InstanceIdentifier.generateUUID() : instanceId.toVefa(),
InstanceType.of(
documentTypeId.getRootNameSpace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,18 +187,20 @@ 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();
assertEquals(header.getSender(), WellKnownParticipant.DIFI_TEST);
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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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");

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<javax.inject.version>1</javax.inject.version>
<commons-dbcp2.version>2.9.0</commons-dbcp2.version>
<bouncycastle.version>1.70</bouncycastle.version>
<vefa.peppol.version>3.1.0</vefa.peppol.version>
<vefa.peppol.version>3.2.0</vefa.peppol.version>
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
<jakarta.mail.version>1.6.7</jakarta.mail.version>
<jakarta.activation.version>1.2.2</jakarta.activation.version>
Expand Down

0 comments on commit 745b40e

Please sign in to comment.