use of com.emc.storageos.model.file.NfsACE in project coprhd-controller by CoprHD.
the class FileSystems method removeNfsAcl.
@FlashException(referrer = { "fileSystem" })
public static void removeNfsAcl(@As(",") String[] ids) {
List<NfsACE> aces = Lists.newArrayList();
String fileSystem = null;
String subDir = null;
String fsMountPath = null;
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = NfsACLForm.extractTypeFromId(id);
String name = NfsACLForm.extractNameFromId(id);
String domain = NfsACLForm.extractDomainFromId(id);
String permissions = NfsACLForm.extractPermissionsFromId(id);
String permissionType = NfsACLForm.extractPermissionTypeFromId(id);
fileSystem = NfsACLForm.extractFileSystemFromId(id);
subDir = NfsACLForm.extractSubDirFromId(id);
fsMountPath = NfsACLForm.extractMounPathFromId(id);
NfsACE ace = new NfsACE();
ace.setUser(name);
ace.setType(type);
ace.setPermissions(permissions.replaceAll("/", ","));
ace.setPermissionType(permissionType);
if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
ace.setDomain(domain);
}
aces.add(ace);
}
FileNfsACLUpdateParams input = new FileNfsACLUpdateParams();
input.setAcesToDelete(aces);
if (subDir != null && !"null".equals(subDir)) {
input.setSubDir(subDir);
}
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSystems().updateNfsACL(uri(fileSystem), input);
}
flash.success(MessagesUtils.get(DELETED));
listNfsAcl(fileSystem, fsMountPath, subDir);
}
use of com.emc.storageos.model.file.NfsACE in project coprhd-controller by CoprHD.
the class NfsACLUtility method validateNfsAceSyntax.
/**
* To verify the syntax of payload
*
* @param nfsAces list of the ACE need to be validated
*/
private void validateNfsAceSyntax(List<NfsACE> nfsAces) {
for (NfsACE ace : nfsAces) {
// PermissionType is optional , if provided check it is proper
if (ace.getPermissionType() != null && !ace.getPermissionType().isEmpty()) {
if (!isValidEnum(ace.getPermissionType(), NfsPermissionType.class)) {
throw APIException.badRequests.invalidPermissionType(ace.getPermissionType());
}
}
// user type is optional , if provided check it is proper
if (ace.getType() != null && !ace.getType().isEmpty()) {
if (!isValidEnum(ace.getType(), NfsUserType.class)) {
throw APIException.badRequests.invalidUserType(ace.getType());
}
}
for (String permission : ace.getPermissionSet()) {
if (!isValidEnum(permission, NfsPermission.class)) {
throw APIException.badRequests.invalidNFSPermission(permission);
}
}
// check if two times domain is provided
int index = ace.getUser().indexOf("\\");
if (index >= 0) {
if (ace.getDomain() != null && !ace.getDomain().isEmpty()) {
throw APIException.badRequests.multipleDomainsFound("update", ace.getDomain(), ace.getUser().substring(0, index));
} else {
// verify the username provided with domain and user
String[] domainAndUser = ace.getUser().split("\\");
if (domainAndUser.length > 2) {
throw APIException.badRequests.multipleDomainsFound("update", domainAndUser[0], domainAndUser[1]);
}
// this is required to store value in DB in one format
if (domainAndUser.length == 2) {
ace.setDomain(domainAndUser[0]);
ace.setUser(domainAndUser[1]);
}
}
}
}
}
use of com.emc.storageos.model.file.NfsACE in project coprhd-controller by CoprHD.
the class NfsACLUtility method verifyNfsACLs.
/**
* This function verify the NfsACLUpdateParams data provided by user to set ACL is valid or not
* it throw exception for invalid NfsACLUpdateParams data
*
* @param param : input ACLs to be updated.
*/
public void verifyNfsACLs(NfsACLUpdateParams param) {
List<NfsACE> addList = param.getAcesToAdd();
List<NfsACE> modifyList = param.getAcesToModify();
List<NfsACE> deleteList = param.getAcesToDelete();
List<NFSShareACL> dbACLList = queryDBSFileNfsACLs(false);
Set<String> userSetDB = new HashSet<String>();
for (NFSShareACL dbAcl : dbACLList) {
userSetDB.add(dbAcl.getUser());
}
if (addList != null && !addList.isEmpty()) {
verifyNfsACLsAddList(addList, userSetDB);
}
if (modifyList != null && !modifyList.isEmpty()) {
verifyNfsACLsModifyOrDeleteList(modifyList, userSetDB);
}
if (deleteList != null && !deleteList.isEmpty()) {
verifyNfsACLsModifyOrDeleteList(deleteList, userSetDB);
}
}
Aggregations