List of usage examples for org.apache.http.client ClientProtocolException printStackTrace
public void printStackTrace()
From source file:com.liato.bankdroid.banking.banks.Osuuspankki.java
@Override public Urllib login() throws LoginException, BankException { try {/*from w ww . j a v a 2 s .c om*/ LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("du nya koder genom att bes")) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { e.printStackTrace(); throw new BankException(e.getMessage()); } return urlopen; }
From source file:com.project.merauke.CustomItemizedOverlay.java
/** * get inputstream data from http request * *//*w w w . ja v a 2 s .c o m*/ private InputStream getConnection(String url) { InputStream is = null; HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse response = client.execute(httpGet); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode == 200) { HttpEntity entity = response.getEntity(); is = entity.getContent(); } else { Log.e("ANGKOT", "Failed to download file"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return is; }
From source file:com.example.pmat_programador_1.portoaguas.ArsGisActivity.java
public ArrayList<Puntos> getPuntos() throws ParseException { String values;/*w w w . j ava 2 s . c om*/ DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://" + JSON.ipserver + "/puntos");// try { HttpResponse response = null; try { response = client.execute(request); } catch (IOException e) { e.printStackTrace(); } HttpEntity entity = response.getEntity(); values = EntityUtils.toString(entity); Log.e("Puntos en el Mapa", values); JSONArray obj = null; try { obj = new JSONArray(values); } catch (JSONException e) { e.printStackTrace(); } for (int index = 0; index < obj.length(); index++) { JSONObject jsonObject = obj.getJSONObject(index); Long idtramitejson = jsonObject.getLong("id_tramite"); Long id_tarea_tramitejson = jsonObject.getLong("id_tarea_tramite"); Long numeroCuentejson = jsonObject.getLong("numero_cuenta"); Long codClientejson = jsonObject.getLong("cod_cliente"); Long codPrediojson = jsonObject.getLong("cod_predio"); Double latitudjson = jsonObject.getDouble("latitud"); Double longitudjson = jsonObject.getDouble("longitud"); Double deuda_portoaguasjson = jsonObject.getDouble("deuda_portoagua"); Long mes_deudajson = jsonObject.getLong("mes_deuda"); String codMedidorjson = jsonObject.getString("codigo_medidor"); String serieMedidorjson = jsonObject.getString("serie_medidor"); String usuarioOficialjson = jsonObject.getString("usuario_oficial"); String tipotramitejson = jsonObject.getString("tipo_tramite"); String clientejson = jsonObject.getString("CLIENTE"); String estado_medidorjson = jsonObject.getString("estado_medidor"); item.add(new Puntos(idtramitejson, id_tarea_tramitejson, numeroCuentejson, codClientejson, codPrediojson, mes_deudajson, latitudjson, longitudjson, deuda_portoaguasjson, codMedidorjson, serieMedidorjson, "I", usuarioOficialjson, tipotramitejson, clientejson, estado_medidorjson)); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } return item; }
From source file:com.liato.bankdroid.banking.banks.DinersClub.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); String response = null;/* w ww. j a va2s . co m*/ Matcher matcher; try { /* We're going to look at all the pages until we find one that has transactions on it */ response = urlopen.open(String.format("https://secure.dinersclub.se/dcs/eSaldo/%s", invoiceUrl)); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Trans. date 2010-10-06 * 2: Specifications Skyways Express Ab * 3: Foreign amount 30,30 EUR * 4: Amount 2.462,00 kr */ transactions.add(new Transaction(matcher.group(1), matcher.group(2), Helpers.parseBalance(matcher.group(4)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.liato.bankdroid.banking.banks.SEB.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); //No transaction history for loans, funds and credit cards. int accType = account.getType(); if (accType == Account.LOANS || accType == Account.FUNDS || accType == Account.CCARD) return;//from www . j a v a2s . c o m Matcher matcher; try { response = urlopen.open( "https://m.seb.se/cgi-bin/pts3/mps/1100/mps1102.aspx?M1=show&P2=1&P4=1&P1=" + account.getId()); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Book. date 101214 * 2: Transaction St1 * 3: Trans. date 10-12-11 * 4: Amount -200,07 * */ String date; if (matcher.group(3) == null || matcher.group(3).length() == 0) { date = Html.fromHtml(matcher.group(1)).toString().trim(); date = String.format("%s-%s-%s", date.substring(0, 2), date.substring(2, 4), date.substring(4, 6)); } else { date = Html.fromHtml(matcher.group(3)).toString().trim(); } transactions.add(new Transaction("20" + date, Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(4)))); } Collections.sort(transactions, Collections.reverseOrder()); account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.mingsoft.weixin.util.GroupUtils.java
/** * ???//from w ww . j av a 2 s . c o m * @return {"groups": [{ </br> * "id":id?, </br> * "name": "??UTF8?", </br> * "count": ?}]}, */ public String queryGrouping() { //??accessToken? String pathUrl = GROUP_URL + GROUP_QUERY_GET + getAccessToken(); HttpGet get = HttpClientConnectionManager.getGetMethod(pathUrl); DefaultHttpClient HTTPCLIENT = new DefaultHttpClient(); try { HttpResponse responses = (HttpResponse) HTTPCLIENT.execute(get); String jsonStr = EntityUtils.toString(responses.getEntity(), "utf-8"); logger.debug("JSON:" + jsonStr); return jsonStr; } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; }
From source file:com.mingsoft.weixin.util.GroupUtils.java
/** * ??JSON?POST// w w w . j ava 2s .co m * @param json JSON? * @param url ? * @return JSON */ private String getPost(String json, String url) { HttpPost httpost = HttpClientConnectionManager.getPostMethod(url); try { httpost.setEntity(new StringEntity(json, "UTF-8")); HttpResponse response = HTTPCLIENT.execute(httpost); String jsonStr = EntityUtils.toString(response.getEntity(), "utf-8"); String obj = JSON.toJSONString(jsonStr); logger.debug("POST?:" + obj); return obj; } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; }
From source file:de.dhbw.organizer.calendar.backend.syncadapter.SyncAdapter.java
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {/*from w ww .j av a 2s.c om*/ HttpResponse httpResponse = null; Log.i(TAG, "SYNCC ME UP!"); long lastSyncMarker = getLastServerSyncMarker(account); // make sure Calendar exists, other wise create it // could be deleted, by user interaction or by first Sync if (!mCalendarManager.calendarExists(account)) { mCalendarManager.createCalendar(account, -1); } long nowInMillis = System.currentTimeMillis(); // make sure we have some time between the last and new sync // some how the sync is triggerd twice in a very short intervall // to prevent this, we allow resync only every // MIN_SYNC_INTERVRALL_IN_MILLIS = 10 sec if (nowInMillis >= (lastSyncMarker + Constants.MIN_SYNC_INTERVRALL_IN_MILLIS)) { long calendarId = mCalendarManager.getCalendarId(account); String calendarHttpUrl = mAccountManager.getUserData(account, Constants.KEY_ACCOUNT_CAL_URL); if (calendarHttpUrl != null && calendarHttpUrl.length() > 11) { // todo check if URL is null HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(calendarHttpUrl); if (!httpGet.containsHeader("Accept-Encoding")) { httpGet.addHeader("Accept-Encoding", "gzip"); } try { Log.i(TAG, "http execute()"); httpResponse = httpClient.execute(httpGet); int httpStatus = httpResponse.getStatusLine().getStatusCode(); HttpEntity entity = httpResponse.getEntity(); if (httpStatus == 200 && entity != null) { InputStream instream = AndroidHttpClient.getUngzippedContent(entity); ICalendar ical = Biweekly.parse(instream).first(); instream.close(); if (ical != null) { ArrayList<VEvent> events = (ArrayList<VEvent>) ical.getEvents(); // mCalendarManager.deleteAllEvents(account, // calendarId); // mCalendarManager.insertEvents(account, // calendarId, // events); mCalendarManager.updateEvents(account, calendarId, events, true); // save timestamp of last succsessful sync setLastServerSyncMarker(account, System.currentTimeMillis()); } else { Log.i(TAG, "ical == null"); } } else { Log.i(TAG, "entity == null"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } else { Log.i(TAG, "NO Sync MIN_SYNC_INTERVRALL_IN_MILLIS = " + Constants.MIN_SYNC_INTERVRALL_IN_MILLIS); } Log.i(TAG, "SYNC DONE"); }
From source file:org.megam.deccanplato.provider.box.handler.FileImpl.java
/** * @return/* ww w . j av a 2 s .com*/ */ private Map<String, String> upload() { Map<String, String> outMap = new HashMap<>(); final String BOX_UPLOAD = "/files/content"; Map<String, String> headerMap = new HashMap<String, String>(); headerMap.put("Authorization", "BoxAuth api_key=" + args.get(API_KEY) + "&auth_token=" + args.get(TOKEN)); MultipartEntity entity = new MultipartEntity(); FileBody filename = new FileBody(new File(args.get(FILE_NAME))); FileBody filename1 = new FileBody(new File("/home/pandiyaraja/Documents/AMIs")); StringBody parent_id = null; try { parent_id = new StringBody(args.get(FOLDER_ID)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } entity.addPart("filename", filename); entity.addPart("parent_id", parent_id); TransportTools tools = new TransportTools(BOX_URI + BOX_UPLOAD, null, headerMap); tools.setFileEntity(entity); String responseBody = null; TransportResponse response = null; try { response = TransportMachinery.post(tools); responseBody = response.entityToString(); System.out.println("OUTPUT:" + responseBody); } catch (ClientProtocolException ce) { ce.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } outMap.put(OUTPUT, responseBody); return outMap; }
From source file:de.dtag.tlabs.cbclient.CBClient.java
/** * Is called by the polling Timer/*from ww w .j ava2 s. c o m*/ */ private void performPolling() { HttpHost targetHost = new HttpHost(contextBrokerIPAddr, contextBrokerPort, "http"); HttpClientContext context = HttpClientContext.create(); // HttpGetWithEntity httpGet = new HttpGetWithEntity(contextBrokerRequestLine); //httpGet.setHeader("Content-Type", "application/xml"); HttpPost httpPostContext = new HttpPost(contextBrokerRequestLine); String getXMLInfo = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<queryContextRequest>" + "<entityIdList>" + "<entityId type=\"User_Context\" isPattern=\"false\">" + "<id>User1</id>" + "</entityId>" + "</entityIdList>" + "<attributeList/>" + "</queryContextRequest>"; StringEntity getEntity = new StringEntity(getXMLInfo, ContentType.APPLICATION_XML); httpPostContext.setEntity(getEntity); try { CloseableHttpResponse response = httpClient.execute(targetHost, httpPostContext, context); HttpEntity entity = response.getEntity(); // System.out.println("Response: " + response.getStatusLine().toString()); // System.out.println("Response Body-Type: " + entity.getContentType()); StringWriter writer = new StringWriter(); InputStream is = entity.getContent(); IOUtils.copy(is, writer); String responseContent = writer.toString(); System.out.println(responseContent); checkForHandOver(responseContent); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }