Commit 2c84d702 by Sarath Subramanian

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

(cherry picked from commit caf89a3098d3187514a8412294b0d84dec68b097)
parent 6d8c50cc
......@@ -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 ###########
......
......@@ -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) {
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment