You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/12/04 07:59:45 UTC

[camel] branch master updated: CAMEL-12057: Camel-Olingo2 - Fixed missing encoding for query params

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 46b30b3  CAMEL-12057: Camel-Olingo2 - Fixed missing encoding for query params
46b30b3 is described below

commit 46b30b33b30d25c5b156a45acf2e7ebb3e6c0deb
Author: Przemek Kubicki <pr...@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" <co...@camel.apache.org>'].