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:org.megam.deccanplato.provider.salesforce.chatter.handler.LikesImpl.java

/**
 * This method shows a specfic like item details
 * it takes like id as input/*from w  w w  .  j a  v a  2s. co m*/
 * @param outMap
 * @return
 */
private Map<String, String> view() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_CHATTER_CONVERSATION_URL = "/services/data/v25.0/chatter/likes/" + args.get(ID);

    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(args.get(INSTANCE_URL) + SALESFORCE_CHATTER_CONVERSATION_URL, null,
            header);
    try {
        String response = TransportMachinery.get(tst).entityToString();
        outMap.put(OUTPUT, response);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:es.eucm.eadventure.tracking.prv.service.TrackingPoster.java

public boolean sendChunk(List<GameLogEntry> entries) {
    if (baseURL == null)
        return false;
    if (chunksPath == null)
        return false;
    boolean sent = false;
    try {//from www  .j a va 2 s. co m
        HttpClient httpclient = new DefaultHttpClient();
        String url = baseURL + (baseURL.endsWith("/") ? "" : "/") + chunksPath;

        String chunk = "";
        for (GameLogEntry entry : entries) {
            chunk += entry.toString();
        }

        HttpPost httpput = new HttpPost(url);
        StringEntity myEntity = new StringEntity(chunk, "UTF-8");
        httpput.setEntity(myEntity);
        HttpResponse response;

        response = httpclient.execute(httpput);
        if (response != null && Integer.toString(response.getStatusLine().getStatusCode()).startsWith("2")) {
            sent = true;
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sent;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.ChatterActivityImpl.java

/**
 * @param outMap/* ww  w. jav  a  2  s .c o m*/
 * @return
 */
private Map<String, String> list(Map<String, String> outMap) {

    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(args.get(INSTANCE_URL) + SALESFORCE_CHATTER_ACTIVITY_URL, null,
            header);
    String responseBody = null;

    TransportResponse response = null;

    try {
        response = TransportMachinery.get(tst);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.ChatterAnswersActivityImpl.java

/**
 * @param outMap//from ww w .jav  a  2 s .co  m
 * @return
 */
private Map<String, String> list(Map<String, String> outMap) {

    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(args.get(INSTANCE_URL) + SALESFORCE_CHATTER_ANSWER_ACTIVITY_URL,
            null, header);
    String responseBody = null;

    TransportResponse response = null;

    try {
        response = TransportMachinery.get(tst);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.ChatterConversationImpl.java

/**
 * @param outMap/*  w  w w  .  j a  v  a2  s  .  co  m*/
 * @return
 */
private Map<String, String> list(Map<String, String> outMap) {

    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(args.get(INSTANCE_URL) + SALESFORCE_CHATTER_CONVERSATION_URL, null,
            header);
    String responseBody = null;

    TransportResponse response = null;

    try {
        response = TransportMachinery.get(tst);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
}

From source file:com.towerlabs.yildizyemek.HttpTask.java

@Override
protected String doInBackground(String... params) {
    // TODO Auto-generated method stub

    try {/*from   www .j a  v  a  2 s  .  c  o m*/

        httpResponse = httpClient.execute(new HttpGet(params[0]));
        inputStream = httpResponse.getEntity().getContent();
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

        String line;
        while ((line = bufferedReader.readLine()) != null)
            builder.append(line);
        line = null;

        error = true;

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        error = false;

    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        error = false;

    } catch (UnknownHostException e) {
        // TODO: handle exception
        Log.d("Balant", "Balant hatas.");
        error = false;

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        error = false;

    }

    return builder.toString();
}

From source file:de.unistuttgart.ipvs.pmp.apps.vhike.tools.JSonRequestReader.java

public static boolean isPicked(String sid) {
    listToParse.clear();//from  w  ww.ja v  a 2s .  c o  m
    listToParse.add(new ParamObject("sid", sid, false));

    JsonObject object = null;

    try {
        object = JSonRequestProvider.doRequest(listToParse, "isPicked.php");
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    boolean suc = false;
    boolean picked = false;
    if (object != null) {
        suc = object.get("successful").getAsBoolean();
        if (suc) {
            picked = object.get("picked").getAsBoolean();
        }
    }
    return picked;
}

From source file:com.openingdesign.qna.service.impl.QueryAndResponseLocalServiceImpl.java

private void createPad(QueryAndResponse qnr) throws PortalException {

    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet(qnr.getUrl() + "?createImmediately=true");
    System.out.println("CREATE_PAD, URI=" + get.getURI());
    try {/* w ww  . j av a  2  s  .  c  o m*/
        HttpResponse response = client.execute(get);
        System.out.println("RESPONSE: status_line=" + response.getStatusLine());
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        throw new PortalException("unable to create pad");
    } catch (IOException e) {
        e.printStackTrace();
        throw new PortalException("unable to create pad");
    }

}

From source file:de.unistuttgart.ipvs.pmp.apps.vhike.tools.JSonRequestReader.java

/**
 * Hitchhiker can accept or decline an offer
 * /*  w w w. j  a v a2 s .c  om*/
 * @param sid
 * @param offer_id
 * @param accept
 * @return status
 */
public static boolean pick_up(String sid, int user_id) {
    listToParse.clear();
    listToParse.add(new ParamObject("sid", sid, false));

    listToParse.add(new ParamObject("user_id", String.valueOf(user_id), true));
    JsonObject object = null;

    try {
        object = JSonRequestProvider.doRequest(listToParse, "pick_up.php");
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    boolean suc = false;
    if (object != null) {
        suc = object.get("successful").getAsBoolean();
        if (suc) {
            return true;
        }
    }
    return false;
}

From source file:com.michael.feng.utils.YahooWeather4a.WOEIDUtils.java

private String queryYahooWeather(Context context, String queryString) {
    Log.d("tag", "QueryYahooWeather");
    String qResult = "";
    //      queryString = Uri.encode(queryString);

    HttpClient httpClient = new DefaultHttpClient();

    // return Uri.encode(queryString);

    HttpGet httpGet = new HttpGet(queryString);

    try {/*from   w  w  w .  j a v a2s .  co m*/
        HttpEntity httpEntity = httpClient.execute(httpGet).getEntity();

        if (httpEntity != null) {
            InputStream inputStream = httpEntity.getContent();
            Reader in = new InputStreamReader(inputStream);
            BufferedReader bufferedreader = new BufferedReader(in);
            StringBuilder stringBuilder = new StringBuilder();

            String stringReadLine = null;

            while ((stringReadLine = bufferedreader.readLine()) != null) {
                stringBuilder.append(stringReadLine + "\n");
            }

            qResult = stringBuilder.toString();
        }

    } catch (ClientProtocolException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    }

    return qResult;

}