OxalisCommunity / oxalis

Oxalis - PEPPOL Access Point open source implementation - Core component
Other
129 stars 91 forks source link

Misleading DocumentTypeIdentifier conversion #327

Closed artjomsk closed 6 years ago

artjomsk commented 6 years ago

Hi! Getting following error with oxalis-4.0.0-RC3:

    java.lang.IllegalArgumentException: Unable to parse 'Invoice##urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol5a:ver2.0:extended:urn:www.difi.no:ehf:faktura:ver2.0::2.1' into PEPPOL Document Type Identifier

        no.difi.oxalis.sniffer.identifier.PeppolDocumentTypeId.valueOf(PeppolDocumentTypeId.java:87)
        no.difi.oxalis.sniffer.PeppolStandardBusinessHeader.toVefa(PeppolStandardBusinessHeader.java:199)
        no.difi.oxalis.outbound.transmission.TransmissionRequestBuilder.build(TransmissionRequestBuilder.java:189)
...

What I'm doing is building SBDH header manually like:

Header header = Header.newInstance()
                    .documentType(DocumentTypeIdentifier.parse("some correct value"))
...

I suppose scheme is missing during conversion from DocumentTypeIdentifier to PeppolDocumentTypeId

klakegg commented 6 years ago

DocumentTypeIdentifier.parse(String) expects the parsed identifier to contain scheme as presented in the SMP. To me it looks like the scheme is not provided, thus is it "magically" "fixed" by using the toString() method, however it breaks lookup in SMP.

Also building the Header object yourself should not be done. Header information should be provided by the sniffer itself or the provided SBDH. Any other way may result in transmissions not compatible with OpenPEPPOL.

artjomsk commented 6 years ago

Sorry, don't completely understand first paragraph.

DocumentTypeIdentifier.parse(String) expects the parsed identifier to contain scheme

Yes, so scheme is provided, but not used in transforming DocumentTypeIdentifier to PeppolDocumentTypeId. Maybe not related to the issue, but you can see in opposite conversion PeppolDocumentTypeId.toVefa() that toString() is used there:

    public DocumentTypeIdentifier toVefa() {
        return DocumentTypeIdentifier.of(toString());
    }

So why not to use toString() where I've updated in commit 78e146e ?

About building the Header object yourself. We want to have more control over sending process. It's clear, that Oxalis is made to work simply and correctly out of the box. Overriding values with TransmissionRequestBuilder still results in parsing document (possibly large) to create SBDH. But we have those values in system and don't need extra parsing.

artjomsk commented 6 years ago

Ok, now it's clear what did you mean by scheme :) Added prefix "cenbii-procid-ubl::" to DocumentTypeIdentifier.parse argument and the change is not needed.

Thank you!