Permalink
Browse files

Merge branch 'master' into TFJ-671

  • Loading branch information...
yusuke committed Nov 15, 2012
2 parents eaade47 + 8839be1 commit 76d67d17f2b8f179769145c02820baf8d5d775c1
View
@@ -29,6 +29,7 @@ Dan Checkoway <dcheckoway at gmail.com>
Dong Wang <dong at twitter.com> @dongwang218
Eric Jensen <ej at twitter.com> @ej
Fiaz Hossain <fiaz at twitter.com> @fiazhossain
+Gonçalo Silva <goncalossilva at gmail.com> @goncalossilva
Hitoshi Kunimatsu <hkhumanoid at gmail.com>
Jacob S. Hoffman-Andrews <jsha at twitter.com> @j4cob
Jenny Loomis <jenny at rockmelt.com>
@@ -41,6 +42,7 @@ marr-masaaki <marr fiveflavors at gmail.com> @marr
Max Penet <m at qbits.cc> @mpenet
Mocel <docel77 at gmail.com> @Mocel
Nobutoshi Ogata <n-ogata at cnt.biglobe.co.jp> @nobu666
+Nicolas Bouillon <nicolas at bouil.org>
Nicholas Dellamaggiore <nick.dellamaggiore at gmail.com> @nickdella
Perry Sakkaris <psakkaris at gmail.com>
Roberto Estrada <robestradac at gmail.com>
@@ -230,6 +230,17 @@ public long getRetweetCount() {
public boolean isRetweetedByMe() {
return getTarget().isRetweetedByMe();
}
+
+ /**
+ * Returns the authenticating user's retweet of this tweet, or null when the tweet was created
+ * before this feature was enabled. Note that the available information is restricted to its id.
+ *
+ * @return the authenticating user's retweet of this tweet
+ * @since Twitter4J 3.0.0
+ */
+ public Status getMyRetweet() {
+ return getTarget().getMyRetweet();
+ }
@Override
public boolean isPossiblySensitive() {
@@ -153,6 +153,15 @@
* @since Twitter4J 2.1.4
*/
boolean isRetweetedByMe();
+
+ /**
+ * Returns the authenticating user's retweet of this tweet, or null when the tweet was created
+ * before this feature was enabled. Note that the available information is restricted to its id.
+ *
+ * @return the authenticating user's retweet of this tweet
+ * @since Twitter4J 3.0.0
+ */
+ Status getMyRetweet();
/**
* Returns true if the status contains a link that is identified as sensitive.
@@ -28,7 +28,7 @@
public class AccessToken extends OAuthToken implements java.io.Serializable {
private static final long serialVersionUID = -8344528374458826291L;
private String screenName;
- private long userId;
+ private long userId = -1L;
AccessToken(HttpResponse res) throws TwitterException {
this(res.asString());
@@ -38,18 +38,27 @@
super(str);
screenName = getParameter("screen_name");
String sUserId = getParameter("user_id");
- if (sUserId != null) userId = Long.parseLong(sUserId);
+ if (sUserId != null) {
+ userId = Long.parseLong(sUserId);
+ }
}
public AccessToken(String token, String tokenSecret) {
super(token, tokenSecret);
String sUserId;
- try {
- sUserId = token.substring(0, token.indexOf("-"));
- } catch (IndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Invalid access token format.");
+ int dashIndex = token.indexOf("-");
+ if (dashIndex != -1) {
+ sUserId = token.substring(0, dashIndex);
+ try {
+ userId = Long.parseLong(sUserId);
+ } catch (NumberFormatException ignore) {
+ }
}
- if (sUserId != null) userId = Long.parseLong(sUserId);
+ }
+
+ public AccessToken(String token, String tokenSecret, long userId) {
+ super(token, tokenSecret);
+ this.userId = userId;
}
/**
@@ -55,7 +55,6 @@
private GeoLocation geoLocation = null;
private Place place = null;
private long retweetCount;
- private boolean wasRetweetedByMe;
private boolean isPossiblySensitive;
private long[] contributorsIDs;
@@ -210,7 +209,6 @@ private void init(JSONObject json) throws TwitterException {
if (!json.isNull("current_user_retweet")) {
try {
myRetweetedStatus = new StatusJSONImpl(json.getJSONObject("current_user_retweet"));
- wasRetweetedByMe = true;
} catch (JSONException ignore) {
ignore.printStackTrace();
logger.warn("failed to parse current_user_retweet:" + json);
@@ -366,7 +364,14 @@ public long getRetweetCount() {
*/
@Override
public boolean isRetweetedByMe() {
- return wasRetweetedByMe;
+ return myRetweetedStatus != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Status getMyRetweet() {
+ return myRetweetedStatus;
}
/**
@@ -468,7 +473,6 @@ public String toString() {
", geoLocation=" + geoLocation +
", place=" + place +
", retweetCount=" + retweetCount +
- ", wasRetweetedByMe=" + wasRetweetedByMe +
", isPossiblySensitive=" + isPossiblySensitive +
", contributorsIDs=" + Arrays.toString(contributorsIDs) +
", retweetedStatus=" + retweetedStatus +
@@ -111,8 +111,8 @@ public static Date getDate(String name, JSONObject json, String format) throws T
public static Date getDate(String name, String format) throws TwitterException {
SimpleDateFormat sdf = formatMap.get().get(format);
if (null == sdf) {
- sdf = new SimpleDateFormat(format, Locale.ENGLISH);
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ sdf = new SimpleDateFormat(format, Locale.US);
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
formatMap.get().put(format, sdf);
}
try {
@@ -208,4 +208,4 @@ public static int toAccessLevel(HttpResponse res) {
}
return accessLevel;
}
-}
+}
@@ -46,8 +46,16 @@
}
public void next(StreamListener[] listeners) throws TwitterException {
- this.listener = (SiteStreamsListener) listeners[0];
- handleNextElement();
+ try {
+ this.listener = (SiteStreamsListener) listeners[0];
+ handleNextElement();
+ } catch (TwitterException e) {
+ if ("Stream closed.".equals(e.getMessage())) {
+ // Reset control URI since stream is closed
+ cs.setControlURI(null);
+ }
+ throw e;
+ }
}
protected String parseLine(String line) {

0 comments on commit 76d67d1

Please sign in to comment.