Search in sources :

Example 21 with RangerTagResourceMap

use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.

the class RangerTagResourceMapService method getTagResourceMapsByServiceId.

public List<RangerTagResourceMap> getTagResourceMapsByServiceId(Long serviceId) {
    List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>();
    List<XXTagResourceMap> xxTagResourceMaps = daoMgr.getXXTagResourceMap().findByServiceId(serviceId);
    if (CollectionUtils.isNotEmpty(xxTagResourceMaps)) {
        for (XXTagResourceMap xxTagResourceMap : xxTagResourceMaps) {
            RangerTagResourceMap tagResourceMap = populateViewBean(xxTagResourceMap);
            ret.add(tagResourceMap);
        }
    }
    return ret;
}
Also used : XXTagResourceMap(org.apache.ranger.entity.XXTagResourceMap) ArrayList(java.util.ArrayList) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 22 with RangerTagResourceMap

use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.

the class RangerTagResourceMapService method getByResourceId.

public List<RangerTagResourceMap> getByResourceId(Long resourceId) {
    List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>();
    List<XXTagResourceMap> xxTagResourceMaps = daoMgr.getXXTagResourceMap().findByResourceId(resourceId);
    if (CollectionUtils.isNotEmpty(xxTagResourceMaps)) {
        for (XXTagResourceMap xxTagResourceMap : xxTagResourceMaps) {
            RangerTagResourceMap tagResourceMap = populateViewBean(xxTagResourceMap);
            ret.add(tagResourceMap);
        }
    }
    return ret;
}
Also used : XXTagResourceMap(org.apache.ranger.entity.XXTagResourceMap) ArrayList(java.util.ArrayList) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 23 with RangerTagResourceMap

use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.

the class RangerTagResourceMapService method getByTagAndResourceGuid.

public RangerTagResourceMap getByTagAndResourceGuid(String tagGuid, String resourceGuid) {
    RangerTagResourceMap ret = null;
    XXTagResourceMap xxTagResourceMap = daoMgr.getXXTagResourceMap().findByTagAndResourceGuid(tagGuid, resourceGuid);
    if (xxTagResourceMap != null) {
        ret = populateViewBean(xxTagResourceMap);
    }
    return ret;
}
Also used : XXTagResourceMap(org.apache.ranger.entity.XXTagResourceMap) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 24 with RangerTagResourceMap

use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.

the class TagPredicateUtil method addPredicateForResourceId.

private Predicate addPredicateForResourceId(final String id, List<Predicate> predicates) {
    if (StringUtils.isEmpty(id)) {
        return null;
    }
    Predicate ret = new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            boolean ret = false;
            if (object == null) {
                return ret;
            }
            if (object instanceof RangerServiceResource) {
                RangerServiceResource resource = (RangerServiceResource) object;
                ret = StringUtils.equals(id, resource.getId().toString());
            } else if (object instanceof RangerTagResourceMap) {
                RangerTagResourceMap tagResourceMap = (RangerTagResourceMap) object;
                ret = StringUtils.equals(id, tagResourceMap.getId().toString());
            }
            return ret;
        }
    };
    if (predicates != null) {
        predicates.add(ret);
    }
    return ret;
}
Also used : RangerServiceResource(org.apache.ranger.plugin.model.RangerServiceResource) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) Predicate(org.apache.commons.collections.Predicate)

Example 25 with RangerTagResourceMap

use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.

the class TagPredicateUtil method addPredicateForTagResourceMapId.

private Predicate addPredicateForTagResourceMapId(final String id, List<Predicate> predicates) {
    if (StringUtils.isEmpty(id)) {
        return null;
    }
    Predicate ret = new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            boolean ret = false;
            if (object == null) {
                return ret;
            }
            if (object instanceof RangerTagResourceMap) {
                RangerTagResourceMap tagResourceMap = (RangerTagResourceMap) object;
                ret = StringUtils.equals(id, tagResourceMap.getId().toString());
            }
            return ret;
        }
    };
    if (predicates != null) {
        predicates.add(ret);
    }
    return ret;
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) Predicate(org.apache.commons.collections.Predicate)

Aggregations

RangerTagResourceMap (org.apache.ranger.plugin.model.RangerTagResourceMap)32 WebApplicationException (javax.ws.rs.WebApplicationException)16 Test (org.junit.Test)12 ExpectedException (org.junit.rules.ExpectedException)12 ArrayList (java.util.ArrayList)9 XXTagResourceMap (org.apache.ranger.entity.XXTagResourceMap)8 RangerServiceResource (org.apache.ranger.plugin.model.RangerServiceResource)7 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 HashMap (java.util.HashMap)3 DELETE (javax.ws.rs.DELETE)3 Predicate (org.apache.commons.collections.Predicate)3 RangerTag (org.apache.ranger.plugin.model.RangerTag)3 Map (java.util.Map)2 RangerTagDef (org.apache.ranger.plugin.model.RangerTagDef)2 RangerServiceResourceSignature (org.apache.ranger.plugin.store.RangerServiceResourceSignature)2 List (java.util.List)1 POST (javax.ws.rs.POST)1