Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.BasicResponseHandler


            }


            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                content = responseHandler.handleResponse(response);
            }
            else {
                // attempt to get a human-readable message
                String message = null;
                try {
View Full Code Here


        HttpResponse response = client.execute(request);
        int statusCode = response.getStatusLine().getStatusCode();
        final String reasonPhrase = response.getStatusLine().getReasonPhrase();
        if (statusCode == 200) {
            countSuccessfulApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, requestUrl);
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String json = responseHandler.handleResponse(response);
            JSONObject userInfo = JSONObject.fromObject(json);
            return userInfo.getString("registrationDate");
        }
        else {
            countFailedApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, requestUrl, reasonPhrase, statusCode, reasonPhrase);
View Full Code Here

        HttpResponse response = client.execute(request);
        final int statusCode = response.getStatusLine().getStatusCode();
        final String reasonPhrase = response.getStatusLine().getReasonPhrase();
        if (statusCode == 200) {
            countSuccessfulApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, requestUrl);
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String json = responseHandler.handleResponse(response);
            JSONObject userInfo = JSONObject.fromObject(json);
            return userInfo.getJSONArray("timezones");
        }
        else {
            countFailedApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, requestUrl, "", statusCode, reasonPhrase);
View Full Code Here

            HttpGet get = new HttpGet(url);
            get.setHeader("Authorization", "Bearer " + updateInfo.getContext("accessToken"));
            HttpResponse response = client.execute(get);
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String content = responseHandler.handleResponse(response);
                countSuccessfulApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, url);
                return content;
            } else {
                handleErrors(statusCode, response, "Could not update Jawbone Up Moves Data");
            }
View Full Code Here

    }

    private void handleErrors(final int statusCode, final HttpResponse response, final String message) throws Exception {
        // try to extract more information from the response
        try {
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String content = responseHandler.handleResponse(response);
            JSONObject errorJson = JSONObject.fromObject(content);
            if (errorJson.has("meta")) {
                JSONObject meta = errorJson.getJSONObject("meta");
                if (meta.has("error_type")) {
                    String details = meta.has("error_detail") ? meta.getString("error_details") : "Unknown Error (no details provided)";
View Full Code Here

        extractRateLimitHeaders(response, STATUSES_USER_TIMELINE, updateInfo);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == 200) {
      countSuccessfulApiCall(updateInfo.apiKey,
          updateInfo.objectTypes, then, requestUrl);
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      String json = responseHandler.handleResponse(response);
      JSONArray statuses = JSONArray.fromObject(json);
      if (statuses!=null) {
        apiDataService.cacheApiDataJSON(updateInfo, json, -1, -1);
      }
      return statuses.size();
View Full Code Here

        extractRateLimitHeaders(response, DIRECT_MESSAGES, updateInfo);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == 200) {
      countSuccessfulApiCall(updateInfo.apiKey,
          updateInfo.objectTypes, then, requestUrl);
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      String json = responseHandler.handleResponse(response);
      JSONArray directMessages = JSONArray.fromObject(json);
      if (directMessages!=null) {
        updateInfo.setContext("sent", "0");
        apiDataService.cacheApiDataJSON(updateInfo, json, -1, -1);
      }
View Full Code Here

        extractRateLimitHeaders(response, DIRECT_MESSAGES_SENT, updateInfo);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == 200) {
      countSuccessfulApiCall(updateInfo.apiKey,
          updateInfo.objectTypes, then, requestUrl);
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      String json = responseHandler.handleResponse(response);
      JSONArray directMessages = JSONArray.fromObject(json);
      if (directMessages!=null) {
        updateInfo.setContext("sent", "1");
        apiDataService.cacheApiDataJSON(updateInfo, json, -1, -1);
      }
View Full Code Here

        extractRateLimitHeaders(response, STATUSES_MENTIONS_TIMELINE, updateInfo);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == 200) {
      countSuccessfulApiCall(updateInfo.apiKey,
          updateInfo.objectTypes, then, requestUrl);
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      String json = responseHandler.handleResponse(response);
      JSONArray mentions = JSONArray.fromObject(json);
      if (mentions!=null) {
        apiDataService.cacheApiDataJSON(updateInfo, json, -1, -1);
      }
      return mentions.size();
View Full Code Here

    private String getActivationInfo(final HttpClient client, final HttpContext httpContext, final String userSignature) throws IOException, UnexpectedHttpResponseCodeException {
        HttpGet get = new HttpGet("http://mymee.iriscouch.com/activation/" + userSignature);
        final HttpResponse response = client.execute(get, httpContext);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == HttpStatus.SC_OK) {
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String content = responseHandler.handleResponse(response);
            JSONObject json = JSONObject.fromObject(content);
            if (json.has("payload")) {
                return json.getString("payload");
            }
            else throw new RuntimeException("Could not get payload from Couch server");
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.BasicResponseHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.