camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/8] camel git commit: CAMEL-11510: camel-twitter fixed paging to use page and count options, so you can get more data, in some of the twitter actions.
Date Wed, 05 Jul 2017 09:27:06 GMT
CAMEL-11510: camel-twitter fixed paging to use page and count options, so you can get more
data, in some of the twitter actions.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dd9e8963
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dd9e8963
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dd9e8963

Branch: refs/heads/camel-2.18.x
Commit: dd9e896378e2301e2d44cad0e62f5eaed40e9ff1
Parents: 9d8b2cb
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jul 5 11:20:18 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jul 5 11:26:20 2017 +0200

----------------------------------------------------------------------
 .../component/twitter/consumer/TwitterConsumer.java     | 10 +++++++++-
 .../twitter/consumer/timeline/HomeConsumer.java         |  6 ++++--
 .../twitter/consumer/timeline/MentionsConsumer.java     |  6 ++++--
 .../twitter/consumer/timeline/RetweetsConsumer.java     |  6 ++++--
 .../twitter/consumer/timeline/UserConsumer.java         | 12 ++++++++----
 5 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dd9e8963/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
index ca877c7..fa27f4c 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
@@ -85,6 +85,14 @@ public abstract class TwitterConsumer {
     }
 
     protected Paging getLastIdPaging() {
-        return new Paging(lastId);
+        Integer pages = endpoint.getProperties().getNumberOfPages();
+        Integer count = endpoint.getProperties().getCount();
+        if (pages != null && count != null) {
+            return new Paging(pages, count, lastId);
+        } else if (pages != null) {
+            return new Paging(pages, lastId);
+        } else {
+            return new Paging(lastId);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/dd9e8963/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
index 0b2a934..58d67bd 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.twitter.consumer.timeline;
 import java.util.List;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
+import twitter4j.Paging;
 import twitter4j.Status;
 import twitter4j.TwitterException;
 
@@ -33,8 +34,9 @@ public class HomeConsumer extends AbstractStatusConsumer {
 
     @Override
     protected List<Status> doPoll() throws TwitterException {
-        log.trace("doPoll.getHomeTimeline(sinceId={})", getLastIdPaging().getSinceId());
-        return getTwitter().getHomeTimeline(getLastIdPaging());
+        Paging paging = getLastIdPaging();
+        log.trace("doPoll.getHomeTimeline(sinceId={})", paging.getSinceId());
+        return getTwitter().getHomeTimeline(paging);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/dd9e8963/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
index cf07350..7b53985 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.twitter.consumer.timeline;
 import java.util.List;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
+import twitter4j.Paging;
 import twitter4j.Status;
 import twitter4j.TwitterException;
 
@@ -33,8 +34,9 @@ public class MentionsConsumer extends AbstractStatusConsumer {
 
     @Override
     protected List<Status> doPoll() throws TwitterException {
-        log.trace("doPoll.getMentionsTimeline(sinceId={})", getLastIdPaging().getSinceId());
-        return getTwitter().getMentionsTimeline(getLastIdPaging());
+        Paging paging = getLastIdPaging();
+        log.trace("doPoll.getMentionsTimeline(sinceId={})", paging.getSinceId());
+        return getTwitter().getMentionsTimeline(paging);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/dd9e8963/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
index 585cff9..9fff920 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.twitter.consumer.timeline;
 import java.util.List;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
+import twitter4j.Paging;
 import twitter4j.Status;
 import twitter4j.TwitterException;
 
@@ -33,8 +34,9 @@ public class RetweetsConsumer extends AbstractStatusConsumer {
 
     @Override
     protected List<Status> doPoll() throws TwitterException {
-        log.trace("doPoll.getRetweetsOfMe(sinceId={})", getLastIdPaging().getSinceId());
-        return getTwitter().getRetweetsOfMe(getLastIdPaging());
+        Paging paging = getLastIdPaging();
+        log.trace("doPoll.getRetweetsOfMe(sinceId={})", paging.getSinceId());
+        return getTwitter().getRetweetsOfMe(paging);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/dd9e8963/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
index ab20665..c08fe4b 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.twitter.consumer.timeline;
 import java.util.List;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
+import twitter4j.Paging;
 import twitter4j.Status;
 import twitter4j.TwitterException;
 
@@ -33,13 +34,16 @@ public class UserConsumer extends AbstractStatusConsumer {
 
     @Override
     protected List<Status> doPoll() throws TwitterException {
-        log.trace("doPoll.getUserTimeline(user={}, sinceId={})", endpoint.getProperties().getUser(),
getLastIdPaging().getSinceId());
-        return getTwitter().getUserTimeline(endpoint.getProperties().getUser(), getLastIdPaging());
+        Paging paging = getLastIdPaging();
+        String user = endpoint.getProperties().getUser();
+        log.trace("doPoll.getUserTimeline(user={}, sinceId={})", user, paging.getSinceId());
+        return getTwitter().getUserTimeline(user, paging);
     }
 
     @Override
     protected List<Status> doDirect() throws TwitterException {
-        log.trace("doDirect.getUserTimeline(user={})", endpoint.getProperties().getUser());
-        return getTwitter().getUserTimeline(endpoint.getProperties().getUser());
+        String user = endpoint.getProperties().getUser();
+        log.trace("doDirect.getUserTimeline(user={})", user);
+        return getTwitter().getUserTimeline(user);
     }
 }


Mime
View raw message