OxalisCommunity / Oxalis-AS4

PEPPOL AS4 pMode plugin for Oxalis
32 stars 25 forks source link

C1CountryIdentifier (COUNTRY_C1) not set in As4PayloadHeader #217

Closed seciq closed 11 months ago

seciq commented 11 months ago

I do have a StatisticsService extension for collecting the data required for TSR/EUSR. In the 6.0.0 version I've managed to succesfuly collect the COUNTRY_C1 from the InboundMetadata using header.getArgument("COUNTRY_C1").

After upgrading to Oxalis 6.1.1 the COUNTRY_C1 scope is not available anymore in the header. I've switched from header.getArgument("COUNTRY_C1") to header.getC1CountryIdentifier() but the value returned is null.

I do suspect the As4PayloadHeader wrapper is missing getter and setter for the c1CountryIdentifier and therefore InboundMetadata.getHeader().getC1CountryIdentifier() is always null.

More Info

The Header object is wrapped in an As4PayloadHeader and, as of 06.10.2023, the c1CountryIdentifier getters and setters are not implemented by this class causing the COUNTRY_C1 to be null. The header.getArgument("COUNTRY_C1") will also be null (not set) because the SbdhReader in vefa-peppol will not set the argument (since it was already added as c1CountryIdentifier).

Refs:

seciq commented 11 months ago

A possible workaround is:

@Override
public void persist(InboundMetadata inboundMetadata) {
    final Header header = inboundMetadata.getHeader();

    C1CountryIdentifier senderCountry = header.getC1CountryIdentifier();

    if (senderCountry == null && header instanceof As4PayloadHeader) {
        final Header wrappedHeader = ((As4PayloadHeader)header).getHeader();
        senderCountry = wrappedHeader.getC1CountryIdentifier();
    }

    // ...     
}
seciq commented 11 months ago

I've submitted a pull-request with the required changes but I haven't assigned any reviewers as I do not have permissions. @aaron-kumar Please review the code changes.

dladlk commented 11 months ago

The reason of this mistake lays in the fact that As4PayloadHeader extends vefa Header, but overrides all its getters with delegate calls. So missing overriding of the new method getC1CountryIdentifier(), introduced in 3.2.0, with a call to a delegate means - method is present but always returns null... The fix introduced by @seciq looks correct, also I confirm the workaround - it is possible to get C1 country via internal original 'Header' instance inside As4PayloadHeader - instead of as4PayloadHeader.getC1CountryIdentifier() do as4PayloadHeader.getHeader().getC1CountryIdentifier().

@aaron-kumar it looks like a critical issue to fix asap...

aaron-kumar commented 11 months ago

Thanks for your contribution @seciq . This fix will be part of upcoming Oxalis/Oxalis-AS4 release (tentative schedule on 15.10.2023)

seciq commented 11 months ago

Thanks for the quick feedback. Looking forward for the new release.

aaron-kumar commented 11 months ago

Released as part of "Oxalis-AS4 6.2.0 Release"