My goodness... It took me almost 10 minutes to find that utility class you suggested, but at last I found it (I hope I catched the correct one :-))
http://camel.465427.n5.nabble.com/svn-commit-r1384447-camel-trunk-components-camel-restlet-src-main-java-org-apache-camel-component-rea-td5719314.html Babak Claus Ibsen-2 wrote > > In camel-core in util, we have a string helper / object helper or what > ever the class is named. > There is a method to assemble a comma separated list of a String, > which handles the "last comma issue". > > > On Wed, Sep 12, 2012 at 11:01 PM, <bvahdat@> wrote: >> Author: bvahdat >> Date: Wed Sep 12 21:01:07 2012 >> New Revision: 1384122 >> >> URL: http://svn.apache.org/viewvc?rev=1384122&view=rev >> Log: >> CAMEL-5600: Removed the last comma being put inside the URI. >> >> Added: >> >> camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java >> >> (with props) >> Modified: >> >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java >> >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java >> >> Modified: >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java?rev=1384122&r1=1384121&r2=1384122&view=diff >> ============================================================================== >> --- >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java >> (original) >> +++ >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java >> Wed Sep 12 21:01:07 2012 >> @@ -66,7 +66,7 @@ public class RestletComponent extends He >> private Boolean useForwardedForHeader; >> >> public RestletComponent() { >> - this.component = new Component(); >> + this(new Component()); >> } >> >> public RestletComponent(Component component) { >> @@ -76,9 +76,7 @@ public class RestletComponent extends He >> } >> >> @Override >> - @SuppressWarnings({"unchecked", "rawtypes"}) >> - protected Endpoint createEndpoint(String uri, String remaining, Map >> parameters) throws Exception { >> - >> + protected Endpoint createEndpoint(String uri, String remaining, >> Map<String, Object> parameters) throws Exception { >> RestletEndpoint result = new RestletEndpoint(this, remaining); >> setEndpointHeaderFilterStrategy(result); >> setProperties(result, parameters); >> >> Modified: >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java?rev=1384122&r1=1384121&r2=1384122&view=diff >> ============================================================================== >> --- >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java >> (original) >> +++ >> camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java >> Wed Sep 12 21:01:07 2012 >> @@ -41,8 +41,8 @@ public class RestletEndpoint extends Def >> >> private Method restletMethod = Method.GET; >> >> - // Optional and for consumer only. This allows a single route to >> service multiple >> - // methods. If it is non-null, restletMethod is ignored. >> + // Optional and for consumer only. This allows a single route to >> service multiple methods. >> + // If it is non-null then restletMethod is ignored. >> private Method[] restletMethods; >> >> private String protocol = DEFAULT_PROTOCOL; >> @@ -50,8 +50,8 @@ public class RestletEndpoint extends Def >> private int port = DEFAULT_PORT; >> private String uriPattern; >> >> - // Optional and for consumer only. This allows a single route to >> service multiple >> - // URI patterns. The URI pattern defined in the endpoint will still >> be honored. >> + // Optional and for consumer only. This allows a single route to >> service multiple URI patterns. >> + // The URI pattern defined in the endpoint will still be honored. >> private List<String> restletUriPatterns; >> >> private Map<String, String> restletRealm; >> @@ -191,17 +191,24 @@ public class RestletEndpoint extends Def >> String endpointUri = getEndpointUri(); >> StringBuilder methods = new StringBuilder(); >> if (getRestletMethods() != null && getRestletMethods().length > >> 0) { >> + // list the method(s) as a comma seperated list >> + boolean first = true; >> for (Method method : getRestletMethods()) { >> - methods = methods.append(method.getName()).append(','); >> + if (first) { >> + first = false; >> + } else { >> + methods.append(','); >> + } >> + methods.append(method.getName()); >> } >> } else { >> - Method method = getRestletMethod(); >> - methods = methods.append(method.getName()); >> - } >> - if (methods != null) { >> - endpointUri = endpointUri + "?restletMethods=" + >> methods.toString(); >> - setEndpointUri(endpointUri); >> + // otherwise consider the single method we own >> + methods.append(getRestletMethod()); >> } >> + >> + // update the uri >> + endpointUri = endpointUri + "?restletMethods=" + methods; >> + setEndpointUri(endpointUri); >> } >> >> @Override >> >> Added: >> camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java?rev=1384122&view=auto >> ============================================================================== >> --- >> camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java >> (added) >> +++ >> camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java >> Wed Sep 12 21:01:07 2012 >> @@ -0,0 +1,59 @@ >> +/** >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> + * (the "License"); you may not use this file except in compliance with >> + * the License. You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> +package org.apache.camel.component.restlet; >> + >> +import org.apache.camel.Endpoint; >> +import org.apache.camel.test.junit4.CamelTestSupport; >> + >> +import org.junit.Test; >> + >> +/** >> + * @version >> + */ >> +public class RestletEndpointUpdateEndpointUriTest extends >> CamelTestSupport { >> + >> + @Override >> + public boolean isUseRouteBuilder() { >> + return false; >> + } >> + >> + @Test >> + public void testUpdateEndpointUri() throws Exception { >> + RestletComponent component = context.getComponent("restlet", >> RestletComponent.class); >> + >> + Endpoint endpoint = >> component.createEndpoint("restlet:http://localhost:9090/users/user"); >> + assertEquals("The restlet endpoint didn't update it's URI >> properly", "http://localhost:9090/users/user?restletMethods=GET", >> + endpoint.getEndpointUri()); >> + >> + endpoint = >> component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=post"); >> + assertEquals("The restlet endpoint didn't update it's URI >> properly", "http://localhost:9090/users/user?restletMethods=POST", >> + endpoint.getEndpointUri()); >> + >> + endpoint = >> component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=lock,head"); >> + assertEquals("The restlet endpoint didn't update it's URI >> properly", "http://localhost:9090/users/user?restletMethods=LOCK,HEAD", >> + endpoint.getEndpointUri()); >> + >> + endpoint = >> component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=proppatch,mkcol,propfind"); >> + assertEquals("The restlet endpoint didn't update it's URI >> properly", >> "http://localhost:9090/users/user?restletMethods=PROPPATCH,MKCOL,PROPFIND", >> + endpoint.getEndpointUri()); >> + >> + endpoint = >> component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=delete,copy,options,connect"); >> + assertEquals("The restlet endpoint didn't update it's URI >> properly", >> "http://localhost:9090/users/user?restletMethods=DELETE,COPY,OPTIONS,CONNECT", >> + endpoint.getEndpointUri()); >> + } >> + >> +} >> \ No newline at end of file >> >> Propchange: >> camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cibsen@ > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > -- View this message in context: http://camel.465427.n5.nabble.com/Re-svn-commit-r1384122-in-camel-trunk-components-camel-restlet-src-main-java-org-apache-camel-compon-tp5719226p5719317.html Sent from the Camel Development mailing list archive at Nabble.com.