Repository: incubator-ranger Updated Branches: refs/heads/tag-policy f52458921 -> a57caadab
RANGER-274: tag servicedef cleanup; fix tag lookup Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/a57caada Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/a57caada Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/a57caada Branch: refs/heads/tag-policy Commit: a57caadabfa4e1c1197442f3beed757d606978bf Parents: f524589 Author: Madhan Neethiraj <[email protected]> Authored: Sat Sep 26 00:42:36 2015 -0700 Committer: Madhan Neethiraj <[email protected]> Committed: Sat Sep 26 09:40:32 2015 -0700 ---------------------------------------------------------------------- .../apache/ranger/plugin/store/TagStore.java | 6 +- .../ranger/plugin/store/file/TagFileStore.java | 98 ++++------------- .../ranger/services/tag/RangerServiceTag.java | 110 +++++++------------ .../service-defs/ranger-servicedef-tag.json | 48 +------- .../java/org/apache/ranger/biz/ServiceMgr.java | 10 +- .../java/org/apache/ranger/biz/TagDBStore.java | 36 +++--- .../java/org/apache/ranger/db/XXTagDefDao.java | 8 ++ .../java/org/apache/ranger/rest/TagREST.java | 82 +++++--------- .../resources/META-INF/jpa_named_queries.xml | 4 + .../ranger/sink/policymgr/TagRESTSink.java | 18 ++- 10 files changed, 137 insertions(+), 283 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/agents-common/src/main/java/org/apache/ranger/plugin/store/TagStore.java ---------------------------------------------------------------------- diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/TagStore.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/TagStore.java index e27947f..1c48ea0 100644 --- a/agents-common/src/main/java/org/apache/ranger/plugin/store/TagStore.java +++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/TagStore.java @@ -53,6 +53,8 @@ public interface TagStore { PList<RangerTagDef> getPaginatedTagDefs(SearchFilter filter) throws Exception; + List<String> getTagTypes() throws Exception; + RangerTag createTag(RangerTag tag) throws Exception; @@ -120,8 +122,4 @@ public interface TagStore { ServiceTags getServiceTagsIfUpdated(String serviceName, Long lastKnownVersion) throws Exception; - - List<String> getTagTypes(String serviceName) throws Exception; - - List<String> lookupTagTypes(String serviceName, String pattern) throws Exception; } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/agents-common/src/main/java/org/apache/ranger/plugin/store/file/TagFileStore.java ---------------------------------------------------------------------- diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/file/TagFileStore.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/file/TagFileStore.java index dd8fd5c..27b4779 100644 --- a/agents-common/src/main/java/org/apache/ranger/plugin/store/file/TagFileStore.java +++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/file/TagFileStore.java @@ -19,6 +19,8 @@ package org.apache.ranger.plugin.store.file; +import java.util.*; + import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -29,15 +31,11 @@ import org.apache.ranger.authorization.hadoop.config.RangerConfiguration; import org.apache.ranger.plugin.model.*; import org.apache.ranger.plugin.store.AbstractTagStore; import org.apache.ranger.plugin.store.PList; -import org.apache.ranger.plugin.store.RangerServiceResourceSignature; import org.apache.ranger.plugin.store.TagPredicateUtil; import org.apache.ranger.plugin.store.TagStore; import org.apache.ranger.plugin.util.SearchFilter; import org.apache.ranger.plugin.util.ServiceTags; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class TagFileStore extends AbstractTagStore { private static final Log LOG = LogFactory.getLog(TagFileStore.class); @@ -343,6 +341,27 @@ public class TagFileStore extends AbstractTagStore { } @Override + public List<String> getTagTypes() throws Exception { + if (LOG.isDebugEnabled()) { + LOG.debug("==> TagFileStore.getTagTypes()"); + } + + List<String> ret = new ArrayList<String>(); + + List<RangerTag> allTags = getAllTags(); + + for (RangerTag tag : allTags) { + ret.add(tag.getType()); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("<== TagFileStore.getTagTypes(): count=" + ret.size()); + } + + return ret; + } + + @Override public RangerTag createTag(RangerTag tag) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> TagFileStore.createTag(" + tag + ")"); @@ -1118,63 +1137,6 @@ public class TagFileStore extends AbstractTagStore { } - @Override - public List<String> getTagTypes(String serviceName) throws Exception { - if (LOG.isDebugEnabled()) { - LOG.debug("==> TagFileStore.getTags(" + serviceName + ")"); - } - - List<String> ret = new ArrayList<String>(); - - // Ignore serviceName - List<RangerTag> allTags = getAllTags(); - - for (RangerTag tag : allTags) { - ret.add(tag.getType()); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("<== TagFileStore.getTags(" + serviceName + "): count=" + ret.size()); - } - - return ret; - } - - @Override - public List<String> lookupTagTypes(String serviceName, String pattern) throws Exception { - if (LOG.isDebugEnabled()) { - LOG.debug("==> TagFileStore.lookupTags(" + serviceName + ", " + pattern + ")"); - } - - List<String> ret = new ArrayList<String>(); - List<String> tags = getTagTypes(serviceName); - - if (CollectionUtils.isNotEmpty(tags)) { - Pattern p = Pattern.compile(pattern); - for (String tagType : tags) { - Matcher m = p.matcher(tagType); - - if (LOG.isDebugEnabled()) { - LOG.debug("TagFileStore.lookupTags) - Trying to match .... pattern=" + pattern + ", tagType=" + tagType); - } - - if (m.matches()) { - if (LOG.isDebugEnabled()) { - LOG.debug("TagFileStore.lookupTags) - Match found.... pattern=" + pattern + ", tagType=" + tagType); - } - - ret.add(tagType); - } - } - } - - if (LOG.isDebugEnabled()) { - LOG.debug("<== TagFileStore.lookupTags(" + serviceName + ", " + pattern + "): count=" + ret.size()); - } - - return ret; - } - private List<RangerTag> getTagsForServiceResourceObject(RangerServiceResource serviceResource) throws Exception { List<RangerTag> tagList = new ArrayList<RangerTag>(); @@ -1392,19 +1354,5 @@ public class TagFileStore extends AbstractTagStore { postDelete(tagResourceMap); } - - private List<RangerServiceResource> getServiceResources(RangerServiceResource resource) throws Exception { - - List<RangerServiceResource> ret = null; - - RangerServiceResourceSignature serializer = new RangerServiceResourceSignature(resource); - String signature = serializer.getSignature(); - - SearchFilter filter = new SearchFilter(SearchFilter.TAG_RESOURCE_SIGNATURE, signature); - - ret = getServiceResources(filter); - - return ret; - } } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/agents-common/src/main/java/org/apache/ranger/services/tag/RangerServiceTag.java ---------------------------------------------------------------------- diff --git a/agents-common/src/main/java/org/apache/ranger/services/tag/RangerServiceTag.java b/agents-common/src/main/java/org/apache/ranger/services/tag/RangerServiceTag.java index 375f0b8..f36a9a6 100644 --- a/agents-common/src/main/java/org/apache/ranger/services/tag/RangerServiceTag.java +++ b/agents-common/src/main/java/org/apache/ranger/services/tag/RangerServiceTag.java @@ -21,12 +21,15 @@ package org.apache.ranger.services.tag; import java.util.*; -import org.apache.ranger.admin.client.RangerAdminClient; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.StringUtils; import org.apache.ranger.plugin.model.RangerService; import org.apache.ranger.plugin.model.RangerServiceDef; -import org.apache.ranger.plugin.service.RangerBasePlugin; import org.apache.ranger.plugin.service.RangerBaseService; import org.apache.ranger.plugin.service.ResourceLookupContext; +import org.apache.ranger.plugin.store.TagStore; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,11 +37,10 @@ public class RangerServiceTag extends RangerBaseService { private static final Log LOG = LogFactory.getLog(RangerServiceTag.class); - public static final String TAG = "tag"; + public static final String TAG_RESOURCE_NAME = "tag"; - public static final String propertyPrefix = "ranger.plugin.tag"; + private TagStore tagStore = null; - public static final String applicationId = "Ranger-GUI"; public RangerServiceTag() { super(); @@ -49,34 +51,20 @@ public class RangerServiceTag extends RangerBaseService { super.init(serviceDef, service); } + public void setTagStore(TagStore tagStore) { + this.tagStore = tagStore; + } + @Override public HashMap<String,Object> validateConfig() throws Exception { - HashMap<String, Object> ret = new HashMap<String, Object>(); - String serviceName = getServiceName(); - boolean connectivityStatus = false; - String message = null; - if(LOG.isDebugEnabled()) { - LOG.debug("==> RangerServiceTag.validateConfig - Service: (" + serviceName + " )"); + LOG.debug("==> RangerServiceTag.validateConfig(" + serviceName + " )"); } - RangerAdminClient adminClient = createAdminClient(serviceName); - - try { - adminClient.getTagTypes(".*"); - connectivityStatus = true; - } catch (Exception e) { - LOG.error("RangerServiceTag.validateConfig() Error:" + e); - connectivityStatus = false; - message = "Cannot connect to TagResource Repository, Exception={" + e + "}. " + "Please check " - + propertyPrefix + " sub-properties."; - } - - ret.put("connectivityStatus", connectivityStatus); - ret.put("message", message); + HashMap<String, Object> ret = new HashMap<String, Object>(); if(LOG.isDebugEnabled()) { - LOG.debug("<== RangerServiceTag.validateConfig - Response : (" + ret + " )"); + LOG.debug("<== RangerServiceTag.validateConfig(" + serviceName + " ): " + ret); } return ret; @@ -84,64 +72,48 @@ public class RangerServiceTag extends RangerBaseService { @Override public List<String> lookupResource(ResourceLookupContext context) throws Exception { - String serviceName = getServiceName(); - if(LOG.isDebugEnabled()) { - LOG.debug("==> RangerServiceTag.lookupResource - Context: (" + context + ")"); + LOG.debug("==> RangerServiceTag.lookupResource(" + context + ")"); } - List<String> tagTypeList = new ArrayList<>(); - - if (context != null) { - - String userInput = context.getUserInput(); - String resource = context.getResourceName(); - Map<String, List<String>> resourceMap = context.getResources(); - final List<String> userProvidedTagList = new ArrayList<>(); + List<String> ret = new ArrayList<String>(); - if (resource != null && resourceMap != null && resourceMap.get(TAG) != null) { + if (context != null && StringUtils.equals(context.getResourceName(), TAG_RESOURCE_NAME)) { + try { + List<String> tags = tagStore != null ? tagStore.getTagTypes() : null; - for (String tag : resourceMap.get(TAG)) { - userProvidedTagList.add(tag); - } - - String suffix = ".*"; - String pattern; - - if (userInput == null) { - pattern = suffix; - } else { - pattern = userInput + suffix; - } - - if (LOG.isDebugEnabled()) { - LOG.debug("RangerServiceTag.lookupResource - pattern : (" + pattern + ")"); - } + if(CollectionUtils.isNotEmpty(tags)) { + List<String> valuesToExclude = MapUtils.isNotEmpty(context.getResources()) ? context.getResources().get(TAG_RESOURCE_NAME) : null; - try { + if(CollectionUtils.isNotEmpty(valuesToExclude)) { + for (String valueToExclude : valuesToExclude) { + tags.remove(valueToExclude); + } + } - RangerAdminClient adminClient = createAdminClient(serviceName); + String valueToMatch = context.getUserInput(); - tagTypeList = adminClient.getTagTypes(pattern); + if(StringUtils.isNotEmpty(valueToMatch)) { + if(! valueToMatch.endsWith("*")) { + valueToMatch += "*"; + } - tagTypeList.removeAll(userProvidedTagList); - - } catch (Exception e) { - LOG.error("RangerServiceTag.lookupResource - Exception={" + e + "}. " + "Please check " + - propertyPrefix + " sub-properties."); + for (String tag : tags) { + if(FilenameUtils.wildcardMatch(tag, valueToMatch)) { + ret.add(tag); + } + } + } } + } catch (Exception excp) { + LOG.error("RangerServiceTag.lookupResource()", excp); } } if(LOG.isDebugEnabled()) { - LOG.debug("<== RangerServiceTag.lookupResource()"); + LOG.debug("<== RangerServiceTag.lookupResource(): tag count=" + ret.size()); } - return tagTypeList; - } - - public static RangerAdminClient createAdminClient( String tagServiceName ) { - return RangerBasePlugin.createAdminClient(tagServiceName, applicationId, propertyPrefix); + return ret; } - } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/agents-common/src/main/resources/service-defs/ranger-servicedef-tag.json ---------------------------------------------------------------------- diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-tag.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-tag.json index dfadd47..30d1b20 100644 --- a/agents-common/src/main/resources/service-defs/ranger-servicedef-tag.json +++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-tag.json @@ -22,7 +22,7 @@ "recursiveSupported": false, "excludesSupported": false, "matcher": "org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher", - "matcherOptions": { "wildCard":true, "ignoreCase":false }, + "matcherOptions": { "wildCard":false, "ignoreCase":false }, "validationRegEx":"", "validationMessage": "", "uiHint":"", @@ -38,45 +38,7 @@ "configs": [ - { - "itemId": 1, - "name": "username", - "type": "string", - "subType": "", - "mandatory": true, - "validationRegEx":"", - "validationMessage": "", - "uiHint":"", - "label": "Username" - }, - - { - "itemId": 2, - "name": "password", - "type": "password", - "subType": "", - "mandatory": true, - "validationRegEx":"", - "validationMessage": "", - "uiHint":"", - "label": "Password" - }, - - { - "itemId": 3, - "name": "URL", - "type": "string", - "mandatory": true, - "label": "URL for tag provider" - }, - { - "itemId": 4, - "name": "SSL_CONFIG_FILE_NAME", - "type": "string", - "mandatory": true, - "label": "SSL Config file" - } ], "enums": @@ -101,14 +63,6 @@ [ { "itemId":1, - "name":"ScriptConditionEvaluator", - "evaluator": "org.apache.ranger.plugin.conditionevaluator.RangerScriptConditionEvaluator", - "evaluatorOptions" : {"engineName":"JavaScript", "ui.isMultiline":"true" }, - "label":"Script", - "description": "Script to execute" - }, - { - "itemId":2, "name":"enforce-expiry", "evaluator": "org.apache.ranger.plugin.conditionevaluator.RangerScriptTemplateConditionEvaluator", "evaluatorOptions" : { "scriptTemplate":"ctx.isAccessedAfter('expiry_date');" }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/security-admin/src/main/java/org/apache/ranger/biz/ServiceMgr.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceMgr.java index 641ab91..7950439 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceMgr.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceMgr.java @@ -43,6 +43,7 @@ import org.apache.ranger.plugin.service.ResourceLookupContext; import org.apache.ranger.plugin.store.EmbeddedServiceDefsUtil; import org.apache.ranger.plugin.store.ServiceStore; import org.apache.ranger.service.RangerServiceService; +import org.apache.ranger.services.tag.RangerServiceTag; import org.apache.ranger.view.VXMessage; import org.apache.ranger.view.VXResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -61,6 +62,9 @@ public class ServiceMgr { ServiceDBStore svcDBStore; @Autowired + TagDBStore tagStore; + + @Autowired TimedExecutor timedExecutor; public List<String> lookupResource(String serviceName, ResourceLookupContext context, ServiceStore svcStore) throws Exception { @@ -171,7 +175,11 @@ public class ServiceMgr { if(cls != null) { ret = cls.newInstance(); - ret.init(serviceDef, service); + ret.init(serviceDef, service); + + if(ret instanceof RangerServiceTag) { + ((RangerServiceTag)ret).setTagStore(tagStore); + } } else { LOG.warn("ServiceMgr.getRangerServiceByService(" + service + "): could not find service class '" + serviceDef.getImplClass() + "'"); } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java index f2a1ad9..962bfde 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java @@ -263,6 +263,21 @@ public class TagDBStore extends AbstractTagStore { return ret; } + @Override + public List<String> getTagTypes() throws Exception { + if (LOG.isDebugEnabled()) { + LOG.debug("==> TagDBStore.getTagTypes()"); + } + + List<String> ret = daoManager.getXXTagDef().getAllNames(); + + if (LOG.isDebugEnabled()) { + LOG.debug("<== TagDBStore.getTagTypes(): count=" + (ret != null ? ret.size() : 0)); + } + + return ret; + } + @Override public RangerTag createTag(RangerTag tag) throws Exception { @@ -876,16 +891,6 @@ public class TagDBStore extends AbstractTagStore { return ret; } - @Override - public List<String> getTagTypes(String serviceName) throws Exception { - throw new Exception("Not implemented"); - } - - @Override - public List<String> lookupTagTypes(String serviceName, String pattern) throws Exception { - throw new Exception("Not implemented"); - } - private List<XXTagAttributeDef> createTagAttributeDefs(Long tagDefId, List<RangerTagAttributeDef> tagAttrDefList) { if (LOG.isDebugEnabled()) { LOG.debug("==> TagDBStore.createTagAttributeDefs(" + tagDefId + ", attributeDefCount=" + (tagAttrDefList == null ? 0 : tagAttrDefList.size()) + ")"); @@ -1038,15 +1043,4 @@ public class TagDBStore extends AbstractTagStore { } } } - - private void deleteResourceValue(Long resourceId) { - List<XXServiceResourceElement> taggedResValueList = daoManager.getXXServiceResourceElement().findByResourceId(resourceId); - for (XXServiceResourceElement taggedResValue : taggedResValueList) { - List<XXServiceResourceElementValue> taggedResValueMapList = daoManager.getXXServiceResourceElementValue().findByResValueId(taggedResValue.getId()); - for (XXServiceResourceElementValue taggedResValueMap : taggedResValueMapList) { - daoManager.getXXServiceResourceElementValue().remove(taggedResValueMap); - } - daoManager.getXXServiceResourceElement().remove(taggedResValue); - } - } } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java index 97b53fd..28ddfde 100644 --- a/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java +++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java @@ -74,6 +74,14 @@ public class XXTagDefDao extends BaseDao<XXTagDef> { } } + public List<String> getAllNames() { + try { + return getEntityManager().createNamedQuery("XXTagDef.getAllNames", String.class).getResultList(); + } catch (NoResultException e) { + return new ArrayList<String>(); + } + } + public void updateServiceForTagDefUpdate(Long tagDefId, Date updateTime) { if (tagDefId == null) { return; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java b/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java index 520c1be..dfa4a64 100644 --- a/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java +++ b/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java @@ -296,6 +296,33 @@ public class TagREST { return ret; } + @GET + @Path(TagRESTConstants.TAGTYPES_RESOURCE) + @Produces({ "application/json", "application/xml" }) + @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") + public List<String> getTagTypes() { + if(LOG.isDebugEnabled()) { + LOG.debug("==> TagREST.getTagTypes()"); + } + + List<String> ret = null; + + try { + ret = tagStore.getTagTypes(); + } catch(Exception excp) { + LOG.error("getTagTypes() failed", excp); + + throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true); + } + + if(LOG.isDebugEnabled()) { + LOG.debug("<== TagREST.getTagTypes(): count=" + (ret != null ? ret.size() : 0)); + } + + return ret; + } + + @POST @Path(TagRESTConstants.TAGS_RESOURCE) @Produces({ "application/json", "application/xml" }) @@ -1014,59 +1041,4 @@ public class TagREST { return ret; } - - // This API is typically used by GUI to get all available tags from RangerAdmin - - @GET - @Path(TagRESTConstants.TAGTYPES_RESOURCE) - @Produces({ "application/json", "application/xml" }) - @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") - public List<String> getTagTypes(@QueryParam(TagRESTConstants.SERVICE_NAME_PARAM) String serviceName) { - - if(LOG.isDebugEnabled()) { - LOG.debug("==> TagREST.getTagTypes(" + serviceName + ")"); - } - List<String> tagTypes = null; - - try { - tagTypes = tagStore.getTagTypes(serviceName); - } catch(Exception excp) { - LOG.error("getTags(" + serviceName + ") failed", excp); - - throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true); - } - - if(LOG.isDebugEnabled()) { - LOG.debug("<== TagREST.getTagTypes(" + serviceName + ")"); - } - return tagTypes; - } - - // This API is typically used by GUI to help lookup available tags from RangerAdmin to help tag-policy writer. It - // may also be used to validate configuration parameters of a tag-service - - @GET - @Path(TagRESTConstants.TAGTYPES_LOOKUP_RESOURCE) - @Produces({ "application/json", "application/xml" }) - public List<String> lookupTagTypes(@QueryParam(TagRESTConstants.SERVICE_NAME_PARAM) String serviceName, - @DefaultValue(".*") @QueryParam(TagRESTConstants.PATTERN_PARAM) String pattern) { - if(LOG.isDebugEnabled()) { - LOG.debug("==> TagREST.lookupTagTypes(" + serviceName + ", " + pattern + ")"); - } - List<String> matchingTagTypes = null; - - try { - matchingTagTypes = tagStore.lookupTagTypes(serviceName, pattern); - } catch(Exception excp) { - LOG.error("lookupTags(" + serviceName + ") failed", excp); - - throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true); - } - - if(LOG.isDebugEnabled()) { - LOG.debug("<== TagREST.lookupTagTypes(" + serviceName + ")"); - } - return matchingTagTypes; - } - } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/security-admin/src/main/resources/META-INF/jpa_named_queries.xml ---------------------------------------------------------------------- diff --git a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml index 375e977..a5f4a6c 100644 --- a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml +++ b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml @@ -613,6 +613,10 @@ (select tag.type from XXTag tag, XXTagResourceMap tagRes, XXServiceResource resource where tag.id = tagRes.tagId and tagRes.resourceId = resource.id and resource.serviceId = :serviceId)</query> </named-query> + <named-query name="XXTagDef.getAllNames"> + <query>select obj.name from XXTagDef obj</query> + </named-query> + <named-query name="XXTagDef.updateTagVersionInService"> <query>update XXService obj set obj.tagVersion = obj.tagVersion + 1, obj.tagUpdateTime = :tagUpdateTime where obj.id in (select res.serviceId from XXServiceResource res, XXTagResourceMap tagRes, XXTag tag http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a57caada/tagsync/src/main/java/org/apache/ranger/sink/policymgr/TagRESTSink.java ---------------------------------------------------------------------- diff --git a/tagsync/src/main/java/org/apache/ranger/sink/policymgr/TagRESTSink.java b/tagsync/src/main/java/org/apache/ranger/sink/policymgr/TagRESTSink.java index 0695cd3..98410d6 100644 --- a/tagsync/src/main/java/org/apache/ranger/sink/policymgr/TagRESTSink.java +++ b/tagsync/src/main/java/org/apache/ranger/sink/policymgr/TagRESTSink.java @@ -21,6 +21,7 @@ package org.apache.ranger.sink.policymgr; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; + import org.apache.commons.collections.MapUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -188,6 +189,12 @@ public class TagRESTSink implements TagSink { throw new Exception("Not implemented"); } + @Override + public List<String> getTagTypes() throws Exception { + // TODO Auto-generated method stub + return null; + } + @Override public RangerTag createTag(RangerTag tag) throws Exception { @@ -483,16 +490,6 @@ public class TagRESTSink implements TagSink { throw new Exception("Not implemented"); } - @Override - public List<String> getTagTypes(String serviceName) throws Exception { - throw new Exception("Not implemented"); - } - - @Override - public List<String> lookupTagTypes(String serviceName, String pattern) throws Exception { - throw new Exception("Not implemented"); - } - private WebResource createWebResource(String url) { return createWebResource(url, null); } @@ -511,5 +508,4 @@ public class TagRESTSink implements TagSink { return ret; } - }
