Repository: atlas
Updated Branches:
  refs/heads/master 6d8c50cca -> 2c84d7029


ATLAS-2062: Add flag to disable v1 gremlin search API using atlas-application 
property

(cherry picked from commit caf89a3098d3187514a8412294b0d84dec68b097)


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

Branch: refs/heads/master
Commit: 2c84d7029808c090489b7a8cecdf691ffed71a93
Parents: 6d8c50c
Author: Sarath Subramanian <ssubraman...@hortonworks.com>
Authored: Fri Aug 18 16:51:16 2017 -0700
Committer: Sarath Subramanian <ssubraman...@hortonworks.com>
Committed: Fri Aug 18 16:51:50 2017 -0700

----------------------------------------------------------------------
 distro/src/conf/atlas-application.properties         |  5 +++++
 .../web/resources/MetadataDiscoveryResource.java     | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/2c84d702/distro/src/conf/atlas-application.properties
----------------------------------------------------------------------
diff --git a/distro/src/conf/atlas-application.properties 
b/distro/src/conf/atlas-application.properties
index 29a4cc1..585a579 100755
--- a/distro/src/conf/atlas-application.properties
+++ b/distro/src/conf/atlas-application.properties
@@ -252,6 +252,11 @@ atlas.metric.query.cache.ttlInSecs=900
 #Set to false to disable full text search.
 #atlas.search.fulltext.enable=true
 
+#########  Gremlin Search Configuration  #########
+
+#Set to false to disable gremlin search.
+atlas.search.gremlin.enable=false
+
 
 ########## Add http headers ###########
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/2c84d702/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
 
b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
index d29c8da..d7c66d3 100755
--- 
a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
+++ 
b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
@@ -28,6 +28,7 @@ import org.apache.atlas.query.QueryParams;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.utils.ParamChecker;
 import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.configuration.Configuration;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -66,6 +67,10 @@ public class MetadataDiscoveryResource {
 
     private final DiscoveryService discoveryService;
 
+    private final  boolean       gremlinSearchEnabled;
+    private static Configuration applicationProperties          = null;
+    private static final String  ENABLE_GREMLIN_SEARCH_PROPERTY = 
"atlas.search.gremlin.enable";
+
     /**
      * Created by the Guice ServletModule and injected with the
      * configured DiscoveryService.
@@ -73,8 +78,10 @@ public class MetadataDiscoveryResource {
      * @param discoveryService metadata service handle
      */
     @Inject
-    public MetadataDiscoveryResource(DiscoveryService discoveryService) {
-        this.discoveryService = discoveryService;
+    public MetadataDiscoveryResource(DiscoveryService discoveryService, 
Configuration configuration) {
+        this.discoveryService  = discoveryService;
+        applicationProperties  = configuration;
+        gremlinSearchEnabled   = applicationProperties != null && 
applicationProperties.getBoolean(ENABLE_GREMLIN_SEARCH_PROPERTY, false);
     }
 
     /**
@@ -212,6 +219,10 @@ public class MetadataDiscoveryResource {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, 
"MetadataDiscoveryResource.searchUsingGremlinQuery(" + gremlinQuery + ")");
             }
 
+            if (!gremlinSearchEnabled) {
+                throw new DiscoveryException("Gremlin search is not enabled.");
+            }
+
             gremlinQuery = ParamChecker.notEmpty(gremlinQuery, "gremlinQuery 
cannot be null or empty");
             final List<Map<String, String>> results = 
discoveryService.searchByGremlin(gremlinQuery);
 

Reply via email to