Twitter updates have broken Twitter River, Update to latest version of Twitter4J, closes #627.
This commit is contained in:
parent
f8b1d1eebd
commit
64e5784623
|
@ -58,6 +58,7 @@
|
|||
<w>geohash</w>
|
||||
<w>guice</w>
|
||||
<w>hadoop</w>
|
||||
<w>hashtag</w>
|
||||
<w>hdfs</w>
|
||||
<w>histo</w>
|
||||
<w>hpux</w>
|
||||
|
|
|
@ -15,10 +15,12 @@
|
|||
<orderEntry type="module-library">
|
||||
<library name="twitter4j">
|
||||
<CLASSES>
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.twitter4j/twitter4j-core/jars/twitter4j-core-2.1.7.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.twitter4j/twitter4j-core/jars/twitter4j-core-2.1.10.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/opt/twitter4j/2.1.10/twitter4j-core/twitter4j-core-2.1.10-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="test-testng" scope="TEST" />
|
||||
|
|
|
@ -32,8 +32,8 @@ configurations {
|
|||
dependencies {
|
||||
compile project(':elasticsearch')
|
||||
|
||||
compile('org.twitter4j:twitter4j-core:2.1.7') { transitive = false }
|
||||
distLib('org.twitter4j:twitter4j-core:2.1.7') { transitive = false }
|
||||
compile('org.twitter4j:twitter4j-core:2.1.10') { transitive = false }
|
||||
distLib('org.twitter4j:twitter4j-core:2.1.10') { transitive = false }
|
||||
}
|
||||
|
||||
task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.elasticsearch.river.RiverName;
|
|||
import org.elasticsearch.river.RiverSettings;
|
||||
import twitter4j.*;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -185,7 +184,8 @@ public class TwitterRiver extends AbstractRiverComponent implements River {
|
|||
dropThreshold = 10;
|
||||
}
|
||||
|
||||
stream = new TwitterStreamFactory(new StatusHandler()).getInstance(user, password);
|
||||
stream = new TwitterStreamFactory().getInstance(user, password);
|
||||
stream.addListener(new StatusHandler());
|
||||
}
|
||||
|
||||
@Override public void start() {
|
||||
|
@ -244,14 +244,15 @@ public class TwitterRiver extends AbstractRiverComponent implements River {
|
|||
builder.field("source", status.getSource());
|
||||
builder.field("truncated", status.isTruncated());
|
||||
|
||||
|
||||
if (status.getUserMentions() != null) {
|
||||
if (status.getUserMentionEntities() != null) {
|
||||
builder.startArray("mention");
|
||||
for (User user : status.getUserMentions()) {
|
||||
for (UserMentionEntity user : status.getUserMentionEntities()) {
|
||||
builder.startObject();
|
||||
builder.field("id", user.getId());
|
||||
builder.field("name", user.getName());
|
||||
builder.field("screen_name", user.getScreenName());
|
||||
builder.field("start", user.getStart());
|
||||
builder.field("end", user.getEnd());
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
|
@ -271,8 +272,16 @@ public class TwitterRiver extends AbstractRiverComponent implements River {
|
|||
builder.endObject();
|
||||
}
|
||||
|
||||
if (status.getHashtags() != null) {
|
||||
builder.array("hashtag", status.getHashtags());
|
||||
if (status.getHashtagEntities() != null) {
|
||||
builder.startArray("hashtag");
|
||||
for (HashtagEntity hashtag : status.getHashtagEntities()) {
|
||||
builder.startObject();
|
||||
builder.field("text", hashtag.getText());
|
||||
builder.field("start", hashtag.getStart());
|
||||
builder.field("end", hashtag.getEnd());
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
}
|
||||
if (status.getContributors() != null) {
|
||||
builder.array("contributor", status.getContributors());
|
||||
|
@ -295,11 +304,21 @@ public class TwitterRiver extends AbstractRiverComponent implements River {
|
|||
builder.field("url", status.getPlace().getURL());
|
||||
builder.endObject();
|
||||
}
|
||||
if (status.getURLs() != null) {
|
||||
if (status.getURLEntities() != null) {
|
||||
builder.startArray("link");
|
||||
for (URL url : status.getURLs()) {
|
||||
for (URLEntity url : status.getURLEntities()) {
|
||||
if (url != null) {
|
||||
builder.value(url.toExternalForm());
|
||||
builder.startObject();
|
||||
builder.field("url", url.getURL().toExternalForm());
|
||||
if (url.getDisplayURL() != null) {
|
||||
builder.field("display_url", url.getDisplayURL());
|
||||
}
|
||||
if (url.getExpandedURL() != null) {
|
||||
builder.field("expand_url", url.getExpandedURL());
|
||||
}
|
||||
builder.field("start", url.getStart());
|
||||
builder.field("end", url.getEnd());
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
builder.endArray();
|
||||
|
|
Loading…
Reference in New Issue