use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSnapshotService method getSnapshotShareACLs.
/**
* Get Snapshot Share ACLs
*
* @param id
* the file system URI
* @param shareName
* name of the share
* @brief List snapshot share ACLs
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ShareACLs getSnapshotShareACLs(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
_log.info("Request recieved to get ACLs with Id: {} shareName: {}", id, shareName);
// Validate the FS id
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
ArgValidator.checkFieldNotNull(shareName, "shareName");
Snapshot snapshot = queryResource(id);
ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
if (!CifsShareUtility.doesShareExist(snapshot, shareName)) {
_log.error("CIFS share does not exist {}", shareName);
throw APIException.notFound.invalidParameterObjectHasNoSuchShare(snapshot.getId(), shareName);
}
ShareACLs acls = new ShareACLs();
CifsShareUtility util = new CifsShareUtility(_dbClient, null, snapshot, shareName);
List<ShareACL> shareAclList = util.queryExistingShareACLs();
_log.info("Number of existing ACLs found : {} ", shareAclList.size());
if (!shareAclList.isEmpty()) {
acls.setShareACLs(shareAclList);
}
return acls;
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class CifsShareUtility method reportModifyErrors.
private void reportModifyErrors(CifsShareACLUpdateParams param) {
String opName = ShareACLOperationType.MODIFY.name();
// Report Add ACL Errors
ShareACLs shareAcls = param.getAclsToModify();
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 ACL_NOT_FOUND:
{
throw APIException.badRequests.shareACLNotFoundFound(opName, acl.toString());
}
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:
default:
break;
}
}
}
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileStorageUtils method createShareACLs.
public static ShareACLs createShareACLs(FileSystemACLs[] acls) {
ShareACLs aclsToAdd = new ShareACLs();
List<ShareACL> aclList = new ArrayList<ShareACL>();
for (FileSystemACLs fileSystemACL : acls) {
ShareACL shareAcl = new ShareACL();
if (fileSystemACL.aclType.equalsIgnoreCase("GROUP")) {
shareAcl.setGroup(fileSystemACL.aclName);
} else {
shareAcl.setUser(fileSystemACL.aclName);
}
if (!StringUtils.isEmpty(fileSystemACL.aclDomain)) {
shareAcl.setDomain(fileSystemACL.aclDomain);
}
shareAcl.setPermission(fileSystemACL.aclPermission);
aclList.add(shareAcl);
}
aclsToAdd.setShareACLs(aclList);
return aclsToAdd;
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSnapshots method removeSnapShotAcl.
/**
* This method called When user selects ACLs and hit delete button.
*
* @param aclURL
* URL of the snapshot share.
* @param ids
* ids of the selected ACL
*/
@FlashException(referrer = { "snapshot" })
public static void removeSnapShotAcl(String aclUrl, @As(",") String[] ids) {
ShareACLs aclsToDelete = new ShareACLs();
List<ShareACL> shareAcls = new ArrayList<ShareACL>();
String snapshotId = null;
String shareName = null;
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = SnapshotShareACLForm.extractTypeFromId(id);
String name = SnapshotShareACLForm.extractNameFromId(id);
String domain = SnapshotShareACLForm.extractDomainFromId(id);
snapshotId = SnapshotShareACLForm.extractSnapshotFromId(id);
shareName = SnapshotShareACLForm.extractShareNameFromId(id);
ShareACL ace = new ShareACL();
if (SnapshotShareACLForm.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);
SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
input.setAclsToDelete(aclsToDelete);
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSnapshots().updateShareACL(uri(snapshotId), shareName, input);
}
flash.success(MessagesUtils.get("resources.filesystem.share.acl.deleted"));
listSnapshotAcl(snapshotId, shareName);
}
use of com.emc.storageos.model.file.ShareACLs in project coprhd-controller by CoprHD.
the class FileSnapshots method createSnapshotCifsShareAclParams.
private static SnapshotCifsShareACLUpdateParams createSnapshotCifsShareAclParams(String formData) {
String[] uiAcls = formData.split(",");
List<ShareACL> acls = new ArrayList<ShareACL>();
for (String uiAce : uiAcls) {
String[] uiData = uiAce.split("~~~");
String uiType = uiData[0];
String uiName = uiData[1];
String uiDomain = uiData[2];
String uiPermission = uiData[3];
ShareACL shareAcl = new ShareACL();
if ("GROUP".equalsIgnoreCase(uiType)) {
shareAcl.setGroup(uiName);
} else {
shareAcl.setUser(uiName);
}
shareAcl.setPermission(uiPermission);
if (uiDomain != null && !"".equals(uiDomain)) {
shareAcl.setDomain(uiDomain);
}
acls.add(shareAcl);
}
SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
ShareACLs aclsToAdd = new ShareACLs();
aclsToAdd.setShareACLs(acls);
input.setAclsToAdd(aclsToAdd);
return input;
}
Aggregations