Search in sources :

Example 11 with ObjectBucketACL

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

the class BucketACLUtility method verifyModifyBucketACL.

private void verifyModifyBucketACL(List<BucketACE> bucketACEList) {
    if (bucketACEList == null) {
        return;
    }
    _log.info("Number of bucket ACE(s) to modify {} ", 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, allow to modify
        if (dbBucketAcl != null) {
            _log.info("Existing ACL in modify request: {}", dbBucketAcl);
            ace.proceedToNextStep();
        } else {
            // If not found, don't allow to proceed further
            if (ace.canProceedToNextStep()) {
                _log.error("No existing ACL found in DB to modify {}", ace);
                ace.cancelNextStep(BucketACLOperationErrorType.ACL_NOT_FOUND);
            }
        }
    }
}
Also used : BucketACE(com.emc.storageos.model.object.BucketACE) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 12 with ObjectBucketACL

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

the class ObjectDeviceController method queryDbBucketAcl.

private List<ObjectBucketACL> queryDbBucketAcl(ObjectDeviceInputOutput args, URI bucketId) {
    List<ObjectBucketACL> acls = new ArrayList<ObjectBucketACL>();
    try {
        ContainmentConstraint containmentConstraint = null;
        _log.info("Querying DB for ACL of Bucket {} ", args.getName());
        containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(bucketId);
        List<ObjectBucketACL> bucketAclList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ObjectBucketACL.class, containmentConstraint);
        Iterator<ObjectBucketACL> bucketAclIter = bucketAclList.iterator();
        while (bucketAclIter.hasNext()) {
            ObjectBucketACL bucketAce = bucketAclIter.next();
            if (args.getName().equals(bucketAce.getBucketName())) {
                acls.add(bucketAce);
            }
        }
    } catch (Exception e) {
        _log.error("Error while querying DB for ACL(s) of a share {}", e);
    }
    return acls;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 13 with ObjectBucketACL

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

the class ObjectDeviceController method queryExistingBucketAcl.

private List<BucketACE> queryExistingBucketAcl(ObjectDeviceInputOutput args, URI buckeId) {
    _log.info("Querying  ACL of Bucket {}", args.getName());
    List<BucketACE> acl = new ArrayList<BucketACE>();
    try {
        List<ObjectBucketACL> dbBucketAclList = queryDbBucketAcl(args, buckeId);
        Iterator<ObjectBucketACL> dbAclIter = dbBucketAclList.iterator();
        while (dbAclIter.hasNext()) {
            ObjectBucketACL dbBucketAcl = dbAclIter.next();
            BucketACE ace = new BucketACE();
            ace.setDomain(dbBucketAcl.getDomain());
            ace.setBucketName(dbBucketAcl.getBucketName());
            ace.setGroup(dbBucketAcl.getGroup());
            ace.setPermissions(dbBucketAcl.getPermissions());
            ace.setNamespace(dbBucketAcl.getNamespace());
            ace.setUser(dbBucketAcl.getUser());
            ace.setCustomGroup(dbBucketAcl.getCustomGroup());
            acl.add(ace);
        }
    } catch (Exception e) {
        _log.error("Error while querying ACL(s) of a share {}", e);
    }
    return acl;
}
Also used : ArrayList(java.util.ArrayList) BucketACE(com.emc.storageos.model.object.BucketACE) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) 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