Repository: atlas
Updated Branches:
  refs/heads/master e4ffcf248 -> 6bacbe946


ATLAS-2673: Decode query string for DSL search

Signed-off-by: Madhan Neethiraj <mad...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/6bacbe94
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/6bacbe94
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/6bacbe94

Branch: refs/heads/master
Commit: 6bacbe946bbc5ca72118304770d5ad920695bd52
Parents: e4ffcf2
Author: nixonrodrigues <ni...@apache.org>
Authored: Fri May 11 16:00:51 2018 +0530
Committer: Madhan Neethiraj <mad...@apache.org>
Committed: Thu May 17 13:14:45 2018 -0700

----------------------------------------------------------------------
 .../java/org/apache/atlas/examples/QuickStartV2.java     |  5 +++++
 .../java/org/apache/atlas/web/rest/DiscoveryREST.java    |  3 +++
 .../main/java/org/apache/atlas/web/util/Servlets.java    | 11 +++++++++++
 3 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/6bacbe94/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java 
b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
index 0ca0ba7..8bd2aad 100755
--- a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
+++ b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
@@ -463,6 +463,9 @@ public class QuickStartV2 {
         return new String[]{
                 "from DB",
                 "DB",
+                "DB where name=%22Reporting%22",
+                "DB where name=%22encode_db_name%22",
+                "Table where name=%2522sales_fact%2522",
                 "DB where name=\"Reporting\"",
                 "DB where DB.name=\"Reporting\"",
                 "DB name = \"Reporting\"",
@@ -519,6 +522,8 @@ public class QuickStartV2 {
                         System.out.println("query [" + dslQuery + "] returned 
[" + fullTextResults.size() + "] rows.");
                     } else if (attribResult != null) {
                         System.out.println("query [" + dslQuery + "] returned 
[" + attribResult.getValues().size() + "] rows.");
+                    } else {
+                        System.out.println("query [" + dslQuery + "] returned 
[ 0 ] rows.");
                     }
                 } else {
                     System.out.println("query [" + dslQuery + "] failed, 
results:" + results);

http://git-wip-us.apache.org/repos/asf/atlas/blob/6bacbe94/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java 
b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
index ad37859..82d6f35 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
@@ -112,6 +112,9 @@ public class DiscoveryREST {
         AtlasPerfTracer perf = null;
 
         try {
+
+            query = Servlets.decodeQueryString(query);
+
             if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, 
"DiscoveryREST.searchUsingDSL(" + query + "," + typeName
                         + "," + classification + "," + limit + "," + offset + 
")");

http://git-wip-us.apache.org/repos/asf/atlas/blob/6bacbe94/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java 
b/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
index ec340cf..71eca2e 100755
--- a/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
+++ b/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
@@ -40,10 +40,12 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.springframework.web.util.UriUtils;
 
 /**
  * Utility functions for dealing with servlets.
@@ -211,4 +213,13 @@ public final class Servlets {
             throw new 
AtlasBaseException(AtlasErrorCode.INVALID_QUERY_PARAM_LENGTH, paramName);
         }
     }
+
+    public static String decodeQueryString(String query){
+        try {
+            return UriUtils.decode(query,"UTF-8");
+
+        } catch (UnsupportedEncodingException e){
+            return query;
+        }
+    }
 }

Reply via email to