Example usage for java.io UncheckedIOException getCause

List of usage examples for java.io UncheckedIOException getCause

Introduction

In this page you can find the example usage for java.io UncheckedIOException getCause.

Prototype

@Override
public IOException getCause() 

Source Link

Document

Returns the cause of this exception.

Usage

From source file:com.github.horrorho.inflatabledonkey.cloud.AuthorizeAssetsClient.java

@Override
public List<FileGroups> apply(HttpClient httpClient, Collection<Asset> assets) throws IOException {
    logger.trace("<< apply() - assets: {}", assets.size());
    try {//from w w w  .  jav  a  2  s .c  om
        List<CloudKit.Asset> ckAssets = ckAssets(assets);
        // Only expecting one contentBaseUrl. 
        // Can probably simplify code to handle only one.
        List<FileGroups> fileGroups = ckAssets.stream()
                .collect(Collectors.groupingBy(CloudKit.Asset::getContentBaseURL)).entrySet().stream()
                .map(e -> fileGroups(httpClient, e.getKey(), e.getValue())).collect(toList());
        logger.trace(">> apply() - fileGroups: {}", fileGroups.size());
        return fileGroups;

    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }
}

From source file:com.github.horrorho.inflatabledonkey.chunk.engine.ChunkListDecrypter.java

/**
 *
 * @param container//from w  w  w  .  jav  a2s. c  om
 * @param inputStream closed on exit
 * @param store
 * @throws IOException
 * @throws ArithmeticException on input streams over 2 Gb.
 * @throws IllegalArgumentException on non 0x01 chunk keys
 */
public void apply(StorageHostChunkList container, InputStream inputStream, ChunkStore store)
        throws IOException {
    logger.trace("<< apply() - input: {}", inputStream);
    // Ensure our chunk offsets are sequentially ordered.
    List<ChunkInfo> list = container.getChunkInfoList().stream().sorted(CHUNK_OFFSET_COMPARATOR)
            .collect(toList());

    try (CountingInputStream countingInputStream = new CountingInputStream(inputStream)) {
        streamChunks(list, countingInputStream, store);
    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }

    if (logger.isDebugEnabled()) {
        // Sanity check. Has a minor IO cost with a disk based chunk store.
        String missingChunks = list.stream().map(ci -> ci.getChunkChecksum().toByteArray())
                .filter(c -> !store.contains(c)).map(c -> "0x" + Hex.toHexString(c)).collect(joining(" "));
        if (missingChunks.isEmpty()) {
            logger.debug("-- apply() - all chunks have been stored");
        } else {
            logger.warn("-- apply() - missing chunks: {}", missingChunks);
        }
    }
    logger.trace(">> apply()");
}

From source file:net.staticsnow.nexus.repository.apt.internal.proxy.AptProxyFacet.java

private List<SnapshotItem> fetchLatest(List<ContentSpecifier> specs) throws IOException {
    try {//from  w  ww .j a v  a 2 s  .  co m
        return specs.stream().map(ioCheck(spec -> fetchLatest(spec))).filter(item -> item.isPresent())
                .map(item -> item.get()).collect(Collectors.toList());
    } catch (UncheckedIOException e) {
        throw e.getCause();
    }
}

From source file:com.twentyn.patentSearch.Searcher.java

/**
 * Search for patents that contain any of the specified chemical synonyms, scored based on synonym and biosynthesis
 * keyword occurrence.  Results are filtered by score.
 * @param synonyms A list of chemical synonyms to use in the search.
 * @return A list of search results whose relevance scores are above the searcher's score threshold.
 * @throws IOException/*from  w  ww  .jav a2  s .co  m*/
 */
public List<SearchResult> searchInClaims(List<String> synonyms) throws IOException {
    if (synonyms.size() == 0) {
        LOGGER.info("Not running search for no synonyms!");
        return Collections.emptyList();
    }

    // Make queries for all synonyms.
    final List<BooleanQuery> queries = makeQueries(synonyms, CLAIMS_FIELD).collect(Collectors.toList());

    // Reuse the compiled queries for all indices.
    try {
        Set<Triple<Float, String, String>> uniqueResults = indexReadersAndSearchers.stream()
                .map(p -> runSearch(p, queries)). // Search to get per-query streams...
                flatMap(Function.identity()). // combine all the streams into one...
                collect(Collectors.toSet()); // and collect the merged results in a list.

        /* Uniq-ify!  It is completely reasonable for a patent to appear for multiple queries.
         * TODO: we haven't seen results appear multiple times with different scores.  We should probably unique-ify
         * on id and take the result with the best score just to be safe. */
        List<Triple<Float, String, String>> results = new ArrayList<>(uniqueResults);
        Collections.sort(results);

        return results.stream().map(t -> new SearchResult(t.getMiddle(), t.getRight(), t.getLeft()))
                .collect(Collectors.toList());
    } catch (UncheckedIOException e) {
        throw e.getCause(); // Promote back to a regular exception for handling by the caller.
    }
}

From source file:com.joyent.manta.client.MantaClient.java

/**
 * Return a stream of the contents of a directory in Manta.
 *
 * @param path The fully qualified path of the directory.
 * @return A {@link Stream} of {@link MantaObjectResponse} listing the contents of the directory.
 * @throws IOException thrown when there is a problem getting the listing over the network
 *//*  ww w  .  j  a  va2s.  c o  m*/
public Stream<MantaObject> listObjects(final String path) throws IOException {
    final MantaDirectoryListingIterator itr = streamingIterator(path);

    /* We preemptively check the iterator for a next value because that will
     * trigger an error if the path doesn't exist or is otherwise inaccessible.
     * This error typically takes the form of an UncheckedIOException, so we
     * unwind that exception if the cause is a MantaClientHttpResponseException
     * and rethrow another MantaClientHttpResponseException, so that the
     * stacktrace will point to this running method.
     */
    try {
        if (!itr.hasNext()) {
            itr.close();
            return Stream.empty();
        }
    } catch (UncheckedIOException e) {
        if (e.getCause() instanceof MantaClientHttpResponseException) {
            throw e.getCause();
        } else {
            throw e;
        }
    }

    final int additionalCharacteristics = Spliterator.CONCURRENT | Spliterator.ORDERED | Spliterator.NONNULL
            | Spliterator.DISTINCT;

    Stream<Map<String, Object>> backingStream = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(itr, additionalCharacteristics), false);

    Stream<MantaObject> stream = backingStream.map(MantaObjectConversionFunction.INSTANCE).onClose(itr::close);

    danglingStreams.add(stream);

    return stream;
}

From source file:onl.area51.filesystem.ftp.client.FTPClient.java

/**
 * List files in the specified directory and pass each one to a consumer
 * <p>/*from   ww  w.  j a v a 2 s.co  m*/
 * @param pathname directory name
 * @param c        Consumer
 * <p>
 * @throws IOException
 */
default void forEach(String pathname, IOConsumer<FTPFile> c) throws IOException {
    try {
        forEachFile(pathname, c.guard());
    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }
}

From source file:onl.area51.filesystem.ftp.client.FTPClient.java

/**
 * List files in the specified directory, apply a filter then pass each one to a consumer
 * <p>/*from   w w  w . j a va  2 s  .c om*/
 * @param pathname directory name
 * @param filter   filter
 * @param c        Consumer
 * <p>
 * @throws IOException
 */
default void forEach(String pathname, FTPFileFilter filter, IOConsumer<FTPFile> c) throws IOException {
    try {
        forEachFile(pathname, filter, c.guard());
    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }
}

From source file:onl.area51.filesystem.ftp.client.FTPClient.java

default void forEachMlist(IOConsumer<FTPFile> c) throws IOException {
    try {/*from  ww w.j  a  v  a  2  s. c o  m*/
        forEachMlistDir(c.guard());
    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }
}

From source file:onl.area51.filesystem.ftp.client.FTPClient.java

default void forEachMlist(String pathname, IOConsumer<FTPFile> c) throws IOException {
    try {// w  w w  .  jav a 2  s  .c o m
        forEachMlistDir(pathname, c.guard());
    } catch (UncheckedIOException ex) {
        throw ex.getCause();
    }
}