use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.
the class CifsShareUtility method getExistingACL.
private CifsShareACL getExistingACL(ShareACL requestAcl) {
CifsShareACL acl = null;
String domainOfReqAce = requestAcl.getDomain();
if (domainOfReqAce == null) {
domainOfReqAce = "";
}
String userOrGroup = requestAcl.getUser() == null ? requestAcl.getGroup() : requestAcl.getUser();
// Construct ACL Index
StringBuffer aclIndex = new StringBuffer();
aclIndex.append(this.fs == null ? this.snapshot.getId().toString() : this.fs.getId().toString());
aclIndex.append(this.shareName).append(domainOfReqAce).append(userOrGroup);
acl = this.queryACLByIndex(aclIndex.toString());
return acl;
}
use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.
the class FileDeviceController method queryDBShareAcls.
private List<CifsShareACL> queryDBShareAcls(FileDeviceInputOutput args) {
List<CifsShareACL> acls = new ArrayList<CifsShareACL>();
try {
ContainmentConstraint containmentConstraint = null;
if (args.getFileOperation()) {
FileShare fs = args.getFs();
_log.info("Querying DB for Share ACLs of share {} of filesystemId {} ", args.getShareName(), fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileCifsShareAclsConstraint(fs.getId());
} else {
URI snapshotId = args.getSnapshotId();
_log.info("Querying DB for Share ACLs of share {} of snapshotId {} ", args.getShareName(), snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotCifsShareAclsConstraint(snapshotId);
}
List<CifsShareACL> shareAclList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, CifsShareACL.class, containmentConstraint);
Iterator<CifsShareACL> shareAclIter = shareAclList.iterator();
while (shareAclIter.hasNext()) {
CifsShareACL shareAcl = shareAclIter.next();
if (shareAcl != null && args.getShareName().equals(shareAcl.getShareName())) {
acls.add(shareAcl);
}
}
} catch (Exception e) {
_log.error("Error while querying DB for ACL(s) of a share {}", e);
}
return acls;
}
use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteShareACLsFromDB.
private void deleteShareACLsFromDB(FileDeviceInputOutput args) {
List<CifsShareACL> existingDBAclList = queryDBShareAcls(args);
List<CifsShareACL> deleteAclList = new ArrayList<CifsShareACL>();
_log.debug("Inside deleteShareACLsFromDB() to delete ACL of share {} from DB", args.getShareName());
for (Iterator<CifsShareACL> iterator = existingDBAclList.iterator(); iterator.hasNext(); ) {
CifsShareACL cifsShareACL = iterator.next();
if (args.getShareName().equals(cifsShareACL.getShareName())) {
cifsShareACL.setInactive(true);
deleteAclList.add(cifsShareACL);
}
}
if (!deleteAclList.isEmpty()) {
_log.info("Deleting ACL of share {}", args.getShareName());
_dbClient.updateObject(deleteAclList);
}
}
use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.
the class FileDeviceController method createDefaultACEForSMBShare.
/**
* Creates default share ACE for fileshares on VNXe, VXFile and Datadomain
*
* @param id
* URI of filesystem or snapshot
* @param fileShare
* @param storageType
*/
private void createDefaultACEForSMBShare(URI id, FileSMBShare fileShare, String storageType) {
StorageSystem.Type storageSystemType = StorageSystem.Type.valueOf(storageType);
if (storageSystemType.equals(Type.vnxe) || storageSystemType.equals(Type.vnxfile) || storageSystemType.equals(Type.datadomain)) {
SMBFileShare share = fileShare.getSMBFileShare();
CifsShareACL ace = new CifsShareACL();
ace.setUser(FileControllerConstants.CIFS_SHARE_USER_EVERYONE);
String permission = null;
switch(share.getPermission()) {
case "read":
permission = FileControllerConstants.CIFS_SHARE_PERMISSION_READ;
break;
case "change":
permission = FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE;
break;
case "full":
permission = FileControllerConstants.CIFS_SHARE_PERMISSION_FULLCONTROL;
break;
}
ace.setPermission(permission);
ace.setId(URIUtil.createId(CifsShareACL.class));
ace.setShareName(share.getName());
if (URIUtil.isType(id, FileShare.class)) {
ace.setFileSystemId(id);
} else {
ace.setSnapshotId(id);
}
_log.info("Creating default ACE for the share: {}", ace);
_dbClient.createObject(ace);
}
}
use of com.emc.storageos.db.client.model.CifsShareACL 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