Hi Just skip sending to the original endpoint and use a producer template to send to the uri you create yourself. Just remove the filename parameter.
You can use reg exp or String concat stuff for that. Or Camel has some API for URI in the util package. That makes it easier to construct the uri without that parameter. On Wed, Sep 29, 2010 at 1:17 PM, Marco Crivellaro <[email protected]> wrote: > > Using interceptSendToEndpoint I've tried setting the header > Exchange.INTERCEPTED_ENDPOINT > to the new endpoint URI (without the fileName) and setting the filename as > Exchange.FILE_NAME. > > However the enpoint parameters being used remain the original one. > > this is the my interceptSendToEndpoint: > > > > interceptSendToEndpoint("(ftp|sftp|ftps):.*").process( > new Processor() { > public void process(Exchange exchange) throws Exception { > Logger logger = Logger.getLogger("Interceptor"); > try > { > String interceptedEndpoint = > exchange.getIn().getHeader(Exchange.INTERCEPTED_ENDPOINT, String.class); > logger.info("Intercepted endpoint: " + interceptedEndpoint); > URI endpointURI = new URI(interceptedEndpoint); > String query = endpointURI.getQuery(); > > Map paramsMap = new HashMap<String,String>(); > String params[] = query.split("&"); > > for (String param : params) { > String temp[] = param.split("="); > paramsMap.put(temp[0], temp[1]); > } > > if(paramsMap.containsKey("fileName")) > { > String fileName = (String) paramsMap.get("fileName"); > logger.debug("fileName:" + fileName); > > > exchange.getIn().setHeader(Exchange.FILE_NAME, fileName); > //TODO: remove the hack > exchange.getIn().setHeader(Exchange.FILE_NAME, "test.xml"); > paramsMap.remove("fileName"); > > StringBuilder amendedQuery = new StringBuilder(); > for(Object eachKey : paramsMap.keySet()) > { > if(amendedQuery.length() > 0) > { > amendedQuery.append("&"); > } > amendedQuery.append(eachKey.toString()); > amendedQuery.append("="); > amendedQuery.append(paramsMap.get(eachKey).toString()); > } > > logger.debug("new querystring:" + amendedQuery.toString()); > > URI amendedEndpointURI = new URI(endpointURI.getScheme(), > endpointURI.getUserInfo(), > endpointURI.getHost(), > endpointURI.getPort(), > endpointURI.getPath(), > amendedQuery.toString(), > endpointURI.getFragment()); > > interceptedEndpoint = amendedEndpointURI.toString(); > logger.info("New endpoint: " + interceptedEndpoint); > exchange.getIn().setHeader(Exchange.INTERCEPTED_ENDPOINT, > interceptedEndpoint); > > } > else > { > logger.error("Cannot find parameter fileName."); > } > } > catch(Exception anException) > { > logger.error("Exception occurred:" + anException); > } > } > } > ); > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/FTP-creating-connections-for-every-file-name-in-the-uri-tp478938p2999929.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
