streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [1/2] git commit: resolves STREAMS-167
Date Thu, 11 Sep 2014 16:38:52 GMT
Repository: incubator-streams
Updated Branches:
  refs/heads/master 3ee517573 -> 35a8fbf4b


resolves STREAMS-167


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

Branch: refs/heads/master
Commit: 411f0fa905bba84adcdba5568a295132e1b6d0b7
Parents: 3ee5175
Author: sblackmon <sblackmon@apache.org>
Authored: Tue Sep 9 16:40:19 2014 -0500
Committer: sblackmon <sblackmon@apache.org>
Committed: Tue Sep 9 16:40:19 2014 -0500

----------------------------------------------------------------------
 .../FetchAndReplaceTwitterProcessor.java        |  4 +-
 .../twitter/provider/TwitterConfigurator.java   | 70 ++++++++++++++
 .../provider/TwitterStreamConfigurator.java     | 99 --------------------
 .../twitter/provider/TwitterStreamProvider.java |  2 +-
 .../provider/TwitterTimelineProvider.java       |  8 +-
 .../TwitterUserInformationProvider.java         |  4 +-
 6 files changed, 79 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/FetchAndReplaceTwitterProcessor.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/FetchAndReplaceTwitterProcessor.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/FetchAndReplaceTwitterProcessor.java
index 7b4093f..0415efa 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/FetchAndReplaceTwitterProcessor.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/FetchAndReplaceTwitterProcessor.java
@@ -30,8 +30,8 @@ import org.apache.streams.twitter.TwitterStreamConfiguration;
 import org.apache.streams.twitter.pojo.Delete;
 import org.apache.streams.twitter.pojo.Retweet;
 import org.apache.streams.twitter.pojo.Tweet;
+import org.apache.streams.twitter.provider.TwitterConfigurator;
 import org.apache.streams.twitter.provider.TwitterEventClassifier;
-import org.apache.streams.twitter.provider.TwitterStreamConfigurator;
 import org.apache.streams.twitter.serializer.StreamsTwitterMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -62,7 +62,7 @@ public class FetchAndReplaceTwitterProcessor implements StreamsProcessor
{
     private int retryCount;
 
     public FetchAndReplaceTwitterProcessor() {
-        this(TwitterStreamConfigurator.detectConfiguration(StreamsConfigurator.config.getConfig("twitter")));
+        this(TwitterConfigurator.detectConfiguration(StreamsConfigurator.config.getConfig("twitter")));
     }
 
     public FetchAndReplaceTwitterProcessor(TwitterStreamConfiguration config) {

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterConfigurator.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterConfigurator.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterConfigurator.java
new file mode 100644
index 0000000..6ba2cda
--- /dev/null
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterConfigurator.java
@@ -0,0 +1,70 @@
+/*
+ * 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.provider;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigException;
+import com.typesafe.config.ConfigRenderOptions;
+import org.apache.streams.config.StreamsConfigurator;
+import org.apache.streams.twitter.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by sblackmon on 12/10/13.
+ */
+public class TwitterConfigurator {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(TwitterConfigurator.class);
+    private final static ObjectMapper mapper = new ObjectMapper();
+
+    public static TwitterConfiguration detectTwitterConfiguration(Config config) {
+        try {
+            return mapper.readValue(config.root().render(ConfigRenderOptions.concise()),
TwitterConfiguration.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static TwitterStreamConfiguration detectConfiguration(Config config) {
+
+        try {
+            return mapper.readValue(config.root().render(ConfigRenderOptions.concise()),
TwitterStreamConfiguration.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static TwitterUserInformationConfiguration detectTwitterUserInformationConfiguration(Config
config) {
+        try {
+            return mapper.readValue(config.root().render(ConfigRenderOptions.concise()),
TwitterUserInformationConfiguration.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamConfigurator.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamConfigurator.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamConfigurator.java
deleted file mode 100644
index b0b572a..0000000
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamConfigurator.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.provider;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigException;
-import org.apache.streams.config.StreamsConfigurator;
-import org.apache.streams.twitter.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * Created by sblackmon on 12/10/13.
- */
-public class TwitterStreamConfigurator {
-
-    private final static Logger LOGGER = LoggerFactory.getLogger(TwitterStreamConfigurator.class);
-    private final static ObjectMapper mapper = new ObjectMapper();
-
-
-    public static TwitterConfiguration detectTwitterConfiguration(Config config) {
-        TwitterConfiguration twitterConfiguration = new TwitterConfiguration();
-
-        try {
-            Config basicauth = StreamsConfigurator.config.getConfig("twitter.basicauth");
-            TwitterBasicAuthConfiguration twitterBasicAuthConfiguration = new TwitterBasicAuthConfiguration();
-            twitterBasicAuthConfiguration.setUsername(basicauth.getString("username"));
-            twitterBasicAuthConfiguration.setPassword(basicauth.getString("password"));
-            twitterConfiguration.setBasicauth(twitterBasicAuthConfiguration);
-        } catch( ConfigException ce ) {}
-
-        try {
-            Config oauth = StreamsConfigurator.config.getConfig("twitter.oauth");
-            TwitterOAuthConfiguration twitterOAuthConfiguration = new TwitterOAuthConfiguration();
-            twitterOAuthConfiguration.setConsumerKey(oauth.getString("consumerKey"));
-            twitterOAuthConfiguration.setConsumerSecret(oauth.getString("consumerSecret"));
-            twitterOAuthConfiguration.setAccessToken(oauth.getString("accessToken"));
-            twitterOAuthConfiguration.setAccessTokenSecret(oauth.getString("accessTokenSecret"));
-            twitterConfiguration.setOauth(twitterOAuthConfiguration);
-        } catch( ConfigException ce ) {}
-
-        twitterConfiguration.setEndpoint(config.getString("endpoint"));
-
-        return twitterConfiguration;
-    }
-
-    public static TwitterStreamConfiguration detectConfiguration(Config config) {
-
-        TwitterStreamConfiguration twitterStreamConfiguration = mapper.convertValue(detectTwitterConfiguration(config),
TwitterStreamConfiguration.class);
-
-        try {
-            twitterStreamConfiguration.setTrack(config.getStringList("track"));
-        } catch( ConfigException ce ) {}
-
-        try {
-            // create the array
-            List<Long> follows = Lists.newArrayList();
-            // add the ids of the people we want to 'follow'
-            for(Integer id : config.getIntList("follow"))
-                follows.add((long)id);
-            // set the array
-            twitterStreamConfiguration.setFollow(follows);
-
-        } catch( ConfigException ce ) {}
-
-        twitterStreamConfiguration.setFilterLevel(config.getString("filter-level"));
-        twitterStreamConfiguration.setWith(config.getString("with"));
-        twitterStreamConfiguration.setReplies(config.getString("replies"));
-        twitterStreamConfiguration.setJsonStoreEnabled("true");
-        twitterStreamConfiguration.setIncludeEntities("true");
-
-        return twitterStreamConfiguration;
-    }
-
-    public static TwitterUserInformationConfiguration detectTwitterUserInformationConfiguration(Config
config) {
-        return mapper.convertValue(detectTwitterConfiguration(config), TwitterUserInformationConfiguration.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProvider.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProvider.java
index 17f13e9..4ca74cd 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProvider.java
@@ -89,7 +89,7 @@ public class TwitterStreamProvider implements StreamsProvider, Serializable,
Dat
 
     public TwitterStreamProvider() {
         Config config = StreamsConfigurator.config.getConfig("twitter");
-        this.config = TwitterStreamConfigurator.detectConfiguration(config);
+        this.config = TwitterConfigurator.detectConfiguration(config);
     }
 
     public TwitterStreamProvider(TwitterStreamConfiguration config) {

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
index 8d9ee46..ae755c2 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
@@ -241,11 +241,11 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable
{
         List<String> screenNames = Lists.newArrayList();
         ids = Lists.newArrayList();
 
-        for(Object account : config.getInfo()) {
-            if(account instanceof String) {
-                screenNames.add((String)account);
-            } else if (account instanceof Long) {
+        for(String account : config.getInfo()) {
+            if(new Long(account) != null) {
                 ids.add(Long.parseLong(Objects.toString(account, null)));
+            } else {
+                screenNames.add(account);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/411f0fa9/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterUserInformationProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterUserInformationProvider.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterUserInformationProvider.java
index b69c937..bd67765 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterUserInformationProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterUserInformationProvider.java
@@ -82,7 +82,7 @@ public class TwitterUserInformationProvider implements StreamsProvider,
Serializ
 
     public TwitterUserInformationProvider() {
         Config config = StreamsConfigurator.config.getConfig("twitter");
-        this.twitterUserInformationConfiguration = TwitterStreamConfigurator.detectTwitterUserInformationConfiguration(config);
+        this.twitterUserInformationConfiguration = TwitterConfigurator.detectTwitterUserInformationConfiguration(config);
 
     }
 
@@ -92,7 +92,7 @@ public class TwitterUserInformationProvider implements StreamsProvider,
Serializ
 
     public TwitterUserInformationProvider(Class klass) {
         Config config = StreamsConfigurator.config.getConfig("twitter");
-        this.twitterUserInformationConfiguration = TwitterStreamConfigurator.detectTwitterUserInformationConfiguration(config);
+        this.twitterUserInformationConfiguration = TwitterConfigurator.detectTwitterUserInformationConfiguration(config);
         this.klass = klass;
     }
 


Mime
View raw message