Search in sources :

Example 11 with RangerTagResourceMap

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

the class TagREST method deleteTagResourceMap.

@DELETE
@Path(TagRESTConstants.TAGRESOURCEMAPS_RESOURCE)
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteTagResourceMap(@QueryParam("tag-guid") String tagGuid, @QueryParam("resource-guid") String resourceGuid) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
    }
    try {
        RangerTagResourceMap exist = validator.preDeleteTagResourceMap(tagGuid, resourceGuid);
        tagStore.deleteTagResourceMap(exist.getId());
    } catch (Exception excp) {
        LOG.error("deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ") failed", excp);
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
    }
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 12 with RangerTagResourceMap

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

the class TagREST method deleteTagResourceMapByGuid.

@DELETE
@Path(TagRESTConstants.TAGRESOURCEMAP_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteTagResourceMapByGuid(@PathParam("guid") String guid) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.deleteTagResourceMapByGuid(" + guid + ")");
    }
    try {
        RangerTagResourceMap exist = validator.preDeleteTagResourceMapByGuid(guid);
        tagStore.deleteServiceResource(exist.getId());
    } catch (Exception excp) {
        LOG.error("deleteTagResourceMapByGuid(" + guid + ") failed", excp);
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== TagREST.deleteTagResourceMapByGuid(" + guid + ")");
    }
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 13 with RangerTagResourceMap

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

the class RangerTagResourceMapService method getByTagAndResourceId.

public RangerTagResourceMap getByTagAndResourceId(Long tagId, Long resourceId) {
    RangerTagResourceMap ret = null;
    XXTagResourceMap xxTagResourceMap = daoMgr.getXXTagResourceMap().findByTagAndResourceId(tagId, resourceId);
    if (xxTagResourceMap != null) {
        ret = populateViewBean(xxTagResourceMap);
    }
    return ret;
}
Also used : XXTagResourceMap(org.apache.ranger.entity.XXTagResourceMap) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 14 with RangerTagResourceMap

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

the class RangerTagResourceMapService method getByTagGuid.

public List<RangerTagResourceMap> getByTagGuid(String tagGuid) {
    List<RangerTagResourceMap> ret = new ArrayList<RangerTagResourceMap>();
    List<XXTagResourceMap> xxTagResourceMaps = daoMgr.getXXTagResourceMap().findByTagGuid(tagGuid);
    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 15 with RangerTagResourceMap

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

the class RangerTagResourceMapService method postUpdate.

@Override
public RangerTagResourceMap postUpdate(XXTagResourceMap tagResMap) {
    RangerTagResourceMap ret = super.postUpdate(tagResMap);
    daoMgr.getXXServiceVersionInfo().updateServiceVersionInfoForServiceResourceUpdate(tagResMap.getResourceId(), tagResMap.getUpdateTime());
    return ret;
}
Also used : 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