List of usage examples for org.apache.http.client ClientProtocolException printStackTrace
public void printStackTrace()
From source file:org.brunocvcunha.taskerbox.impl.crawler.PastebinAction.java
public void spreadAction(final String id, String postTitle) { try {/*from w w w . j ava 2 s . co m*/ log.debug("Getting " + URL_START + id); HttpResponse response = TaskerboxHttpBox.getInstance().getResponseForURL(URL_START + id); String content = TaskerboxHttpBox.getInstance().readResponseFromEntity(response.getEntity()); if (isConsiderable(id, content)) { if (isValid(id, content)) { logInfo(log, "[+] Bound: [" + postTitle + "]"); doValid("pastebin_" + id, content); } else { log.debug("[-] Not Bound: [" + postTitle + "]"); doInvalid("pastebin_" + id, content); } } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:edu.rit.csh.androidwebnews.HttpsPutAsyncTask.java
/** * The method that gets run when execute() is run. This sends the URL with the * PUT parameters to the server and gets the results * * @param params - [0] is the URL to got to, the rest are parameters to the request * @return String representation of page results *//*w w w . j av a 2 s . co m*/ @Override protected String doInBackground(BasicNameValuePair... params) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); String line; try { HttpPut request = new HttpPut(params[0].getValue()); request.addHeader("accept", "application/json"); //params = Arrays.copyOfRange(params, 1, params.length); for (BasicNameValuePair param : params) { nvp.add(new BasicNameValuePair(param.getName(), param.getValue())); } request.setEntity(new UrlEncodedFormEntity(nvp)); HttpResponse response = httpclient.execute(request); BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder sb = new StringBuilder(""); String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line).append(NL); } in.close(); return sb.toString(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return ""; }
From source file:org.brunocvcunha.taskerbox.impl.crawler.CodepadAction.java
public void spreadAction(final String id, String postTitle) { try {//from w w w.j a v a2 s. co m log.debug("Getting " + URL_DOWNLOAD.replace("{id}", id)); HttpResponse response = TaskerboxHttpBox.getInstance() .getResponseForURL(URL_DOWNLOAD.replace("{id}", id)); String content = TaskerboxHttpBox.getInstance().readResponseFromEntity(response.getEntity()); if (isConsiderable(id, content)) { if (isValid(id, content)) { logInfo(log, "[+] Bound: [" + postTitle + "]"); doValid("codepad_" + id, content); } else { log.debug("[-] Not Bound: [" + postTitle + "]"); doInvalid("codepad_" + id, content); } } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:org.brunocvcunha.taskerbox.impl.crawler.PastieAction.java
public void spreadAction(final String id, String postTitle) { try {// w w w .ja v a 2 s . co m log.debug("Getting " + DOWNLOAD_URL.replace("{id}", id)); HttpResponse response = TaskerboxHttpBox.getInstance() .getResponseForURL(DOWNLOAD_URL.replace("{id}", id)); String content = TaskerboxHttpBox.getInstance().readResponseFromEntity(response.getEntity()); if (isConsiderable(id, content)) { if (isValid(id, content)) { logInfo(log, "[+] Bound: [" + postTitle + "]"); doValid("pastie_" + id, content); } else { log.debug("[-] Not Bound: [" + postTitle + "]"); doInvalid("pastie_" + id, content); } } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.SaveConfigurationHandler.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { try {/*from w w w .ja v a 2s . com*/ saveConfigurations(SkillproService.getSkillproProvider().getAssetRepo().getRootAssets()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:org.megam.deccanplato.provider.sugarcrm.SugarCRMAdapterAccess.java
@Override public <T extends Object> DataMap<T> authenticate(DataMap<T> access) throws AdapterAccessException { Map<String, T> accessMap = access.map(); SugarLogin sl = new SugarLogin(accessMap); Gson gson = new Gson(); String json = gson.toJson(sl); List<NameValuePair> list = new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair(METHOD, MODULE)); list.add(new BasicNameValuePair(INPUT_TYPE, TYPE)); list.add(new BasicNameValuePair(RESPONSE_TYPE, TYPE)); list.add(new BasicNameValuePair(DATA, json)); TransportTools tools = new TransportTools(SUGAR_URL, list); String responseBody = null;/*from ww w . ja v a 2s .com*/ TransportResponse response = null; try { response = TransportMachinery.post(tools); responseBody = response.entityToString(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } DataMap<T> respMap = new DefaultDataMap<T>(); respMap = parsOutput(responseBody, respMap); return respMap; }
From source file:org.megam.deccanplato.provider.salesforce.chatter.handler.InfluenceThresholdsImpl.java
/** * this method lists details about influence threshold * @param outMap//from w w w . j av a 2 s.c o m * @return */ private Map<String, String> list() { Map<String, String> outMap = new HashMap<>(); 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:org.megam.deccanplato.provider.salesforce.chatter.handler.FileFeedImpl.java
/** * this method lists all file//w w w. ja v a2 s .co m * @param outMap * @return a map */ private Map<String, String> list() { Map<String, String> outMap = new HashMap<>(); final String SALESFORCE_CHATTER_ACTIVITY_URL = "/services/data/v25.0/chatter/feeds/news/0059000000103ohAAA/feed-items"; 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); 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:Recieve.java
public String send(String URL) { String output2 = ""; try {//w w w . j ava 2 s. c o m DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet getRequest = new HttpGet(URL); getRequest.addHeader("accept", "application/json"); HttpResponse response = httpClient.execute(getRequest); if (response.getStatusLine().getStatusCode() != 200) { throw new RuntimeException( "Failed : HTTP error code : " + response.getStatusLine().getStatusCode()); } BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { output2 = output; System.out.println(output); } httpClient.getConnectionManager().shutdown(); return output2; } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return output2; }
From source file:uk.ac.bbsrc.tgac.miso.core.service.integration.ws.pacbio.PacBioService.java
public String getPlateStatus(String plateId) { HttpGet httpget = new HttpGet(baseRestUri.toString() + "/Jobs/Plate/" + plateId + "/Status"); try {// w w w . j a v a2s . co m HttpResponse response = httpclient.execute(httpget); String out = parseEntity(response.getEntity()); JSONObject j = JSONObject.fromObject(out); if (j.has("Status")) { return j.getString("Status"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }