Search in sources :

Example 1 with ShareACLOperationErrorType

use of com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType in project coprhd-controller by CoprHD.

the class CifsShareUtility method reportModifyErrors.

private void reportModifyErrors(CifsShareACLUpdateParams param) {
    String opName = ShareACLOperationType.MODIFY.name();
    // Report Add ACL Errors
    ShareACLs shareAcls = param.getAclsToModify();
    if (shareAcls == null || shareAcls.getShareACLs().isEmpty()) {
        return;
    }
    List<ShareACL> shareAclList = shareAcls.getShareACLs();
    for (ShareACL acl : shareAclList) {
        if (!acl.canProceedToNextStep()) {
            ShareACLOperationErrorType error = acl.getErrorType();
            switch(error) {
                case SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY:
                    {
                        throw APIException.badRequests.snapshotSMBSharePermissionReadOnly();
                    }
                case INVALID_PERMISSION:
                    {
                        if (acl.getPermission() != null) {
                            throw APIException.badRequests.invalidPermissionForACL(acl.getPermission());
                        } else {
                            throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSION);
                        }
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.bothUserAndGroupInACLFound(acl.getUser(), acl.getGroup());
                    }
                case USER_OR_GROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
                    {
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
                    }
                case ACL_NOT_FOUND:
                    {
                        throw APIException.badRequests.shareACLNotFoundFound(opName, acl.toString());
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = acl.getDomain();
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_EXISTS:
                default:
                    break;
            }
        }
    }
}
Also used : ShareACLOperationErrorType(com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType) ShareACLs(com.emc.storageos.model.file.ShareACLs) ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 2 with ShareACLOperationErrorType

use of com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType in project coprhd-controller by CoprHD.

the class CifsShareUtility method reportDeleteErrors.

private void reportDeleteErrors(CifsShareACLUpdateParams param) {
    String opName = ShareACLOperationType.DELETE.name();
    // Report Add ACL Errors
    ShareACLs shareAcls = param.getAclsToDelete();
    if (shareAcls == null || shareAcls.getShareACLs().isEmpty()) {
        return;
    }
    List<ShareACL> shareAclList = shareAcls.getShareACLs();
    for (ShareACL acl : shareAclList) {
        if (!acl.canProceedToNextStep()) {
            ShareACLOperationErrorType error = acl.getErrorType();
            switch(error) {
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.bothUserAndGroupInACLFound(acl.getUser(), acl.getGroup());
                    }
                case USER_OR_GROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
                    {
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = acl.getDomain();
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_NOT_FOUND:
                    {
                        throw APIException.badRequests.shareACLNotFoundFound(opName, acl.toString());
                    }
                default:
                    break;
            }
        }
    }
}
Also used : ShareACLOperationErrorType(com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType) ShareACLs(com.emc.storageos.model.file.ShareACLs) ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 3 with ShareACLOperationErrorType

use of com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType in project coprhd-controller by CoprHD.

the class CifsShareUtility method reportAddErrors.

private void reportAddErrors(CifsShareACLUpdateParams param) {
    String opName = ShareACLOperationType.ADD.name();
    // Report Add ACL Errors
    ShareACLs shareAcls = param.getAclsToAdd();
    if (shareAcls == null || shareAcls.getShareACLs().isEmpty()) {
        return;
    }
    List<ShareACL> shareAclList = shareAcls.getShareACLs();
    for (ShareACL acl : shareAclList) {
        if (!acl.canProceedToNextStep()) {
            ShareACLOperationErrorType error = acl.getErrorType();
            switch(error) {
                case SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY:
                    {
                        throw APIException.badRequests.snapshotSMBSharePermissionReadOnly();
                    }
                case INVALID_PERMISSION:
                    {
                        if (acl.getPermission() != null) {
                            throw APIException.badRequests.invalidPermissionForACL(acl.getPermission());
                        } else {
                            throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSION);
                        }
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.bothUserAndGroupInACLFound(acl.getUser(), acl.getGroup());
                    }
                case USER_OR_GROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
                    {
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = acl.getDomain();
                        String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
                        String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_EXISTS:
                    {
                        throw APIException.badRequests.shareACLAlreadyExists(opName, acl.toString());
                    }
                // case ACL_NOT_FOUND:
                default:
                    break;
            }
        }
    }
}
Also used : ShareACLOperationErrorType(com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType) ShareACLs(com.emc.storageos.model.file.ShareACLs) ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Aggregations

CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)3 ShareACLOperationErrorType (com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType)3 ShareACL (com.emc.storageos.model.file.ShareACL)3 ShareACLs (com.emc.storageos.model.file.ShareACLs)3