use of org.apache.camel.component.dropbox.dto.DropboxSearchResult in project camel by apache.
the class DropboxScheduledPollSearchConsumer method poll.
/**
* Poll from a dropbox remote path and put the result in the message exchange
* @return number of messages polled
* @throws Exception
*/
@Override
protected int poll() throws Exception {
Exchange exchange = endpoint.createExchange();
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());
if (LOG.isDebugEnabled()) {
LOG.debug("Downloaded: {}", result.toString());
}
try {
// send message to next processor in the route
getProcessor().process(exchange);
// number of messages polled
return 1;
} finally {
// log exception if an exception occurred and was not handled
if (exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
}
}
use of org.apache.camel.component.dropbox.dto.DropboxSearchResult 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());
}
Aggregations