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

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:ua.naiksoftware.chars.Sender.java

/**
 *
 * @param <b>p</b> score and time
 * @return true if ok, else false//from w w w .  j  ava  2  s. c  o  m
 */
@Override
protected Boolean doInBackground(Integer... p) {
    Log.d(tag, "doInBacckground begin");
    int score = p[0];
    int time = p[1];
    String model = Build.MANUFACTURER + " " + Build.MODEL;
    String devId = Build.FINGERPRINT;
    if (model == null || model.equals("")) {
        model = "Unknown";
    }
    Log.d(tag, "doInBackground: data set: devId=" + (devId == null ? "null" : devId));
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(URL.replace("game", "chars"));
    Log.d(tag, "doInBackground: httppost created");

    HttpResponse response = null;
    try {
        // Add my data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
        nameValuePairs.add(new BasicNameValuePair("score", String.valueOf(score)));
        nameValuePairs.add(new BasicNameValuePair("time", String.valueOf(time)));
        nameValuePairs.add(new BasicNameValuePair("l", MainActivity.login));
        nameValuePairs.add(new BasicNameValuePair("p", MainActivity.pass));
        nameValuePairs.add(new BasicNameValuePair("model", model));
        nameValuePairs.add(new BasicNameValuePair("devid", devId));
        nameValuePairs.add(new BasicNameValuePair("valid",
                md5(MainActivity.login + MainActivity.pass + MainActivity.login.length())));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        Log.d(tag, "doInBackground: form set, pre execute httpclient");
        // Execute HTTP Post Request
        response = httpclient.execute(httppost);
        Log.d(tag, "doInBackground: executed httpclient");

    } catch (ClientProtocolException e) {
        Log.e(tag, "doInBackground: protocol exception", e);
        err = e.getMessage().replace("eof-cms.h2m.ru", "annimon.com");// security :)
        return false;
    } catch (IOException e) {
        Log.d(tag, "doInBackground: IOException", e);
        err = e.getMessage().replace("eof-cms.h2m.ru", "annimon.com");// security :)
        return false;
    }
    Log.d(tag, "doInBackground: all right (end)");
    return true;
}

From source file:com.liato.bankdroid.banking.banks.AkeliusInvest.java

public Urllib login() throws LoginException, BankException {
    try {//from www .jav  a  2  s . co m
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        Matcher matcher = reError.matcher(response);
        if (matcher.find()) {
            String errormsg = Html.fromHtml(matcher.group(1).trim()).toString();
            if (errormsg.contains("ord eller personnummer") || errormsg.contains("et alternativ")
                    || errormsg.contains("fyra siffror")) {
                throw new LoginException(errormsg);
            } else {
                throw new BankException(errormsg);
            }
        }
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:net.evecom.androidecssp.activity.EventListActivity.java

/**
 * //  w ww . ja v a 2  s . co  m
 */
private void initlist() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Message message = new Message();

            try {
                resutArray = connServerForResultPost("jfs/ecssp/mobile/eventCtr/getEnentList", null);
            } catch (ClientProtocolException e) {
                message.what = MESSAGETYPE_02;
                Log.e("mars", e.getMessage());
            } catch (IOException e) {
                message.what = MESSAGETYPE_02;
                Log.e("mars", e.getMessage());
            }
            if (resutArray.length() > 0) {
                try {
                    eventInfos = getObjsInfo(resutArray);
                    if (null == eventInfos) {
                        message.what = MESSAGETYPE_02;
                    } else {
                        message.what = MESSAGETYPE_01;
                    }
                } catch (JSONException e) {
                    message.what = MESSAGETYPE_02;
                    Log.e("mars", e.getMessage());
                }
            } else {
                message.what = MESSAGETYPE_02;
            }
            Log.v("mars", resutArray);
            eventListHandler.sendMessage(message);

        }
    }).start();

}

From source file:org.prx.prp.utility.HttpHelper.java

private synchronized String execute(final HttpRequestBase method) {
    String response = null;//from ww  w . j  a v  a 2  s. c om
    try {
        response = HttpHelper.client.execute(method, this.responseHandler);
    } catch (ClientProtocolException e) {
        response = HttpHelper.HTTP_RESPONSE_ERROR + " - " + e.getClass().getSimpleName() + " " + e.getMessage();
    } catch (IOException e) {
        response = HttpHelper.HTTP_RESPONSE_ERROR + " - " + e.getClass().getSimpleName() + " " + e.getMessage();
    }
    return response;
}

From source file:com.liato.bankdroid.banking.banks.SEBKortBase.java

@Override
public void update() throws BankException, LoginException, BankChoiceException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }//  ww  w  .j  a  v a2 s  .  co  m
    urlopen = login();
    Matcher matcher;
    try {
        if (!String.format("https://application.sebkort.com/nis/%s/main.do", provider_part)
                .equals(urlopen.getCurrentURI())) {
            response = urlopen
                    .open(String.format("https://application.sebkort.com/nis/%s/main.do", provider_part));
        }
        matcher = reAccounts.matcher(response);
        /*
         * Capture groups:
         * GROUP                EXAMPLE DATA
         * 1: amount            10 579,43
         * 
         */
        if (matcher.find()) {
            Account account = new Account("Kpgrns", Helpers.parseBalance(matcher.group(1)), "3");
            account.setType(Account.OTHER);
            account.setAliasfor("1");
            accounts.add(account);
        }
        if (matcher.find()) {
            Account account = new Account("Saldo", Helpers.parseBalance(matcher.group(1)), "2");
            account.setType(Account.OTHER);
            account.setAliasfor("1");
            accounts.add(account);
        }
        if (matcher.find()) {
            Account account = new Account("Disponibelt belopp", Helpers.parseBalance(matcher.group(1)), "1");
            account.setType(Account.CCARD);
            accounts.add(account);
            balance = balance.add(Helpers.parseBalance(matcher.group(1)));
        }
        Collections.reverse(accounts);
        if (accounts.isEmpty()) {
            throw new BankException(res.getText(R.string.no_accounts_found).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    } finally {
        super.updateComplete();
    }
}

From source file:com.liato.bankdroid.banking.banks.IkanoBank.java

@Override
public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException {
    super.updateTransactions(account, urlopen);

    // Find viewstate and eventvalidation from last page.
    Matcher matcher;//from ww  w .  ja va  2 s  .  c o m
    matcher = reViewState.matcher(response);
    if (!matcher.find()) {
        Log.e(TAG, "Unable to find ViewState. L156.");
        return;
    }
    String strViewState = matcher.group(1);
    matcher = reEventValidation.matcher(response);
    if (!matcher.find()) {
        Log.e(TAG, "Unable to find EventValidation. L161.");
        return;
    }
    String strEventValidation = matcher.group(1);

    try {
        List<NameValuePair> postData = new ArrayList<NameValuePair>();
        postData.add(new BasicNameValuePair("__EVENTTARGET", account.getId().replace("_", "$")));
        postData.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
        postData.add(new BasicNameValuePair("__VIEWSTATE", strViewState));
        postData.add(new BasicNameValuePair("__EVENTVALIDATION", strEventValidation));
        response = urlopen.open("https://secure.ikanobank.se/engines/page.aspx?structid=1787", postData);

        matcher = reTransactions.matcher(response);
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Date              2010-10-27
             * 2: Specification     ?VERF?RING
             * 3: Amount            50
             *   
             */
            transactions.add(new Transaction(matcher.group(1).trim(),
                    Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3))));
        }
        account.setTransactions(transactions);

    } catch (ClientProtocolException e) {
        Log.e(TAG, "CPE: " + e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "IOE: " + e.getMessage());
    }
}

From source file:de.dhbw.organizer.calendar.backend.manager.NetworkManager.java

/**
 * Downloads a File from the given URl via HTTP GET and gzipped and returns
 * an open InputStream to read from/*from ww w.  j  a  v a  2 s . co  m*/
 * 
 * @param url
 * @return InputStream
 */
public InputStream downloadHttpFile(String url) {

    if (isOnline()) {

        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);

        if (!httpGet.containsHeader("Accept-Encoding")) {
            httpGet.addHeader("Accept-Encoding", "gzip");
        }

        HttpResponse httpResponse = null;

        try {
            httpResponse = httpClient.execute(httpGet);

            int httpStatus = httpResponse.getStatusLine().getStatusCode();
            Log.i(TAG, "downloadHttpFile()  url = " + url + " HTTP:  " + httpStatus);

            HttpEntity entity = httpResponse.getEntity();

            return AndroidHttpClient.getUngzippedContent(entity);

        } catch (ClientProtocolException e) {
            e.printStackTrace();
            Log.e(TAG, "downloadHttpFile() ERROR: " + e.getMessage());
            return null;
        } catch (IOException e) {
            Log.e(TAG, "downloadHttpFile()  ERROR: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    } else
        return null;

}

From source file:gov.nih.nci.caxchange.messaging.SpecimenIntegrationTest.java

/**
 * Testcase for Create Specimen when CollectionProtocol is invalid
 *///w  w  w.  ja v  a 2  s.  co m
@Test
public void createSpecimenForInvalidCollectionProtocolSpecimens() {
    try {
        final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl);
        final StringEntity reqentity = new StringEntity(getInsertInvalidCollectionProtocolXMLStr());
        httppost.setEntity(reqentity);
        httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT);

        final HttpResponse response = httpclient.execute(httppost);
        final HttpEntity entity = response.getEntity();

        String createdXML = null;

        if (entity != null) {
            createdXML = EntityUtils.toString(entity);
            Assert.assertEquals(true, createdXML.contains("<errorCode>1101</errorCode>"));
        }
    } catch (ClientProtocolException e) {
        Assert.fail(e.getMessage());
    } catch (IllegalStateException e) {
        Assert.fail(e.getMessage());
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}

From source file:gov.nih.nci.caxchange.messaging.SpecimenIntegrationTest.java

/**
 * Testcase for Create Specimen//ww w. ja  v a2  s . c  o  m
 */
@Test
public void createSpecimen() {
    try {
        final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl);
        final StringEntity reqentity = new StringEntity(getInsertSpecimenXMLStr());
        httppost.setEntity(reqentity);
        httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT);

        final HttpResponse response = httpclient.execute(httppost);
        final HttpEntity entity = response.getEntity();

        String createdXML = null;

        if (entity != null) {
            createdXML = EntityUtils.toString(entity);
            Assert.assertEquals(true, createdXML.contains("<responseStatus>SUCCESS</responseStatus>"));
        }
    } catch (ClientProtocolException e) {
        Assert.fail(e.getMessage());
    } catch (IllegalStateException e) {
        Assert.fail(e.getMessage());
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}

From source file:gov.nih.nci.caxchange.messaging.SpecimenIntegrationTest.java

private void createSpecimenForUpdation() {
    try {/*w  ww.j  a va  2 s . com*/
        final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl);
        String xmlString = getInsertSpecimenXMLStr();
        xmlString = xmlString.replaceAll("102", "102_UPDT");
        final StringEntity reqentity = new StringEntity(xmlString);
        httppost.setEntity(reqentity);
        httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT);

        final HttpResponse response = httpclient.execute(httppost);
        final HttpEntity entity = response.getEntity();

        String createdXML = null;

        if (entity != null) {
            createdXML = EntityUtils.toString(entity);
            Assert.assertEquals(true, createdXML.contains("<responseStatus>SUCCESS</responseStatus>"));
        }
    } catch (ClientProtocolException e) {
        Assert.fail(e.getMessage());
    } catch (IllegalStateException e) {
        Assert.fail(e.getMessage());
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}