Search in sources :

Example 6 with ObjectBucketACL

use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.

the class ECSObjectStorageDevice method queryDbBucketACL.

private List<ObjectBucketACL> queryDbBucketACL(Bucket bucket) {
    try {
        ContainmentConstraint containmentConstraint = null;
        _log.info("Querying DB for ACL of bucket {} ", bucket.getName());
        containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(bucket.getId());
        List<ObjectBucketACL> dbBucketBucketAcl = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ObjectBucketACL.class, containmentConstraint);
        return dbBucketBucketAcl;
    } catch (Exception e) {
        _log.error("Error while querying DB for ACL of a bucket {}", e);
    }
    return null;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ECSException(com.emc.storageos.ecs.api.ECSException) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 7 with ObjectBucketACL

use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.

the class ECSObjectStorageDevice method doDeleteBucket.

@Override
public BiosCommandResult doDeleteBucket(StorageSystem storageObj, Bucket bucket, String deleteType, final String taskId) {
    BiosCommandResult result;
    try {
        ECSApi objectAPI = getAPI(storageObj);
        if (ObjectControllerConstants.DeleteTypeEnum.INTERNAL_DB_ONLY.toString().equalsIgnoreCase(deleteType.toString())) {
            _log.info("Inventory only bucket delete {}", bucket.getName());
        } else {
            objectAPI.deleteBucket(bucket.getName(), bucket.getNamespace());
        }
        // Deleting the ACL for bucket if any
        List<ObjectBucketACL> aclToDelete = queryDbBucketACL(bucket);
        if (aclToDelete != null && !aclToDelete.isEmpty()) {
            for (ObjectBucketACL ace : aclToDelete) {
                ObjectBucketACL dbBucketAcl = new ObjectBucketACL();
                if (ace != null) {
                    dbBucketAcl.setId(ace.getId());
                    dbBucketAcl.setInactive(true);
                    _log.info("Marking acl inactive in DB: {}", dbBucketAcl);
                    _dbClient.updateObject(dbBucketAcl);
                }
            }
        }
        bucket.setInactive(true);
        _dbClient.persistObject(bucket);
        result = BiosCommandResult.createSuccessfulResult();
        completeTask(bucket.getId(), taskId, "Bucket deleted successfully!");
    } catch (ECSException e) {
        _log.error("Delete Bucket : {} failed.", bucket.getName(), e);
        result = BiosCommandResult.createErrorResult(e);
        completeTask(bucket.getId(), taskId, e);
    }
    return result;
}
Also used : ECSApi(com.emc.storageos.ecs.api.ECSApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ECSException(com.emc.storageos.ecs.api.ECSException) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 8 with ObjectBucketACL

use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.

the class ECSObjectStorageDevice method getExistingBucketAclFromDB.

private ObjectBucketACL getExistingBucketAclFromDB(ObjectBucketACL dbBucketAcl) {
    ObjectBucketACL acl = null;
    String index = null;
    URIQueryResultList result = new URIQueryResultList();
    index = dbBucketAcl.getBucketACLIndex();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBucketACLConstraint(index), result);
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        acl = _dbClient.queryObject(ObjectBucketACL.class, it.next());
        if (acl != null && !acl.getInactive()) {
            _log.info("Existing ACE found in DB: {}", acl);
            return acl;
        }
    }
    return null;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 9 with ObjectBucketACL

use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.

the class BucketACLUtility method verifyAddBucketACL.

private void verifyAddBucketACL(List<BucketACE> bucketACEList) {
    if (bucketACEList == null) {
        return;
    }
    _log.info("Number of bucket ACE(s) to add {} ", bucketACEList.size());
    for (BucketACE ace : bucketACEList) {
        ace.proceedToNextStep();
        _log.info("Verifying ACL {}", ace.toString());
        // Are there same user or group found in other acls. If so, report
        // error
        verifyUserGroupCustomgroup(ace);
        if (!ace.canProceedToNextStep()) {
            break;
        }
        validatePermissions(ace);
        if (!ace.canProceedToNextStep()) {
            break;
        }
        // Verify with existing ACL
        ObjectBucketACL dbBucketAcl = getExistingACL(ace);
        // If same acl exists, don't allow to add again.
        if (dbBucketAcl != null) {
            _log.error("Duplicate ACL in add request. User/group/customgroup in ACL for bucket already exists: {}", dbBucketAcl);
            ace.cancelNextStep(BucketACLOperationErrorType.ACL_EXISTS);
            break;
        } else // If not found proceed for further verifications.
        {
            if (ace.canProceedToNextStep()) {
                _log.info("No existing ACL found in DB {}", ace);
            }
        }
    }
}
Also used : BucketACE(com.emc.storageos.model.object.BucketACE) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 10 with ObjectBucketACL

use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.

the class BucketACLUtility method queryACLByIndex.

private ObjectBucketACL queryACLByIndex(String index) {
    _log.info("Querying ACL in DB by alternate Id: {}", index);
    URIQueryResultList result = new URIQueryResultList();
    ObjectBucketACL acl = null;
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBucketACLConstraint(index), result);
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        if (result.iterator().hasNext()) {
            acl = dbClient.queryObject(ObjectBucketACL.class, it.next());
            if (acl != null && !acl.getInactive()) {
                _log.info("Existing ACE found in DB: {}", acl);
                break;
            }
        }
    }
    return acl;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Aggregations

ObjectBucketACL (com.emc.storageos.db.client.model.ObjectBucketACL)13 BucketACE (com.emc.storageos.model.object.BucketACE)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)3 ECSException (com.emc.storageos.ecs.api.ECSException)3 ArrayList (java.util.ArrayList)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ECSApi (com.emc.storageos.ecs.api.ECSApi)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)1