Search in sources :

Example 1 with ShareACLs

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

the class FileSnapshotService method getSnapshotShareACLs.

/**
 * Get Snapshot Share ACLs
 *
 * @param id
 *            the file system URI
 * @param shareName
 *            name of the share
 * @brief List snapshot share ACLs
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ShareACLs getSnapshotShareACLs(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
    _log.info("Request recieved to get ACLs with Id: {}  shareName: {}", id, shareName);
    // Validate the FS id
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    Snapshot snapshot = queryResource(id);
    ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
    if (!CifsShareUtility.doesShareExist(snapshot, shareName)) {
        _log.error("CIFS share does not exist {}", shareName);
        throw APIException.notFound.invalidParameterObjectHasNoSuchShare(snapshot.getId(), shareName);
    }
    ShareACLs acls = new ShareACLs();
    CifsShareUtility util = new CifsShareUtility(_dbClient, null, snapshot, shareName);
    List<ShareACL> shareAclList = util.queryExistingShareACLs();
    _log.info("Number of existing ACLs found : {} ", shareAclList.size());
    if (!shareAclList.isEmpty()) {
        acls.setShareACLs(shareAclList);
    }
    return acls;
}
Also used : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) ShareACLs(com.emc.storageos.model.file.ShareACLs) CifsShareUtility(com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility) ShareACL(com.emc.storageos.model.file.ShareACL) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ShareACLs

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

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

the class FileStorageUtils method createShareACLs.

public static ShareACLs createShareACLs(FileSystemACLs[] acls) {
    ShareACLs aclsToAdd = new ShareACLs();
    List<ShareACL> aclList = new ArrayList<ShareACL>();
    for (FileSystemACLs fileSystemACL : acls) {
        ShareACL shareAcl = new ShareACL();
        if (fileSystemACL.aclType.equalsIgnoreCase("GROUP")) {
            shareAcl.setGroup(fileSystemACL.aclName);
        } else {
            shareAcl.setUser(fileSystemACL.aclName);
        }
        if (!StringUtils.isEmpty(fileSystemACL.aclDomain)) {
            shareAcl.setDomain(fileSystemACL.aclDomain);
        }
        shareAcl.setPermission(fileSystemACL.aclPermission);
        aclList.add(shareAcl);
    }
    aclsToAdd.setShareACLs(aclList);
    return aclsToAdd;
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) SetFileSystemShareACL(com.emc.sa.service.vipr.file.tasks.SetFileSystemShareACL) ShareACL(com.emc.storageos.model.file.ShareACL) SetFileSnapshotShareACL(com.emc.sa.service.vipr.file.tasks.SetFileSnapshotShareACL)

Example 4 with ShareACLs

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

the class FileSnapshots method removeSnapShotAcl.

/**
 * This method called When user selects ACLs and hit delete button.
 *
 * @param aclURL
 *            URL of the snapshot share.
 * @param ids
 *            ids of the selected ACL
 */
@FlashException(referrer = { "snapshot" })
public static void removeSnapShotAcl(String aclUrl, @As(",") String[] ids) {
    ShareACLs aclsToDelete = new ShareACLs();
    List<ShareACL> shareAcls = new ArrayList<ShareACL>();
    String snapshotId = null;
    String shareName = null;
    if (ids != null && ids.length > 0) {
        for (String id : ids) {
            String type = SnapshotShareACLForm.extractTypeFromId(id);
            String name = SnapshotShareACLForm.extractNameFromId(id);
            String domain = SnapshotShareACLForm.extractDomainFromId(id);
            snapshotId = SnapshotShareACLForm.extractSnapshotFromId(id);
            shareName = SnapshotShareACLForm.extractShareNameFromId(id);
            ShareACL ace = new ShareACL();
            if (SnapshotShareACLForm.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);
        SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
        input.setAclsToDelete(aclsToDelete);
        ViPRCoreClient client = BourneUtil.getViprClient();
        client.fileSnapshots().updateShareACL(uri(snapshotId), shareName, input);
    }
    flash.success(MessagesUtils.get("resources.filesystem.share.acl.deleted"));
    listSnapshotAcl(snapshotId, shareName);
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) 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 5 with ShareACLs

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

the class FileSnapshots method createSnapshotCifsShareAclParams.

private static SnapshotCifsShareACLUpdateParams createSnapshotCifsShareAclParams(String formData) {
    String[] uiAcls = formData.split(",");
    List<ShareACL> acls = new ArrayList<ShareACL>();
    for (String uiAce : uiAcls) {
        String[] uiData = uiAce.split("~~~");
        String uiType = uiData[0];
        String uiName = uiData[1];
        String uiDomain = uiData[2];
        String uiPermission = uiData[3];
        ShareACL shareAcl = new ShareACL();
        if ("GROUP".equalsIgnoreCase(uiType)) {
            shareAcl.setGroup(uiName);
        } else {
            shareAcl.setUser(uiName);
        }
        shareAcl.setPermission(uiPermission);
        if (uiDomain != null && !"".equals(uiDomain)) {
            shareAcl.setDomain(uiDomain);
        }
        acls.add(shareAcl);
    }
    SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
    ShareACLs aclsToAdd = new ShareACLs();
    aclsToAdd.setShareACLs(acls);
    input.setAclsToAdd(aclsToAdd);
    return input;
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL)

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