streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reba...@apache.org
Subject [4/6] incubator-streams git commit: STEAMS-279 | Removed println() statement and seperated function
Date Mon, 23 Feb 2015 22:54:10 GMT
STEAMS-279 | Removed println() statement and seperated function


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/47f33563
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/47f33563
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/47f33563

Branch: refs/heads/master
Commit: 47f335633eaa9b7b804e2fd169eb78f7c782f2f9
Parents: 850ae97
Author: Ryan Ebanks <ryanebanks@gmail.com>
Authored: Mon Feb 23 10:46:31 2015 -0600
Committer: Ryan Ebanks <ryanebanks@gmail.com>
Committed: Mon Feb 23 10:46:31 2015 -0600

----------------------------------------------------------------------
 .../youtube/processor/YoutubeTypeConverter.java |  1 -
 .../youtube/serializer/YoutubeActivityUtil.java | 30 +++++++++++---------
 2 files changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/47f33563/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
index 35a3aec..adafa0d 100644
--- a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
+++ b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
@@ -91,7 +91,6 @@ public class YoutubeTypeConverter implements StreamsProcessor {
     private Object deserializeItem(Object item) {
         try {
             Class klass = YoutubeEventClassifier.detectClass((String) item);
-            System.out.println(klass.getName());
             if (klass.equals(Video.class)) {
                 item = mapper.readValue((String) item, Video.class);
             } else if(klass.equals(Channel.class)) {

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/47f33563/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
index cf57e55..5089486 100644
--- a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
+++ b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
@@ -82,20 +82,8 @@ public class YoutubeActivityUtil {
     public static void updateActivity(Channel channel, Activity activity, String channelId)
throws ActivitySerializerException {
         try {
             activity.setProvider(getProvider());
-            Actor actor = new Actor();
             activity.setVerb("post");
-            actor.setId("id:youtube:"+channel.getId());
-            actor.setSummary(channel.getSnippet().getDescription());
-            actor.setDisplayName(channel.getSnippet().getTitle());
-            Image image = new Image();
-            image.setUrl(channel.getSnippet().getThumbnails().getHigh().getUrl());
-            actor.setImage(image);
-            actor.setUrl("https://youtube.com/user/" + channel.getId());
-            Map<String, Object> actorExtensions = Maps.newHashMap();
-            actorExtensions.put("followers", channel.getStatistics().getSubscriberCount());
-            actorExtensions.put("posts", channel.getStatistics().getVideoCount());
-            actor.setAdditionalProperty("extensions", actorExtensions);
-            activity.setActor(actor);
+            activity.setActor(createActorForChannel(channel));
             Map<String, Object> extensions = Maps.newHashMap();
             extensions.put("youtube", channel);
             activity.setAdditionalProperty("extensions", extensions);
@@ -104,6 +92,22 @@ public class YoutubeActivityUtil {
         }
     }
 
+    public static Actor createActorForChannel(Channel channel) {
+        Actor actor = new Actor();
+        actor.setId("id:youtube:"+channel.getId());
+        actor.setSummary(channel.getSnippet().getDescription());
+        actor.setDisplayName(channel.getSnippet().getTitle());
+        Image image = new Image();
+        image.setUrl(channel.getSnippet().getThumbnails().getHigh().getUrl());
+        actor.setImage(image);
+        actor.setUrl("https://youtube.com/user/" + channel.getId());
+        Map<String, Object> actorExtensions = Maps.newHashMap();
+        actorExtensions.put("followers", channel.getStatistics().getSubscriberCount());
+        actorExtensions.put("posts", channel.getStatistics().getVideoCount());
+        actor.setAdditionalProperty("extensions", actorExtensions);
+        return actor;
+    }
+
     /**
      * Given a video object, create the appropriate activity object with a valid image
      * (thumbnail) and video URL


Mime
View raw message