Search in sources :

Example 1 with BucketACLOperationErrorType

use of com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType in project coprhd-controller by CoprHD.

the class BucketACLUtility method reportModifyErrors.

private void reportModifyErrors(BucketACLUpdateParams param) {
    String opName = BucketACLOperationType.MODIFY.name();
    // Report Add ACL Errors
    BucketACL bucketACL = param.getAclToModify();
    if (bucketACL == null || bucketACL.getBucketACL().isEmpty()) {
        return;
    }
    List<BucketACE> bucketACEList = bucketACL.getBucketACL();
    for (BucketACE bucketACE : bucketACEList) {
        if (!bucketACE.canProceedToNextStep()) {
            BucketACLOperationErrorType error = bucketACE.getErrorType();
            switch(error) {
                case INVALID_PERMISSIONS:
                    {
                        if (bucketACE.getPermissions() != null) {
                            throw APIException.badRequests.invalidPermissionForBucketACL(bucketACE.getPermissions());
                        } else {
                            throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSIONS);
                        }
                    }
                case USER_AND_GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), null);
                    }
                case USER_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), null, bucketACE.getCustomGroup());
                    }
                case GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(null, bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_OR_GROUP_OR_CUSTOMGROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupOrCustomGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP_CUSTOMGROUP:
                    {
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        throw APIException.badRequests.multipleACLsWithUserOrGroupOrCustomGroupFound(opName, userOrGroupOrCustomgroup);
                    }
                case ACL_NOT_FOUND:
                    {
                        throw APIException.badRequests.bucketACLNotFound(opName, bucketACE.toString());
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = bucketACE.getDomain();
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        String domain2 = userOrGroupOrCustomgroup.substring(0, userOrGroupOrCustomgroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_EXISTS:
                default:
                    break;
            }
        }
    }
}
Also used : BucketACLOperationErrorType(com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL) BucketACL(com.emc.storageos.model.object.BucketACL) BucketACE(com.emc.storageos.model.object.BucketACE)

Example 2 with BucketACLOperationErrorType

use of com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType in project coprhd-controller by CoprHD.

the class BucketACLUtility method reportAddErrors.

private void reportAddErrors(BucketACLUpdateParams param) {
    String opName = BucketACLOperationType.ADD.name();
    // Report Add ACL Errors
    BucketACL bucketAcl = param.getAclToAdd();
    if (bucketAcl == null || bucketAcl.getBucketACL().isEmpty()) {
        return;
    }
    List<BucketACE> bucketACEList = bucketAcl.getBucketACL();
    for (BucketACE bucketACE : bucketACEList) {
        if (!bucketACE.canProceedToNextStep()) {
            BucketACLOperationErrorType error = bucketACE.getErrorType();
            switch(error) {
                case INVALID_PERMISSIONS:
                    {
                        if (bucketACE.getPermissions() != null) {
                            throw APIException.badRequests.invalidPermissionForBucketACL(bucketACE.getPermissions());
                        } else {
                            throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSIONS);
                        }
                    }
                case USER_AND_GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), null);
                    }
                case USER_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), null, bucketACE.getCustomGroup());
                    }
                case GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(null, bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_OR_GROUP_OR_CUSTOMGROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupOrCustomGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP_CUSTOMGROUP:
                    {
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        throw APIException.badRequests.multipleACLsWithUserOrGroupOrCustomGroupFound(opName, userOrGroupOrCustomgroup);
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = bucketACE.getDomain();
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        String domain2 = userOrGroupOrCustomgroup.substring(0, userOrGroupOrCustomgroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_EXISTS:
                    {
                        throw APIException.badRequests.bucketACLAlreadyExists(opName, bucketACE.toString());
                    }
                // case ACL_NOT_FOUND:
                default:
                    break;
            }
        }
    }
}
Also used : BucketACLOperationErrorType(com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL) BucketACL(com.emc.storageos.model.object.BucketACL) BucketACE(com.emc.storageos.model.object.BucketACE)

Example 3 with BucketACLOperationErrorType

use of com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType in project coprhd-controller by CoprHD.

the class BucketACLUtility method reportDeleteErrors.

private void reportDeleteErrors(BucketACLUpdateParams param) {
    String opName = BucketACLOperationType.DELETE.name();
    // Report Add ACL Errors
    BucketACL bucketACL = param.getAclToDelete();
    if (bucketACL == null || bucketACL.getBucketACL().isEmpty()) {
        return;
    }
    List<BucketACE> bucketACELits = bucketACL.getBucketACL();
    for (BucketACE bucketACE : bucketACELits) {
        if (!bucketACE.canProceedToNextStep()) {
            BucketACLOperationErrorType error = bucketACE.getErrorType();
            switch(error) {
                case USER_AND_GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), null);
                    }
                case USER_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), null, bucketACE.getCustomGroup());
                    }
                case GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(null, bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_OR_GROUP_OR_CUSTOMGROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupOrCustomGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP_CUSTOMGROUP:
                    {
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        throw APIException.badRequests.multipleACLsWithUserOrGroupOrCustomGroupFound(opName, userOrGroupOrCustomgroup);
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = bucketACE.getDomain();
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        String domain2 = userOrGroupOrCustomgroup.substring(0, userOrGroupOrCustomgroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_NOT_FOUND:
                    {
                        throw APIException.badRequests.bucketACLNotFound(opName, bucketACE.toString());
                    }
                default:
                    break;
            }
        }
    }
}
Also used : BucketACLOperationErrorType(com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL) BucketACL(com.emc.storageos.model.object.BucketACL) BucketACE(com.emc.storageos.model.object.BucketACE)

Aggregations

ObjectBucketACL (com.emc.storageos.db.client.model.ObjectBucketACL)3 BucketACE (com.emc.storageos.model.object.BucketACE)3 BucketACL (com.emc.storageos.model.object.BucketACL)3 BucketACLOperationErrorType (com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType)3