You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by co...@apache.org on 2017/03/03 09:17:07 UTC
ranger git commit: RANGER-1348:Atlas Autocompletion not working
properly
Repository: ranger
Updated Branches:
refs/heads/master b79e1cf8f -> 24c83278d
RANGER-1348:Atlas Autocompletion not working properly
Signed-off-by: Colm O hEigeartaigh <co...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/24c83278
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/24c83278
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/24c83278
Branch: refs/heads/master
Commit: 24c83278df4b8c6558fe4373cae7443a74e23a74
Parents: b79e1cf
Author: zhangqiang2 <zh...@zte.com.cn>
Authored: Wed Mar 1 03:59:39 2017 -0500
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Mar 3 09:10:25 2017 +0000
----------------------------------------------------------------------
.../services/atlas/RangerServiceAtlas.java | 100 ++-
.../services/atlas/client/AtlasClient.java | 687 +++++++++++++++----
.../atlas/client/AtlasConnectionMgr.java | 4 +-
.../services/atlas/client/AtlasResourceMgr.java | 65 +-
.../json/model/ResourceEntityResponse.java | 60 ++
.../json/model/ResourceOperationResponse.java | 83 +++
.../json/model/ResourceTaxonomyResponse.java | 50 ++
.../atlas/json/model/ResourceTermResponse.java | 51 ++
.../atlas/json/model/ResourceTypeResponse.java | 53 ++
9 files changed, 920 insertions(+), 233 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/RangerServiceAtlas.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/RangerServiceAtlas.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/RangerServiceAtlas.java
index ba4d263..7e7dfe3 100644
--- a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/RangerServiceAtlas.java
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/RangerServiceAtlas.java
@@ -30,61 +30,59 @@ import org.apache.ranger.plugin.service.RangerBaseService;
import org.apache.ranger.plugin.service.ResourceLookupContext;
import org.apache.ranger.services.atlas.client.AtlasResourceMgr;
-
public class RangerServiceAtlas extends RangerBaseService {
- private static final Log LOG = LogFactory.getLog(RangerServiceAtlas.class);
-
- public RangerServiceAtlas() {
- super();
- }
+ private static final Log LOG = LogFactory.getLog(RangerServiceAtlas.class);
- @Override
- public void init(RangerServiceDef serviceDef, RangerService service) {
- super.init(serviceDef, service);
- }
+ public RangerServiceAtlas() {
+ super();
+ }
- @Override
- public HashMap<String,Object> validateConfig() throws Exception {
- HashMap<String, Object> responseMap = new HashMap<String, Object>();
- String serviceName = getServiceName();
- if(LOG.isDebugEnabled()) {
- LOG.debug("==> RangerServiceAtlas.validateConfig Service: (" + serviceName + " )");
- }
- if ( configs != null) {
- try {
- responseMap = AtlasResourceMgr.validateConfig(serviceName, configs);
- } catch (Exception e) {
- LOG.error("<== RangerServiceAtlas.validateConfig Error:" + e);
- throw e;
- }
- }
- if(LOG.isDebugEnabled()) {
- LOG.debug("<== RangerServiceAtlas.validateConfig Response : (" + responseMap + " )");
- }
- return responseMap;
- }
+ @Override
+ public void init(RangerServiceDef serviceDef, RangerService service) {
+ super.init(serviceDef, service);
+ }
+ @Override
+ public HashMap<String, Object> validateConfig() throws Exception {
+ HashMap<String, Object> responseMap = new HashMap<String, Object>();
+ String serviceName = getServiceName();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> RangerServiceAtlas.validateConfig Service: ("+ serviceName + " )");
+ }
+ if (configs != null) {
+ try {
+ responseMap = AtlasResourceMgr.validateConfig(serviceName,configs);
+ } catch (Exception e) {
+ LOG.error("<== RangerServiceAtlas.validateConfig Error:" + e);
+ throw e;
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("<== RangerServiceAtlas.validateConfig Response : ("+ responseMap + " )");
+ }
+ return responseMap;
+ }
- @Override
- public List<String> lookupResource(ResourceLookupContext context) throws Exception {
- List<String> ret = new ArrayList<String>();
- String serviceName = getServiceName();
- Map<String,String> configs = getConfigs();
- if(LOG.isDebugEnabled()) {
- LOG.debug("==> RangerServiceAtlas.lookupResource Context: (" + context + ")");
- }
- if (context != null) {
- try {
- ret = AtlasResourceMgr.getAtlasTermResources(serviceName,configs,context);
- } catch (Exception e) {
- LOG.error( "<==RangerServiceAtlas.lookupResource Error : " + e);
- throw e;
- }
- }
- if(LOG.isDebugEnabled()) {
- LOG.debug("<== RangerServiceAtlas.lookupResource Response: (" + ret + ")");
- }
- return ret;
- }
+ @Override
+ public List<String> lookupResource(ResourceLookupContext context)throws Exception {
+ List<String> ret = new ArrayList<String>();
+ String serviceName = getServiceName();
+ Map<String, String> configs = getConfigs();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> RangerServiceAtlas.lookupResource Context: ("+ context + ")");
+ }
+ if (context != null) {
+ try {
+ ret = AtlasResourceMgr.getAtlasResources(serviceName, configs,context);
+ } catch (Exception e) {
+ LOG.error("<==RangerServiceAtlas.lookupResource Error : " + e);
+ throw e;
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("<== RangerServiceAtlas.lookupResource Response: (" + ret+ ")");
+ }
+ return ret;
+ }
}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasClient.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasClient.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasClient.java
index b959f97..62b67dc 100644
--- a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasClient.java
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasClient.java
@@ -35,7 +35,15 @@ import org.apache.log4j.Logger;
import org.apache.ranger.plugin.client.BaseClient;
import org.apache.ranger.plugin.client.HadoopException;
import org.apache.ranger.plugin.util.PasswordUtils;
-
+import org.apache.ranger.services.atlas.json.model.ResourceEntityResponse;
+import org.apache.ranger.services.atlas.json.model.ResourceOperationResponse;
+import org.apache.ranger.services.atlas.json.model.ResourceOperationResponse.Results;
+import org.apache.ranger.services.atlas.json.model.ResourceTaxonomyResponse;
+import org.apache.ranger.services.atlas.json.model.ResourceTermResponse;
+import org.apache.ranger.services.atlas.json.model.ResourceTypeResponse;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
@@ -46,201 +54,588 @@ public class AtlasClient extends BaseClient {
private static final Logger LOG = Logger.getLogger(AtlasClient.class);
private static final String EXPECTED_MIME_TYPE = "application/json";
private static final String ATLAS_STATUS_API_ENDPOINT = "/j_spring_security_check";
- private static final String ATLAS_LIST_TERM_API_ENDPOINT = "/api/atlas/types";
- private static final String errMessage = " You can still save the repository and start creating "
- + "policies, but you would not be able to use autocomplete for "
- + "resource names. Check ranger_admin.log for more info.";
+ /*** TYPE **/
+ private static final String ATLAS_LIST_TYPE_API_ENDPOINT = "/api/atlas/types/";
+ /**** ENTITY **/
+ private static final String ATLAS_ENTITY_lIST_API_ENDPOINT = "/api/atlas/v1/entities";
+ /*** TERM **/
+ private static final String ATLAS_LIST_TERM_API_ENDPOINT = "/api/atlas/v1/taxonomies/Catalog/terms/";
+ /*** TAXONOMY **/
+ private static final String ATLAS_LIST_TAXONOMY_API_ENDPOINT = "/api/atlas/v1/taxonomies/";
+ /*** OPERATION **/
+ private static final String ATLAS_OPERATION_SEARCH_API_ENDPOINT = "/api/atlas/discovery/search/gremlin/query=";
+ private static final String errMessage = " You can still save the repository and start creating "
+ + "policies, but you would not be able to use autocomplete for "
+ + "resource names. Check ranger_admin.log for more info.";
private String atlasUrl;
private String userName;
private String password;
+ private String statusUrl;
- public AtlasClient(String serviceName, Map<String, String> configs) {
+ public AtlasClient(String serviceName, Map<String, String> configs) {
- super(serviceName,configs,"atlas-client");
+ super(serviceName, configs, "atlas-client");
this.atlasUrl = configs.get("atlas.rest.address");
this.userName = configs.get("username");
this.password = configs.get("password");
+ this.statusUrl = atlasUrl + ATLAS_STATUS_API_ENDPOINT;
if (this.atlasUrl == null || this.atlasUrl.isEmpty()) {
LOG.error("No value found for configuration 'atlas.rest.address'. Atlas resource lookup will fail");
- }
+ }
if (this.userName == null || this.userName.isEmpty()) {
- LOG.error("No value found for configuration 'usename'. Atlas resource lookup will fail");
- }
+ LOG.error("No value found for configuration 'username'. Atlas resource lookup will fail");
+ }
if (this.password == null || this.password.isEmpty()) {
- LOG.error("No value found for configuration 'password'. Atlas resource lookup will fail");
- }
+ LOG.error("No value found for configuration 'password'. Atlas resource lookup will fail");
+ }
if (LOG.isDebugEnabled()) {
- LOG.debug("Atlas Client is build with url [" + this.atlasUrl + "] user: [" + this.userName + "], password: [" + "*********" + "]");
+ LOG.debug("Atlas Client is build with url [" + this.atlasUrl + "] user: [" + this.userName
+ + "], password: [" + "*********" + "]");
}
}
- public List<String> getTermList( String termNameMatching, List<String> existingTermList) {
+ public List<String> getResourceList(final String resourceNameMatching, final String atlasResourceParameter,
+ final List<String> existingResourceList) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Getting Atlas Terms list for termNameMatching : " + termNameMatching);
+ LOG.debug("Getting Atlas Resource list for resourceNameMatching : " + resourceNameMatching);
}
final String errMsg = errMessage;
List<String> ret = null;
-
- Callable<List<String>> callableAtlasTermListGetter = new Callable<List<String>>() {
+ Callable<List<String>> callableAtlasResourceListGetter = new Callable<List<String>>() {
@Override
public List<String> call() {
- List<String> atlasTermListGetter = null;
-
+ List<String> atlasResourceListGetter = null;
Subject subj = getLoginSubject();
-
if (subj != null) {
- atlasTermListGetter = Subject.doAs(subj, new PrivilegedAction<List<String>>() {
-
- @Override
- public List<String> run() {
-
- List<String> lret = new ArrayList<String>();
-
- String statusUrl = atlasUrl + ATLAS_STATUS_API_ENDPOINT;
- String resultUrl = atlasUrl + ATLAS_LIST_TERM_API_ENDPOINT;
-
- Client client = null;
- ClientResponse statusResponse = null;
- ClientResponse resultResponse = null;
-
- try {
- client = Client.create();
- WebResource webResource = client.resource(statusUrl);
- MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
- formData.add("j_username", userName);
-
- String decryptedPwd = null;
+ atlasResourceListGetter = Subject.doAs(subj, new PrivilegedAction<List<String>>() {
+ @Override
+ public List<String> run() {
+ Client client = null;
+ List<String> lret = new ArrayList<String>();
try {
- decryptedPwd = PasswordUtils.decryptPassword(password);
- } catch (Exception ex) {
- LOG.info("Password decryption failed; trying Atlas connection with received password string");
- decryptedPwd = null;
+ client = Client.create();
+
+ if (null == resourceNameMatching || "".equals(resourceNameMatching)) {
+ lret = connectionTestResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ } else if ("type".equals(resourceNameMatching)) {
+ lret = getTypeResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ } else if ("term".equals(resourceNameMatching)) {
+ lret = getTermResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ } else if ("taxonomy".equals(resourceNameMatching)) {
+ lret = getTaxonomyResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ } else if ("entity".equals(resourceNameMatching)) {
+ lret = getEntityResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ } else if ("operation".equals(resourceNameMatching)) {
+ lret = getOperationResource(resourceNameMatching, atlasResourceParameter,
+ existingResourceList, client);
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas Resource List.";
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg,
+ null, null);
+ throw hdpException;
} finally {
- if (decryptedPwd == null) {
- decryptedPwd = password;
+ if (client != null) {
+ client.destroy();
}
}
- formData.add("j_password", decryptedPwd);
+ return lret;
+ }
+ });
+ }
+ return atlasResourceListGetter;
+ }
+ };
+ try {
+ ret = timedTask(callableAtlasResourceListGetter, 5, TimeUnit.SECONDS);
+ } catch (Throwable t) {
+ LOG.error("Unable to get Atlas Resource list", t);
+ String msgDesc = "Unable to get a valid response for " + "expected mime type : [" + EXPECTED_MIME_TYPE
+ + "] ";
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ }
+ return ret;
+ }
- try {
- statusResponse = webResource.type("application/x-www-form-urlencoded").post(
- ClientResponse.class, formData);
- } catch (Exception e) {
- String msgDesc = "Unable to get a valid statusResponse for "
- + "expected mime type : [" + EXPECTED_MIME_TYPE
- + "] URL : " + statusUrl + " - got null response.";
- LOG.error(msgDesc);
- }
+ private ClientResponse getStatusResponse(Client client) {
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ try {
+ WebResource webResource = client.resource(statusUrl);
+ MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
+ formData.add("j_username", userName);
+ String decryptedPwd = null;
+ try {
+ decryptedPwd = PasswordUtils.decryptPassword(password);
+ } catch (Exception ex) {
+ LOG.info("Password decryption failed; trying Atlas connection with received password string");
+ decryptedPwd = null;
+ } finally {
+ if (decryptedPwd == null) {
+ decryptedPwd = password;
+ }
+ }
+ formData.add("j_password", PasswordUtils.decryptPassword(password));
+ try {
+ statusResponse = webResource.type("application/x-www-form-urlencoded").post(ClientResponse.class,
+ formData);
+ } catch (Exception e) {
+ String msgDesc = "Unable to get a valid statusResponse for " + "expected mime type : ["
+ + EXPECTED_MIME_TYPE + "] URL : " + statusUrl + " - got null response.";
+ LOG.error(msgDesc);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getStatusResponse():calling " + statusUrl);
+ }
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getStatusResponse():response.getStatus()= " + statusResponse.getStatus());
+ }
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas Resource List." + " URL : " + statusUrl;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ }
+ return statusResponse;
+ }
- if (LOG.isDebugEnabled()) {
- LOG.debug("getTermList():calling " + statusUrl);
- }
+ public List<String> connectionTestResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ String testConnectiontUrl = atlasUrl + ATLAS_LIST_TYPE_API_ENDPOINT;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
+ try {
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTypeResource():response.getStatus()= " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceTestConnection = client.resource(testConnectiontUrl);
+ WebResource.Builder builder = webResourceTestConnection.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ lret.add(resultResponse.getEntity(String.class));
+ } else {
+ LOG.info("connectionTestResource():response.getStatus()= " + statusResponse.getStatus()
+ + " for URL " + statusUrl + ", so returning null list");
+ LOG.info(statusResponse.getEntity(String.class));
+ lret = null;
+ }
+ }
+ } catch (Throwable t) {
+ lret = null;
+ String msgDesc = "Exception while getting Atlas Resource List." + " URL : " + statusUrl;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
+ if (client != null) {
+ client.destroy();
+ }
+ }
+ return lret;
+ }
- if (statusResponse != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("getTermList():response.getStatus()= " + statusResponse.getStatus());
- }
- if (statusResponse.getStatus() == 200) {
- WebResource webResource2 = client
- .resource(resultUrl);
- WebResource.Builder builder = webResource2.getRequestBuilder();
- for (NewCookie cook : statusResponse.getCookies()) { builder = builder.cookie(cook);
+ public List<String> getTypeResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
+ try {
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTypeResource():response.getStatus()= " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceType = client.resource(atlasUrl + ATLAS_LIST_TYPE_API_ENDPOINT);
+ WebResource.Builder builder = webResourceType.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ if (resultResponse != null) {
+ String jsonString = resultResponse.getEntity(String.class).toString();
+ Gson gson = new Gson();
+ List<String> responseResourceList = new ArrayList<String>();
+ ResourceTypeResponse resourceTypeResponses = gson.fromJson(jsonString,
+ ResourceTypeResponse.class);
+ if (resourceTypeResponses != null) {
+ responseResourceList = resourceTypeResponses.getResults();
+ }
+ if (responseResourceList != null) {
+ for (String responseResource : responseResourceList) {
+ if (responseResource != null) {
+ if (existingResourceList != null && existingResourceList.contains(responseResource)) {
+ continue;
+ }
+ if (atlasResourceParameter == null || atlasResourceParameter.isEmpty()
+ || responseResource.startsWith(atlasResourceParameter)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTypeResource():Adding existsResource " + responseResource);
+ }
+ lret.add(responseResource);
}
- resultResponse = builder.get(ClientResponse.class);
- lret.add(resultResponse.getEntity(String.class));
- } else{
- LOG.info("getTermList():response.getStatus()= " + statusResponse.getStatus() + " for URL " + statusUrl + ", so returning null list");
- LOG.info(statusResponse.getEntity(String.class));
- lret = null;
}
}
- } catch (Throwable t) {
- lret = null;
- String msgDesc = "Exception while getting Atlas Term List."
- + " URL : " + statusUrl;
- HadoopException hdpException = new HadoopException(msgDesc,
- t);
- LOG.error(msgDesc, t);
- hdpException.generateResponseDataMap(false,
- BaseClient.getMessage(t), msgDesc + errMsg, null,
- null);
- throw hdpException;
-
- } finally {
- if (statusResponse != null) {
- statusResponse.close();
+ }
+ }
+ }
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas TypeResource List." + " URL : " + atlasUrl
+ + ATLAS_LIST_TYPE_API_ENDPOINT;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
+ if (client != null) {
+ client.destroy();
+ }
+ }
+ return lret;
+ }
+
+ public List<String> getEntityResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
+
+ try {
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getEntityResource():response.getStatus() = " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceEntity = client.resource(atlasUrl + ATLAS_ENTITY_lIST_API_ENDPOINT);
+ WebResource.Builder builder = webResourceEntity.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ if (resultResponse != null) {
+ String jsonString = resultResponse.getEntity(String.class).toString();
+ Gson gson = new Gson();
+ List<String> responseResourceList = new ArrayList<String>();
+ List<ResourceEntityResponse> resourceEntityResponses = gson.fromJson(jsonString,
+ new TypeToken<List<ResourceEntityResponse>>() {
+ }.getType());
+ if (resourceEntityResponses != null) {
+ for (ResourceEntityResponse resourceEntityResponse : resourceEntityResponses) {
+ if (resourceEntityResponse != null) {
+ responseResourceList.add(resourceEntityResponse.getName());
+ }
}
- if (resultResponse != null) {
- resultResponse.close();
+ if (responseResourceList != null) {
+ for (String responseResource : responseResourceList) {
+ if (responseResource != null) {
+ if (existingResourceList != null
+ && existingResourceList.contains(responseResource)) {
+ continue;
+ }
+ if (atlasResourceParameter == null || atlasResourceParameter.isEmpty()
+ || responseResource.startsWith(atlasResourceParameter)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getEntityResource():Adding existsResource "
+ + responseResource);
+ }
+ lret.add(responseResource);
+ }
+ }
+ }
}
+ }
+ }
+ }
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas getEntityResource List." + " URL : " + atlasUrl
+ + ATLAS_ENTITY_lIST_API_ENDPOINT;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
+ }
+ return lret;
+ }
- if (client != null) {
- client.destroy();
+ public List<String> getTermResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
+ try {
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTermResource():response.getStatus()= " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceTerm = client.resource(atlasUrl + ATLAS_LIST_TERM_API_ENDPOINT);
+ WebResource.Builder builder = webResourceTerm.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ if (resultResponse != null) {
+ String jsonString = resultResponse.getEntity(String.class).toString();
+ Gson gson = new Gson();
+ List<String> responseResourceList = new ArrayList<String>();
+ List<ResourceTermResponse> resourceTermResponses = gson.fromJson(jsonString,
+ new TypeToken<List<ResourceTermResponse>>() {
+ }.getType());
+ for (ResourceTermResponse resourceTermResponse : resourceTermResponses) {
+ responseResourceList.add(resourceTermResponse.getName());
+ }
+ if (responseResourceList != null) {
+ for (String responseResource : responseResourceList) {
+ if (responseResource != null) {
+ if (existingResourceList != null && existingResourceList.contains(responseResource)) {
+ continue;
+ }
+ if (atlasResourceParameter == null || atlasResourceParameter.isEmpty()
+ || responseResource.startsWith(atlasResourceParameter)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTermResource():Adding existsResource " + responseResource);
+ }
+ lret.add(responseResource);
+ }
+ }
}
}
- return lret;
}
- } );
}
- return atlasTermListGetter;
- }
- };
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas getTermResource List." + " URL : " + atlasUrl
+ + ATLAS_LIST_TERM_API_ENDPOINT;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
+ }
+ return lret;
+ }
+
+ public List<String> getTaxonomyResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
try {
- ret = timedTask(callableAtlasTermListGetter, 5, TimeUnit.SECONDS);
- } catch ( Throwable t) {
- LOG.error("Unable to get Atlas Terms list from [" + atlasUrl + "]", t);
- String msgDesc = "Unable to get a valid response for "
- + "expected mime type : [" + EXPECTED_MIME_TYPE
- + "] URL : " + atlasUrl;
- HadoopException hdpException = new HadoopException(msgDesc,
- t);
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTaxonomyResource():response.getStatus()= " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceTaxonomy = client.resource(atlasUrl + ATLAS_LIST_TAXONOMY_API_ENDPOINT);
+ WebResource.Builder builder = webResourceTaxonomy.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ if (resultResponse != null) {
+ String jsonString = resultResponse.getEntity(String.class).toString();
+ Gson gson = new Gson();
+ List<String> responseResourceList = new ArrayList<String>();
+ List<ResourceTaxonomyResponse> resourceTaxonomyResponses = gson.fromJson(jsonString,
+ new TypeToken<List<ResourceTaxonomyResponse>>() {
+ }.getType());
+ for (ResourceTaxonomyResponse resourceTaxonomyResponse : resourceTaxonomyResponses) {
+ responseResourceList.add(resourceTaxonomyResponse.getName());
+ }
+ if (responseResourceList != null) {
+ for (String responseResource : responseResourceList) {
+ if (responseResource != null) {
+ if (existingResourceList != null && existingResourceList.contains(responseResource)) {
+ continue;
+ }
+ if (atlasResourceParameter == null || atlasResourceParameter.isEmpty()
+ || responseResource.startsWith(atlasResourceParameter)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getTaxonomyResource():Adding existsResource " + responseResource);
+ }
+ lret.add(responseResource);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas TaxonomyResource List." + " URL : " + atlasUrl
+ + ATLAS_LIST_TAXONOMY_API_ENDPOINT;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ throw hdpException;
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
+ }
+ return lret;
+ }
- hdpException.generateResponseDataMap(false,
- BaseClient.getMessage(t), msgDesc + errMsg, null,
- null);
+ public List<String> getOperationResource(final String resourceNameMatching, final String atlasResourceParameter,
+ List<String> existingResourceList, Client client) {
+ List<String> lret = new ArrayList<String>();
+ final String errMsg = errMessage;
+ ClientResponse statusResponse = null;
+ ClientResponse resultResponse = null;
+ try {
+ client = Client.create();
+ statusResponse = getStatusResponse(client);
+ if (statusResponse != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getOperationResource():response.getStatus()= " + statusResponse.getStatus());
+ }
+ if (statusResponse.getStatus() == 200) {
+ WebResource webResourceEntity = client.resource(atlasUrl + ATLAS_OPERATION_SEARCH_API_ENDPOINT);
+ WebResource.Builder builder = webResourceEntity.getRequestBuilder();
+ for (NewCookie cook : statusResponse.getCookies()) {
+ builder = builder.cookie(cook);
+ }
+ resultResponse = builder.get(ClientResponse.class);
+ if (resultResponse != null) {
+ String jsonString = resultResponse.getEntity(String.class).toString();
+ Gson gson = new Gson();
+ List<String> responseResourceList = new ArrayList<String>();
+ List<ResourceOperationResponse> resourceOperationResponses = gson.fromJson(jsonString,
+ new TypeToken<List<ResourceOperationResponse>>() {
+ }.getType());
+ for (ResourceOperationResponse resourceOperationResponse : resourceOperationResponses) {
+ List<Results> results = resourceOperationResponse.getResults();
+ for (Results result : results) {
+ responseResourceList.add(result.getResult());
+ }
+ }
+ if (responseResourceList != null) {
+ for (String responseResource : responseResourceList) {
+ if (responseResource != null) {
+ if (existingResourceList != null && existingResourceList.contains(responseResource)) {
+ continue;
+ }
+ if (atlasResourceParameter == null || atlasResourceParameter.isEmpty()
+ || responseResource.startsWith(atlasResourceParameter)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getOperationResource():Adding existsResource "
+ + responseResource);
+ }
+ lret.add(responseResource);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Throwable t) {
+ String msgDesc = "Exception while getting Atlas OperationResource List." + " URL : " + atlasUrl
+ + ATLAS_OPERATION_SEARCH_API_ENDPOINT;
+ HadoopException hdpException = new HadoopException(msgDesc, t);
+ LOG.error(msgDesc, t);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
throw hdpException;
+
+ } finally {
+ if (statusResponse != null) {
+ statusResponse.close();
+ }
+ if (resultResponse != null) {
+ resultResponse.close();
+ }
}
- return ret;
+ return lret;
}
- public static HashMap<String, Object> connectionTest(String serviceName,
- Map<String, String> configs) {
+ public static HashMap<String, Object> connectionTest(String serviceName, Map<String, String> configs) {
String errMsg = errMessage;
boolean connectivityStatus = false;
HashMap<String, Object> responseData = new HashMap<String, Object>();
+ AtlasClient AtlasClient = getAtlasClient(serviceName, configs);
+ List<String> strList = getAtlasResource(AtlasClient, "", "", null);
- AtlasClient AtlasClient = getAtlasClient(serviceName,
- configs);
- List<String> strList = getAtlasTermResource(AtlasClient, "",null);
-
- if (strList != null && strList.size() > 0 ) {
+ if (strList != null && strList.size() > 0) {
if (LOG.isDebugEnabled()) {
- LOG.debug("TESTING Term list size" + strList.size() + " Atlas Terms");
+ LOG.debug("TESTING Resource list size" + strList.size() + " Atlas Resource");
}
connectivityStatus = true;
}
-
if (connectivityStatus) {
String successMsg = "ConnectionTest Successful";
- BaseClient.generateResponseDataMap(connectivityStatus, successMsg,
- successMsg, null, null, responseData);
+ BaseClient.generateResponseDataMap(connectivityStatus, successMsg, successMsg, null, null, responseData);
} else {
- String failureMsg = "Unable to retrieve any Atlas Terms using given parameters.";
- BaseClient.generateResponseDataMap(connectivityStatus, failureMsg,
- failureMsg + errMsg, null, null, responseData);
+ String failureMsg = "Unable to retrieve any Atlas Resource using given parameters.";
+ BaseClient.generateResponseDataMap(connectivityStatus, failureMsg, failureMsg + errMsg, null, null,
+ responseData);
}
-
return responseData;
}
- public static AtlasClient getAtlasClient(String serviceName,
- Map<String, String> configs) {
+ public static AtlasClient getAtlasClient(String serviceName, Map<String, String> configs) {
AtlasClient AtlasClient = null;
if (LOG.isDebugEnabled()) {
LOG.debug("Getting AtlasClient for datasource: " + serviceName);
@@ -250,56 +645,50 @@ public class AtlasClient extends BaseClient {
String msgDesc = "Could not connect as Connection ConfigMap is empty.";
LOG.error(msgDesc);
HadoopException hdpException = new HadoopException(msgDesc);
- hdpException.generateResponseDataMap(false, msgDesc, msgDesc
- + errMsg, null, null);
+ hdpException.generateResponseDataMap(false, msgDesc, msgDesc + errMsg, null, null);
throw hdpException;
} else {
- AtlasClient = new AtlasClient (serviceName, configs);
+ AtlasClient = new AtlasClient(serviceName, configs);
}
return AtlasClient;
}
- public static List<String> getAtlasTermResource (final AtlasClient atlasClient,
- String atlasTermName, List<String> existingAtlasTermName) {
+ public static List<String> getAtlasResource(final AtlasClient atlasClient, String atlasResourceName,
+ String atlasResourceParameter, List<String> existingAtlasResourceName) {
List<String> resultList = new ArrayList<String>();
String errMsg = errMessage;
try {
if (atlasClient == null) {
- String msgDesc = "Unable to get Atlas Terms : AtlasClient is null.";
+ String msgDesc = "Unable to get Atlas Resource : AtlasClient is null.";
LOG.error(msgDesc);
HadoopException hdpException = new HadoopException(msgDesc);
- hdpException.generateResponseDataMap(false, msgDesc, msgDesc
- + errMsg, null, null);
+ hdpException.generateResponseDataMap(false, msgDesc, msgDesc + errMsg, null, null);
throw hdpException;
}
- if (atlasTermName != null) {
- String finalAtlasTermName = atlasTermName.trim();
- resultList = atlasClient
- .getTermList(finalAtlasTermName,existingAtlasTermName);
+ if (atlasResourceName != null) {
+ String finalAtlasResourceName = atlasResourceName.trim();
+ resultList = atlasClient.getResourceList(finalAtlasResourceName, atlasResourceParameter,
+ existingAtlasResourceName);
if (resultList != null) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Returning list of " + resultList.size() + " Atlas Terms");
+ LOG.debug("Returning list of " + resultList.size() + " Atlas Resources");
}
}
}
- }catch (Throwable t) {
- String msgDesc = "getAtlasResource: Unable to get Atlas resources.";
+ } catch (Throwable t) {
+ String msgDesc = "getAtlasResource: Unable to get Atlas Resources.";
LOG.error(msgDesc, t);
HadoopException hdpException = new HadoopException(msgDesc);
-
- hdpException.generateResponseDataMap(false,
- BaseClient.getMessage(t), msgDesc + errMsg, null, null);
+ hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + errMsg, null, null);
throw hdpException;
}
-
return resultList;
}
- public static <T> T timedTask(Callable<T> callableObj, long timeout,
- TimeUnit timeUnit) throws Exception {
+ public static <T> T timedTask(Callable<T> callableObj, long timeout, TimeUnit timeUnit) throws Exception {
return callableObj.call();
}
}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasConnectionMgr.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasConnectionMgr.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasConnectionMgr.java
index 84e24c5..140f91e 100644
--- a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasConnectionMgr.java
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasConnectionMgr.java
@@ -24,7 +24,7 @@ import java.util.Map;
public class AtlasConnectionMgr {
public static AtlasClient getAtlasClient(String serviceName, Map<String, String> configs) {
- return new AtlasClient(serviceName, configs);
- }
+ return new AtlasClient(serviceName, configs);
+ }
}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasResourceMgr.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasResourceMgr.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasResourceMgr.java
index 93b2662..cb2ac9a 100644
--- a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasResourceMgr.java
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/client/AtlasResourceMgr.java
@@ -26,10 +26,8 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.ranger.plugin.service.ResourceLookupContext;
-
public class AtlasResourceMgr {
private static final Logger LOG = Logger.getLogger(AtlasResourceMgr.class);
- private static final String ATLASTERM = "terms";
public static HashMap<String, Object> validateConfig(String serviceName, Map<String, String> configs) throws Exception {
@@ -52,37 +50,42 @@ public class AtlasResourceMgr {
return ret;
}
- public static List<String> getAtlasTermResources(String serviceName, Map<String, String> configs,ResourceLookupContext context) {
- String userInput = context.getUserInput();
- Map<String, List<String>> resourceMap = context.getResources();
- List<String> resultList = null;
- List<String> atlasTermList = null;
- String atlasTermName = null;
-
- if ( resourceMap != null && !resourceMap.isEmpty() &&
- resourceMap.get(ATLASTERM) != null ) {
- atlasTermName = userInput;
- atlasTermList = resourceMap.get(ATLASTERM);
+ public static List<String> getAtlasResources(String serviceName, Map<String, String> configs,
+ ResourceLookupContext context) {
+ String userInput = context.getUserInput();
+ Map<String, List<String>> resourceMap = context.getResources();
+ List<String> resultList = null;
+ List<String> atlasResourceList = null;
+ String atlasResourceName = null;
+ String atlasResourceParameter = null;
+ if (null != context) {
+ atlasResourceName = context.getResourceName();
+ }
+ if (resourceMap != null && !resourceMap.isEmpty()) {
+ atlasResourceParameter = userInput;
+ atlasResourceList = resourceMap.get(atlasResourceName);
} else {
- atlasTermName = userInput;
+ atlasResourceParameter = userInput;
}
- if (configs == null || configs.isEmpty()) {
- LOG.error("Connection Config is empty");
- } else {
- resultList = getAtlasTermResource(serviceName, configs, atlasTermName,atlasTermList);
- }
- return resultList;
- }
+ if (configs == null || configs.isEmpty()) {
+ LOG.error("Connection Config is empty");
+ } else {
+ resultList = getAtlasResource(serviceName, configs, atlasResourceName, atlasResourceParameter,
+ atlasResourceList);
+ }
+ return resultList;
+ }
- public static List<String> getAtlasTermResource(String serviceName, Map<String, String> configs, String atlasTermName, List<String> atlasTermList) {
- final AtlasClient atlasClient = AtlasConnectionMgr.getAtlasClient(serviceName, configs);
- List<String> termList = null;
- if (atlasClient != null) {
- synchronized(atlasClient) {
- termList = atlasClient.getTermList(atlasTermName, atlasTermList);
- }
- }
- return termList;
- }
+ public static List<String> getAtlasResource(String serviceName, Map<String, String> configs,
+ String atlasResourceName, String atlasResourceParameter, List<String> atlasResourceList) {
+ final AtlasClient atlasClient = AtlasConnectionMgr.getAtlasClient(serviceName, configs);
+ List<String> resourceList = null;
+ if (atlasClient != null) {
+ synchronized (atlasClient) {
+ resourceList = atlasClient.getResourceList(atlasResourceName, atlasResourceParameter, atlasResourceList);
+ }
+ }
+ return resourceList;
+ }
}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceEntityResponse.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceEntityResponse.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceEntityResponse.java
new file mode 100644
index 0000000..a9ebc66
--- /dev/null
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceEntityResponse.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.services.atlas.json.model;
+
+public class ResourceEntityResponse {
+
+ private String href;
+ private String name;
+ private String id;
+ private String type;
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceOperationResponse.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceOperationResponse.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceOperationResponse.java
new file mode 100644
index 0000000..d017e47
--- /dev/null
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceOperationResponse.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.services.atlas.json.model;
+
+import java.util.List;
+
+public class ResourceOperationResponse {
+ private String requestId;
+ private String query;
+ private String queryType;
+ private List<Results> results;
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ public String getQueryType() {
+ return queryType;
+ }
+
+ public void setQueryType(String queryType) {
+ this.queryType = queryType;
+ }
+
+ public List<Results> getResults() {
+ return results;
+ }
+
+ public void setResults(List<Results> results) {
+ this.results = results;
+ }
+
+ public class Results {
+
+ private String result;
+ private String count;
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public String getCount() {
+ return count;
+ }
+
+ public void setCount(String count) {
+ this.count = count;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTaxonomyResponse.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTaxonomyResponse.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTaxonomyResponse.java
new file mode 100644
index 0000000..8d4d183
--- /dev/null
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTaxonomyResponse.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.services.atlas.json.model;
+
+public class ResourceTaxonomyResponse {
+ private String href;
+ private String name;
+ private String description;
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTermResponse.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTermResponse.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTermResponse.java
new file mode 100644
index 0000000..75259ec
--- /dev/null
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTermResponse.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.services.atlas.json.model;
+
+public class ResourceTermResponse {
+
+ private String href;
+ private String name;
+ private String description;
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/24c83278/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTypeResponse.java
----------------------------------------------------------------------
diff --git a/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTypeResponse.java b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTypeResponse.java
new file mode 100644
index 0000000..6df9782
--- /dev/null
+++ b/plugin-atlas/src/main/java/org/apache/ranger/services/atlas/json/model/ResourceTypeResponse.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.services.atlas.json.model;
+
+import java.util.List;
+
+public class ResourceTypeResponse {
+
+ private List<String> results;
+ private String count;
+ private String requestId;
+
+ public String getCount() {
+ return count;
+ }
+
+ public void setCount(String count) {
+ this.count = count;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public List<String> getResults() {
+ return results;
+ }
+
+ public void setResults(List<String> results) {
+ this.results = results;
+ }
+
+}