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);
}
}
Aggregations