I have this Json:
{"request": {"cc": "000120000111SS000222M" }}
and this blueprint:
<route id="SGPIF-bonifico-dynamic-jetty">
<from uri="jetty:http://0.0.0.0:9100/ifom/esterno/bonifico/dynamic?matchOnUriPrefix=true"/>
<choice>
<when>
<jsonpath suppressExceptions="true">request.cc=~'0000111'</jsonpath>
<log message="Json choice equals "/>
<log message="SGPIF-bonifico-dynamic-jetty header: ${headers}"/>
<to uri="log:SGPIF-bonifico-dynamic-jetty" />
<wireTap uri="direct:requestEvent"/>
<to uri="jetty:http://127.0.0.1:8080/om/esterno/bonifico/dynamic?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
<log message="SGPIF-bonifico-dynamic-jetty-done header: ${headers}"/>
<wireTap uri="direct:responseEvent"/>
<to uri="log:SGPIF-bonifico-dynamic-jetty-done" />
</when>
<otherwise>
<log message="Else choice"/>
<log message="SGPIF-bonifico-dynamic-jetty header: ${headers}"/>
<to uri="log:SGPIF-bonifico-dynamic-jetty" />
<wireTap uri="direct:requestEvent"/>
<to uri="jetty:http://127.0.0.1:8080/ifom/esterno/bonifico/dynamic?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
<log message="SGPIF-bonifico-dynamic-jetty-done header: ${headers}"/>
<wireTap uri="direct:responseEvent"/>
<to uri="log:SGPIF-bonifico-dynamic-jetty-done" />
</otherwise>
</choice>
</route>
In this case I'm filtering if this value 0000111 exists in json. Can I filter by position? I would like to do a substring on this 000120000111SS000222M. Is there any way to do this?
Ok it work's fine with contains.But i need something like this:
setHeader headerName="JsonValue">
<jsonpath>$.request.cc</jsonpath>
</setHeader>
<bean ref="parser" method="doSomething"/>
<choice>
<when>
<simple>${header.JsonValue} == '0000111'</simple>
And trying to do something like this:
public void doSomething(@Header("JsonValue") String jsonValue, @Body String body) {
jsonValue += jsonValue.substring(5,12);
}
What if you put the value first in a header and then evaluate the headers value with simple language? see below
<setHeader headerName="CamelRequestCc">
<jsonpath>$.request.cc</jsonpath>
</setHeader>
<choice>
<when>
<simple>${header.CamelRequestCc} contains '0000111'</simple>
<log message="Json choice equals "/>
...