List of usage examples for org.apache.http.client ClientProtocolException printStackTrace
public void printStackTrace()
From source file:ca.ualberta.cs.c301f12t01.serverStorage.Server.java
/** * // w w w . j a v a 2 s . c om * @param nvp * NameValuePair to post to the server * @return * The json formatted string we got back */ public String post(List<BasicNameValuePair> nvp) { String jsonStringVersion = null; DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpGet = new HttpPost(serverName); try { httpGet.setEntity(new UrlEncodedFormEntity(nvp)); HttpResponse response = httpclient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { //System.out.println(response.getStatusLine()); InputStream is = entity.getContent(); jsonStringVersion = ServerUtils.convertStreamToString(is); } return jsonStringVersion; } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; //hopefully we never get here }
From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.WipeResourceExecutableSkillsHandler.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { try {/*from w w w . j a v a 2 s . c o m*/ Report report = wipeWipeWipe(); MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.OK); messageBox.setText("Wiping Resource Executable Skills"); messageBox.setMessage(report.message); messageBox.open(); } catch (ClientProtocolException e) { e.printStackTrace(); MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "Protocol exception", e.getMessage(), SWT.SHEET); } catch (IOException e) { e.printStackTrace(); MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "IOException exception", e.getMessage(), SWT.SHEET); } return null; }
From source file:ops.http.GsonRestClient.java
protected <D> D executeGet(String url, Type listType, Param... params) { try {//from w w w . ja v a2s . c o m String addParams = "?"; for (Param param : params) { addParams += param.key + "=" + param.value + "&"; } if (addParams.endsWith("&") || addParams.endsWith("?")) { addParams = addParams.substring(0, addParams.length() - 1); } HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(baseUrl + url + addParams); HttpResponse execute = client.execute(httpGet); return (D) gson.fromJson(new InputStreamReader(execute.getEntity().getContent()), listType); } catch (ClientProtocolException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }
From source file:models.ApiConnector.java
public JSONArray GetAllTeas() { String url = "http://chuangmi.my-place.us/getAllTeas.php"; /*/*from ww w. java 2 s . c o m*/ * Get HttpResponse object from the url * Get HttpEntity from Http Response object */ HttpEntity httpEntity = null; try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); httpEntity = httpResponse.getEntity(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //convert HttpEntity into JSON array JSONArray jsonArray = null; if (httpEntity != null) { try { String entityResponse = EntityUtils.toString(httpEntity); Log.e("Entity Response : ", entityResponse); jsonArray = new JSONArray(entityResponse); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return jsonArray; }
From source file:models.ApiConnectorPromotions.java
public JSONArray GetAllTeas() { String url = "http://chuangmi.my-place.us/getAllPromotionInfo.php"; /*/* ww w .j a v a 2 s . c om*/ * Get HttpResponse object from the url * Get HttpEntity from Http Response object */ HttpEntity httpEntity = null; try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); httpEntity = httpResponse.getEntity(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //convert HttpEntity into JSON array JSONArray jsonArray = null; if (httpEntity != null) { try { String entityResponse = EntityUtils.toString(httpEntity); Log.e("Entity Response : ", entityResponse); jsonArray = new JSONArray(entityResponse); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return jsonArray; }
From source file:org.thiesen.hhpt.geolookup.appengine.AppEngineStationFinder.java
public Stations makeGeoLookup(final double lat, final double lon, final double defaultSearchRadiusMiles) { final HttpClient client = new DefaultHttpClient(); final HttpGet get = new HttpGet("http://hhpt-search.appspot.com/search?lat=" + lat + "&lng=" + lon + "&radius=" + defaultSearchRadiusMiles); try {//from w w w . ja v a 2 s . c om final ResponseHandler<String> responseHandler = new BasicResponseHandler(); final String body = client.execute(get, responseHandler); return parse(body); } catch (final ClientProtocolException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } catch (final JSONException e) { e.printStackTrace(); } return new Stations(); }
From source file:com.almende.arum.RESTEndpoint.java
/** * Gets the job./*from ww w . j a v a 2 s .c o m*/ */ public void getJob() { String url = "http://95.211.177.143:8080/arum/fnsd/production/jobs/"; HttpGet httpGet = new HttpGet(URI.create(url)); try { httpGet.addHeader("Accept", "application/json"); HttpResponse resp = client.execute(httpGet); String responseBody = EntityUtils.toString(resp.getEntity()); ArrayNode tree = (ArrayNode) JOM.getInstance().readTree(responseBody); if (oldData != null) { } oldData = tree; } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (httpGet != null) { httpGet.reset(); } } }
From source file:org.brunocvcunha.taskerbox.impl.crawler.SlexyAction.java
public void spreadAction(final String id, String postTitle) { try {//from www .j a v a 2s. c o m log.debug("Getting " + URL_DOWNLOAD.replace("{id}", id)); HttpGet get = new HttpGet(URL_DOWNLOAD.replace("{id}", id)); get.addHeader("Referer", "http://slexy.org/recent"); HttpResponse response = TaskerboxHttpBox.getInstance().getHttpClient().execute(get); String content = TaskerboxHttpBox.getInstance().readResponseFromEntity(response.getEntity()); if (isConsiderable(id, content)) { if (isValid(id, content)) { logInfo(log, "[+] Bound: [" + postTitle + "]"); doValid("slexy_" + id, content); } else { logInfo(log, "[-] Not Bound: [" + postTitle + "]"); doInvalid("slexy_" + id, content); } } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.brunocvcunha.taskerbox.impl.crawler.SniptAction.java
public void spreadAction(final String id, String postTitle) { try {//from w w w . jav a 2s . c o 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("snipt_" + id, content); } else { log.debug("[-] Not Bound: [" + postTitle + "]"); doInvalid("snipt_" + 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:com.aremaitch.codestock2010.datadownloader.ScheduleBuilder.java
public ArrayList<Long> getBuiltSchedule() { ArrayList<Long> result = new ArrayList<Long>(); DefaultHttpClient hc = new DefaultHttpClient(); HttpGet hg = new HttpGet( scheduleBuilderURL + "?" + scheduleBuilderSvc + "=" + Long.toString(this._builderID)); HttpResponse response;/*ww w . j a va2s . c om*/ try { response = hc.execute(hg); String queryResult = EntityUtils.toString(response.getEntity()); JSONObject jObj; jObj = new JSONObject(queryResult); JSONArray dArray = jObj.getJSONArray("d"); for (int i = 0; i <= dArray.length() - 1; i++) { result.add(dArray.getLong(i)); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return result; }