Search in sources :

Example 1 with DropboxScheduledPollGetConsumer

use of org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer in project camel by apache.

the class DropboxEndpoint method createConsumer.

/**
     * Create one of the camel consumer available based on the configuration
     * @param processor  the given processor
     * @return the camel consumer
     * @throws Exception
     */
public Consumer createConsumer(Processor processor) throws Exception {
    LOG.trace("Resolve consumer dropbox endpoint {" + configuration.getOperation().toString() + "}");
    LOG.trace("Resolve consumer dropbox attached client:" + configuration.getClient());
    DropboxScheduledPollConsumer consumer;
    if (this.configuration.getOperation() == DropboxOperation.search) {
        consumer = new DropboxScheduledPollSearchConsumer(this, processor, configuration);
        consumer.setDelay(POLL_CONSUMER_DELAY);
        return consumer;
    } else if (this.configuration.getOperation() == DropboxOperation.get) {
        consumer = new DropboxScheduledPollGetConsumer(this, processor, configuration);
        consumer.setDelay(POLL_CONSUMER_DELAY);
        return consumer;
    } else {
        throw new DropboxException("Operation specified is not valid for consumer!");
    }
}
Also used : DropboxScheduledPollSearchConsumer(org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollSearchConsumer) DropboxException(org.apache.camel.component.dropbox.util.DropboxException) DropboxScheduledPollGetConsumer(org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer) DropboxScheduledPollConsumer(org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollConsumer)

Example 2 with DropboxScheduledPollGetConsumer

use of org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer in project camel by apache.

the class DropboxConsumerTest method shouldCreateGetConsumer.

@Test
public void shouldCreateGetConsumer() throws Exception {
    // Given
    Endpoint dropboxEndpoint1 = context.getEndpoint("dropbox://get?accessToken={{accessToken}}&clientIdentifier={{clientIdentifier}}&remotePath=/path");
    // When
    Consumer consumer1 = dropboxEndpoint1.createConsumer(null);
    // Then
    Assert.assertTrue(consumer1 instanceof DropboxScheduledPollGetConsumer);
    // Given
    Endpoint dropboxEndpoint2 = context.getEndpoint("dropbox://get?accessToken={{accessToken}}&clientIdentifier={{clientIdentifier}}&remotePath=/path with spaces/file");
    // When
    Consumer consumer2 = dropboxEndpoint2.createConsumer(null);
    // Then
    Assert.assertTrue(consumer2 instanceof DropboxScheduledPollGetConsumer);
}
Also used : Endpoint(org.apache.camel.Endpoint) DropboxScheduledPollGetConsumer(org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer) Consumer(org.apache.camel.Consumer) DropboxScheduledPollGetConsumer(org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer) Test(org.junit.Test)

Aggregations

DropboxScheduledPollGetConsumer (org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer)2 Consumer (org.apache.camel.Consumer)1 Endpoint (org.apache.camel.Endpoint)1 DropboxScheduledPollConsumer (org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollConsumer)1 DropboxScheduledPollSearchConsumer (org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollSearchConsumer)1 DropboxException (org.apache.camel.component.dropbox.util.DropboxException)1 Test (org.junit.Test)1