Package Exception

Examples of Exception.DownloadHandlerException


        return FileUtils.SubTitleExtensions.values();
    }

    public void doLogin(DownloadHandlerVO handlerVO) throws DownloadHandlerException {
        if ((handlerVO.getUserName() == null) || (handlerVO.getPassword() == null))
            throw new DownloadHandlerException();

        _handlerVO = handlerVO;

        httpclient = new DefaultHttpClient();

        try {
            HttpPost httpost = new HttpPost(getURLForAction("login_verificar.php"));

            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("txtLogin", _handlerVO.getUserName()));
            nvps.add(new BasicNameValuePair("txtSenha", _handlerVO.getPassword()));
            nvps.add(new BasicNameValuePair("chkLogin", "1"));

            httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.ISO_8859_1));

            HttpResponse response = httpclient.execute(httpost);

            if (response.getStatusLine().getStatusCode() != 200) {
                throw new RuntimeException("Status Response Error: " + response.getStatusLine());
            }

            HttpEntity ent = response.getEntity();
            InputStream entStream = ent.getContent();

            String respHTML = FileUtils.InputToString(entStream, _pageEncoding);
            if (respHTML.indexOf("Bem vindo(a), voce está sendo redirecionado(a)!") < 0) {
                throw new DownloadHandlerException();
            }
            isLogged = true;
            // Consome o resto da resposta para não entupir o pipeline do httpclient
            ent.consumeContent();
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of Exception.DownloadHandlerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.