use of com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility in project coprhd-controller by CoprHD.
the class BucketService method updateBucketACL.
/**
* Add/Update the ACL settings for bucket
*
* @param id
* @param param
* @brief Change a bucket ACL
* @return TaskResponse
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateBucketACL(@PathParam("id") URI id, ObjectBucketACLUpdateParams param) throws InternalException {
_log.info("Update bucket acl request received. BucketId: {}", id.toString());
_log.info("Request body: {}", param.toString());
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
if (bucket.getVersion() == null) {
syncBucketACL(bucket);
}
// Verify the Bucket ACL Settings
BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
bucketACLUtil.verifyBucketACL(param);
_log.info("Request payload verified. No errors found.");
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
String task = UUID.randomUUID().toString();
_log.info(String.format("Bucket ACL Update --- Bucket id: %1$s, Task: %2$s", id, task));
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.UPDATE_BUCKET_ACL);
op.setDescription("Bucket ACL update");
controller.updateBucketACL(bucket.getStorageDevice(), id, param, task);
auditOp(OperationTypeEnum.UPDATE_BUCKET_ACL, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
return toTask(bucket, task, op);
}
use of com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility in project coprhd-controller by CoprHD.
the class BucketService method getBucketACL.
/**
* Gets the ACL settings for bucket
*
* @param id
* @brief Get ACLs for a bucket
* @return BucketACL
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BucketACL getBucketACL(@PathParam("id") URI id) throws InternalException {
_log.info("Request recieved to get Bucket ACL with Id: {}", id);
// Validate the Bucket
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
if (bucket.getVersion() == null) {
syncBucketACL(bucket);
}
BucketACL bucketAcl = new BucketACL();
BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
List<BucketACE> bucketAces = bucketACLUtil.queryExistingBucketACL();
_log.info("Number of existing ACLs found : {} ", bucketAces.size());
if (!bucketAces.isEmpty()) {
bucketAcl.setBucketACL(bucketAces);
}
return bucketAcl;
}
Aggregations