Search in sources :

Example 11 with ShareACLs

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

the class FileSystems method saveAce.

/**
 * This method called When user Modifies ACE.
 *
 * @param shareACL
 *            Form Data from modify screen.
 */
@FlashException(referrer = { "fileSystem" })
public static void saveAce(ShareACLForm shareACL) {
    String name = params.get("name");
    String type = params.get("type");
    String domain = params.get("domain");
    String shareName = params.get("shareName");
    String fileSystemId = params.get("fileSystemId");
    String permission = shareACL.permission;
    List<ShareACL> ace = new ArrayList<ShareACL>();
    ShareACL shareAcl = new ShareACL();
    ShareACLs aclsToModify = new ShareACLs();
    if ("GROUP".equalsIgnoreCase(type)) {
        shareAcl.setGroup(name);
    } else {
        shareAcl.setUser(name);
    }
    shareAcl.setPermission(permission);
    if (domain != null && !"".equals(domain)) {
        shareAcl.setDomain(domain);
    }
    ace.add(shareAcl);
    aclsToModify.setShareACLs(ace);
    FileCifsShareACLUpdateParams input = new FileCifsShareACLUpdateParams();
    input.setAclsToModify(aclsToModify);
    ViPRCoreClient client = BourneUtil.getViprClient();
    client.fileSystems().updateShareACL(uri(fileSystemId), shareName, input);
    listAcl(fileSystemId, shareName);
}
Also used : FileCifsShareACLUpdateParams(com.emc.storageos.model.file.FileCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) FlashException(controllers.util.FlashException)

Example 12 with ShareACLs

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

the class FileSystems method removeAcl.

/**
 * This method called When user selects ACLs and hit delete button.
 *
 * @param aclURL
 *            URL of the file system share.
 * @param ids
 *            ids of the selected ACL
 */
@FlashException(referrer = { "fileSystem" })
public static void removeAcl(String aclUrl, @As(",") String[] ids) {
    ShareACLs aclsToDelete = new ShareACLs();
    List<ShareACL> shareAcls = new ArrayList<ShareACL>();
    String fileSystem = null;
    String shareName = null;
    if (ids != null && ids.length > 0) {
        for (String id : ids) {
            String type = ShareACLForm.extractTypeFromId(id);
            String name = ShareACLForm.extractNameFromId(id);
            String domain = ShareACLForm.extractDomainFromId(id);
            fileSystem = ShareACLForm.extractFileSystemFromId(id);
            shareName = ShareACLForm.extractShareNameFromId(id);
            ShareACL ace = new ShareACL();
            if ("Group".equalsIgnoreCase(type)) {
                ace.setGroup(name);
            } else {
                ace.setUser(name);
            }
            if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
                ace.setDomain(domain);
            }
            shareAcls.add(ace);
        }
        aclsToDelete.setShareACLs(shareAcls);
        FileCifsShareACLUpdateParams input = new FileCifsShareACLUpdateParams();
        input.setAclsToDelete(aclsToDelete);
        ViPRCoreClient client = BourneUtil.getViprClient();
        client.fileSystems().updateShareACL(uri(fileSystem), shareName, input);
    }
    flash.success(MessagesUtils.get(DELETED));
    listAcl(fileSystem, shareName);
}
Also used : FileCifsShareACLUpdateParams(com.emc.storageos.model.file.FileCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) FlashException(controllers.util.FlashException)

Example 13 with ShareACLs

use of com.emc.storageos.model.file.ShareACLs 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 14 with ShareACLs

use of com.emc.storageos.model.file.ShareACLs 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)

Example 15 with ShareACLs

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

the class CifsShareUtility method verifyShareACLs.

public void verifyShareACLs(CifsShareACLUpdateParams param) {
    ShareACLs shareAcls = null;
    // Add Payload
    shareAcls = param.getAclsToAdd();
    validateShareACLs(shareAcls, ShareACLOperationType.ADD);
    reportErrors(param, ShareACLOperationType.ADD);
    // Modify Payload
    shareAcls = param.getAclsToModify();
    validateShareACLs(shareAcls, ShareACLOperationType.MODIFY);
    reportErrors(param, ShareACLOperationType.MODIFY);
    // Delete Payload
    shareAcls = param.getAclsToDelete();
    validateShareACLs(shareAcls, ShareACLOperationType.DELETE);
    reportErrors(param, ShareACLOperationType.DELETE);
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs)

Aggregations

ShareACLs (com.emc.storageos.model.file.ShareACLs)16 ShareACL (com.emc.storageos.model.file.ShareACL)13 ArrayList (java.util.ArrayList)7 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)4 FileCifsShareACLUpdateParams (com.emc.storageos.model.file.FileCifsShareACLUpdateParams)4 ShareACLOperationErrorType (com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType)3 SnapshotCifsShareACLUpdateParams (com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 FlashException (controllers.util.FlashException)3 CifsShareUtility (com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2