2

I'm using camel-olingo2 component for query SAP SuccessFactors on ODataV2 endpoints. The route is:

        from("direct:start")
            .to(olingoEndpoint)
            .process(paging)
            .loopDoWhile(simple("\${header.CamelOlingo2.\$skiptoken} != null"))
            .to(olingoEndpoint)
            .process(paging)
            .end()

Paging processor is:

    Processor paging = new Processor() {
    @Override
    void process(Exchange g) throws Exception {
        ODataDeltaFeed feed = g.in.getMandatoryBody(ODataDeltaFeed)
        if (consumer) feed.getEntries().forEach(consumer)
        String next = feed.getFeedMetadata().getNextLink()
        if (next) {
            List<NameValuePair> lst = URLEncodedUtils.parse(new URI(next), StandardCharsets.UTF_8)
            NameValuePair skiptoken = lst.find { it.name == "\$skiptoken" }
            g.out.headers."CamelOlingo2.\$skiptoken" = skiptoken.value
        } else {
            g.out.headers.remove("CamelOlingo2.\$skiptoken")
        }
    }
}

Everything is OK with most of entities but there are fields for several entities with wrong nullability or data length so I got:

Caused by: org.apache.olingo.odata2.api.edm.EdmSimpleTypeException: The metadata constraints '[Nullable=true, MaxLength=16]' do not match the literal 'Bor.Kralja Petra I.16'.
at org.apache.olingo.odata2.core.edm.EdmString.internalValueOfString(EdmString.java:62)
at org.apache.olingo.odata2.core.edm.AbstractSimpleType.valueOfString(AbstractSimpleType.java:91)
at org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readSimpleProperty(JsonPropertyConsumer.java:236)
at org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readPropertyValue(JsonPropertyConsumer.java:169)

In documentation for Olingo2 camel component I cannot find the way to disable this checking or other walkaround. Can you suggest me the good way? Please do not recommend server-side data changes, ex metadata modifiyng, it's out of scope for this task.

I have plan B: to use HTTPS requests with JSON parsing, it's quite simple but little boring.

Iliya Kuznetsov
  • 310
  • 3
  • 15
  • finally I avoided it changing metadata on server side – Iliya Kuznetsov Aug 06 '19 at 08:01
  • How did you solve it? Thx! – dotchuZ Aug 22 '19 at 17:49
  • 1
    It was really https://apps.support.sap.com/sap/support/knowledge/public/en/2294037 case with timezone. Invalid data were imported so in timezone field was wrong value. – Iliya Kuznetsov Aug 23 '19 at 06:22
  • ah, timezone is always one of the biggest issues with SFSF + coding ... they have some construct that the timezone is always the one of the server, and if you have a server in another timezone you got to convert. Thanks for the hint. – dotchuZ Aug 23 '19 at 06:31

0 Answers0