Search in sources :

Example 16 with ShareACLs

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

the class FileDeviceController method updateShareACLsInDB.

private void updateShareACLsInDB(CifsShareACLUpdateParams param, FileShare fs, FileDeviceInputOutput args) {
    try {
        // Create new Acls
        ShareACLs shareAcls = param.getAclsToAdd();
        List<ShareACL> shareAclList = null;
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    dbShareAcl.setId(URIUtil.createId(CifsShareACL.class));
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    _log.info("Storing new acl in DB: {}", dbShareAcl);
                    _dbClient.createObject(dbShareAcl);
                }
            }
        }
        // Modify existing acls
        shareAcls = param.getAclsToModify();
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    CifsShareACL dbShareAclTemp = getExistingShareAclFromDB(dbShareAcl, args);
                    dbShareAcl.setId(dbShareAclTemp.getId());
                    _log.info("Updating acl in DB: {}", dbShareAcl);
                    _dbClient.updateObject(dbShareAcl);
                }
            }
        }
        // Delete existing acls
        shareAcls = param.getAclsToDelete();
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    CifsShareACL dbShareAclTemp = getExistingShareAclFromDB(dbShareAcl, args);
                    dbShareAcl.setId(dbShareAclTemp.getId());
                    dbShareAcl.setInactive(true);
                    _log.info("Marking acl inactive in DB: {}", dbShareAcl);
                    _dbClient.updateObject(dbShareAcl);
                }
            }
        }
    } catch (Exception e) {
        _log.error("Error While executing CRUD Operations {}", e);
    }
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) ShareACL(com.emc.storageos.model.file.ShareACL) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

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