use of java.nio.file.attribute.FileOwnerAttributeView in project OpenClinica by OpenClinica.
the class SystemController method displayOwnerShipForTomcatDirectory.
public ArrayList<HashMap<String, Object>> displayOwnerShipForTomcatDirectory(File file) throws IOException {
ArrayList<HashMap<String, Object>> listOfHashMaps = new ArrayList<>();
HashMap<String, Object> hashMap = null;
if (file.isDirectory()) {
hashMap = new HashMap<String, Object>();
hashMap.put("Read Access", getReadAccess(file));
hashMap.put("Write Access", getWriteAccess(file));
Path path = Paths.get(file.getCanonicalPath());
FileOwnerAttributeView ownerAttributeView = Files.getFileAttributeView(path, FileOwnerAttributeView.class);
UserPrincipal owner = ownerAttributeView.getOwner();
// hashMap.put("ownership", owner.getName());
hashMap.put("Folder Name", file.getName());
listOfHashMaps.add(hashMap);
int dirCount = getNumberOfSubFolders(file.getCanonicalPath().toString());
if (dirCount != 0) {
hashMap.put("Sub Folders", displayOwnerShipForTomcatSubDirectories(file));
}
}
return listOfHashMaps;
}
Aggregations