camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] branch camel-2.20.x updated: CAMEL-12057: Camel-Olingo2 - Fixed missing encoding for query params
Date Mon, 04 Dec 2017 08:11:48 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino 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 0f5d436  CAMEL-12057: Camel-Olingo2 - Fixed missing encoding for query params
0f5d436 is described below

commit 0f5d436b88c155e6d7ba3c761669143fa5e15b81
Author: Przemek Kubicki <przemek.kubicki@gmail.com>
AuthorDate: Fri Dec 1 21:14:35 2017 +0100

    CAMEL-12057: Camel-Olingo2 - Fixed missing encoding for query params
---
 .../camel/component/olingo2/api/impl/Olingo2AppImpl.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
index f4423b7..f1198a0 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLEncoder;
 import java.nio.charset.Charset;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.ArrayList;
@@ -221,7 +222,7 @@ public final class Olingo2AppImpl implements Olingo2App {
 
         final UriInfoWithType uriInfo = parseUri(edm, resourcePath, queryParams);
 
-        execute(new HttpGet(createUri(resourcePath, queryParams)), getResourceContentType(uriInfo),
+        execute(new HttpGet(createUri(resourcePath, encodeQueryParams(queryParams))), getResourceContentType(uriInfo),
             endpointHttpHeaders, new AbstractFutureCallback<T>(responseHandler) {
 
                 @Override
@@ -242,7 +243,7 @@ public final class Olingo2AppImpl implements Olingo2App {
 
         final UriInfoWithType uriInfo = parseUri(edm, resourcePath, queryParams);
 
-        execute(new HttpGet(createUri(resourcePath, queryParams)), getResourceContentType(uriInfo),
+        execute(new HttpGet(createUri(resourcePath, encodeQueryParams(queryParams))), getResourceContentType(uriInfo),
             endpointHttpHeaders, new AbstractFutureCallback<InputStream>(responseHandler)
{
 
                 @Override
@@ -255,6 +256,17 @@ public final class Olingo2AppImpl implements Olingo2App {
             });
     }
 
+    private Map<String, String> encodeQueryParams(Map<String, String> queryParams)
{
+        Map<String, String> encodedQueryParams = queryParams;
+        if (queryParams != null) {
+            encodedQueryParams = new HashMap<String, String>(queryParams.size());
+            for (Map.Entry<String, String> entry : queryParams.entrySet()) {
+                encodedQueryParams.put(entry.getKey(), URLEncoder.encode(entry.getValue()));
+            }
+        }
+        return encodedQueryParams;
+    }
+
     private ContentType getResourceContentType(UriInfoWithType uriInfo) {
         ContentType resourceContentType;
         switch (uriInfo.getUriType()) {

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

Mime
View raw message