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.Villabanken.java

@Override
public Urllib login() throws LoginException, BankException {
    try {/*from  w w  w.  j ava  2s  .c o  m*/
        LoginPackage lp = preLogin();
        String loginResponse = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (loginResponse.contains("misslyckades")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
        this.accountResponse = urlopen.open(accountUrl);

    } 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.Eurocard.java

@Override
public Urllib login() throws LoginException, BankException {
    try {/*w  w  w  .  j ava  2s .  c  om*/
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("Felaktig 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;
}

From source file:com.liato.bankdroid.banking.banks.SEB.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 .  j a va 2 s.  com

    urlopen = login();
    Matcher matcher;
    try {
        response = urlopen.open("https://m.seb.se/cgi-bin/pts3/mps/1100/mps1101.aspx?X1=digipassAppl1");
        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                    EXAMPLE DATA
             * 1: ID                    GJmQRqlrOPmM++1zf50d6Q==
             * 2: Name                  Personkonto
             * 3: Amount                2.208,03
             * 
             */
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), matcher.group(1).trim()));
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        }

        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.normalexception.app.rx8club.html.VBForumFactory.java

/**
  * Grab the forum as a jsoup document/*from w w  w.  ja va  2  s .c  o m*/
  * @return   A jsoup document object that contains the 
  *          forum contents
  */
public Document get(Activity src, String addr) {
    LoginFactory lf = LoginFactory.getInstance();

    String output = "";
    try {
        VBForumFactory ff = VBForumFactory.getInstance();
        output = ff.getForumPage(src, lf, addr);
        return Jsoup.parse(output);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "Error grabbing category page: " + e.getMessage(), e);
    } catch (IOException e) {
        Log.e(TAG, "Error grabbing category page: " + e.getMessage(), e);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Error grabbing category page: " + e.getMessage(), e);
    }

    return null;
}

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

/**
 * POST (HTTPS)/*from  w  w  w . j  a v  a 2s  .co  m*/
 * @param url
 * @param data
 * @return
 * @throws ClientProtocolException
 * @throws IOException
 */

public HttpResponse doSecurePost(Request request) throws ClientProtocolException, IOException {

    HttpResponse httpResponse = null;
    HttpPost httpPost = null;
    TLSManager tlsManager = new TLSManager();
    DefaultHttpClient httpclient = tlsManager.getTLSHttpClient();

    if (httpclient != null) {
        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, TIMEOUT);
        httpPost = new HttpPost(request.getUrl());
        StringEntity s = new StringEntity(request.getData().toString());
        s.setContentEncoding("UTF-8");
        s.setContentType("application/xml");
        httpPost.setEntity(s);
        httpPost.addHeader("accept", "application/xml");
        httpPost.addHeader("connection-type", request.getType());
        httpPost.setHeader("poll-interval", getInStringSeconds(request.getPollInterval()));
    }

    if (cookie != null && !cookie
            .isExpired(new Date()) /*!isSessionExpired(new Date(), AlarmReceiver.LAST_SENT_POLL_INTERVAL)*/) {
        httpclient.getCookieStore().addCookie(cookie);
        try {
            httpResponse = httpclient.execute(httpPost);
        } catch (ClientProtocolException e) {
            Log.d(TAG, e.getMessage());
        } catch (IOException e) {
            Log.d(TAG, e.getMessage());
        }
    } else {
        try {
            httpResponse = httpclient.execute(httpPost);
            List<Cookie> cookies = httpclient.getCookieStore().getCookies();
            if (!cookies.isEmpty()) {
                cookie = cookies.get(0);
            }

        } catch (ClientProtocolException e) {
            Log.d(TAG, e.getMessage());
        } catch (IOException e) {
            Log.d(TAG, e.getMessage());
        }
    }

    AlarmReceiver.LAST_SENT_POLL_INTERVAL = Integer.parseInt(request.getPollInterval());
    return httpResponse;

}

From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.WipeResourceExecutableSkillsHandler.java

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {/*w ww . j a  va 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:com.liato.bankdroid.banking.banks.Swedbank.java

@Override
public void update() throws BankException, LoginException {
    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 2 s.com
    urlopen = login();
    String response = null;
    Matcher matcher;
    try {
        response = urlopen.open("https://mobilbank.swedbank.se/banking/swedbank/accounts.html");
        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            Account account = new Account(Html.fromHtml(matcher.group(3)).toString(),
                    Helpers.parseBalance(matcher.group(4)),
                    matcher.group(1).trim() == "loan" ? "l:" + matcher.group(2).trim()
                            : matcher.group(2).trim());
            if (matcher.group(1).trim() == "loan") {
                account.setType(Account.LOANS);
            } else {
                balance = balance.add(Helpers.parseBalance(matcher.group(4)));
            }
            accounts.add(account);
        }
        matcher = reLinklessAccounts.matcher(response);
        int accid = 0;
        while (matcher.find()) {
            Account account = new Account(Html.fromHtml(matcher.group(1)).toString(),
                    Helpers.parseBalance(matcher.group(2)), "ll:" + accid);
            account.setType(Account.OTHER);
            accounts.add(account);
            accid++;
        }
        if (accounts.isEmpty()) {
            throw new BankException(res.getText(R.string.no_accounts_found).toString());
        }
        // Konungens konto
        //accounts.add(new Account("Personkonto", Helpers.parseBalance("85351"), "0"));
        //accounts.add(new Account("Sparkonto", Helpers.parseBalance("8590700"), "1"));
    } 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.Hemkop.java

public Urllib login() throws LoginException, BankException {
    try {/* w w w. j  av a 2s.co m*/
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (!response.contains("Inloggad som")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
        response = urlopen.open("https://www.hemkop.se/Mina-sidor/Bonussaldo/");
    } 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.IkanoBank.java

public Urllib login() throws LoginException, BankException {
    try {//from   ww w .  j av  a2  s .  co  m
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("Ogiltigt personnummer") || response.contains("felaktigt personnummer")) {
            Matcher matcher = reErrorMessage.matcher(response);
            if (matcher.find()) {
                throw new LoginException(Helpers.removeHtml(matcher.group(1).replace("<BR>", "\n")));
            } else {
                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.seleritycorp.context.RequestResponseHandlerTest.java

@Test
public void testHandleResponseWrongContentType() throws Exception {
    HttpResponse response = mockResponse(200, "{\"foo\":42}", "text/plain");
    RequestResponseHandler handler = createRequestResponseHandler();

    replayAll();/*from w  ww .j  a v a 2  s . c  o  m*/

    try {
        handler.handleResponse(response);
        failBecauseExceptionWasNotThrown(ClientProtocolException.class);
    } catch (ClientProtocolException e) {
        assertThat(e.getMessage()).contains("text/plain");
        assertThat(e.getMessage()).contains("application/json");
    }

    verifyAll();
}