void ensureControlURISet() throws TwitterException { synchronized (lock) { try { int waits = 0; while (controlURI == null) { lock.wait(1000); waits++; if (waits > 29) throw new TwitterException("timed out for control uri to be ready"); } } catch (InterruptedException e) { } } }
/** * Returns the same text displayed on http://twitter.com/home when a maintenance window is scheduled, in the requested format. * * @return the schedule * @throws TwitterException when Twitter service or network is unavailable * @since Twitter4J 1.0.4 * @deprecated this method is not supported by the Twitter API anymore */ public String getDowntimeSchedule() throws TwitterException { throw new TwitterException( "this method is not supported by the Twitter API anymore" , new NoSuchMethodException("this method is not supported by the Twitter API anymore")); }
protected static void ensureRootNodeNameIs(String rootName, Element elem) throws TwitterException { if (!rootName.equals(elem.getNodeName())) { throw new TwitterException("Unexpected root node name:" + elem.getNodeName() + ". Expected:" + rootName + ". Check the availability of the Twitter API at http://status.twitter.com/."); } }
protected static void ensureRootNodeNameIs(String rootName, Document doc) throws TwitterException { Element elem = doc.getDocumentElement(); if (!rootName.equals(elem.getNodeName())) { throw new TwitterException("Unexpected root node name:" + elem.getNodeName() + ". Expected:" + rootName + ". Check the availability of the Twitter API at http://status.twitter.com/"); } }
RequestToken reqToken = (RequestToken) session.getAttribute(REQUEST_TOKEN); session.removeAttribute(REQUEST_TOKEN); if (!reqToken.getToken().equals(oauthToken)) { throw new TwitterException("Wrong oauth_token"); } AccessToken token = twitter.getOAuthAccessToken(reqToken);
public MuleHttpResponse(HttpClientConfiguration conf, MuleMessage response) throws TwitterException { super(conf); this.response = response; try { this.is = response.getPayload(InputStream.class); } catch (TransformerException e) { throw new TwitterException(e); } }
@Override public StatusStream getStream() throws TwitterException { try { return new SiteStreamsImpl(getDispatcher(), getSiteStream(withFollowings, follow), conf, cs); } catch (IOException e) { throw new TwitterException(e); } } });
long[] asFriendList(JSONObject json) throws TwitterException { JSONArray friends; try { friends = json.getJSONArray("friends"); long[] friendIds = new long[friends.length()]; for (int i = 0; i < friendIds.length; ++i) { friendIds[i] = Long.parseLong(friends.getString(i)); } return friendIds; } catch (JSONException e) { throw new TwitterException(e); } }
TimeZoneJSONImpl(JSONObject jSONObject) throws TwitterException { try { UTC_OFFSET = ParseUtil.getInt("utc_offset", jSONObject); NAME = jSONObject.getString("name"); TZINFO_NAME = jSONObject.getString("tzinfo_name"); } catch (JSONException jsone) { throw new TwitterException(jsone); } }
@Override public ResponseList<User> createUserListFromJSONArray_Users(HttpResponse res) throws TwitterException { try { return UserJSONImpl.createUserList(res.asJSONObject().getJSONArray("users"), res, conf); } catch (JSONException jsone) { throw new TwitterException(jsone); } }
/** * Returns the response body as twitter4j.org.json.JSONArray.<br> * Disconnects the internal HttpURLConnection silently. * @return response body as twitter4j.org.json.JSONArray * @throws TwitterException */ public JSONArray asJSONArray() throws TwitterException { try { return new JSONArray(asString()); } catch (JSONException jsone) { throw new TwitterException(jsone.getMessage() + ":" + this.responseAsString, jsone); } }
@Override public String getTermsOfService() throws TwitterException { try { return get(conf.getRestBaseURL() + "help/tos.json").asJSONObject().getString("tos"); } catch (JSONException e) { throw new TwitterException(e); } }
@Override public String getPrivacyPolicy() throws TwitterException { try { return get(conf.getRestBaseURL() + "help/privacy.json").asJSONObject().getString("privacy"); } catch (JSONException e) { throw new TwitterException(e); } }
DirectMessage asDirectMessage(JSONObject json) throws TwitterException { try { JSONObject dmJSON = json.getJSONObject("direct_message"); DirectMessage directMessage = new DirectMessageJSONImpl(dmJSON); if (CONF.isJSONStoreEnabled()) { TwitterObjectFactory.registerJSONObject(directMessage, dmJSON); } return directMessage; } catch (JSONException jsone) { throw new TwitterException(jsone); } }
private void init(JSONObject json) throws TwitterException { try { name = json.getString("name"); code = json.getString("code"); status = json.getString(("status")); } catch (JSONException jsone) { throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone); } }
private StatusStream getCountStream(String relativeUrl, int count) throws TwitterException { ensureAuthorizationEnabled(); try { return new StatusStreamImpl(getDispatcher(), http.post(conf.getStreamBaseURL() + relativeUrl , new HttpParameter[]{new HttpParameter("count", String.valueOf(count)) , stallWarningsParam}, auth, null), conf); } catch (IOException e) { throw new TwitterException(e); } }
static ResponseList<Place> createPlaceList(HttpResponse res, Configuration conf) throws TwitterException { JSONObject json = null; try { json = res.asJSONObject(); return createPlaceList(json.getJSONObject("result").getJSONArray("places"), res, conf); } catch (JSONException jsone) { throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone); } }
private void init(JSONObject json) throws TwitterException { try { JSONArray indicesArray = json.getJSONArray("indices"); setStart(indicesArray.getInt(0)); setEnd(indicesArray.getInt(1)); if (!json.isNull("text")) { this.text = json.getString("text"); } } catch (JSONException jsone) { throw new TwitterException(jsone); } }
private void init(JSONObject savedSearch) throws TwitterException { try { createdAt = parseDate(savedSearch.getString("created_at"), "EEE MMM dd HH:mm:ss z yyyy"); query = getString("query", savedSearch, true); position = getInt("position", savedSearch); name = getString("name", savedSearch, true); id = getInt("id", savedSearch); } catch (JSONException jsone) { throw new TwitterException(jsone.getMessage() + ":" + savedSearch.toString(), jsone); } }
static Trends constructTrends(Response res) throws TwitterException { JSONObject json = res.asJSONObject(); try { Date asOf = parseDate(json.getString("as_of")); JSONArray array = json.getJSONArray("trends"); Trend[] trendsArray = jsonArrayToTrendArray(array); return new Trends(res, asOf, asOf, trendsArray); } catch (JSONException jsone) { throw new TwitterException(jsone.getMessage() + ":" + res.asString(), jsone); } }