Example usage for org.apache.http.client ClientProtocolException printStackTrace

List of usage examples for org.apache.http.client ClientProtocolException printStackTrace

Introduction

In this page you can find the example usage for org.apache.http.client ClientProtocolException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.github.znwabudike.androidphonedatabase.http.HttpHelper.java

public HttpResponse getResponse(String uri) {
    client = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(uri);
    HttpResponse response = null;//from   w w  w.jav  a 2s  .c  o  m

    try {
        log("Sending request");
        response = client.execute(httpGet);
        log("Got Response");
        StatusLine statusLine = response.getStatusLine();
        log("Getting Status");
        int statusCode = statusLine.getStatusCode();
        log("Status Code = " + (statusCode == 200 ? "Ok" : ("Fail " + statusCode)));

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return response;
}

From source file:org.brunocvcunha.taskerbox.impl.custom.slickdeals.SlickDealsEmailAction.java

@Override
public void spreadAction(final String url, String postTitle) {
    EmailAction email = getEmailAction();

    EmailValueVO emailVO = new EmailValueVO();
    StringBuffer sb = new StringBuffer();
    sb.append(url);/*from   w w w.j  av a2  s .  c om*/

    emailVO.setTitle("SlickDeals - " + postTitle);

    try {
        Document doc = TaskerboxHttpBox.getInstance().getDocumentForURL(url);

        for (Element post : doc.select(".post_message")) {
            sb.append("<br>");
            sb.append(post.html());
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    emailVO.setBody(sb.toString());

    email.action(emailVO);

}

From source file:org.service.TaskInsert.java

@Override
protected Boolean doInBackground(String... params) {
    Boolean r = false;//from  www.  j  av a2s.c  o  m
    ApiRest apiRest = new ApiRest();
    try {
        r = apiRest.uploadPhoto(params[0], nameEdifice, nameFloor, numberFloor);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return r;
}

From source file:com.example.lilach.alsweekathon_new.MainActivity.java

public static void makeRequest(String uri, String json) {
    final String uri_final = uri;
    final String json_final = json;
    Thread thread = new Thread(new Runnable() {
        @Override/*  ww w.j a  v a2  s .c o  m*/
        public void run() {
            try {
                //Your code goes here

                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(uri_final);
                httppost.setHeader("Accept", "application/json");
                httppost.setHeader("Content-type", "application/json");

                try {
                    // Add your data

                    httppost.setEntity(new StringEntity(json_final));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);
                    Log.d("response: ", response.getEntity().toString());
                    // return response;

                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                    Log.d("exception: ", e.getMessage());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    Log.d("exception: ", e.getMessage());
                } catch (Exception e) {
                    Log.d("exception: ", e.getMessage());
                }
                // return null;
            } catch (Exception e) {
                e.printStackTrace();
                Log.d("exception: ", e.getMessage());
            }
        }
    });

    thread.start();

    //        //HttpClient httpClient = new DefaultHttpClient();
    //       // HttpClient httpclient = HttpClientBuilder.create().build();
    //       // MinimalHttpClient httpclient = new HttpClientBuilder().build();
    //       // AndroidHttpClient
    //        try {
    //            HttpPost httpPost = new HttpPost(uri);
    //            httpPost.setEntity(new StringEntity(json));
    //            httpPost.setHeader("Accept", "application/json");
    //            httpPost.setHeader("Content-type", "application/json");
    //            return new DefaultHttpClient().execute(httpPost);
    //        } catch (UnsupportedEncodingException e) {
    //            e.printStackTrace();
    //        } catch (ClientProtocolException e) {
    //            e.printStackTrace();
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        }
    //        return null;
}

From source file:org.jreader.reader.Reader.java

public void start() {
    HttpConnector conn = new HttpConnector(uri);
    try {/*w  w  w  .j a v a  2s .  com*/
        conn.start();

        if (uriType == Rss) {
            readRss(conn.getEntity().getContent());
        }

    } catch (ClientProtocolException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (DataSourceException e) {
        e.printStackTrace();
    }

    //      
    // String
    // contentType=conn.getHeader(HttpConnector.HEADER_CONTENT_TYPE).getValue();
    // if(contentType.endsWith("xml")){// rss ?
    //         
    // }else if(contentType.endsWith("html")){// blog
    //         
    // }
}

From source file:com.kasabi.data.movies.dbpedia.DBPediaBaseLinker.java

protected String getURI(HttpClient httpclient, String type, String string) {
    String uri = null;//  w ww  .  j a  va 2 s.  co m
    try {
        String queryClass = type != null ? "&QueryClass=" + URLEncoder.encode(type, "UTF-8") : "";
        String queryString = "?QueryString=" + URLEncoder.encode(string, "UTF-8");
        HttpGet httpget = new HttpGet(
                "http://lookup.dbpedia.org/api/search.asmx/KeywordSearch" + queryString + queryClass);
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httpget, responseHandler);
        Document document = Jsoup.parse(responseBody);
        Elements elements = document.select("result > uri");
        if (!elements.isEmpty()) {
            uri = elements.first().text();
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return uri;
}

From source file:goofyhts.torrentkinesis.http.client.DefaultHttpClient.java

@Override
public String getURL(String url) {
    System.out.println("Request=" + url);
    String responseString = null;
    try {//from   w  w  w  . j  a va2 s . com
        HttpGet httpGet = new HttpGet(url);
        CloseableHttpResponse response = client.execute(httpGet, context);
        responseString = IOUtils.toString(response.getEntity().getContent());
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return responseString;
}

From source file:org.megam.deccanplato.provider.twilio.TwilioAdapterAccess.java

@Override
public <T> DataMap<T> authenticate(DataMap<T> accessMap) throws AdapterAccessException {
    Map<String, T> access = accessMap.map();
    final String twilioAccount_url = "https://" + access.get(ACCOUNT_SID) + ":" + access.get(OAUTH_TOKEN)
            + "@api.twilio.com/2010-04-01/Accounts.json";

    TransportTools tools = new TransportTools(twilioAccount_url, null);
    String responseBody = null;//  w w w. ja  va2 s.c om

    TransportResponse response = null;
    try {
        response = TransportMachinery.get(tools);
        responseBody = response.entityToString();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    success = true;
    return accessMap;
}

From source file:org.megam.deccanplato.provider.zoho.crm.ZohoCRMAdapterAccess.java

@Override
public <T extends Object> DataMap<T> authenticate(DataMap<T> access) throws AdapterAccessException {
    Map<String, T> accessMap = access.map();
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new BasicNameValuePair("SCOPE", "ZohoCRM/crmapi"));
    list.add(new BasicNameValuePair("EMAIL_ID", (String) accessMap.get(EMAIL_ID)));
    list.add(new BasicNameValuePair("PASSWORD", (String) accessMap.get(PASSWORD)));

    TransportTools tools = new TransportTools(ZOHO_AUTH_URL, list);
    String responseBody = null;/*from  w w  w.  j  a  v  a  2s  .c  o m*/

    TransportResponse response = null;
    try {
        response = TransportMachinery.post(tools);
        responseBody = response.entityToString();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return parseOutput(responseBody);
}

From source file:org.megam.deccanplato.provider.zoho.invoice.ZohoInvoiceAdapterAccess.java

@Override
public <T extends Object> DataMap<T> authenticate(DataMap<T> access) throws AdapterAccessException {
    Map<String, T> accessMap = access.map();
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new BasicNameValuePair("SCOPE", "ZohoInvoice/invoiceapi"));
    list.add(new BasicNameValuePair("EMAIL_ID", (String) accessMap.get(EMAIL_ID)));
    list.add(new BasicNameValuePair("PASSWORD", (String) accessMap.get(PASSWORD)));

    TransportTools tools = new TransportTools(ZOHO_AUTH_URL, list);
    String responseBody = null;/*from   w ww  .  j a  va2 s. co  m*/

    TransportResponse response = null;
    try {
        response = TransportMachinery.post(tools);
        responseBody = response.entityToString();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return parseOutput(responseBody);
}