Search in sources :

Example 1 with SnapshotCifsShareACLUpdateParams

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

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

Example 3 with SnapshotCifsShareACLUpdateParams

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

the class SetFileSnapshotShareACL method doExecute.

@Override
protected Task<FileSnapshotRestRep> doExecute() throws Exception {
    SnapshotCifsShareACLUpdateParams aclUpdate = new SnapshotCifsShareACLUpdateParams();
    ShareACLs shareACLs = FileStorageUtils.createShareACLs(acls);
    aclUpdate.setAclsToAdd(shareACLs);
    return getClient().fileSnapshots().updateShareACL(fileSystemId, shareName, aclUpdate);
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ShareACLs(com.emc.storageos.model.file.ShareACLs)

Example 4 with SnapshotCifsShareACLUpdateParams

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

the class FileSnapshots method addSnapshotAcl.

/**
 * This method called when user Adds an access control entry from UI.
 *
 * @param aclURL
 *            URL of the snapshot share.
 * @param shareACL
 *            This contains the form data from UI.
 */
public static void addSnapshotAcl(String aclURL, SnapshotShareACLForm shareACL, String formAccessControlList) {
    String snapshotId = null;
    String shareName = null;
    if (StringUtils.isNotBlank(aclURL)) {
        String[] parts = aclURL.split("/");
        if (parts.length == 7) {
            snapshotId = parts[3];
            shareName = parts[5];
        }
    }
    if (formAccessControlList == null || "".equals(formAccessControlList)) {
        flash.error(MessagesUtils.get("resources.filesystem.share.acl.invalid.settings"), null);
        listSnapshotAcl(snapshotId, shareName);
    }
    SnapshotCifsShareACLUpdateParams input = createSnapshotCifsShareAclParams(formAccessControlList);
    ViPRCoreClient client = BourneUtil.getViprClient();
    try {
        client.fileSnapshots().updateShareACL(uri(snapshotId), shareName, input);
    } catch (ServiceErrorException e) {
        flash.error(e.getMessage(), null);
        listSnapshotAcl(snapshotId, shareName);
    }
    flash.success(MessagesUtils.get("resources.filesystem.share.acl.added"));
    listSnapshotAcl(snapshotId, shareName);
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

SnapshotCifsShareACLUpdateParams (com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams)4 ShareACLs (com.emc.storageos.model.file.ShareACLs)3 ShareACL (com.emc.storageos.model.file.ShareACL)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ArrayList (java.util.ArrayList)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 FlashException (controllers.util.FlashException)1