Search in sources :

Example 1 with BucketACLUtility

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);
}
Also used : BucketACLUtility(com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with BucketACLUtility

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;
}
Also used : BucketACL(com.emc.storageos.model.object.BucketACL) BucketACLUtility(com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) BucketACE(com.emc.storageos.model.object.BucketACE) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

MapBucket (com.emc.storageos.api.mapper.functions.MapBucket)2 BucketACLUtility (com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility)2 Bucket (com.emc.storageos.db.client.model.Bucket)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Operation (com.emc.storageos.db.client.model.Operation)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 BucketACE (com.emc.storageos.model.object.BucketACE)1 BucketACL (com.emc.storageos.model.object.BucketACL)1 ObjectController (com.emc.storageos.volumecontroller.ObjectController)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1