use of com.emc.storageos.security.authorization.InheritCheckPermission in project coprhd-controller by CoprHD.
the class TaggedResource method assignTags.
/**
* @brief Assign tags to resource
* Assign tags
*
* @prereq none
*
* @param id the URN of a ViPR resource
* @param assignment tag assignments
* @return No data returned in response body
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/tags")
@InheritCheckPermission(writeAccess = true)
public Tags assignTags(@PathParam("id") URI id, TagAssignment assignment) {
DataObject object = queryResource(id);
ArgValidator.checkEntityNotNull(object, id, isIdEmbeddedInURL(id));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_082);
ScopedLabelSet tagSet = object.getTag();
if (tagSet == null) {
tagSet = new ScopedLabelSet();
object.setTag(tagSet);
}
if (assignment.getAdd() != null && !assignment.getAdd().isEmpty()) {
Iterator<String> it = assignment.getAdd().iterator();
while (it.hasNext()) {
String tagName = it.next();
if (tagName == null || tagName.isEmpty() || tagName.length() < 2) {
throw APIException.badRequests.parameterTooShortOrEmpty("Tag", 2);
}
ScopedLabel tagLabel = new ScopedLabel(getTenantOwnerIdString(id), tagName);
tagSet.add(tagLabel);
}
}
if (assignment.getRemove() != null && !assignment.getRemove().isEmpty()) {
Iterator<String> it = assignment.getRemove().iterator();
while (it.hasNext()) {
String tagName = it.next();
if (tagName == null || tagName.isEmpty()) {
continue;
}
ScopedLabel tagLabel = new ScopedLabel(getTenantOwnerIdString(id), tagName);
if (tagSet.contains(tagLabel)) {
tagSet.remove(tagLabel);
}
}
}
_dbClient.updateAndReindexObject(object);
return getTagsResponse(object);
}
use of com.emc.storageos.security.authorization.InheritCheckPermission in project coprhd-controller by CoprHD.
the class TaggedResource method getTags.
/**
* @brief List tags assigned to resource
* Returns assigned tags
*
* @prereq none
*
* @param id the URN of a ViPR Resource
* @return Tags information
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/tags")
@InheritCheckPermission
public Tags getTags(@PathParam("id") URI id) {
DataObject object = queryResource(id);
ArgValidator.checkEntityNotNull(object, id, isIdEmbeddedInURL(id));
return getTagsResponse(object);
}
Aggregations