use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSystems method saveAce.
/**
* This method called When user Modifies ACE.
*
* @param shareACL
* Form Data from modify screen.
*/
@FlashException(referrer = { "fileSystem" })
public static void saveAce(ShareACLForm shareACL) {
String name = params.get("name");
String type = params.get("type");
String domain = params.get("domain");
String shareName = params.get("shareName");
String fileSystemId = params.get("fileSystemId");
String permission = shareACL.permission;
List<ShareACL> ace = new ArrayList<ShareACL>();
ShareACL shareAcl = new ShareACL();
ShareACLs aclsToModify = new ShareACLs();
if ("GROUP".equalsIgnoreCase(type)) {
shareAcl.setGroup(name);
} else {
shareAcl.setUser(name);
}
shareAcl.setPermission(permission);
if (domain != null && !"".equals(domain)) {
shareAcl.setDomain(domain);
}
ace.add(shareAcl);
aclsToModify.setShareACLs(ace);
FileCifsShareACLUpdateParams input = new FileCifsShareACLUpdateParams();
input.setAclsToModify(aclsToModify);
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSystems().updateShareACL(uri(fileSystemId), shareName, input);
listAcl(fileSystemId, shareName);
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSystems method removeAcl.
/**
* This method called When user selects ACLs and hit delete button.
*
* @param aclURL
* URL of the file system share.
* @param ids
* ids of the selected ACL
*/
@FlashException(referrer = { "fileSystem" })
public static void removeAcl(String aclUrl, @As(",") String[] ids) {
ShareACLs aclsToDelete = new ShareACLs();
List<ShareACL> shareAcls = new ArrayList<ShareACL>();
String fileSystem = null;
String shareName = null;
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = ShareACLForm.extractTypeFromId(id);
String name = ShareACLForm.extractNameFromId(id);
String domain = ShareACLForm.extractDomainFromId(id);
fileSystem = ShareACLForm.extractFileSystemFromId(id);
shareName = ShareACLForm.extractShareNameFromId(id);
ShareACL ace = new ShareACL();
if ("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);
FileCifsShareACLUpdateParams input = new FileCifsShareACLUpdateParams();
input.setAclsToDelete(aclsToDelete);
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSystems().updateShareACL(uri(fileSystem), shareName, input);
}
flash.success(MessagesUtils.get(DELETED));
listAcl(fileSystem, shareName);
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class CifsShareUtility method reportDeleteErrors.
private void reportDeleteErrors(CifsShareACLUpdateParams param) {
String opName = ShareACLOperationType.DELETE.name();
// Report Add ACL Errors
ShareACLs shareAcls = param.getAclsToDelete();
if (shareAcls == null || shareAcls.getShareACLs().isEmpty()) {
return;
}
List<ShareACL> shareAclList = shareAcls.getShareACLs();
for (ShareACL acl : shareAclList) {
if (!acl.canProceedToNextStep()) {
ShareACLOperationErrorType error = acl.getErrorType();
switch(error) {
case USER_AND_GROUP_PROVIDED:
{
throw APIException.badRequests.bothUserAndGroupInACLFound(acl.getUser(), acl.getGroup());
}
case USER_OR_GROUP_NOT_PROVIDED:
{
throw APIException.badRequests.missingUserOrGroupInACE(opName);
}
case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
{
String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
}
case MULTIPLE_DOMAINS_FOUND:
{
String domain1 = acl.getDomain();
String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
}
case ACL_NOT_FOUND:
{
throw APIException.badRequests.shareACLNotFoundFound(opName, acl.toString());
}
default:
break;
}
}
}
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class CifsShareUtility method reportAddErrors.
private void reportAddErrors(CifsShareACLUpdateParams param) {
String opName = ShareACLOperationType.ADD.name();
// Report Add ACL Errors
ShareACLs shareAcls = param.getAclsToAdd();
if (shareAcls == null || shareAcls.getShareACLs().isEmpty()) {
return;
}
List<ShareACL> shareAclList = shareAcls.getShareACLs();
for (ShareACL acl : shareAclList) {
if (!acl.canProceedToNextStep()) {
ShareACLOperationErrorType error = acl.getErrorType();
switch(error) {
case SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY:
{
throw APIException.badRequests.snapshotSMBSharePermissionReadOnly();
}
case INVALID_PERMISSION:
{
if (acl.getPermission() != null) {
throw APIException.badRequests.invalidPermissionForACL(acl.getPermission());
} else {
throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSION);
}
}
case USER_AND_GROUP_PROVIDED:
{
throw APIException.badRequests.bothUserAndGroupInACLFound(acl.getUser(), acl.getGroup());
}
case USER_OR_GROUP_NOT_PROVIDED:
{
throw APIException.badRequests.missingUserOrGroupInACE(opName);
}
case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
{
String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
}
case MULTIPLE_DOMAINS_FOUND:
{
String domain1 = acl.getDomain();
String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
}
case ACL_EXISTS:
{
throw APIException.badRequests.shareACLAlreadyExists(opName, acl.toString());
}
// case ACL_NOT_FOUND:
default:
break;
}
}
}
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class CifsShareUtility method verifyShareACLs.
public void verifyShareACLs(CifsShareACLUpdateParams param) {
ShareACLs shareAcls = null;
// Add Payload
shareAcls = param.getAclsToAdd();
validateShareACLs(shareAcls, ShareACLOperationType.ADD);
reportErrors(param, ShareACLOperationType.ADD);
// Modify Payload
shareAcls = param.getAclsToModify();
validateShareACLs(shareAcls, ShareACLOperationType.MODIFY);
reportErrors(param, ShareACLOperationType.MODIFY);
// Delete Payload
shareAcls = param.getAclsToDelete();
validateShareACLs(shareAcls, ShareACLOperationType.DELETE);
reportErrors(param, ShareACLOperationType.DELETE);
}
Aggregations