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:org.cerberus.crud.service.impl.TestCaseExecutionwwwDetService.java

@Override
public void registerDetail(long runId, String file, String page) {
    try {/* www  .  ja v a 2s. co  m*/
        JsonFactory f = new JsonFactory();
        JsonParser jp = f.createJsonParser(file);

        HarFileReader r = new HarFileReader();
        HarLog log = r.readHarFile(jp, null);
        StatisticDetail detail;

        for (HarEntry entry : log.getEntries().getEntries()) {
            detail = new StatisticDetail();
            detail.setStart(entry.getStartedDateTime().getTime());
            detail.setTime(entry.getTime());
            detail.setEnd(entry.getStartedDateTime().getTime() + entry.getTime());
            detail.setPageRes(page);
            detail.setUrl(entry.getRequest().getUrl());
            detail.setExt(entry.getResponse().getContent().getMimeType().split("/")[1]);
            detail.setStatus(entry.getResponse().getStatus());
            detail.setMethod(entry.getRequest().getMethod());
            detail.setBytes(entry.getRequest().getHeadersSize() + entry.getRequest().getBodySize());
            detail.setHostReq(entry.getRequest().getUrl().split("/")[2]);
            detail.setContentType();

            this.testCaseExecutionWWWDetDAO.register(runId, detail);
        }
    } catch (IOException exception) {
        MyLogger.log(TestCaseExecutionwwwDetService.class.getName(), Level.WARN,
                exception.toString() + "\nrunID: " + runId);
    }
}

From source file:eionet.cr.harvest.UploadHarvest.java

@Override
protected void doHarvest() throws HarvestException {

    int noOfTriples = 0;
    try {/*from  w  w w . j  a v a2s. c  o  m*/

        if (file != null) {
            LOGGER.debug("Loading the file contents into the triple store");
            noOfTriples = processLocalContent(file, contentType);
            setStoredTriplesCount(noOfTriples);
            LOGGER.debug(noOfTriples + " triples stored by the triple store");
        }

        finishWithOK(noOfTriples);

    } catch (IOException e) {
        finishWithError(e, noOfTriples);
        throw new HarvestException(e.toString(), e);
    } catch (SAXException e) {
        finishWithError(e, noOfTriples);
        throw new HarvestException(e.toString(), e);
    } catch (DAOException e) {
        finishWithError(e, noOfTriples);
        throw new HarvestException(e.toString(), e);
    } catch (RDFHandlerException e) {
        finishWithError(e, noOfTriples);
        throw new HarvestException(e.toString(), e);
    } catch (RDFParseException e) {
        finishWithError(e, noOfTriples);
        throw new HarvestException(e.toString(), e);
    }
}

From source file:com.denimgroup.threadfix.importer.impl.remoteprovider.utils.RemoteProviderHttpUtilsImpl.java

@Override
public HttpResponse postUrlWithConfigurer(String url, RequestConfigurer requestConfigurer) {
    if (url == null) {
        throw new IllegalArgumentException("Null url passed to postUrlWithConfigurer.");
    }/*from w w w . j  a v  a2 s. com*/

    if (requestConfigurer == null) {
        throw new IllegalArgumentException("Null configurer passed to postUrlWithConfigurer.");
    }

    PostMethod post = new PostMethod(url);

    requestConfigurer.configure(post);

    int status = -1;

    try {

        HttpClient client = getConfiguredHttpClient(classInstance);

        status = client.executeMethod(post);

        if (status != 200) {
            LOG.warn("Status wasn't 200, it was " + status);
            return HttpResponse.failure(status, post.getResponseBodyAsStream());
        } else {
            return HttpResponse.success(status, post.getResponseBodyAsStream());
        }

    } catch (IOException e1) {
        LOG.error("Encountered IOException while making request to remote provider. " + e1.toString());
        LOG.warn("There was an error and the POST request was not finished.");
        throw new RestException(e1, e1.toString());
    }

}

From source file:com.photon.phresco.nativeapp.unit.test.testcases.A_MainActivityTest.java

/**
 *  get the application configuration from web server
 *  and check its application version/*  ww  w .j  ava 2s.  co m*/
 *
 */

public void testSplashAppConfig() {
    try {
        PhrescoLogger.info(TAG + " testSplashAppConfig -------------- START ");

        JSONObject appConfigJSONObj = AppConfig.getAppConfigJSONObject(
                Constants.getWebContextURL() + Constants.getRestAPI() + Constants.CONFIG_URL);
        assertNotNull(appConfigJSONObj);
        JSONObject appConfigObj;

        appConfigObj = appConfigJSONObj.getJSONObject("appVersionInfo");
        assertNotNull(appConfigObj);

        PhrescoLogger.info(TAG + " testSplashAppConfig -------------- END ");
    } catch (IOException ex) {
        PhrescoLogger.info(TAG + "testSplashAppConfig - IOException: " + ex.toString());
        PhrescoLogger.warning(ex);
    } catch (JSONException ex) {
        PhrescoLogger.info(TAG + "testSplashAppConfig - JSONException: " + ex.toString());
        PhrescoLogger.warning(ex);
    }

}

From source file:it.tidalwave.bluemarine2.downloader.impl.DefaultDownloader.java

/*******************************************************************************************************************
 *
 *
 *
 ******************************************************************************************************************/
/* VisibleForTesting */ void onDownloadRequest(final @ListensTo @Nonnull DownloadRequest request)
        throws URISyntaxException {
    try {/*w w w.j  a v  a 2 s  . com*/
        log.info("onDownloadRequest({})", request);

        URL url = request.getUrl();

        for (;;) {
            final HttpCacheContext context = HttpCacheContext.create();
            @Cleanup
            final CloseableHttpResponse response = httpClient.execute(new HttpGet(url.toURI()), context);
            final byte[] bytes = bytesFrom(response);
            final CacheResponseStatus cacheResponseStatus = context.getCacheResponseStatus();
            log.debug(">>>> cacheResponseStatus: {}", cacheResponseStatus);

            final Origin origin = cacheResponseStatus.equals(CacheResponseStatus.CACHE_HIT) ? Origin.CACHE
                    : Origin.NETWORK;

            // FIXME: shouldn't do this by myself
            // FIXME: upon configuration, everything should be cached (needed for supporting integration tests)
            if (!origin.equals(Origin.CACHE)
                    && Arrays.asList(200, 303).contains(response.getStatusLine().getStatusCode())) {
                final Date date = new Date();
                final Resource resource = new HeapResource(bytes);
                cacheStorage.putEntry(url.toExternalForm(), new HttpCacheEntry(date, date,
                        response.getStatusLine(), response.getAllHeaders(), resource));
            }

            // FIXME: if the redirect were enabled, we could drop this check
            if (request.isOptionPresent(DownloadRequest.Option.FOLLOW_REDIRECT)
                    && response.getStatusLine().getStatusCode() == 303) // SEE_OTHER FIXME
            {
                url = new URL(response.getFirstHeader("Location").getValue());
                log.info(">>>> following 'see also' to {} ...", url);
            } else {
                messageBus.publish(new DownloadComplete(request.getUrl(),
                        response.getStatusLine().getStatusCode(), bytes, origin));
                return;
            }
        }
    } catch (IOException e) {
        log.error("{}: {}", request.getUrl(), e.toString());
        messageBus.publish(new DownloadComplete(request.getUrl(), -1, new byte[0], Origin.NETWORK));
    }
}

From source file:com.grendelscan.proxy.ssl.TunneledSSLConnection.java

@Override
protected void assertOpen() throws IllegalStateException {
    if (!open) {/*from ww  w.j a  v  a 2  s.  c o  m*/
        String message = "assertOpen failed: tunnel is not open";
        LOGGER.warn(message);
        throw new IllegalStateException(message);
    }

    if (socket.isClosed() || !socket.isConnected()) {
        String message = "assertOpen failed: socket is unexpectidly not open";
        LOGGER.warn(message);
        open = false;
        try {
            sslSocket.close();
        } catch (IOException e) {
            LOGGER.trace("Problem closing ssl socket: " + e.toString(), e);
        }
        throw new IllegalStateException(message);
    }

    if (sslSocket.isClosed() || !sslSocket.isConnected()) {
        String message = "assertOpen failed: sslSocket is unexpectidly not open";
        LOGGER.warn(message);
        open = false;
        try {
            socket.close();
        } catch (IOException e) {
            LOGGER.trace("Problem closing socket: " + e.toString(), e);
        }
        throw new IllegalStateException(message);
    }
}

From source file:beans.FotoBean.java

public void tirarFoto(CaptureEvent captureEvent) throws IOException {
    arquivo = gerarNome();/*from ww w . j ava2  s . c  o  m*/
    byte[] data = captureEvent.getData();

    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
            .getContext();
    String pasta = servletContext.getRealPath("") + File.separator + "resources" + File.separator
            + "fotossalvas";
    File vpasta = new File(pasta);
    if (!vpasta.exists()) {
        vpasta.setWritable(true);
        vpasta.mkdirs();
    }
    String novoarquivo = pasta + File.separator + arquivo + ".jpeg";
    System.out.println(novoarquivo);
    fotosalva = new File(novoarquivo);
    fotosalva.createNewFile();
    FileImageOutputStream imageOutput;
    try {
        imageOutput = new FileImageOutputStream(fotosalva);
        imageOutput.write(data, 0, data.length);
        imageOutput.close();

    } catch (IOException e) {
        Util.criarMensagemErro(e.toString());

    }
}

From source file:playground.anhorni.crossborder.verification.Verification.java

private void writeTGZMGraph() {

    int width = 800;
    int height = 600;

    for (int i = 0; i < 4; i++) {
        TGZMCompare tgzm = new TGZMCompare(this.xTripsPerHour[i], this.aggregatedVolumePerHourTGZM[i]);

        JFreeChart chart = tgzm.createChart(this.getActTypeString(i));
        String fileName = "TGZMCompare" + this.getActTypeString(i);

        try {//from   w  ww .java  2 s .c o  m
            ChartRenderingInfo info = null;
            info = new ChartRenderingInfo(new StandardEntityCollection());
            File file1 = new File("output/" + fileName + ".png");
            ChartUtilities.saveChartAsPNG(file1, chart, width, height, info);
        } catch (IOException e) {
            System.out.println(e.toString());
        } //catch   
    }

    int[] sumTripsPerHour = new int[24];
    double[] sumAggregatedVolumePerHour = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 4; j++) {
            sumTripsPerHour[i] += this.xTripsPerHour[j][i];
            sumAggregatedVolumePerHour[i] += this.aggregatedVolumePerHourTGZM[j][i];
        }
    }

    TGZMCompare tgzm = new TGZMCompare(sumTripsPerHour, sumAggregatedVolumePerHour);
    JFreeChart chart = tgzm.createChart("All");
    String fileName = "TGZMCompare All";

    try {
        ChartRenderingInfo info = null;
        info = new ChartRenderingInfo(new StandardEntityCollection());
        File file1 = new File("output/" + fileName + ".png");
        ChartUtilities.saveChartAsPNG(file1, chart, width, height, info);
    } catch (IOException e) {
        System.out.println(e.toString());
    } //catch
}

From source file:com.cisco.dvbu.ps.utils.net.FtpFile.java

public void ftpFile(String fileName) throws CustomProcedureException, SQLException {

    // new ftp client
    FTPClient ftp = new FTPClient();
    OutputStream output = null;/*from  ww  w.  jav  a 2s  . com*/

    success = false;
    try {
        //try to connect
        ftp.connect(hostIp);

        //login to server
        if (!ftp.login(userId, userPass)) {
            ftp.logout();
            qenv.log(LOG_ERROR, "Ftp server refused connection user/password incorrect.");
        }
        int reply = ftp.getReplyCode();

        //FTPReply stores a set of constants for FTP Reply codes
        if (!FTPReply.isPositiveCompletion(reply)) {
            ftp.disconnect();
            qenv.log(LOG_ERROR, "Ftp server refused connection.");
        }

        //enter passive mode
        ftp.setFileType(FTPClient.BINARY_FILE_TYPE, FTPClient.BINARY_FILE_TYPE);
        ftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
        ftp.enterLocalPassiveMode();

        //get system name
        //System.out.println("Remote system is " + ftp.getSystemType());

        //change current directory
        ftp.changeWorkingDirectory(ftpDirName);
        System.out.println("Current directory is " + ftp.printWorkingDirectory());
        System.out.println("File is " + fileName);

        output = new FileOutputStream(dirName + "/" + fileName);

        //get the file from the remote system
        success = ftp.retrieveFile(fileName, output);

        //close output stream
        output.close();

    } catch (IOException ex) {
        throw new CustomProcedureException("Error in CJP " + getName() + ": " + ex.toString());
    }
}

From source file:com.polyvi.xface.extension.XStorageExt.java

/**
 * ?.//from  ww  w. j av  a  2 s.  c o m
 *
 * @param db
 *            ???
 */
private boolean openDatabase(XIWebContext webContext, String db) {
    if (null != mMyDb) {
        mMyDb.close();
    }

    File dbDir = new File(webContext.getApplication().getDataDir(), DB_DIR_NAME);
    if (!dbDir.exists()) {
        dbDir.mkdirs();
    }
    boolean isValidDbPath = true;
    try {
        // ???openDatabase???null??null???????
        String dbPath = new File(dbDir, db).getCanonicalPath();
        // ?????appData?database
        if (!XFileUtils.isFileAncestorOf(dbDir.getAbsolutePath(), dbPath)) {
            XLog.e(CLASS_NAME, dbPath);
            isValidDbPath = false;
        } else {
            mMyDb = SQLiteDatabase.openOrCreateDatabase(dbPath, null);
        }
    } catch (IOException e) {
        isValidDbPath = false;
        XLog.e(CLASS_NAME, e.toString());
    }
    return isValidDbPath;
}