Repository: camel Updated Branches: refs/heads/master 7c1a06ac6 -> e63d01305
CAMEL-11315 camel-twitter: Replace dummy URI paths on directmessage and search with something meaningful Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e63d0130 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e63d0130 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e63d0130 Branch: refs/heads/master Commit: e63d01305e3f0bb0225968c4e746a6e40879d6af Parents: 7c1a06a Author: Tomohisa Igarashi <tm.igara...@gmail.com> Authored: Wed May 24 23:38:36 2017 +0900 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jun 6 09:43:27 2017 +0200 ---------------------------------------------------------------------- .../docs/twitter-directmessage-component.adoc | 8 ++-- .../src/main/docs/twitter-search-component.adoc | 8 ++-- .../main/docs/twitter-streaming-component.adoc | 5 +-- .../main/docs/twitter-timeline-component.adoc | 4 +- .../twitter/AbstractTwitterEndpoint.java | 10 ----- .../CommonPropertiesTwitterEndpoint.java | 37 ++++++++++++++++ .../component/twitter/TwitterComponent.java | 4 +- .../component/twitter/TwitterConfiguration.java | 44 -------------------- .../twitter/TwitterEndpointDirect.java | 20 +++++++-- .../component/twitter/TwitterEndpointEvent.java | 27 +++++++++++- .../twitter/TwitterEndpointPolling.java | 22 ++++++++-- .../camel/component/twitter/TwitterHelper.java | 22 +++++----- .../directmessage/DirectMessageProducer.java | 6 ++- .../TwitterDirectMessageEndpoint.java | 16 +++---- .../twitter/search/SearchConsumerHandler.java | 9 ++-- .../twitter/search/SearchProducer.java | 6 ++- .../twitter/search/TwitterSearchEndpoint.java | 19 ++++----- .../FilterStreamingConsumerHandler.java | 7 +++- .../streaming/TwitterStreamingComponent.java | 3 +- .../streaming/TwitterStreamingEndpoint.java | 9 +++- .../timeline/TwitterTimelineComponent.java | 3 +- .../timeline/TwitterTimelineEndpoint.java | 9 ++-- .../twitter/timeline/UserConsumerHandler.java | 9 ++-- .../twitter/CamelComponentVerifierTest.java | 2 +- .../twitter/SearchByExchangeDirectTest.java | 2 +- .../SearchDirectCustomComponentTest.java | 2 +- .../component/twitter/SearchDirectTest.java | 2 +- .../component/twitter/SearchPollingTest.java | 2 +- components/readme.adoc | 4 +- .../OSGI-INF/blueprint/camel-twitter.xml | 2 +- .../websocket/TwitterWebSocketRoute.java | 2 +- 31 files changed, 186 insertions(+), 139 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/docs/twitter-directmessage-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/docs/twitter-directmessage-component.adoc b/components/camel-twitter/src/main/docs/twitter-directmessage-component.adoc index 2ac1e0a..86a352d 100644 --- a/components/camel-twitter/src/main/docs/twitter-directmessage-component.adoc +++ b/components/camel-twitter/src/main/docs/twitter-directmessage-component.adoc @@ -33,7 +33,7 @@ The Twitter Direct Message component supports 9 options which are listed below. // endpoint options: START The Twitter Direct Message endpoint is configured using URI syntax: - twitter-directmessage:endpointId + twitter-directmessage:user with the following path and query parameters: @@ -42,15 +42,14 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= | Name | Description | Default | Type -| **endpointId** | *Required* The endpoint ID (not used). | | String +| **user** | *Required* The user name to send a direct message. This will be ignored for consumer. | | String |======================================================================= -#### Query Parameters (43 parameters): +#### Query Parameters (41 parameters): [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= | Name | Description | Default | Type -| **user** (common) | Username used for user timeline consumption direct message production etc. | | String | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean | **sendEmptyMessageWhenIdle** (consumer) | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead. | false | boolean | **type** (consumer) | Endpoint type to use. Only streaming supports event type. | polling | EndpointType @@ -66,7 +65,6 @@ with the following path and query parameters: | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean | **count** (filter) | Limiting number of results per page. | | Integer | **filterOld** (filter) | Filter out old tweets that has previously been polled. This state is stored in memory only and based on last tweet id. | true | boolean -| **keywords** (filter) | Can be used for search and streaming/filter. Multiple values can be separated with comma. | | String | **lang** (filter) | The lang string ISO_639-1 which will be used for searching | | String | **numberOfPages** (filter) | The number of pages result which you want camel-twitter to consume. | 1 | Integer | **sinceId** (filter) | The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running. | 1 | long http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/docs/twitter-search-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/docs/twitter-search-component.adoc b/components/camel-twitter/src/main/docs/twitter-search-component.adoc index d33677f..4661e9c 100644 --- a/components/camel-twitter/src/main/docs/twitter-search-component.adoc +++ b/components/camel-twitter/src/main/docs/twitter-search-component.adoc @@ -32,7 +32,7 @@ The Twitter Search component supports 9 options which are listed below. // endpoint options: START The Twitter Search endpoint is configured using URI syntax: - twitter-search:endpointId + twitter-search:keywords with the following path and query parameters: @@ -41,15 +41,14 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= | Name | Description | Default | Type -| **endpointId** | *Required* The endpoint ID (not used). | | String +| **keywords** | *Required* The search keywords. Multiple values can be separated with comma. | | String |======================================================================= -#### Query Parameters (43 parameters): +#### Query Parameters (41 parameters): [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= | Name | Description | Default | Type -| **user** (common) | Username used for user timeline consumption direct message production etc. | | String | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean | **sendEmptyMessageWhenIdle** (consumer) | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead. | false | boolean | **type** (consumer) | Endpoint type to use. Only streaming supports event type. | polling | EndpointType @@ -65,7 +64,6 @@ with the following path and query parameters: | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean | **count** (filter) | Limiting number of results per page. | | Integer | **filterOld** (filter) | Filter out old tweets that has previously been polled. This state is stored in memory only and based on last tweet id. | true | boolean -| **keywords** (filter) | Can be used for search and streaming/filter. Multiple values can be separated with comma. | | String | **lang** (filter) | The lang string ISO_639-1 which will be used for searching | | String | **numberOfPages** (filter) | The number of pages result which you want camel-twitter to consume. | 1 | Integer | **sinceId** (filter) | The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running. | 1 | long http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/docs/twitter-streaming-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/docs/twitter-streaming-component.adoc b/components/camel-twitter/src/main/docs/twitter-streaming-component.adoc index 58da2f8..81446bc 100644 --- a/components/camel-twitter/src/main/docs/twitter-streaming-component.adoc +++ b/components/camel-twitter/src/main/docs/twitter-streaming-component.adoc @@ -44,7 +44,7 @@ with the following path and query parameters: | **streamingType** | *Required* The streaming type to consume. | | StreamingType |======================================================================= -#### Query Parameters (43 parameters): +#### Query Parameters (42 parameters): [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= @@ -52,7 +52,6 @@ with the following path and query parameters: | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean | **sendEmptyMessageWhenIdle** (consumer) | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead. | false | boolean | **type** (consumer) | Endpoint type to use. Only streaming supports event type. | polling | EndpointType -| **user** (consumer) | Username used for user timeline consumption direct message production etc. | | String | **distanceMetric** (consumer) | Used by the non-stream geography search to search by radius using the configured metrics. The unit can either be mi for miles or km for kilometers. You need to configure all the following options: longitude latitude radius and distanceMetric. | km | String | **exceptionHandler** (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | **exchangePattern** (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern @@ -65,7 +64,7 @@ with the following path and query parameters: | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean | **count** (filter) | Limiting number of results per page. | | Integer | **filterOld** (filter) | Filter out old tweets that has previously been polled. This state is stored in memory only and based on last tweet id. | true | boolean -| **keywords** (filter) | Can be used for search and streaming/filter. Multiple values can be separated with comma. | | String +| **keywords** (filter) | Can be used for a streaming filter. Multiple values can be separated with comma. | | String | **lang** (filter) | The lang string ISO_639-1 which will be used for searching | | String | **numberOfPages** (filter) | The number of pages result which you want camel-twitter to consume. | 1 | Integer | **sinceId** (filter) | The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running. | 1 | long http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/docs/twitter-timeline-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/docs/twitter-timeline-component.adoc b/components/camel-twitter/src/main/docs/twitter-timeline-component.adoc index a9a1c90..6644d21 100644 --- a/components/camel-twitter/src/main/docs/twitter-timeline-component.adoc +++ b/components/camel-twitter/src/main/docs/twitter-timeline-component.adoc @@ -44,12 +44,11 @@ with the following path and query parameters: | **timelineType** | *Required* The timeline type to produce/consume. | | TimelineType |======================================================================= -#### Query Parameters (43 parameters): +#### Query Parameters (41 parameters): [width="100%",cols="2,5,^1,2",options="header"] |======================================================================= | Name | Description | Default | Type -| **user** (common) | Username used for user timeline consumption direct message production etc. | | String | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean | **sendEmptyMessageWhenIdle** (consumer) | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead. | false | boolean | **type** (consumer) | Endpoint type to use. Only streaming supports event type. | polling | EndpointType @@ -65,7 +64,6 @@ with the following path and query parameters: | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean | **count** (filter) | Limiting number of results per page. | | Integer | **filterOld** (filter) | Filter out old tweets that has previously been polled. This state is stored in memory only and based on last tweet id. | true | boolean -| **keywords** (filter) | Can be used for search and streaming/filter. Multiple values can be separated with comma. | | String | **lang** (filter) | The lang string ISO_639-1 which will be used for searching | | String | **numberOfPages** (filter) | The number of pages result which you want camel-twitter to consume. | 1 | Integer | **sinceId** (filter) | The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running. | 1 | long http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/AbstractTwitterEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/AbstractTwitterEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/AbstractTwitterEndpoint.java index c9c047c..cadeb1b 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/AbstractTwitterEndpoint.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/AbstractTwitterEndpoint.java @@ -67,16 +67,6 @@ public abstract class AbstractTwitterEndpoint extends DefaultPollingEndpoint imp } @ManagedAttribute - public String getKeywords() { - return getProperties().getKeywords(); - } - - @ManagedAttribute - public void setKeywords(String keywords) { - getProperties().setKeywords(keywords); - } - - @ManagedAttribute public String getLocations() { return getProperties().getLocations(); } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/CommonPropertiesTwitterEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/CommonPropertiesTwitterEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/CommonPropertiesTwitterEndpoint.java new file mode 100644 index 0000000..b6ea399 --- /dev/null +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/CommonPropertiesTwitterEndpoint.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.twitter; + +import org.apache.camel.Endpoint; +import org.apache.camel.component.twitter.data.EndpointType; + +/** + * @deprecated This has been introduced to just keep deprecated endpoints working as is. + * Remove this once Endpoint{Direct,Event,Polling} is removed. + */ +@Deprecated +public interface CommonPropertiesTwitterEndpoint extends TwitterEndpoint { + + String getKeywords(); + + void setKeywords(String keywords); + + String getUser(); + + void setUser(String user); + +} http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java index 092fe2f..a1b7e5d 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java @@ -56,7 +56,7 @@ public class TwitterComponent extends AbstractTwitterComponent { String[] tokens = remaining.split("/"); LOG.warn("The scheme syntax 'twitter:{}' has been deprecated. Use 'twitter-{}' instead.", tokens[0], tokens[0]); - TwitterEndpoint endpoint; + CommonPropertiesTwitterEndpoint endpoint; switch (properties.getType()) { case POLLING: @@ -69,6 +69,8 @@ public class TwitterComponent extends AbstractTwitterComponent { endpoint = new TwitterEndpointDirect(uri, remaining, this, properties); break; } + endpoint.setUser(getAndRemoveParameter(parameters, "user", String.class)); + endpoint.setKeywords(getAndRemoveParameter(parameters, "keywords", String.class)); return endpoint; } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java index fcb47e0..f4a32bb 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java @@ -32,10 +32,6 @@ import twitter4j.conf.ConfigurationBuilder; @UriParams public class TwitterConfiguration { - //@UriPath(description = "The kind of endpoint", enums = "directmessage,search,streaming/filter,streaming/sample,streaming/user" - // + ",timeline/home,timeline/mentions,timeline/retweetsofme,timeline/user") @Metadata(required = "true") - @Deprecated - private String kind; @UriParam(label = "consumer", defaultValue = "polling", enums = "polling,direct,event") private EndpointType type = EndpointType.POLLING; @UriParam(label = "security", secret = true) @@ -46,10 +42,6 @@ public class TwitterConfiguration { private String consumerKey; @UriParam(label = "security", secret = true) private String consumerSecret; - @UriParam - private String user; - @UriParam(label = "consumer,filter") - private String keywords; @UriParam(label = "consumer,filter") private String userIds; @UriParam(label = "consumer,filter", defaultValue = "true") @@ -162,20 +154,6 @@ public class TwitterConfiguration { return twitterStream; } - @Deprecated - public String getKind() { - return kind; - } - - /** - * What polling mode to use, direct, polling or event based. - * The event mode is only supported when the endpoint kind is event based. - */ - @Deprecated - public void setKind(String kind) { - this.kind = kind; - } - public String getConsumerKey() { return consumerKey; } @@ -220,28 +198,6 @@ public class TwitterConfiguration { this.accessTokenSecret = accessTokenSecret; } - public String getUser() { - return user; - } - - /** - * Username, used for user timeline consumption, direct message production, etc. - */ - public void setUser(String user) { - this.user = user; - } - - public String getKeywords() { - return keywords; - } - - /** - * Can be used for search and streaming/filter. Multiple values can be separated with comma. - */ - public void setKeywords(String keywords) { - this.keywords = keywords; - } - public EndpointType getType() { return type; } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java index 1e72dc3..02b9ec8 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java @@ -32,12 +32,16 @@ import org.apache.camel.component.twitter.data.EndpointType; * */ @Deprecated -public class TwitterEndpointDirect extends DirectEndpoint implements TwitterEndpoint { +public class TwitterEndpointDirect extends DirectEndpoint implements CommonPropertiesTwitterEndpoint { private final String kind; // only TwitterEndpointPolling is annotated private TwitterConfiguration properties; + private String user; + + private String keywords; + public TwitterEndpointDirect(String uri, String remaining, TwitterComponent component, TwitterConfiguration properties) { super(uri, component); this.kind = remaining; @@ -97,13 +101,23 @@ public class TwitterEndpointDirect extends DirectEndpoint implements TwitterEndp } @ManagedAttribute + public String getUser() { + return user; + } + + @ManagedAttribute + public void setUser(String user) { + this.user = user; + } + + @ManagedAttribute public String getKeywords() { - return getProperties().getKeywords(); + return keywords; } @ManagedAttribute public void setKeywords(String keywords) { - getProperties().setKeywords(keywords); + this.keywords = keywords; } @ManagedAttribute http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointEvent.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointEvent.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointEvent.java index 54d707f..b8d8922 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointEvent.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointEvent.java @@ -25,12 +25,16 @@ import org.apache.camel.component.twitter.data.EndpointType; import org.apache.camel.impl.DefaultEndpoint; @Deprecated -public class TwitterEndpointEvent extends DefaultEndpoint implements TwitterEndpoint { +public class TwitterEndpointEvent extends DefaultEndpoint implements CommonPropertiesTwitterEndpoint { private final String kind; // only TwitterEndpointPolling is annotated private TwitterConfiguration properties; + private String user; + + private String keywords; + public TwitterEndpointEvent(String uri, String remaining, TwitterComponent component, TwitterConfiguration properties) { super(uri, component); this.kind = remaining; @@ -73,4 +77,25 @@ public class TwitterEndpointEvent extends DefaultEndpoint implements TwitterEndp properties.getTwitterStream().shutdown(); } } + + @Override + public String getUser() { + return user; + } + + @Override + public void setUser(String user) { + this.user = user; + } + + @Override + public String getKeywords() { + return keywords; + } + + @Override + public void setKeywords(String keywords) { + this.keywords = keywords; + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java index 008167a..d745d1c 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java @@ -37,7 +37,7 @@ import org.apache.camel.spi.UriPath; @Deprecated @ManagedResource(description = "Managed Twitter Endpoint") @UriEndpoint(firstVersion = "2.10.0", scheme = "twitter", title = "Twitter", syntax = "twitter:kind", consumerClass = AbstractTwitterConsumerHandler.class, label = "api,social") -public class TwitterEndpointPolling extends DefaultPollingEndpoint implements TwitterEndpoint { +public class TwitterEndpointPolling extends DefaultPollingEndpoint implements CommonPropertiesTwitterEndpoint { @UriPath(description = "The kind of endpoint", enums = "directmessage,search,streaming/filter,streaming/sample,streaming/user" + ",timeline/home,timeline/mentions,timeline/retweetsofme,timeline/user") @Metadata(required = "true") private final String kind; @@ -49,6 +49,12 @@ public class TwitterEndpointPolling extends DefaultPollingEndpoint implements Tw @UriParam private TwitterConfiguration properties; + @UriParam(description = "Username, used for user timeline consumption, direct message production, etc.") + private String user; + + @UriParam(description = "Can be used for search and streaming/filter. Multiple values can be separated with comma.", label = "consumer,filter") + private String keywords; + public TwitterEndpointPolling(String uri, String remaining, TwitterComponent component, TwitterConfiguration properties) { super(uri, component); this.kind = remaining; @@ -86,13 +92,23 @@ public class TwitterEndpointPolling extends DefaultPollingEndpoint implements Tw } @ManagedAttribute + public String getUser() { + return user; + } + + @ManagedAttribute + public void setUser(String user) { + this.user = user; + } + + @ManagedAttribute public String getKeywords() { - return getProperties().getKeywords(); + return keywords; } @ManagedAttribute public void setKeywords(String keywords) { - getProperties().setKeywords(keywords); + this.keywords = keywords; } @ManagedAttribute http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterHelper.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterHelper.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterHelper.java index e51e08f..af6a219 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterHelper.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterHelper.java @@ -66,7 +66,7 @@ public final class TwitterHelper { } @Deprecated - public static AbstractTwitterConsumerHandler createConsumer(TwitterEndpoint te, String uri, String remaining) throws IllegalArgumentException { + public static AbstractTwitterConsumerHandler createConsumer(CommonPropertiesTwitterEndpoint te, String uri, String remaining) throws IllegalArgumentException { String[] tokens = remaining.split("/"); if (tokens.length > 0) { @@ -74,12 +74,12 @@ public final class TwitterHelper { case DIRECTMESSAGE: return new DirectMessageConsumerHandler(te); case SEARCH: - boolean hasNoKeywords = te.getProperties().getKeywords() == null - || te.getProperties().getKeywords().trim().isEmpty(); + boolean hasNoKeywords = te.getKeywords() == null + || te.getKeywords().trim().isEmpty(); if (hasNoKeywords) { throw new IllegalArgumentException("Type set to SEARCH but no keywords were provided."); } else { - return new SearchConsumerHandler(te); + return new SearchConsumerHandler(te, te.getKeywords()); } case STREAMING: if (tokens.length > 1) { @@ -87,7 +87,7 @@ public final class TwitterHelper { case SAMPLE: return new SampleStreamingConsumerHandler(te); case FILTER: - return new FilterStreamingConsumerHandler(te); + return new FilterStreamingConsumerHandler(te, te.getKeywords()); case USER: return new UserStreamingConsumerHandler(te); default: @@ -105,10 +105,10 @@ public final class TwitterHelper { case RETWEETSOFME: return new RetweetsConsumerHandler(te); case USER: - if (te.getProperties().getUser() == null || te.getProperties().getUser().trim().isEmpty()) { + if (te.getUser() == null || te.getUser().trim().isEmpty()) { throw new IllegalArgumentException("Fetch type set to USER TIMELINE but no user was set."); } else { - return new UserConsumerHandler(te); + return new UserConsumerHandler(te, te.getUser()); } default: break; @@ -141,17 +141,17 @@ public final class TwitterHelper { } @Deprecated - public static Producer createProducer(TwitterEndpoint te, String uri, String remaining) throws IllegalArgumentException { + public static Producer createProducer(CommonPropertiesTwitterEndpoint te, String uri, String remaining) throws IllegalArgumentException { String[] tokens = remaining.split("/"); if (tokens.length > 0) { switch (ConsumerType.fromString(tokens[0])) { case DIRECTMESSAGE: - if (te.getProperties().getUser() == null || te.getProperties().getUser().trim().isEmpty()) { + if (te.getUser() == null || te.getUser().trim().isEmpty()) { throw new IllegalArgumentException( "Producer type set to DIRECT MESSAGE but no recipient user was set."); } else { - return new DirectMessageProducer(te); + return new DirectMessageProducer(te, te.getUser()); } case TIMELINE: if (tokens.length > 1) { @@ -164,7 +164,7 @@ public final class TwitterHelper { } break; case SEARCH: - return new SearchProducer(te); + return new SearchProducer(te, te.getKeywords()); default: break; } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/DirectMessageProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/DirectMessageProducer.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/DirectMessageProducer.java index 078c6cd..d8a7dc7 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/DirectMessageProducer.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/DirectMessageProducer.java @@ -29,15 +29,17 @@ import org.apache.camel.util.ObjectHelper; public class DirectMessageProducer extends DefaultProducer { private TwitterEndpoint endpoint; + private String user; - public DirectMessageProducer(TwitterEndpoint endpoint) { + public DirectMessageProducer(TwitterEndpoint endpoint, String user) { super(endpoint); this.endpoint = endpoint; + this.user = user; } public void process(Exchange exchange) throws Exception { // send direct message - String toUsername = endpoint.getProperties().getUser(); + String toUsername = user; if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(TwitterConstants.TWITTER_USER, String.class))) { toUsername = exchange.getIn().getHeader(TwitterConstants.TWITTER_USER, String.class); } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/TwitterDirectMessageEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/TwitterDirectMessageEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/TwitterDirectMessageEndpoint.java index 360da52..5bd3074 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/TwitterDirectMessageEndpoint.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/directmessage/TwitterDirectMessageEndpoint.java @@ -25,31 +25,27 @@ import org.apache.camel.component.twitter.TwitterHelper; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriPath; +import org.apache.camel.util.ObjectHelper; /** * The Twitter Direct Message Component consumes/produces user's direct messages. */ -@UriEndpoint(firstVersion = "2.10.0", scheme = "twitter-directmessage", title = "Twitter Direct Message", syntax = "twitter-directmessage:endpointId", +@UriEndpoint(firstVersion = "2.10.0", scheme = "twitter-directmessage", title = "Twitter Direct Message", syntax = "twitter-directmessage:user", consumerClass = DirectMessageConsumerHandler.class, label = "api,social") public class TwitterDirectMessageEndpoint extends AbstractTwitterEndpoint { - @UriPath(description = "The endpoint ID (not used).") + @UriPath(description = "The user name to send a direct message. This will be ignored for consumer.") @Metadata(required = "true") - private String endpointId; + private String user; public TwitterDirectMessageEndpoint(String uri, String remaining, TwitterDirectMessageComponent component, TwitterConfiguration properties) { super(uri, component, properties); - this.endpointId = remaining; + this.user = remaining; } @Override public Producer createProducer() throws Exception { - if (getProperties().getUser() == null || getProperties().getUser().trim().isEmpty()) { - throw new IllegalArgumentException( - "Producer type set to DIRECT MESSAGE but no recipient user was set."); - } else { - return new DirectMessageProducer(this); - } + return new DirectMessageProducer(this, user); } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchConsumerHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchConsumerHandler.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchConsumerHandler.java index 649b836..de096c2 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchConsumerHandler.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchConsumerHandler.java @@ -41,12 +41,15 @@ public class SearchConsumerHandler extends AbstractTwitterConsumerHandler { private static final Logger LOG = LoggerFactory.getLogger(SearchConsumerHandler.class); - public SearchConsumerHandler(TwitterEndpoint te) { + private String keywords; + + public SearchConsumerHandler(TwitterEndpoint te, String keywords) { super(te); + this.keywords = keywords; } public List<Exchange> pollConsume() throws TwitterException { - String keywords = endpoint.getProperties().getKeywords(); + String keywords = this.keywords; Query query; @@ -66,7 +69,7 @@ public class SearchConsumerHandler extends AbstractTwitterConsumerHandler { } public List<Exchange> directConsume() throws TwitterException { - String keywords = endpoint.getProperties().getKeywords(); + String keywords = this.keywords; if (keywords == null || keywords.trim().length() == 0) { return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchProducer.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchProducer.java index 30886bd..cb6b883 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchProducer.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/SearchProducer.java @@ -34,10 +34,12 @@ public class SearchProducer extends DefaultProducer { private volatile long lastId; private TwitterEndpoint endpoint; + private String keywords; - public SearchProducer(TwitterEndpoint endpoint) { + public SearchProducer(TwitterEndpoint endpoint, String keywords) { super(endpoint); this.endpoint = endpoint; + this.keywords = keywords; } @Override @@ -47,7 +49,7 @@ public class SearchProducer extends DefaultProducer { // keywords from header take precedence String keywords = exchange.getIn().getHeader(TwitterConstants.TWITTER_KEYWORDS, String.class); if (keywords == null) { - keywords = endpoint.getProperties().getKeywords(); + keywords = this.keywords; } if (keywords == null) { http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/TwitterSearchEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/TwitterSearchEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/TwitterSearchEndpoint.java index 1653a97..98bfb15 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/TwitterSearchEndpoint.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/search/TwitterSearchEndpoint.java @@ -25,37 +25,32 @@ import org.apache.camel.component.twitter.TwitterHelper; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriPath; +import org.apache.camel.util.ObjectHelper; /** * The Twitter Search component consumes search results. */ -@UriEndpoint(firstVersion = "2.10.0", scheme = "twitter-search", title = "Twitter Search", syntax = "twitter-search:endpointId", +@UriEndpoint(firstVersion = "2.10.0", scheme = "twitter-search", title = "Twitter Search", syntax = "twitter-search:keywords", consumerClass = SearchConsumerHandler.class, label = "api,social") public class TwitterSearchEndpoint extends AbstractTwitterEndpoint { - @UriPath(description = "The endpoint ID (not used).") + @UriPath(description = "The search keywords. Multiple values can be separated with comma.") @Metadata(required = "true") - private String endpointId; + private String keywords; public TwitterSearchEndpoint(String uri, String remaining, TwitterSearchComponent component, TwitterConfiguration properties) { super(uri, component, properties); - this.endpointId = remaining; + this.keywords = remaining; } @Override public Producer createProducer() throws Exception { - return new SearchProducer(this); + return new SearchProducer(this, keywords); } @Override public Consumer createConsumer(Processor processor) throws Exception { - boolean hasNoKeywords = getProperties().getKeywords() == null - || getProperties().getKeywords().trim().isEmpty(); - if (hasNoKeywords) { - throw new IllegalArgumentException("Type set to SEARCH but no keywords were provided."); - } else { - return TwitterHelper.createConsumer(processor, this, new SearchConsumerHandler(this)); - } + return TwitterHelper.createConsumer(processor, this, new SearchConsumerHandler(this, keywords)); } } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/FilterStreamingConsumerHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/FilterStreamingConsumerHandler.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/FilterStreamingConsumerHandler.java index b505d9d..a33a6d5 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/FilterStreamingConsumerHandler.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/FilterStreamingConsumerHandler.java @@ -25,8 +25,11 @@ import twitter4j.StallWarning; */ public class FilterStreamingConsumerHandler extends AbstractStreamingConsumerHandler { - public FilterStreamingConsumerHandler(TwitterEndpoint endpoint) { + private String keywords; + + public FilterStreamingConsumerHandler(TwitterEndpoint endpoint, String keywords) { super(endpoint); + this.keywords = keywords; } @Override @@ -53,7 +56,7 @@ public class FilterStreamingConsumerHandler extends AbstractStreamingConsumerHan filterQuery.locations(locations); } - String keywords = endpoint.getProperties().getKeywords(); + String keywords = this.keywords; if (keywords != null && keywords.length() > 0) { filterQuery.track(keywords.split(",")); } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingComponent.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingComponent.java index 1e4c058..1ccf160 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingComponent.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingComponent.java @@ -32,7 +32,8 @@ import org.apache.camel.spi.Metadata; public class TwitterStreamingComponent extends AbstractTwitterComponent { protected Endpoint doCreateEndpoint(TwitterConfiguration properties, String uri, String remaining, Map<String, Object> parameters) throws Exception { - return new TwitterStreamingEndpoint(uri, remaining, this, properties); + String keywords = getAndRemoveParameter(parameters, "keywords", String.class); + return new TwitterStreamingEndpoint(uri, remaining, keywords, this, properties); } /** http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingEndpoint.java index ef8faaf..76228d8 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingEndpoint.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/streaming/TwitterStreamingEndpoint.java @@ -26,6 +26,7 @@ import org.apache.camel.component.twitter.consumer.AbstractTwitterConsumerHandle import org.apache.camel.component.twitter.data.StreamingType; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; /** @@ -39,12 +40,16 @@ public class TwitterStreamingEndpoint extends AbstractTwitterEndpoint { @Metadata(required = "true") private StreamingType streamingType; - public TwitterStreamingEndpoint(String uri, String remaining, TwitterStreamingComponent component, TwitterConfiguration properties) { + @UriParam(description = "Can be used for a streaming filter. Multiple values can be separated with comma.", label = "consumer,filter") + private String keywords; + + public TwitterStreamingEndpoint(String uri, String remaining, String keywords, TwitterStreamingComponent component, TwitterConfiguration properties) { super(uri, component, properties); if (remaining == null) { throw new IllegalArgumentException(String.format("The streaming type must be specified for '%s'", uri)); } this.streamingType = StreamingType.valueOf(remaining.toUpperCase()); + this.keywords = keywords; } @Override @@ -60,7 +65,7 @@ public class TwitterStreamingEndpoint extends AbstractTwitterEndpoint { handler = new SampleStreamingConsumerHandler(this); break; case FILTER: - handler = new FilterStreamingConsumerHandler(this); + handler = new FilterStreamingConsumerHandler(this, keywords); break; case USER: handler = new UserStreamingConsumerHandler(this); http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineComponent.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineComponent.java index 6af0e6d..0c9c885 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineComponent.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineComponent.java @@ -33,7 +33,8 @@ public class TwitterTimelineComponent extends AbstractTwitterComponent { @Override protected Endpoint doCreateEndpoint(TwitterConfiguration properties, String uri, String remaining, Map<String, Object> parameters) throws Exception { - return new TwitterTimelineEndpoint(uri, remaining, this, properties); + String user = getAndRemoveParameter(parameters, "user", String.class); + return new TwitterTimelineEndpoint(uri, remaining, user, this, properties); } /** http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineEndpoint.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineEndpoint.java index 92472ae..32d845d 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineEndpoint.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/TwitterTimelineEndpoint.java @@ -39,12 +39,15 @@ public class TwitterTimelineEndpoint extends AbstractTwitterEndpoint { @Metadata(required = "true") private TimelineType timelineType; - public TwitterTimelineEndpoint(String uri, String remaining, TwitterTimelineComponent component, TwitterConfiguration properties) { + private String user; + + public TwitterTimelineEndpoint(String uri, String remaining, String user, TwitterTimelineComponent component, TwitterConfiguration properties) { super(uri, component, properties); if (remaining == null) { throw new IllegalArgumentException(String.format("The timeline type must be specified for '%s'", uri)); } this.timelineType = TimelineType.valueOf(remaining.toUpperCase()); + this.user = user; } @Override @@ -72,10 +75,10 @@ public class TwitterTimelineEndpoint extends AbstractTwitterEndpoint { handler = new RetweetsConsumerHandler(this); break; case USER: - if (getProperties().getUser() == null || getProperties().getUser().trim().isEmpty()) { + if (user == null || user.trim().isEmpty()) { throw new IllegalArgumentException("Fetch type set to USER TIMELINE but no user was set."); } else { - handler = new UserConsumerHandler(this); + handler = new UserConsumerHandler(this, user); break; } default: http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/UserConsumerHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/UserConsumerHandler.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/UserConsumerHandler.java index ad13b75..7f45024 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/UserConsumerHandler.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/timeline/UserConsumerHandler.java @@ -27,17 +27,20 @@ import twitter4j.TwitterException; */ public class UserConsumerHandler extends AbstractStatusConsumerHandler { - public UserConsumerHandler(TwitterEndpoint endpoint) { + private String user; + + public UserConsumerHandler(TwitterEndpoint endpoint, String user) { super(endpoint); + this.user = user; } @Override protected List<Status> doPoll() throws TwitterException { - return getTwitter().getUserTimeline(endpoint.getProperties().getUser(), getLastIdPaging()); + return getTwitter().getUserTimeline(user, getLastIdPaging()); } @Override protected List<Status> doDirect() throws TwitterException { - return getTwitter().getUserTimeline(endpoint.getProperties().getUser()); + return getTwitter().getUserTimeline(user); } } http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java index be8eb81..28c2992 100644 --- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java +++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java @@ -96,7 +96,7 @@ public class CamelComponentVerifierTest extends CamelTwitterTestSupport { Assert.assertEquals(5, result.getErrors().size()); List<String> expected = new LinkedList<>(); - expected.add("endpointId"); + expected.add("keywords"); expected.add("consumerKey"); expected.add("consumerSecret"); expected.add("accessToken"); http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java index 644fb87..a3ae18b 100644 --- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java +++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java @@ -120,7 +120,7 @@ public class SearchByExchangeDirectTest extends CamelTwitterTestSupport { return new RouteBuilder() { public void configure() { from("direct:start") - .toF("twitter-search://foo?%s&keywords=java", getUriTokens()) + .toF("twitter-search://java?%s", getUriTokens()) .split().body() .to("mock:result"); http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectCustomComponentTest.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectCustomComponentTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectCustomComponentTest.java index 5d01a48..5d853c4 100644 --- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectCustomComponentTest.java +++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectCustomComponentTest.java @@ -36,7 +36,7 @@ public class SearchDirectCustomComponentTest extends CamelTwitterConsumerTestSup @Override protected String getUri() { - return "my-twitter://foo?type=direct&keywords=java&"; + return "my-twitter://java?type=direct&"; } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java index 59b6128..0512cda 100644 --- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java +++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java @@ -26,7 +26,7 @@ public class SearchDirectTest extends CamelTwitterConsumerTestSupport { @Override protected String getUri() { - return "twitter-search://foo?type=direct&keywords=java&"; + return "twitter-search://java?type=direct&"; } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java index 2cd7f73..0ebae1c 100644 --- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java +++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java @@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory; public class SearchPollingTest extends CamelTwitterConsumerTestSupport { @Override protected String getUri() { - return "twitter-search://foo?type=polling&keywords=java&delay=5000&"; + return "twitter-search://java?type=polling&delay=5000&"; } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/components/readme.adoc ---------------------------------------------------------------------- diff --git a/components/readme.adoc b/components/readme.adoc index efb0aa0..a14247c 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -750,10 +750,10 @@ Number of Components: 266 in 186 JAR artifacts (16 deprecated) `twitter:kind` | 2.10 | *deprecated* Use twitter-directmessage twitter-search twitter-streaming and twitter-timeline instead of this component. | link:camel-twitter/src/main/docs/twitter-directmessage-component.adoc[Twitter Direct Message] (camel-twitter) + -`twitter-directmessage:endpointId` | 2.10 | The Twitter Direct Message Component consumes/produces user's direct messages. +`twitter-directmessage:user` | 2.10 | The Twitter Direct Message Component consumes/produces user's direct messages. | link:camel-twitter/src/main/docs/twitter-search-component.adoc[Twitter Search] (camel-twitter) + -`twitter-search:endpointId` | 2.10 | The Twitter Search component consumes search results. +`twitter-search:keywords` | 2.10 | The Twitter Search component consumes search results. | link:camel-twitter/src/main/docs/twitter-streaming-component.adoc[Twitter Streaming] (camel-twitter) + `twitter-streaming:streamingType` | 2.10 | The Twitter Streaming component consumes twitter statuses using Streaming API. http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml index ae0ea8e..ecbaac1 100644 --- a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml +++ b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml @@ -30,7 +30,7 @@ <route id="twitter-route"> <!-- consume from twitter search to get new tweets about gaga every 5th second --> - <from uri="twitter-search://foo?type=polling&delay=6000&keywords=gaga + <from uri="twitter-search://gaga?type=polling&delay=6000 &accessToken={{access.token}}&accessTokenSecret={{access.token-secret}}&consumerKey={{consumer.key}}&consumerSecret={{consumer.secret}}"/> <!-- log tweet to the log --> http://git-wip-us.apache.org/repos/asf/camel/blob/e63d0130/examples/camel-example-twitter-websocket/src/main/java/org/apache/camel/example/websocket/TwitterWebSocketRoute.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-twitter-websocket/src/main/java/org/apache/camel/example/websocket/TwitterWebSocketRoute.java b/examples/camel-example-twitter-websocket/src/main/java/org/apache/camel/example/websocket/TwitterWebSocketRoute.java index b77fe86..a2eaee7 100644 --- a/examples/camel-example-twitter-websocket/src/main/java/org/apache/camel/example/websocket/TwitterWebSocketRoute.java +++ b/examples/camel-example-twitter-websocket/src/main/java/org/apache/camel/example/websocket/TwitterWebSocketRoute.java @@ -106,7 +106,7 @@ public class TwitterWebSocketRoute extends RouteBuilder { tc.setConsumerSecret(consumerSecret); // poll twitter search for new tweets - fromF("twitter-search://foo?delay=%s&keywords=%s", delay, searchTerm) + fromF("twitter-search://%s?delay=%s", searchTerm, delay) .to("log:tweet") // and push tweets to all web socket subscribers on camel-tweet .to("websocket:camel-tweet?sendToAll=true");