use of com.emc.storageos.model.file.NfsACL in project coprhd-controller by CoprHD.
the class NfsACLUtility method getNfsAclFromDB.
/**
* This function return all the ACL in the DB in the format of xml Object
*
* @param allDirs if true function will return complete list of ACL including its SubDir
* @return list of NFS ACLs.
*/
public NfsACLs getNfsAclFromDB(boolean allDirs) {
NfsACLs acls = new NfsACLs();
List<NfsACL> nfsAclList = new ArrayList<NfsACL>();
Map<String, List<NfsACE>> nfsAclMap = new HashMap<String, List<NfsACE>>();
_log.info("Sub-directory {} and allDirs {}", this.subDir, allDirs);
// Query All ACl Specific to a File System.
List<NFSShareACL> nfsAcls = queryDBSFileNfsACLs(allDirs);
_log.info("Number of existing ACL found : {} ", nfsAcls.size());
// Group the ACLs based on file system path!!!
for (NFSShareACL nfsAcl : nfsAcls) {
String fsPath = nfsAcl.getFileSystemPath();
List<NfsACE> nfsAceList = nfsAclMap.get(fsPath);
if (nfsAceList == null) {
nfsAceList = new ArrayList<NfsACE>();
}
NfsACE ace = getNFSAce(nfsAcl);
nfsAceList.add(ace);
nfsAclMap.put(fsPath, nfsAceList);
}
// Convert all ACE to ACLs!!
for (Map.Entry<String, List<NfsACE>> pathAcls : nfsAclMap.entrySet()) {
String mountPath = pathAcls.getKey();
NfsACL nfsAcl = new NfsACL(mountPath, pathAcls.getValue());
if (mountPath.length() > fs.getPath().length()) {
nfsAcl.setSubDir(mountPath.substring(fs.getPath().length() + 1));
}
nfsAclList.add(nfsAcl);
}
if (!nfsAclList.isEmpty()) {
acls.setNfsACLs(nfsAclList);
}
return acls;
}
use of com.emc.storageos.model.file.NfsACL in project coprhd-controller by CoprHD.
the class FileSystems method listNfsAclJson.
public static void listNfsAclJson(String fileSystemSubDirAndPath) {
renderArgs.put("dataTable", new NfsACLDataTable());
String fileSystemId = null;
String subDir = null;
String fsMountPath = null;
if (StringUtils.isNotBlank(fileSystemSubDirAndPath)) {
String[] parts = fileSystemSubDirAndPath.split("~~~");
if (parts.length == 3) {
fileSystemId = parts[0];
subDir = parts[1];
fsMountPath = parts[2];
}
}
renderArgs.put("subDir", subDir);
renderArgs.put("fsMountPath", fsMountPath);
renderArgs.put("fileSystemId", uri(fileSystemId));
renderArgs.put("fileSystemName", uri(fileSystemId));
ViPRCoreClient client = BourneUtil.getViprClient();
List<NfsACL> nfsAcls = client.fileSystems().getNfsACLs(uri(fileSystemId), subDir);
NfsACL nfsAcl = new NfsACL();
List<NfsACLDataTable.NfsAclInfo> nfsAccessControlList = Lists.newArrayList();
if (nfsAcls.size() > 0) {
nfsAcl = nfsAcls.get(0);
List<NfsACE> acl = nfsAcl.getNfsAces();
for (NfsACE ace : acl) {
String name = ace.getUser();
String type = ace.getType();
String permissions = ace.getPermissions();
String domain = ace.getDomain();
String permissionType = ace.getPermissionType();
nfsAccessControlList.add(new NfsACLDataTable.NfsAclInfo(name, type, permissions, fileSystemId, subDir, domain, fsMountPath, permissionType));
}
}
renderJSON(DataTablesSupport.createJSON(nfsAccessControlList, params));
}
use of com.emc.storageos.model.file.NfsACL in project coprhd-controller by CoprHD.
the class FileSystems method fileSystemNfsACLs.
public static void fileSystemNfsACLs(String fileSystemId) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<NfsACL> nfsAcls = client.fileSystems().getAllNfsACLs(uri(fileSystemId));
render(nfsAcls);
}
Aggregations