Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

In this page you can find the example usage for java.io IOException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:info.magnolia.jaas.sp.jcr.JCRAuthenticationModule.java

/**
 * Authenticate against magnolia/jcr user repository
 *//*  w w  w. j  a v a2  s .  c  om*/
public boolean login() throws LoginException {
    if (this.callbackHandler == null) {
        throw new LoginException("Error: no CallbackHandler available for JCRModule");
    }

    Callback[] callbacks = new Callback[2];
    callbacks[0] = new NameCallback("name");
    callbacks[1] = new PasswordCallback("pswd", false);

    this.success = false;
    try {
        this.callbackHandler.handle(callbacks);
        this.name = ((NameCallback) callbacks[0]).getName();
        this.pswd = ((PasswordCallback) callbacks[1]).getPassword();
        this.success = this.isValidUser();
    } catch (IOException ioe) {
        if (log.isDebugEnabled()) {
            log.debug("Exception caught", ioe);
        }
        throw new LoginException(ioe.toString());
    } catch (UnsupportedCallbackException ce) {
        if (log.isDebugEnabled()) {
            log.debug(ce.getMessage(), ce);
        }
        throw new LoginException(ce.getCallback().toString() + " not available");
    }
    if (!this.success) {
        throw new LoginException("failed to authenticate " + this.name);
    }

    return this.success;
}

From source file:com.panet.imeta.www.SlaveServerJobStatus.java

public SlaveServerJobStatus(Node jobStatusNode) {
    this();/*from   w ww  .j a  v  a2  s.  com*/
    jobName = XMLHandler.getTagValue(jobStatusNode, "jobname");
    statusDescription = XMLHandler.getTagValue(jobStatusNode, "status_desc");
    errorDescription = XMLHandler.getTagValue(jobStatusNode, "error_desc");

    String loggingString64 = XMLHandler.getTagValue(jobStatusNode, "logging_string");

    // This is a Base64 encoded GZIP compressed stream of data.
    //
    try {
        byte[] bytes = new byte[] {};
        if (loggingString64 != null)
            bytes = Base64.decodeBase64(loggingString64.getBytes());
        if (bytes.length > 0) {
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            GZIPInputStream gzip = new GZIPInputStream(bais);
            int c;
            StringBuffer buffer = new StringBuffer();
            while ((c = gzip.read()) != -1)
                buffer.append((char) c);
            gzip.close();
            loggingString = buffer.toString();
        } else {
            loggingString = "";
        }
    } catch (IOException e) {
        loggingString = "Unable to decode logging from remote server : " + e.toString() + Const.CR
                + Const.getStackTracker(e) + Const.CR;
    }

    // get the result object, if there is any...
    //
    Node resultNode = XMLHandler.getSubNode(jobStatusNode, Result.XML_TAG);
    if (resultNode != null) {
        try {
            result = new Result(resultNode);
        } catch (IOException e) {
            loggingString += "Unable to serialize result object as XML" + Const.CR + Const.getStackTracker(e)
                    + Const.CR;
        }
    }
}

From source file:io.agi.core.ml.supervised.Svm.java

@Override
public void loadModel(String modelString) {
    Reader stringReader = new StringReader(modelString);
    BufferedReader bufferedReader = new BufferedReader(stringReader);

    try {/*from   w w  w.j  a v  a2s.  c  o  m*/
        _model = svm.svm_load_model(bufferedReader);
        saveModel();
    } catch (IOException e) {
        _logger.error("Unable to load svm model.");
        _logger.error(e.toString(), e);
    }
}

From source file:TcpClient.java

/** Initialize a server socket for communicating with the client. */
private void initServerSocket()
{
    this.inboundAddr = new InetSocketAddress(COMM_PORT);
    try/*  www  .  j  a v a 2 s.  co m*/
    {
        this.serverSocket = new java.net.ServerSocket(COMM_PORT);
        assert this.serverSocket.isBound();
        if (this.serverSocket.isBound())
        {
            System.out.println("SERVER inbound data port " +
                this.serverSocket.getLocalPort() +
                " is ready and waiting for client to connect...");
        }
    }
    catch (SocketException se)
    {
        System.err.println("Unable to create socket.");
        System.err.println(se.toString());
        System.exit(1);
    }
    catch (IOException ioe)
    {
        System.err.println("Unable to read data from an open socket.");
        System.err.println(ioe.toString());
        System.exit(1);
    }
}

From source file:com.keybox.manage.socket.SecureShellWS.java

@OnMessage
public void onMessage(String message) {

    if (session.isOpen() && StringUtils.isNotEmpty(message)) {

        Map jsonRoot = new Gson().fromJson(message, Map.class);

        String command = (String) jsonRoot.get("command");

        Integer keyCode = null;/*w  w  w .j  a v a2s  .  c o  m*/
        Double keyCodeDbl = (Double) jsonRoot.get("keyCode");
        if (keyCodeDbl != null) {
            keyCode = keyCodeDbl.intValue();
        }

        for (String idStr : (ArrayList<String>) jsonRoot.get("id")) {
            Integer id = Integer.parseInt(idStr);

            //get servletRequest.getSession() for user
            UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId);
            if (userSchSessions != null) {
                SchSession schSession = userSchSessions.getSchSessionMap().get(id);
                if (keyCode != null) {
                    if (keyMap.containsKey(keyCode)) {
                        try {
                            schSession.getCommander().write(keyMap.get(keyCode));
                        } catch (IOException ex) {
                            log.error(ex.toString(), ex);
                        }
                    }
                } else {
                    schSession.getCommander().print(command);
                }
            }

        }
        //update timeout
        AuthUtil.setTimeout(httpSession);

    }

}

From source file:aes.pica.touresbalon.tb_serviciosbolivariano.ServiciosBolivarianos.java

@Override
public List<ViajeVO> consultarViajes(String fechaViaje, String ciudadOrigen, String ciudadDestino) {
    List<ViajeVO> listaViajes = new ArrayList<>();
    String nombreArchivo = Constantes.NAME_VIAJES + fechaViaje + Constantes.CSV_FILE;
    try {/*from  ww w . ja v a 2s.c  o  m*/
        File archivoConsulta = FileUtils.getFile(rutaConsulta, nombreArchivo);
        if (archivoConsulta != null && archivoConsulta.exists()) {
            List<String> lineasArchivo = FileUtils.readLines(archivoConsulta);
            System.out.println("Archivo encontrado: " + archivoConsulta.getAbsoluteFile());
            ViajeVO viajeAux;
            for (String s : lineasArchivo) {
                viajeAux = new ViajeVO(s);
                if (viajeAux.getCiudadOrigen().equalsIgnoreCase(ciudadOrigen)
                        && viajeAux.getCiudadDestino().equalsIgnoreCase(ciudadDestino)) {
                    listaViajes.add(viajeAux);
                }
            }
        } else {
            System.out.println("No existe archivo: " + nombreArchivo + " en el directorio: " + rutaConsulta);
        }
    } catch (IOException ex) {
        System.err.println(ex.toString());
    }
    return listaViajes;
}

From source file:com.legstar.pli2cob.AbstractTester.java

/**
 * Apply the lexer to produce a token stream from source.
 * @param source the source code/*from   w  w w  .j  av a2 s  .co m*/
 * @return an antlr token stream
 */
public CommonTokenStream lexify(final String source) {
    try {
        PLIStructureLexer lex = new PLIStructureLexerImpl(
                new ANTLRNoCaseReaderStream(new StringReader(source)));
        CommonTokenStream tokens = new CommonTokenStream(lex);
        assertEquals(0, lex.getNumberOfSyntaxErrors());
        assertTrue(tokens != null);
        return tokens;
    } catch (IOException e) {
        _log.error("test failed", e);
        fail(e.toString());
    }
    return null;
}

From source file:aes.pica.touresbalon.tb_serviciosbolivariano.ServiciosBolivarianos.java

@Override
public List<ViajeVO> consultarViajes(String fechaViaje, String ciudadOrigen, String ciudadDestino,
        String horaSalida) {//from w  w  w.  ja v a 2 s . c  om
    List<ViajeVO> listaViajes = new ArrayList<>();
    String nombreArchivo = Constantes.NAME_VIAJES + fechaViaje + Constantes.CSV_FILE;
    try {
        File archivoConsulta = FileUtils.getFile(rutaConsulta, nombreArchivo);
        if (archivoConsulta != null && archivoConsulta.exists()) {
            List<String> lineasArchivo = FileUtils.readLines(archivoConsulta);
            System.out.println("Archivo encontrado: " + archivoConsulta.getAbsoluteFile());
            ViajeVO viajeAux;
            for (String s : lineasArchivo) {
                viajeAux = new ViajeVO(s);
                if (viajeAux.getCiudadOrigen().equalsIgnoreCase(ciudadOrigen)
                        && viajeAux.getCiudadDestino().equalsIgnoreCase(ciudadDestino)
                        && viajeAux.getHoraSalida().equalsIgnoreCase(horaSalida)) {
                    listaViajes.add(viajeAux);
                }
            }
        } else {
            System.out.println("No existe archivo: " + nombreArchivo + " en el directorio: " + rutaConsulta);
        }
    } catch (IOException ex) {
        System.err.println(ex.toString());
    }
    return listaViajes;
}

From source file:edu.utsa.sifter.FileInfo.java

Document rawDoc(final Analyzer analyzer, final Document doc, final InputStream data, final String fp,
        final boolean testBody) {
    try {//w  ww . j  av  a2 s  .  c  om
        Strings = new StringsParser();
        if (!DocMaker.addBodyField(doc, Strings.extract(data), analyzer, testBody)) {
            // System.out.println(fp + " had no content, will not be indexed");
            return null;
        }
    } catch (IOException ex) {
        System.err.println("Had IOException generating raw body on " + fp + ". " + ex.toString());
    }
    return doc;
}

From source file:com.streamsets.pipeline.lib.io.FileContext.java

public void close() {
    if (open && reader != null) {
        open = false;//from  www  .  j  av  a2s .  c o m
        try {
            reader.close();
        } catch (IOException ex) {
            LOG.warn("Could not close '{}' file property: {}", reader.getLiveFile(), ex.toString(), ex);
        } finally {
            reader = null;
        }
    }
}