Search in sources :

Example 36 with ShareACL

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

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