Search in sources :

Example 31 with ShareACL

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

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

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

the class CifsShareUtility method queryExistingShareACLs.

public List<ShareACL> queryExistingShareACLs() {
    List<ShareACL> aclList = new ArrayList<ShareACL>();
    List<CifsShareACL> dbShareAclList = queryDBShareACLs();
    if (dbShareAclList != null) {
        Iterator<CifsShareACL> shareAclIter = dbShareAclList.iterator();
        while (shareAclIter.hasNext()) {
            CifsShareACL dbShareAcl = shareAclIter.next();
            if (shareName.equals(dbShareAcl.getShareName())) {
                ShareACL acl = new ShareACL();
                acl.setShareName(shareName);
                acl.setDomain(dbShareAcl.getDomain());
                acl.setUser(dbShareAcl.getUser());
                acl.setGroup(dbShareAcl.getGroup());
                acl.setPermission(dbShareAcl.getPermission());
                if (this.fs != null) {
                    acl.setFileSystemId(this.fs.getId());
                } else {
                    acl.setSnapshotId(this.snapshot.getId());
                }
                aclList.add(acl);
            }
        }
    }
    return aclList;
}
Also used : ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 34 with ShareACL

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

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

ShareACL (com.emc.storageos.model.file.ShareACL)36 ArrayList (java.util.ArrayList)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ShareACLs (com.emc.storageos.model.file.ShareACLs)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)10 NetAppException (com.emc.storageos.netapp.NetAppException)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 NetAppCException (com.emc.storageos.netappc.NetAppCException)4 CifsAcl (com.iwave.ext.netapp.model.CifsAcl)4 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 IsilonSMBShare (com.emc.storageos.isilon.restapi.IsilonSMBShare)3 Permission (com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission)3 ShareACLOperationErrorType (com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType)3 FileCifsShareACLUpdateParams (com.emc.storageos.model.file.FileCifsShareACLUpdateParams)3 NetAppApi (com.emc.storageos.netapp.NetAppApi)3 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)3