[
https://issues.apache.org/jira/browse/STREAMS-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14313049#comment-14313049
]
ASF GitHub Bot commented on STREAMS-274:
----------------------------------------
Github user robdouglas commented on a diff in the pull request:
https://github.com/apache/incubator-streams/pull/176#discussion_r24372792
--- Diff:
streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
---
@@ -0,0 +1,110 @@
+/*
+ * 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
+ *
+ * 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 com.youtube.processor;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.api.services.youtube.model.Video;
+import com.google.common.collect.Lists;
+import com.youtube.serializer.YoutubeActivityUtil;
+import com.youtube.serializer.YoutubeEventClassifier;
+import com.youtube.serializer.YoutubeVideoDeserializer;
+import org.apache.streams.core.StreamsDatum;
+import org.apache.streams.core.StreamsProcessor;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Queue;
+
+public class YoutubeTypeConverter implements StreamsProcessor {
+ public final static String STREAMS_ID = "YoutubeTypeConverter";
+
+ private final static Logger LOGGER =
LoggerFactory.getLogger(YoutubeTypeConverter.class);
+ private StreamsJacksonMapper mapper;
+ private Queue<Video> inQueue;
+ private Queue<StreamsDatum> outQueue;
+ private YoutubeActivityUtil youtubeActivityUtil;
+ private int count = 0;
+
+ public YoutubeTypeConverter() {}
+
+
+ @Override
+ public List<StreamsDatum> process(StreamsDatum streamsDatum) {
+ StreamsDatum result = null;
+
+ try {
+ Object item = streamsDatum.getDocument();
+
+ LOGGER.debug("{} processing {}", STREAMS_ID, item.getClass());
+ Activity activity = null;
+
+ if(item instanceof String) {
+ item = deserializeItem(item);
+ }
+
+ if(item instanceof Video) {
+ activity = new Activity();
+ youtubeActivityUtil.updateActivity((Video)item, activity,
streamsDatum.getId());
+ }
+
+ if(activity != null) {
+ result = new StreamsDatum(activity);
+ count++;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
--- End diff --
Will change
> Create a YoutubeTypeConverter and serializer
> --------------------------------------------
>
> Key: STREAMS-274
> URL: https://issues.apache.org/jira/browse/STREAMS-274
> Project: Streams
> Issue Type: Task
> Reporter: Robert Douglas
>
> As a Streams user, I should be able to convert valid Youtube Video objects
> into usable Activity Streams.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)