Search in sources :

Example 6 with DropboxAPIFacade

use of org.apache.camel.component.dropbox.core.DropboxAPIFacade in project camel by apache.

the class DropboxPutProducer method process.

@Override
public void process(Exchange exchange) throws Exception {
    DropboxFileUploadResult result = new DropboxAPIFacade(configuration.getClient(), exchange).put(configuration.getLocalPath(), configuration.getRemotePath(), configuration.getUploadMode());
    Map<String, DropboxResultCode> map = result.getResults();
    if (map.size() == 1) {
        for (Map.Entry<String, DropboxResultCode> entry : map.entrySet()) {
            exchange.getIn().setHeader(DropboxResultHeader.UPLOADED_FILE.name(), entry.getKey());
            exchange.getIn().setBody(entry.getValue());
        }
    } else {
        StringBuilder pathsExtracted = new StringBuilder();
        for (Map.Entry<String, DropboxResultCode> entry : map.entrySet()) {
            pathsExtracted.append(entry.getKey()).append("\n");
        }
        exchange.getIn().setHeader(DropboxResultHeader.UPLOADED_FILES.name(), pathsExtracted.toString());
        exchange.getIn().setBody(map);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Uploaded: {}", result.toString());
    }
}
Also used : DropboxResultCode(org.apache.camel.component.dropbox.util.DropboxResultCode) DropboxFileUploadResult(org.apache.camel.component.dropbox.dto.DropboxFileUploadResult) Map(java.util.Map) DropboxAPIFacade(org.apache.camel.component.dropbox.core.DropboxAPIFacade)

Example 7 with DropboxAPIFacade

use of org.apache.camel.component.dropbox.core.DropboxAPIFacade in project camel by apache.

the class DropboxSearchProducer method process.

@Override
public void process(Exchange exchange) throws Exception {
    DropboxSearchResult result = new DropboxAPIFacade(configuration.getClient(), exchange).search(configuration.getRemotePath(), configuration.getQuery());
    StringBuilder fileExtracted = new StringBuilder();
    for (DbxEntry entry : result.getFound()) {
        fileExtracted.append(entry.name).append("-").append(entry.path).append("\n");
    }
    exchange.getIn().setHeader(DropboxResultHeader.FOUND_FILES.name(), fileExtracted.toString());
    exchange.getIn().setBody(result.getFound());
}
Also used : DbxEntry(com.dropbox.core.DbxEntry) DropboxSearchResult(org.apache.camel.component.dropbox.dto.DropboxSearchResult) DropboxAPIFacade(org.apache.camel.component.dropbox.core.DropboxAPIFacade)

Aggregations

DropboxAPIFacade (org.apache.camel.component.dropbox.core.DropboxAPIFacade)7 Map (java.util.Map)3 DbxEntry (com.dropbox.core.DbxEntry)2 Exchange (org.apache.camel.Exchange)2 DropboxFileDownloadResult (org.apache.camel.component.dropbox.dto.DropboxFileDownloadResult)2 DropboxSearchResult (org.apache.camel.component.dropbox.dto.DropboxSearchResult)2 DropboxDelResult (org.apache.camel.component.dropbox.dto.DropboxDelResult)1 DropboxFileUploadResult (org.apache.camel.component.dropbox.dto.DropboxFileUploadResult)1 DropboxMoveResult (org.apache.camel.component.dropbox.dto.DropboxMoveResult)1 DropboxResultCode (org.apache.camel.component.dropbox.util.DropboxResultCode)1