Example usage for java.io UncheckedIOException UncheckedIOException

List of usage examples for java.io UncheckedIOException UncheckedIOException

Introduction

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

Prototype

public UncheckedIOException(IOException cause) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:com.discovery.darchrow.util.ResourceBundleUtil.java

/**
 * ResourceBundle({@link PropertyResourceBundle}),????(file).
 *
 * @param inputStream// www.j a v a  2 s  .c  o  m
 *            the input stream
 * @return the resource bundle,may be null
 * @see java.util.PropertyResourceBundle#PropertyResourceBundle(InputStream)
 * @since 1.0.9
 */
public static ResourceBundle getResourceBundle(InputStream inputStream) {
    if (Validator.isNullOrEmpty(inputStream)) {
        throw new IllegalArgumentException("inputStream can't be null/empty!");
    }
    try {
        ResourceBundle resourceBundle = new PropertyResourceBundle(inputStream);
        return resourceBundle;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.discovery.darchrow.util.ResourceBundleUtil.java

/**
 *  resource bundle({@link PropertyResourceBundle}),????(file).
 *
 * @param reader/*from w  w w  . j a v a2 s .  co  m*/
 *            the reader
 * @return the resource bundle
 * @see java.util.PropertyResourceBundle#PropertyResourceBundle(Reader)
 * @since 1.0.9
 */
public static ResourceBundle getResourceBundle(Reader reader) {
    if (Validator.isNullOrEmpty(reader)) {
        throw new IllegalArgumentException("reader can't be null/empty!");
    }
    try {
        ResourceBundle resourceBundle = new PropertyResourceBundle(reader);
        return resourceBundle;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.addthis.hydra.task.source.AbstractStreamFileDataSource.java

@Override
public void close() {
    if (shuttingDown.compareAndSet(false, true)) {
        log.info("closing stream file data source. preOpened={} queue={}", preOpened.size(), queue.size());
        try {/*  w w w  . j  a v a  2s  .co  m*/
            log.info("Waiting up to {} seconds for outstanding worker tasks to complete.", latchTimeout);
            getUninterruptibly(aggregateWorkerFuture, latchTimeout, TimeUnit.SECONDS);
            log.info("All threads have finished.");

            log.debug("closing wrappers");
            closePreOpenedQueue();

            log.debug("shutting down mesh");
            //we may overwrite the local source variable and in doing so throw away the Persistance flag
            PersistentStreamFileSource baseSource = getSource();
            if (baseSource != null) {
                baseSource.shutdown();
            } else {
                log.warn("getSource() returned null and no source was shutdown");
            }

            closeMarkDB();
            log.info(fileStatsToString("shutdown complete"));
        } catch (IOException ex) {
            UncheckedIOException unchecked = new UncheckedIOException(ex);
            closeFuture.completeExceptionally(unchecked);
            throw unchecked;
        } catch (Throwable t) {
            closeFuture.completeExceptionally(t);
            throw propagate(t);
        }
        workerThreadPool.shutdown();
        closeFuture.complete(null);
    } else {
        try {
            closeFuture.join();
        } catch (CompletionException ex) {
            throw propagate(ex.getCause());
        }
    }
}

From source file:org.jboss.as.test.integration.logging.handlers.SocketHandlerTestCase.java

private static Path createTempDir() {
    try {//w  w  w  . j  av  a  2 s .  c o m
        return Files.createTempDirectory("wf-test");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.act.lcms.v2.TraceIndexExtractor.java

public Iterator<Pair<Double, List<XZ>>> getIteratorOverTraces(File index) throws IOException, RocksDBException {
    RocksDBAndHandles<COLUMN_FAMILIES> dbAndHandles = DBUtil.openExistingRocksDB(index,
            COLUMN_FAMILIES.values());/*from   w w w .  ja  v  a2s  .  c om*/
    final RocksDBAndHandles.RocksDBIterator rangesIterator = dbAndHandles
            .newIterator(COLUMN_FAMILIES.TARGET_TO_WINDOW);

    rangesIterator.reset();

    final List<Double> times;
    try {
        byte[] timeBytes = dbAndHandles.get(COLUMN_FAMILIES.TIMEPOINTS, TIMEPOINTS_KEY);
        times = deserializeDoubleList(timeBytes);
    } catch (RocksDBException e) {
        LOGGER.error("Caught RocksDBException when trying to fetch times: %s", e.getMessage());
        throw new RuntimeException(e);
    } catch (IOException e) {
        LOGGER.error("Caught IOException when trying to fetch timese %s", e.getMessage());
        throw new UncheckedIOException(e);
    }

    return new Iterator<Pair<Double, List<XZ>>>() {
        int windowNum = 0;

        @Override
        public boolean hasNext() {
            return rangesIterator.isValid();
        }

        @Override
        public Pair<Double, List<XZ>> next() {
            byte[] valBytes = rangesIterator.value();
            MZWindow window;
            windowNum++;
            try {
                window = deserializeObject(valBytes);
            } catch (IOException e) {
                LOGGER.error("Caught IOException when iterating over mz windows (%d): %s", windowNum,
                        e.getMessage());
                throw new UncheckedIOException(e);
            } catch (ClassNotFoundException e) {
                LOGGER.error("Caught ClassNotFoundException when iterating over mz windows (%d): %s", windowNum,
                        e.getMessage());
                throw new RuntimeException(e);
            }

            byte[] traceKeyBytes;
            try {
                traceKeyBytes = serializeObject(window.getIndex());
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }

            List<Double> trace;
            try {
                byte[] traceBytes = dbAndHandles.get(COLUMN_FAMILIES.ID_TO_TRACE, traceKeyBytes);
                if (traceBytes == null) {
                    String msg = String.format("Got null byte array back for trace key %d (target: %.6f)",
                            window.getIndex(), window.getTargetMZ());
                    LOGGER.error(msg);
                    throw new RuntimeException(msg);
                }
                trace = deserializeDoubleList(traceBytes);
            } catch (RocksDBException e) {
                LOGGER.error("Caught RocksDBException when trying to extract trace %d (%.6f): %s",
                        window.getIndex(), window.getTargetMZ(), e.getMessage());
                throw new RuntimeException(e);
            } catch (IOException e) {
                LOGGER.error("Caught IOException when trying to extract trace %d (%.6f): %s", window.getIndex(),
                        window.getTargetMZ(), e.getMessage());
                throw new UncheckedIOException(e);
            }

            if (trace.size() != times.size()) {
                LOGGER.error("Found mismatching trace and times size (%d vs. %d), continuing anyway",
                        trace.size(), times.size());
            }

            List<XZ> xzs = new ArrayList<>(times.size());
            for (int i = 0; i < trace.size() && i < times.size(); i++) {
                xzs.add(new XZ(times.get(i), trace.get(i)));
            }

            /* The Rocks iterator pattern is a bit backwards from the Java model, as we don't need an initial next() call
             * to prime the iterator, and `isValid` indicates whether we've gone past the end of the iterator.  We thus
             * advance only after we've read the current value, which means the next hasNext call after we've walked off the
             * edge will return false. */
            rangesIterator.next();
            return Pair.of(window.getTargetMZ(), xzs);
        }
    };
}

From source file:org.mitre.mpf.wfm.service.PipelineServiceImpl.java

private void xStreamSave(Object object, WritableResource resource) {
    try (OutputStream outStream = resource.getOutputStream()) {
        xStream.toXML(object, outStream);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }/*from  ww  w . j  a  v  a2 s .c  o  m*/
}

From source file:com.taobao.android.builder.manager.AtlasAppTaskManager.java

@Override
public void runTask() {

    appExtension.getApplicationVariants().forEach(new Consumer<ApplicationVariant>() {

        @Override//from   w  w  w . java 2  s  .  com
        public void accept(ApplicationVariant applicationVariant) {

            AppVariantContext appVariantContext = AtlasBuildContext.sBuilderAdapter.appVariantContextFactory
                    .getAppVariantContext(project, applicationVariant);
            if (!AtlasBuildContext.atlasMainDexHelperMap.containsKey(appVariantContext.getVariantName())) {
                AtlasBuildContext.atlasMainDexHelperMap.put(appVariantContext.getVariantName(),
                        new AtlasMainDexHelper());
            }

            TransformReplacer transformReplacer = new TransformReplacer(appVariantContext);

            repalceAndroidBuilder(applicationVariant);

            List<MtlTaskContext> mtlTaskContextList = new ArrayList<MtlTaskContext>();

            mtlTaskContextList.add(new MtlTaskContext(appVariantContext.getVariantData().preBuildTask));

            mtlTaskContextList.add(new MtlTaskContext(BuildAtlasEnvTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(ScanDupResTask.ConfigActon.class, null));

            mtlTaskContextList.add(new MtlTaskContext(LogDependenciesTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(PrepareAPTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(appVariantContext.getVariantData().mergeAssetsTask));

            mtlTaskContextList.add(new MtlTaskContext(RenderscriptCompile.class));

            mtlTaskContextList.add(new MtlTaskContext(StandardizeLibManifestTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(PrepareBundleInfoTask.ConfigAction.class, null));

            if (!atlasExtension.getTBuildConfig().getClassInject() && atlasExtension.isAtlasEnabled()) {
                mtlTaskContextList.add(new MtlTaskContext(GenerateAtlasSourceTask.ConfigAction.class, null));
            }

            mtlTaskContextList.add(new MtlTaskContext(PreparePackageIdsTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(PrepareAaptTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(AidlCompile.class));

            mtlTaskContextList.add(new MtlTaskContext(GenerateBuildConfig.class));

            mtlTaskContextList.add(new MtlTaskContext(MergeResAwbsConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(MergeAssetAwbsConfigAction.class, null));

            if (null != androidExtension.getDataBinding() && androidExtension.getDataBinding().isEnabled()) {

                //                                                                  mtlTaskContextList.add(
                //                                                                          new MtlTaskContext(AwbDataBindingProcessLayoutTask.ConfigAction.class, null));
                mtlTaskContextList
                        .add(new MtlTaskContext(AwbDataBindingExportBuildInfoTask.ConfigAction.class, null));
                mtlTaskContextList
                        .add(new MtlTaskContext(AwbDataBindingMergeArtifactsTask.ConfigAction.class, null));

            }

            mtlTaskContextList.add(new MtlTaskContext(MergeManifests.class));

            mtlTaskContextList.add(new MtlTaskContext(MergeManifestAwbsConfigAction.class, null));

            //mtlTaskContextList.add(new MtlTaskContext(MergeResV4Dir.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(ProcessAndroidResources.class));

            ProcessAndroidResources processAndroidResources = appVariantContext.getScope()
                    .getProcessResourcesTask()
                    .get(new TaskContainerAdaptor(appVariantContext.getProject().getTasks()));
            if (processAndroidResources.isAapt2Enabled()) {
                processAndroidResources.doLast(new Action<Task>() {
                    @Override
                    public void execute(Task task) {
                        File processResourcePackageOutputDirectory = appVariantContext.getScope()
                                .getProcessResourcePackageOutputDirectory();
                        File[] files = processResourcePackageOutputDirectory
                                .listFiles((file, name) -> name.endsWith(SdkConstants.DOT_RES));
                        for (File file : files) {
                            try {
                                ResourcePatch.makePatchable(file);
                            } catch (IOException e) {
                                throw new UncheckedIOException(e);
                            }
                        }
                    }
                });
            }
            mtlTaskContextList.add(new MtlTaskContext(ProcessResAwbsTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(JavacAwbsTask.ConfigAction.class, null));

            if (null != androidExtension.getDataBinding() && androidExtension.getDataBinding().isEnabled()) {
                mtlTaskContextList.add(new MtlTaskContext(AwbDataBindingRenameTask.ConfigAction.class, null));
            }

            mtlTaskContextList.add(new MtlTaskContext(TransformTask.class));

            mtlTaskContextList.add(new MtlTaskContext(PackageAwbsTask.ConfigAction.class, null));

            if (appVariantContext.getAtlasExtension().getTBuildConfig().isIncremental()
                    && (appVariantContext.getBuildType().getPatchConfig() == null
                            || !appVariantContext.getBuildType().getPatchConfig().isCreateTPatch())) {
                //                                                                  mtlTaskContextList.add(new MtlTaskContext(PrepareBaseApkTask.ConfigAction.class, null));
                final TaskFactory tasks = new TaskContainerAdaptor(project.getTasks());
                VariantScope variantScope = appVariantContext.getVariantData().getScope();

                // create the stream generated from this task
                variantScope.getTransformManager()
                        .addStream(OriginalStream.builder(project, applicationVariant.getName())
                                .addContentType(QualifiedContent.DefaultContentType.RESOURCES)
                                .addScope(QualifiedContent.Scope.PROJECT)
                                .setFolders(new Supplier<Collection<File>>() {
                                    @Override
                                    public Collection<File> get() {
                                        return ImmutableList
                                                .of(new File(appVariantContext.apContext.getBaseApk() + "_"));
                                    }
                                }).build());
            }

            final TaskFactory tasks = new TaskContainerAdaptor(project.getTasks());
            VariantScope variantScope = appVariantContext.getVariantData().getScope();

            mtlTaskContextList.add(new MtlTaskContext(PackageApplication.class));

            if (appVariantContext.getAtlasExtension().isInstantAppEnabled()) {

                mtlTaskContextList.add(new MtlTaskContext(AtlasBundleInstantApp.ConfigAction.class, null));
            }

            mtlTaskContextList.add(new MtlTaskContext(ApBuildTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(DiffBundleInfoTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(TPatchDiffResAPBuildTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(TPatchDiffApkBuildTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext(TPatchTask.ConfigAction.class, null));

            mtlTaskContextList.add(new MtlTaskContext("assemble"));

            new MtlTaskInjector(appVariantContext).injectTasks(mtlTaskContextList, tAndroidBuilder);

            List<MtlTransformContext> mtlTransformContextList = new ArrayList<MtlTransformContext>();

            if (atlasExtension.getTBuildConfig().getClassInject()) {
                mtlTransformContextList.add(new MtlTransformContext(ClassInjectTransform.class,
                        ProGuardTransform.class, DexTransform.class));
            }
            if (!mtlTransformContextList.isEmpty()) {
                new MtlTransformInjector(appVariantContext).injectTasks(mtlTransformContextList);
            }
            Collection<BaseVariantOutput> baseVariantOutputDataList = appVariantContext.getVariantOutputData();

            boolean multiDexEnabled = appVariantContext.getVariantData().getVariantConfiguration()
                    .isMultiDexEnabled();

            if (atlasExtension.getTBuildConfig().isAtlasMultiDex() && multiDexEnabled) {
                transformReplacer.replaceMultiDexListTransform();
            }

            transformReplacer.replaceProguardTransform();

            transformReplacer.disableCache();

            if (variantScope.getGlobalScope().getExtension().getDataBinding().isEnabled()) {
                transformReplacer.replaceDataBindingMergeArtifactsTransform();
            }

            for (final BaseVariantOutput vod : baseVariantOutputDataList) {
                transformReplacer.replaceFixStackFramesTransform(vod);
                transformReplacer.replaceDesugarTransform(vod);
                transformReplacer.replaceDexArchiveBuilderTransform(vod);
                transformReplacer.replaceDexExternalLibMerge(vod);
                transformReplacer.replaceDexMerge(vod);
                transformReplacer.replaceDexTransform(appVariantContext, vod);
                transformReplacer.replaceShrinkResourcesTransform();
                transformReplacer.replaceMergeJavaResourcesTransform(appVariantContext, vod);

                if (atlasExtension.getTBuildConfig().isIncremental()) {
                    InstantRunPatchingPolicy patchingPolicy = variantScope.getInstantRunBuildContext()
                            .getPatchingPolicy();
                    BaseVariantOutputImpl variantOutput = (BaseVariantOutputImpl) vod;
                    ApkData data = ApkDataUtils.get(variantOutput);
                    AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees
                            .get(variantScope.getFullVariantName());

                    //                                                                      for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
                    //                                                                          AndroidTask<Dex> dexTask = androidTasks.create(tasks, new Dex.ConfigAction(
                    //                                                                                  appVariantContext.getVariantData().getScope(), appVariantContext.getAppVariantOutputContext(data), awbBundle));
                    //                                                                          dexTask.dependsOn(tasks, Iterables
                    //                                                                                  .getLast(TaskQueryHelper.findTask(project, TransformTask.class, appVariantContext.getVariantData())));
                    //                                                                          PackagingScope packagingScope = new AwbPackagingScope(appVariantContext.getScope(), appVariantContext,
                    //                                                                                  awbBundle,vod);
                    //                                                                          AndroidTask<PackageAwb> packageAwb = androidTasks.create(tasks,
                    //                                                                                  new PackageAwb
                    //                                                                                          .StandardConfigAction(
                    //                                                                                          packagingScope,
                    //                                                                                          patchingPolicy));
                    ////
                    //                                                                         packageAwb.dependsOn(tasks, dexTask);
                    //                                                                         PackageAwbsTask packageAwbsTask = Iterators.getOnlyElement(
                    //                                                                                  TaskQueryHelper.findTask(project, PackageAwbsTask.class, appVariantContext.getVariantData()).iterator());
                    //                                                                          packageAwbsTask.setEnabled(false);
                    //                                                                          packageAwbsTask.dependsOn(packageAwb.get(tasks));
                    //                                                                     }
                    //                                                                             AndroidTask<AwoInstallTask> awoInstallTask = androidTasks.create(tasks,
                    //                                                                              new AwoInstallTask.ConfigAction(appVariantContext, vod));
                    //                                                                                awoInstallTask.dependsOn(tasks, variantScope.getPackageApplicationTask().getName());
                }

            }

            Boolean includeCompileClasspath = appVariantContext.getScope().getVariantConfiguration()
                    .getJavaCompileOptions().getAnnotationProcessorOptions().getIncludeCompileClasspath();

            appVariantContext.getVariantData().javaCompilerTask.doFirst(task -> {
                JavaCompile compile = (JavaCompile) task;
                Set<File> mainDexFiles = new MainFilesCollection(appVariantContext.getVariantName()).getFiles();
                FileCollection mainFiles = appVariantContext.getProject().files(mainDexFiles);
                FileCollection files = appVariantContext.getScope()
                        .getArtifactFileCollection(ANNOTATION_PROCESSOR, ALL, JAR);
                FileCollection bootFiles = appVariantContext.getProject().files(appVariantContext.getScope()
                        .getGlobalScope().getAndroidBuilder().getBootClasspath(false));
                mainFiles = mainFiles.plus(bootFiles);
                FileCollection fileCollection = compile.getClasspath();
                File kotlinClasses = null;
                for (File file : fileCollection) {
                    if (file.getAbsolutePath().contains("kotlin-classes")) {
                        mainFiles = mainFiles.plus(appVariantContext.getProject().files(file));
                        kotlinClasses = file;
                        break;
                    }
                }
                compile.setClasspath(mainFiles);
                if (Boolean.TRUE.equals(includeCompileClasspath)) {
                    compile.getOptions().setAnnotationProcessorPath(files.plus(mainFiles));
                }
            });

            appVariantContext.getVariantData().javaCompilerTask.doLast(new Action<Task>() {
                @Override
                public void execute(Task task) {
                    JavaCompile compile = (JavaCompile) task;
                    AtlasBuildContext.atlasMainDexHelperMap.get(appVariantContext.getVariantName())
                            .getInputDirs().add(compile.getDestinationDir());
                }
            });

            PackageAndroidArtifact packageAndroidArtifact = appVariantContext.getVariantData()
                    .getTaskByType(PackageAndroidArtifact.class);
            if (packageAndroidArtifact != null) {
                ReflectUtils.updateField(packageAndroidArtifact, "javaResourceFiles",
                        new AbstractFileCollection() {
                            @Override
                            public String getDisplayName() {
                                return "java-merge-res.jar";
                            }

                            @Override
                            public Set<File> getFiles() {
                                if (AtlasBuildContext.atlasMainDexHelperMap
                                        .get(packageAndroidArtifact.getVariantName())
                                        .getMainJavaRes() == null) {
                                    return Sets.newHashSet();
                                }
                                return Sets.newHashSet(AtlasBuildContext.atlasMainDexHelperMap
                                        .get(packageAndroidArtifact.getVariantName()).getMainJavaRes());
                            }
                        });
            }

            TaskCollection<ExtractTryWithResourcesSupportJar> taskCollection = appVariantContext.getProject()
                    .getTasks().withType(ExtractTryWithResourcesSupportJar.class);
            for (ExtractTryWithResourcesSupportJar task : taskCollection) {
                task.doLast(new Action<Task>() {
                    @Override
                    public void execute(Task task) {
                        ConfigurableFileCollection fileCollection = variantScope
                                .getTryWithResourceRuntimeSupportJar();
                        for (File file : fileCollection.getFiles()) {
                            if (file.exists()) {
                                AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName())
                                        .addMainDex(new BuildAtlasEnvTask.FileIdentity(
                                                "runtime-deps-try-with-resources", file, false, false));
                                break;
                            }
                        }
                    }
                });

            }
        }
    });
}

From source file:com.facebook.presto.hive.s3.PrestoS3FileSystem.java

private LocatedFileStatus createLocatedFileStatus(FileStatus status) {
    try {//from w ww  .j  a  va2s  .  c om
        BlockLocation[] fakeLocation = getFileBlockLocations(status, 0, status.getLen());
        return new LocatedFileStatus(status, fakeLocation);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.apache.taverna.databundle.DataBundles.java

/**
 * Deeply resolve path as a {@link Stream} that only contain leaf elements of 
 * the specified class.//ww w  . ja  v  a2s.  co  m
 * <p>
 * This method is somewhat equivalent to {@link #resolve(Path, ResolveOptions...)}, but 
 * the returned stream is not in any particular order, and will contain the leaf
 * items from all deep lists. Empty lists and error documents are ignored.
 * <p>
 * Any {@link IOException}s occurring during resolution are 
 * wrapped as {@link UncheckedIOException}.
 * <p>
 * Supported types include:
 * <ul>
 *   <li>{@link String}.class</li>
 *   <li><code>byte[].class</code></li>
 *   <li>{@link Path}.class</li>
 *   <li>{@link URI}.class</li>
 *   <li>{@link URL}.class</li>  
 *   <li>{@link File}.class</li>
 *   <li>{@link ErrorDocument}.class</li>
 *   <li>{@link Object}.class</li>
 * </ul>
 * 
 * @param path Data bundle path to resolve
 * @param type Type of objects to return, e.g. <code>String.class</code>
 * @return A {@link Stream} of resolved objects, or an empty stream if no such objects were resolved.
 * @throws UncheckedIOException If the path could not be accessed. 
 */
public static <T> Stream<T> resolveAsStream(Path path, Class<T> type) throws UncheckedIOException {
    ResolveOptions options;
    if (type == String.class) {
        options = ResolveOptions.STRING;
    } else if (type == byte[].class) {
        options = ResolveOptions.BYTES;
    } else if (type == Path.class) {
        options = ResolveOptions.PATH;
    } else if (type == URI.class) {
        options = ResolveOptions.URI;
    } else {
        // Dummy-option, we'll filter on the returned type anyway
        options = ResolveOptions.DEFAULT;
    }
    if (isList(path)) {
        // return Stream of unordered list of resolved list items,   
        // recursing to find the leaf nodes         
        try {
            return Files.walk(path)
                    // avoid re-recursion
                    .filter(p -> !Files.isDirectory(p)).flatMap(p -> resolveItemAsStream(p, type, options));
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    } else {
        return resolveItemAsStream(path, type, options);
    }
}

From source file:org.mitre.mpf.wfm.util.PropertiesUtil.java

private static WritableResource getDataResource(WritableResource dataResource,
        InputStreamSource templateResource) {
    if (dataResource.exists()) {
        return dataResource;
    }//from   w w w .  j a  va  2  s .  co  m

    try {
        log.info("{} doesn't exist. Copying from {}", dataResource, templateResource);
        copyResource(dataResource, templateResource);
        return dataResource;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}