Camel Olingo2解析URI?

时间:2016-09-16 21:00:31

标签: apache-camel odata olingo

我正在尝试使用top,format和filter queryParams运行Camel Olingo2路由到OData服务,但Olingo组件不编码params,因此它抛出URISyntaxException,如果我在调用之前编码params组件然后param将返回为无效,有没有办法使用Olingo2组件的过滤器参数?

示例:

路线示例

from("timer://camelpoll?period=120000")
    .id("PersonPoll")
    .log("CAMEL_POLLING_IN_PROGRESS")
    .setHeader("CamelOlingo2.$top", constant("5"))
    .setHeader("CamelOlingo2.$format", constant("json"))
    .setHeader("CamelOlingo2.$filter", constant("Timestamp gt datetime'2014-06-26T03:30:00.000'"))
    .to("olingo2://read/Persons");

错误日志

Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 131: https://<hostname>/Persons/?$top=5&$filter=Timestamp gt datetime'2014-06-26T03:30:00.000'&$format=json
    at java.net.URI.create(URI.java:852) ~[na:1.8.0_45]
    at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69) ~[httpclient-4.5.2.jar:4.5.2]
    at org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl.read(Olingo2AppImpl.java:190) ~[camel-olingo2-api-2.17.1.jar:2.17.1]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at org.apache.camel.util.component.ApiMethodHelper.invokeMethod(ApiMethodHelper.java:461) ~[camel-core-2.17.1.jar:2.17.1]
    ... 13 common frames omitted
Caused by: java.net.URISyntaxException: Illegal character in query at index 131: https://<hostname>/Persons/?$top=5&$filter=Timestamp gt datetime'2014-06-26T03:30:00.000'&$format=json
    at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_45]
    at java.net.URI$Parser.checkChars(URI.java:3021) ~[na:1.8.0_45]
    at java.net.URI$Parser.parseHierarchical(URI.java:3111) ~[na:1.8.0_45]
    at java.net.URI$Parser.parse(URI.java:3053) ~[na:1.8.0_45]
    at java.net.URI.<init>(URI.java:588) ~[na:1.8.0_45]
    at java.net.URI.create(URI.java:850) ~[na:1.8.0_45]
    ... 20 common frames omitted

1 个答案:

答案 0 :(得分:0)

好吧,看起来像olingo2组件有问题所以我必须创建一个自定义组件来实现这一点。