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:com.liato.bankdroid.banking.banks.Handelsbanken.java

@Override
public Urllib login() throws LoginException, BankException {
    try {//from ww  w .  ja v  a 2s  .  c o m
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("ontrollera dina uppgifter")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
    } catch (ClientProtocolException e) {
        Log.w(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.w(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.liato.bankdroid.banking.banks.Handelsbanken.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  . ja  va  2s.c om*/

    urlopen = login();
    Matcher matcher;
    try {
        matcher = reAccountsUrl.matcher(response);
        if (!matcher.find()) {
            throw new BankException(res.getText(R.string.unable_to_find).toString() + " accounts url.");
        }
        String strAccountsUrl = "https://m.handelsbanken.se/primary/_-" + matcher.group(1);
        response = urlopen.open(strAccountsUrl);
        matcher = reBalance.matcher(response);
        Integer accountId = 0;
        while (matcher.find()) {
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3).trim()), accountId.toString()));
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
            accountIds.add(matcher.group(1));
            accountId += 1;
        }
        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.TicketRikskortet.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());
    }/*from w  w w  .  ja  v a 2s. com*/
    urlopen = login();
    if (!"https://www.edenred.se/sv/Apps/Employee/Start/".equalsIgnoreCase(urlopen.getCurrentURI())) {
        try {
            response = urlopen.open("https://www.edenred.se/sv/Apps/Employee/Start/");
        } catch (ClientProtocolException e) {
            throw new BankException(e.getMessage());
        } catch (IOException e) {
            throw new BankException(e.getMessage());
        }
    }

    Matcher matcher = reBalance.matcher(response);
    if (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                EXAMPLE DATA
         * 1: Balance           590,22 kr
         * 
         */
        BigDecimal b = Helpers.parseBalance(matcher.group(1));
        accounts.add(new Account("Saldo", b, "1"));
        balance = balance.add(Helpers.parseBalance(matcher.group(1)));
    }
    if (accounts.isEmpty()) {
        throw new BankException(res.getText(R.string.no_accounts_found).toString());
    }
    super.updateComplete();
}

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

@Override
public Urllib login() throws LoginException, BankException {
    try {//  w  ww . j  ava  2s.c  o m
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());

        if (response.contains("Fel personr/organisationsnr och/eller lsenord.")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }

        if (response.contains("Internetbanken r stngd fr tillfllet och berknas vara tillgnglig")) {
            throw new LoginException(res.getText(R.string.bank_closed).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:ch.uzh.ifi.attempto.ape.APEWebservice.java

private String getEntity(HttpClient httpclient, HttpUriRequest httpRequest) {
    try {// w w w  . j a va  2  s  .  c om
        HttpResponse response = httpclient.execute(httpRequest);
        HttpEntity entity = response.getEntity();

        if (entity == null) {
            throw new RuntimeException(ERROR_MESSAGE + ": " + response.getStatusLine());
        }
        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            throw new RuntimeException(ERROR_MESSAGE + ": " + response.getStatusLine());
        }
        // The APE webservice returns the data in UTF8, even if it doesn't declare it.
        if (entity.getContentEncoding() == null) {
            return EntityUtils.toString(entity, HTTP.UTF_8);
        }
        return EntityUtils.toString(entity);

    } catch (ClientProtocolException e) {
        throw new RuntimeException(ERROR_MESSAGE + ": " + e.getMessage());
    } catch (IOException e) {
        throw new RuntimeException(ERROR_MESSAGE + ": " + e.getMessage());
    } finally {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:eu.musesproject.client.connectionmanager.HttpConnectionsHelper.java

/**
 * Http post implementation //from www. ja  v  a 2 s .  c om
 * @param url
 * @param data
 * @return httpResponse
 * @throws ClientProtocolException
 * @throws IOException
 */

public synchronized HttpResponse doPost(String type, String url, String data)
        throws ClientProtocolException, IOException {
    HttpResponse httpResponse = null;
    HttpPost httpPost = new HttpPost(url);
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, TIMEOUT);
    DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters);
    StringEntity s = new StringEntity(data.toString());
    s.setContentEncoding("UTF-8");
    s.setContentType("application/xml");
    httpPost.addHeader("connection-type", type);
    httpPost.setEntity(s);
    httpPost.addHeader("accept", "application/xml");
    if (cookie == null || cookie.isExpired(new Date())) {
        try {
            httpResponse = httpclient.execute(httpPost);
            List<Cookie> cookies = httpclient.getCookieStore().getCookies();
            if (cookies.isEmpty()) {
                Log.d(TAG, "None");
            } else {
                cookie = cookies.get(0);
                cookieExpiryDate = cookie.getExpiryDate();
                Log.d(TAG, "Curent cookie expiry : " + cookieExpiryDate);
            }
        } catch (ClientProtocolException e) {
            Log.d(TAG, e.getMessage());
        } catch (Exception e) {
            Log.d(TAG, e.getMessage());
        }

    } else {
        httpPost.addHeader("accept", "application/xml");
        httpclient.getCookieStore().addCookie(cookie);
        try {
            httpResponse = httpclient.execute(httpPost);
        } catch (ClientProtocolException e) {
            Log.d(TAG, e.getMessage());
        } catch (Exception e) {
            Log.d(TAG, e.getMessage());
        }
    }
    return httpResponse;
}

From source file:com.liato.bankdroid.banking.banks.payson.Payson.java

@Override
public Urllib login() throws LoginException, BankException {
    try {/*from  w  w  w. j a  v a  2  s.  c  o  m*/
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("Felaktig E-postadress") || response.contains("Lsenord saknas")
                || response.contains("E-postadress saknas")) {
            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.liato.bankdroid.banking.banks.BetterGlobe.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());
    }//from   www  . j  a v a 2 s .  c o  m

    urlopen = login();
    Matcher matcher;
    String response;
    try {
        response = urlopen.open("http://betterglobe.com/bgaccount.aspx/report");
        matcher = reBalance.matcher(response);

        while (matcher.find()) {
            Account tillgangligt = new Account("Tillgngligt", Helpers.parseBalance(matcher.group(1)),
                    "tillgangligt");
            tillgangligt.setCurrency("EUR");
            accounts.add(tillgangligt);
            balance = balance.add(Helpers.parseBalance(matcher.group(1)));
        }

        response = urlopen.open("http://betterglobe.com/mytrees.aspx/Valueforecast");
        matcher = reForecast.matcher(response);

        while (matcher.find()) {
            Account inkop = new Account("Inkp", Helpers.parseBalance(matcher.group(2)), "inkop");
            Account netto = new Account("Berknad vinst", Helpers.parseBalance(matcher.group(3)), "netto");
            Account brutto = new Account("Berknat slutvrde", Helpers.parseBalance(matcher.group(1)),
                    "brutto");
            inkop.setCurrency("EUR");
            brutto.setCurrency("EUR");
            netto.setCurrency("EUR");
            accounts.add(inkop);
            accounts.add(brutto);
            accounts.add(netto);
            balance = balance.add(Helpers.parseBalance(matcher.group(2)));
            ;
        }

        response = urlopen.open("http://betterglobe.com/mytrees.aspx");
        matcher = reTrees.matcher(response);

        while (matcher.find()) {
            Account trees = new Account("Innehav", Helpers.parseBalance(matcher.group(1)), "trees");
            trees.setCurrency("trd");
            accounts.add(trees);
        }

        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());
    }
}

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

@Override
public Urllib login() throws LoginException, BankException {
    try {//from  w w w . j av  a2 s  .  c  o m
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());

        if (response.contains("eller personnumme") || response.contains("elaktigt personnummer")
                || response.contains("ontrollera personnummer")
                || response.contains("elaktig inloggningskod")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }

    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

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

@Override
public Urllib login() throws LoginException, BankException {
    try {//  w  w w  . j ava2s  . c o  m
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("elaktig kombination")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}