[
https://issues.apache.org/jira/browse/STREAMS-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14380695#comment-14380695
]
ASF GitHub Bot commented on STREAMS-277:
----------------------------------------
Github user steveblackmon commented on a diff in the pull request:
https://github.com/apache/incubator-streams/pull/200#discussion_r27162296
--- Diff:
streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/converter/TwitterDocumentClassifier.java
---
@@ -0,0 +1,77 @@
+/*
+ * 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 org.apache.streams.twitter.converter;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.streams.data.DocumentClassifier;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Follow;
+import org.apache.streams.twitter.pojo.*;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Ensures twitter documents can be converted to Activity
+ */
+public class TwitterDocumentClassifier implements DocumentClassifier {
+
+ private static ObjectMapper mapper;
+
+ public List<Class> detectClasses(Object document) {
+
+ Preconditions.checkNotNull(document);
+ Preconditions.checkArgument(document instanceof String || document
instanceof ObjectNode);
+
+ mapper = new
StreamsJacksonMapper(Lists.newArrayList(StreamsTwitterMapper.TWITTER_FORMAT));
+
+ ObjectNode objectNode;
+ try {
+ if( document instanceof String )
+ objectNode = mapper.readValue((String)document,
ObjectNode.class);
+ else
+ objectNode = (ObjectNode) document;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
--- End diff --
i agree. will merge a fix.
> Upgrade streams-provider-twitter to work with reflection-based conversion
> -------------------------------------------------------------------------
>
> Key: STREAMS-277
> URL: https://issues.apache.org/jira/browse/STREAMS-277
> Project: Streams
> Issue Type: Sub-task
> Reporter: Steve Blackmon
>
> Upgrade streams-provider-twitter with StreamsDateTimeFormat,
> DocumentClassifier, and ActivityConverter implementations and tests.
> Additional details in parent issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)