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:com.photon.phresco.nativeapp.unit.test.testcases.E_OffersActivityTest.java

/**
 *  get the Special offer list//from ww w.ja  v a  2  s.c  om
 *  from web server
 *
 */
@Test
public final void testSpecialOffers() {
    Product product = new Product();

    try {
        PhrescoLogger.info(TAG + " testSpecialOffers -------------- START ");

        JSONObject offersJSONObj = product.getProductJSONObject(
                Constants.getWebContextURL() + Constants.getRestAPI() + Constants.SPECIAL_PRODUCTS_URL);
        assertNotNull(offersJSONObj);
        JSONArray offerProductArray = offersJSONObj.getJSONArray("product");
        assertTrue(offerProductArray.length() > 0);

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

From source file:org.powertac.common.repo.RandomSeedRepo.java

/**
 * Pre-loads seeds from a stream./*  w  w  w . j  av a2s .c  o  m*/
 */
public void loadSeeds(InputStreamReader reader) {
    BufferedReader input = new BufferedReader(reader);
    String seedClass = RandomSeed.class.getName();
    try {
        String line;
        while ((line = input.readLine()) != null) {
            log.debug("original line: " + line);
            // first, strip off the process time nnnn:
            int colon = line.indexOf(':');
            if (colon <= 0 || line.length() <= colon + 2) {
                log.warn("Malformed line " + line);
                break;
            }
            line = line.substring(colon + 1);
            String[] fields = line.split("::");
            if (seedClass.equals(fields[0])) {
                if (fields.length != 7) {
                    log.error("Bad seed spec: " + line);
                } else {
                    System.out.println("fields[3, 4, 5, 6]: " + fields[3] + "," + fields[4] + "," + fields[5]
                            + "," + fields[6]);
                    //RandomSeed seed = new RandomSeed(fields[3],
                    //                                 Long.parseLong(fields[4]), 
                    //                                 fields[5],
                    //                                 Long.parseLong(fields[6]));
                    pendingSeedMap.put(composeName(fields[3], Long.parseLong(fields[4]), fields[5]),
                            Long.parseLong(fields[6]));
                }
            }
        }
    } catch (IOException ioe) {
        log.error("IOException reading seedfile:" + ioe.toString());
    }
}

From source file:com.cisco.oss.foundation.http.apache.ApacheHttpResponse.java

@Override
public InputStream getInputStream() {
    if (hasResponseBody()) {
        try {/*from  w w w. ja  v  a  2s  .  c om*/
            return httpResponse.getEntity().getContent();
        } catch (IOException e) {
            throw new ClientException(e.toString(), e);
        }
    } else {
        return null;
    }
}

From source file:com.googlecode.messagefixture.MessageConfiguration.java

private void loadProperties() {
    try {//from   ww  w  .  ja  v a2s.c o  m
        properties.load(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(SERVICEFIXTURE_PROPERTIES));
    } catch (IOException e) {
        InfoLogger.log(log,
                "Unable to loaded properties from " + SERVICEFIXTURE_PROPERTIES + " due to:" + e.toString());
    }
}

From source file:hudson.plugins.clearcase.action.BaseSnapshotCheckoutAction.java

@Override
public boolean checkout(Launcher launcher, FilePath workspace, String viewTag)
        throws IOException, InterruptedException {
    boolean viewCreated = cleanAndCreateViewIfNeeded(workspace, viewTag, viewPath, null);

    // At this stage, we have a valid view and a valid path
    boolean needSetCs = true;
    SnapshotCheckoutAction.LoadRulesDelta loadRulesDelta = null;
    if (!viewCreated) {
        ConfigSpec viewConfigSpec = new ConfigSpec(getCleartool().catcs(viewTag), launcher.isUnix());
        loadRulesDelta = getLoadRulesDelta(viewConfigSpec.getLoadRules(), launcher);
        needSetCs = !configSpec.stripLoadRules().equals(viewConfigSpec.stripLoadRules())
                || !ArrayUtils.isEmpty(loadRulesDelta.getRemoved());
    }/*from  w  w w  . ja v a 2  s  . co  m*/
    CleartoolUpdateResult result = null;
    if (needSetCs) {
        try {
            result = getCleartool().setcs2(viewPath, SetcsOption.CONFIGSPEC,
                    configSpec.setLoadRules(loadRules).getRaw());
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
    } else {
        // Perform a full update of the view to reevaluate config spec
        try {
            result = getCleartool().setcs2(viewPath, SetcsOption.CURRENT, null);
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
        String[] addedLoadRules = loadRulesDelta.getAdded();
        if (!ArrayUtils.isEmpty(addedLoadRules)) {
            // Config spec haven't changed, but there are new load rules
            try {
                result = getCleartool().update2(viewPath, addedLoadRules);
            } catch (IOException e) {
                launcher.getListener().fatalError(e.toString());
                return false;
            }
        }
    }
    if (result != null) {
        updtFile = result.getUpdateFile();
        launcher.getListener().getLogger().println("[INFO] updt file name: '" + updtFile.getRemote() + "'");
    }

    if (build != null) {
        // add config spec to dataAction
        ClearCaseDataAction dataAction = build.getAction(ClearCaseDataAction.class);
        if (dataAction != null) {
            dataAction.setCspec(getCleartool().catcs(viewTag).trim());
        }
    }

    return true;
}

From source file:muni.fi.dp.jz.jbatch.webservice.CliBatchResource.java

@GET
@Path("start/{deployment}/{jobName}/{properties}")
@RolesAllowed("admin")
public Response startJobCli(@PathParam("deployment") String deploymentName,
        @PathParam("jobName") String jobName, @PathParam("properties") String properties) {

    Properties props = new Properties();
    JSONObject jsonResp = new JSONObject();
    try {/*from   ww w .j a v a2 s  .  c  om*/
        props.load(new StringReader(properties));
    } catch (IOException ex) {
        LOG.error("Invalid job properties caused an exception: " + ex.toString());
        return Response.status(Response.Status.NOT_ACCEPTABLE).build();
    } catch (ForbiddenException ex) {
        jsonResp.put("outcome", "failed");
        jsonResp.put("description", "User not allowed to start the job: " + ex.toString());
        LOG.error("Unauthorized operation: start job via cli: " + ex.toString());
        return Response.ok(jsonResp, MediaType.APPLICATION_JSON).build();
    }
    try {
        String resp = cliService.startJobCli(deploymentName, jobName, props);
        return Response.ok(resp, MediaType.APPLICATION_JSON).build();
    } catch (EJBAccessException e) {
        jsonResp = constructJsonFailed("failed", "User not allowed to start the job", e);
        return Response.ok(jsonResp, MediaType.APPLICATION_JSON).build();
    }
    //        LOG.info("Job " + jobName + " started via cli! Server response returned.\n");

}

From source file:com.redhat.victims.cli.commands.ScanDirCommand.java

@Override
public CommandResult execute(List<String> args) {

    CommandResult result = new ExitSuccess(null);
    DirectoryScanner scanner = new DirectoryScanner(recursiveMode, repl);
    for (String arg : args) {
        try {//  w  ww  .j  a va 2s .  co  m
            // dispatched and reported asynchronously
            scanner.scan(arg);
        } catch (IOException e) {
            result.addVerboseOutput(String.format("error: (%s) - %s", arg, e.toString()));
        }

    }

    return result;
}

From source file:com.cisco.oss.foundation.http.apache.ApacheHttpResponse.java

@Override
public byte[] getResponse() {
    if (hasResponseBody()) {
        if (!isClosed) {
            try {
                return EntityUtils.toByteArray(httpResponse.getEntity());
            } catch (IOException e) {
                throw new ClientException(e.toString(), e);
            }//from  w w w  . j  av  a  2s .c  om
        } else {
            return responseBody;
        }
    } else {
        return new byte[0];
    }
}

From source file:com.cisco.oss.foundation.http.apache.ApacheHttpResponse.java

@Override
public String getResponseAsString() {
    if (hasResponseBody()) {
        if (!isClosed) {
            try {
                return EntityUtils.toString(httpResponse.getEntity());
            } catch (IOException e) {
                throw new ClientException(e.toString(), e);
            }//w  w  w. j  ava 2 s.  co  m
        } else {
            return new String(responseBody);
        }
    } else {
        return "";
    }
}

From source file:com.seleritycorp.context.RequestUtils.java

/**
 * Builds a User-Agent header value that identifies this build.
 *
 * @return the User-Agent header value that identifies this build
 *///from   w w w  .ja  v a  2s . c o  m
private String getUserAgent() {
    String buildPropertiesPath = "/META-INF/main-application/build.properties";
    Properties properties = new Properties();
    try (InputStream stream = RequestUtils.class.getResourceAsStream(buildPropertiesPath)) {
        properties.load(stream);
    } catch (IOException e) {
        System.err.println("Could not load build properties at '" + buildPropertiesPath + "'." + e.toString());
    }

    return properties.getProperty("artifactId") + "/" + properties.getProperty("version") + " (build "
            + properties.getProperty("git.description") + "/" + properties.getProperty("build.time") + ")";
}