Search in sources :

Example 16 with RangerTagResourceMap

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

the class RangerTagResourceMapService method postCreate.

@Override
public RangerTagResourceMap postCreate(XXTagResourceMap tagResMap) {
    RangerTagResourceMap ret = super.postCreate(tagResMap);
    daoMgr.getXXServiceVersionInfo().updateServiceVersionInfoForServiceResourceUpdate(tagResMap.getResourceId(), tagResMap.getUpdateTime());
    return ret;
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 17 with RangerTagResourceMap

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

the class TagREST method createTagResourceMap.

@POST
@Path(TagRESTConstants.TAGRESOURCEMAPS_RESOURCE)
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTagResourceMap createTagResourceMap(@QueryParam("tag-guid") String tagGuid, @QueryParam("resource-guid") String resourceGuid, @DefaultValue("false") @QueryParam("lenient") boolean lenient) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.createTagResourceMap(" + tagGuid + ", " + resourceGuid + ", " + lenient + ")");
    }
    RangerTagResourceMap tagResourceMap;
    try {
        tagResourceMap = tagStore.getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid);
        if (tagResourceMap == null) {
            tagResourceMap = validator.preCreateTagResourceMap(tagGuid, resourceGuid);
            tagResourceMap = tagStore.createTagResourceMap(tagResourceMap);
        } else if (!lenient) {
            throw new Exception("tagResourceMap with tag-guid=" + tagGuid + " and resource-guid=" + resourceGuid + " already exists");
        }
    } catch (Exception excp) {
        LOG.error("createTagResourceMap(" + tagGuid + ", " + resourceGuid + ", " + lenient + ") failed", excp);
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.createTagResourceMap(" + tagGuid + ", " + resourceGuid + ", " + lenient + ")");
    }
    return tagResourceMap;
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 18 with RangerTagResourceMap

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

the class RangerTagResourceMapService method getByResourceGuid.

public List<RangerTagResourceMap> getByResourceGuid(String resourceGuid) {
    List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>();
    List<XXTagResourceMap> xxTagResourceMaps = daoMgr.getXXTagResourceMap().findByResourceGuid(resourceGuid);
    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 19 with RangerTagResourceMap

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

the class RangerTagResourceMapService method getByTagId.

public List<RangerTagResourceMap> getByTagId(Long tagId) {
    List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>();
    List<XXTagResourceMap> xxTagResourceMaps = daoMgr.getXXTagResourceMap().findByTagId(tagId);
    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 20 with RangerTagResourceMap

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

the class RangerTagResourceMapService method getByGuid.

public RangerTagResourceMap getByGuid(String guid) {
    RangerTagResourceMap ret = null;
    XXTagResourceMap xxTagResourceMap = daoMgr.getXXTagResourceMap().findByGuid(guid);
    if (xxTagResourceMap != null) {
        ret = populateViewBean(xxTagResourceMap);
    }
    return ret;
}
Also used : XXTagResourceMap(org.apache.ranger.entity.XXTagResourceMap) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

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