camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arunodhaya80 <t...@arunma.com>
Subject Re: JAX-RS and Camel - Except 1st QueryParameter all others are null
Date Fri, 01 Nov 2013 14:28:12 GMT
Thanks a lot for helping out and the heads-up. 

Yes, you are right.  I could get the query portion alone using: 

String query = exchange.getIn().getHeader(Exchange.HTTP_QUERY,
String.class);

Taking up from your hint, I am doing the following and my flow looks
complete : 

***Interface ***
    @GET
    @Path("search")
    @Produces(MediaType.APPLICATION_JSON)
    public String searchGet();


***Implementation - Target method***

public SearchResult<WikiSearchHit> wikiGet(Exchange exchange){
        String q = exchange.getIn().getHeader("q", String.class);
        String size = exchange.getIn().getHeader("size", String.class);
        String start = exchange.getIn().getHeader("start", String.class);


***Router***
public class RestToBeanRouter extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        from("cxfrs://bean://rsServer?bindingStyle=SimpleConsumer")
                .process(new ParameterProcessor())
                .removeHeaders("CamelHttp*")
                .multicast()
                .parallelProcessing()
                .aggregationStrategy(new CoreSearchResponseAggregator())
                .beanRef("searchRestServiceImpl", "wikiGet")
                ....
                .end()
                .marshal().json(JsonLibrary.Jackson);
        //.to("log://camelLogger?level=TRACE");

    }


    class ParameterProcessor implements Processor {
        @Override
        public void process(Exchange exchange) throws Exception {

            Map<String, String> stringStringMap =
convertQueryStringAsMap(exchange.getIn().getHeader(Exchange.HTTP_QUERY,
String.class));

            //System.out.println("stringStringMap = " + stringStringMap);

            for (Map.Entry<String, String> eachParamEntry :
stringStringMap.entrySet()) {
                exchange.getIn().setHeader(eachParamEntry.getKey(),
eachParamEntry.getValue());
            }
        }


        private Map<String,String> convertQueryStringAsMap(String
queryString){

            return
Splitter.on("&").omitEmptyStrings().trimResults().withKeyValueSeparator("=").split(queryString);

        }

    }
}


Thanks a ton !!!





--
View this message in context: http://camel.465427.n5.nabble.com/JAX-RS-and-Camel-Except-1st-QueryParameter-all-others-are-null-tp5742470p5742502.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message