use of com.emc.atmos.api.bean.DirectoryEntry in project camel by apache.
the class AtmosAPIFacade method downloadFilesInFolder.
private void downloadFilesInFolder(String atmosPath, Map<String, ByteArrayOutputStream> resultEntries) throws AtmosException {
ObjectPath atmosEntry = new ObjectPath(atmosPath);
if (AtmosAPIFacade.client.getSystemMetadata(atmosEntry) == null) {
throw new AtmosException(atmosPath + " does not exist or cannot obtain metadata");
}
if (!atmosEntry.isDirectory()) {
LOG.debug("downloading a single file...");
downloadSingleFile(atmosPath, resultEntries);
return;
}
ListDirectoryRequest listRequest = new ListDirectoryRequest().path(atmosEntry);
AtmosAPIFacade.client.listDirectory(listRequest);
for (DirectoryEntry entry : AtmosAPIFacade.client.listDirectory(listRequest).getEntries()) {
if (!entry.isDirectory()) {
try {
//get the baos of the file
downloadSingleFile(atmosEntry.getPath().concat(entry.getFilename()), resultEntries);
} catch (AtmosException e) {
LOG.warn("Cannot download from " + entry.getFilename());
}
} else {
//iterate on folder
downloadFilesInFolder(atmosEntry.getPath().concat(entry.getFilename()), resultEntries);
}
}
}
Aggregations