use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TagREST method updateServiceResourceByGuid.
@PUT
@Path(TagRESTConstants.RESOURCE_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource updateServiceResourceByGuid(@PathParam("guid") String guid, RangerServiceResource resource) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.updateServiceResourceByGuid(" + guid + ", " + resource + ")");
}
RangerServiceResource ret;
try {
validator.preUpdateServiceResourceByGuid(guid, resource);
ret = tagStore.updateServiceResource(resource);
} catch (Exception excp) {
LOG.error("updateServiceResourceByGuid(" + guid + ", " + resource + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== TagREST.updateServiceResourceByGuid(" + guid + ", " + resource + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class RangerServiceResourceService method getTaggedResourcesInServiceId.
public List<RangerServiceResource> getTaggedResourcesInServiceId(Long serviceId) {
List<RangerServiceResource> ret = new ArrayList<RangerServiceResource>();
List<XXServiceResource> xxServiceResources = daoMgr.getXXServiceResource().findByServiceId(serviceId);
if (CollectionUtils.isNotEmpty(xxServiceResources)) {
for (XXServiceResource xxServiceResource : xxServiceResources) {
RangerServiceResource serviceResource = populateViewBean(xxServiceResource);
ret.add(serviceResource);
}
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class RangerServiceResourceService method getByServiceAndResourceSignature.
public RangerServiceResource getByServiceAndResourceSignature(Long serviceId, String resourceSignature) {
RangerServiceResource ret = null;
XXServiceResource xxServiceResource = daoMgr.getXXServiceResource().findByServiceAndResourceSignature(serviceId, resourceSignature);
if (xxServiceResource != null) {
ret = populateViewBean(xxServiceResource);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerServiceResource 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;
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TagPredicateUtil method addPredicateForResourceSignature.
private Predicate addPredicateForResourceSignature(final String signature, List<Predicate> predicates) {
if (StringUtils.isEmpty(signature)) {
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(signature, resource.getResourceSignature());
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
Aggregations