use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class ServiceTagsProcessor method findMatchingTag.
private RangerTag findMatchingTag(RangerTag incomingTag, List<RangerTag> existingTags) throws Exception {
RangerTag ret = null;
if (StringUtils.isNotEmpty(incomingTag.getGuid())) {
ret = tagStore.getTagByGuid(incomingTag.getGuid());
}
if (ret == null) {
if (isResourcePrivateTag(incomingTag)) {
for (RangerTag existingTag : existingTags) {
if (StringUtils.equals(incomingTag.getType(), existingTag.getType())) {
// Check attribute values
Map<String, String> incomingTagAttributes = incomingTag.getAttributes();
Map<String, String> existingTagAttributes = existingTag.getAttributes();
if (CollectionUtils.isEqualCollection(incomingTagAttributes.keySet(), existingTagAttributes.keySet())) {
boolean matched = true;
for (Map.Entry<String, String> entry : incomingTagAttributes.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!StringUtils.equals(value, existingTagAttributes.get(key))) {
matched = false;
break;
}
}
if (matched) {
ret = existingTag;
break;
}
}
}
}
}
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TagREST method updateTag.
@PUT
@Path(TagRESTConstants.TAG_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTag updateTag(@PathParam("id") Long id, RangerTag tag) {
RangerTag ret;
try {
validator.preUpdateTag(id, tag);
ret = tagStore.updateTag(tag);
} catch (Exception excp) {
LOG.error("updateTag(" + id + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== TagREST.updateTag(" + id + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class RangerTagService method getTagsForResourceGuid.
public List<RangerTag> getTagsForResourceGuid(String resourceGuid) {
List<RangerTag> ret = new ArrayList<RangerTag>();
List<XXTag> xxTags = daoMgr.getXXTag().findForResourceGuid(resourceGuid);
if (CollectionUtils.isNotEmpty(xxTags)) {
for (XXTag xxTag : xxTags) {
RangerTag tag = populateViewBean(xxTag);
ret.add(tag);
}
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class RangerTagService method getTagByGuid.
public RangerTag getTagByGuid(String guid) {
RangerTag ret = null;
XXTag xxTag = daoMgr.getXXTag().findByGuid(guid);
if (xxTag != null) {
ret = populateViewBean(xxTag);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class RangerTagService method getTagsByServiceId.
public List<RangerTag> getTagsByServiceId(Long serviceId) {
List<RangerTag> ret = new ArrayList<RangerTag>();
List<XXTag> xxTags = daoMgr.getXXTag().findByServiceId(serviceId);
if (CollectionUtils.isNotEmpty(xxTags)) {
for (XXTag xxTag : xxTags) {
RangerTag tag = populateViewBean(xxTag);
ret.add(tag);
}
}
return ret;
}
Aggregations