Search in sources :

Example 1 with DirectoryEntry

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);
        }
    }
}
Also used : ObjectPath(com.emc.atmos.api.ObjectPath) AtmosException(org.apache.camel.component.atmos.util.AtmosException) ListDirectoryRequest(com.emc.atmos.api.request.ListDirectoryRequest) DirectoryEntry(com.emc.atmos.api.bean.DirectoryEntry)

Aggregations

ObjectPath (com.emc.atmos.api.ObjectPath)1 DirectoryEntry (com.emc.atmos.api.bean.DirectoryEntry)1 ListDirectoryRequest (com.emc.atmos.api.request.ListDirectoryRequest)1 AtmosException (org.apache.camel.component.atmos.util.AtmosException)1