camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] branch camel-2.20.x updated: CAMEL-12097- handle if both path and query params set and supress with the value in the path
Date Wed, 03 Jan 2018 13:36:03 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.20.x by this push:
     new b0ed33d  CAMEL-12097- handle if both path and query params set and supress with the
value in the path
b0ed33d is described below

commit b0ed33d049368510b0901d57ef046d2edefd5051
Author: onders86 <ondersezgin@gmail.com>
AuthorDate: Tue Jan 2 18:12:44 2018 +0300

    CAMEL-12097- handle if both path and query params set and supress with the value in the
path
---
 .../java/org/apache/camel/component/restlet/RestletProducer.java | 9 +++++----
 .../org/apache/camel/component/restlet/RestletProducerTest.java  | 8 ++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
index 47c0293..b4c3b25 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
@@ -211,10 +211,6 @@ public class RestletProducer extends DefaultAsyncProducer {
         if (uri == null) {
             uri = endpoint.getProtocol() + "://" + endpoint.getHost() + ":" + endpoint.getPort()
+ endpoint.getUriPattern();
         }
-        // include any query parameters if needed
-        if (endpoint.getQueryParameters() != null) {
-            uri = URISupport.appendParametersToURI(uri, endpoint.getQueryParameters());
-        }
 
         // substitute { } placeholders in uri and use mandatory headers
         LOG.trace("Substituting '{value}' placeholders in uri: {}", uri);
@@ -235,6 +231,11 @@ public class RestletProducer extends DefaultAsyncProducer {
             // we replaced uri so reset and go again
             matcher.reset(uri);
         }
+        
+        // include any query parameters if needed
+        if (endpoint.getQueryParameters() != null) {
+            uri = URISupport.appendParametersToURI(uri, endpoint.getQueryParameters());
+        }
 
         // rest producer may provide an override query string to be used which we should
discard if using (hence the remove)
         String query = (String) exchange.getIn().removeHeader(Exchange.REST_HTTP_QUERY);
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
index 34ccd05..f2e6828 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
@@ -33,6 +33,12 @@ public class RestletProducerTest extends RestletTestSupport {
     }
     
     @Test
+    public void testRestletProducerGetWithPathQueryParams() throws Exception {
+        String out = template.requestBodyAndHeader("direct:startWithPathQueryParams", null,
"id", 123, String.class);
+        assertEquals("1235;Donald Duck", out);
+    }
+    
+    @Test
     public void testRestletProducerDelete() throws Exception {
         String out = template.requestBodyAndHeader("direct:delete", null, "id", 123, String.class);
         assertEquals("123;Donald Duck", out);
@@ -45,6 +51,8 @@ public class RestletProducerTest extends RestletTestSupport {
             public void configure() throws Exception {
                 from("direct:start").to("restlet:http://localhost:" + portNum + "/users/{id}/basic").to("log:reply");
                 
+                from("direct:startWithPathQueryParams").to("restlet:http://localhost:" +
portNum + "/users/{id}/basic?id=1235").to("log:reply");
+                
                 from("direct:delete").to("restlet:http://localhost:" + portNum + "/users/{id}/basic?restletMethod=DELETE");
 
                 from("restlet:http://localhost:" + portNum + "/users/{id}/basic?restletMethods=GET,DELETE")

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <commits@camel.apache.org>'].

Mime
View raw message