use of org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile in project scheduling by ow2-proactive.
the class FileSystem method list.
public static ListFile list(FileObject fo, List<String> includes, List<String> excludes) throws FileSystemException {
fo.refresh();
ListFile answer = new ListFile();
List<String> dirList = Lists.newArrayList();
List<String> fileList = Lists.newArrayList();
List<String> fullList = Lists.newArrayList();
List<FileObject> foundFileObjects = new LinkedList<>();
if (isNullOrEmpty(includes) && isNullOrEmpty(excludes)) {
fo.findFiles(Selectors.SELECT_CHILDREN, false, foundFileObjects);
} else {
FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector(includes, excludes);
fo.findFiles(selector, false, foundFileObjects);
}
for (FileObject child : foundFileObjects) {
FileType type = child.getType();
FileName childName = child.getName();
switch(type) {
case FOLDER:
if (!child.equals(fo)) {
// exclude root directory from the list
String relativePath = fo.getName().getRelativeName(childName);
dirList.add(relativePath);
fullList.add(relativePath);
}
break;
case FILE:
String relativePath = fo.getName().getRelativeName(childName);
fileList.add(relativePath);
fullList.add(relativePath);
break;
default:
throw new RuntimeException("Unknown : " + type);
}
}
Collections.sort(dirList);
Collections.sort(fileList);
Collections.sort(fullList);
answer.setDirectoryListing(dirList);
answer.setFileListing(fileList);
answer.setFullListing(fullList);
return answer;
}
use of org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile in project scheduling by ow2-proactive.
the class SchedulerRestClient method list.
public ListFile list(String sessionId, String dataspacePath, String pathname) throws Exception {
StringBuffer uriTmpl = (new StringBuffer()).append(restEndpointURL).append(addSlashIfMissing(restEndpointURL)).append("data/").append(dataspacePath).append('/');
ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).providerFactory(providerFactory).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(pathname).queryParam("comp", "list");
Response response = null;
try {
response = target.request().header("sessionid", sessionId).get();
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedRestException("User not authenticated or session timeout.");
} else {
throwException(String.format("Cannot list the specified location: %s", pathname), response);
}
}
return response.readEntity(ListFile.class);
} finally {
if (response != null) {
response.close();
}
}
}
Aggregations