@Test public void testCacheRepoInits_emptyRepoInits() throws Exception { final File testOutDir = new File(tempDir, "testCacheRepoInits_emptyRepoInits"); FileUtils.deleteDirectory(testOutDir); final File cacheDir = new File(testOutDir, "oakpal-cache"); Result<URL> urlResult = Options.cacheRepoInits(cacheDir, Collections.emptyList()); assertTrue("empty repoInits get failure to cache", urlResult.isFailure()); }
static Result<URL> cacheRepoInits(final @NotNull File cacheDir, final @NotNull List<String> repoInits) { if (repoInits.isEmpty()) { return Result.failure("refusing to cache empty repoinit script"); } final byte[] repoInitBytes = getRepoInitBytes(repoInits); final File parentDir = cacheDir.toPath().resolve("repoinits").toFile(); parentDir.mkdirs(); return fileNameForRepoInitBytes(repoInitBytes) .map(fileName -> new File(parentDir, fileName)) .flatMap(cacheFile -> { final Result<URL> cacheFileUrl = compose1(File::toURI, result1(URI::toURL)).apply(cacheFile); if (cacheFile.exists()) { return cacheFileUrl; } else { return writeToStream(repoInitBytes, () -> new FileOutputStream(cacheFile)) .flatMap(constantly1(() -> cacheFileUrl)); } }); }
Options { static Result<URL> cacheRepoInits(final @NotNull File cacheDir, final @NotNull List<String> repoInits) { if (repoInits.isEmpty()) { return Result.failure("refusing to cache empty repoinit script"); } final byte[] repoInitBytes = getRepoInitBytes(repoInits); final File parentDir = cacheDir.toPath().resolve("repoinits").toFile(); parentDir.mkdirs(); return fileNameForRepoInitBytes(repoInitBytes) .map(fileName -> new File(parentDir, fileName)) .flatMap(cacheFile -> { final Result<URL> cacheFileUrl = compose1(File::toURI, result1(URI::toURL)).apply(cacheFile); if (cacheFile.exists()) { return cacheFileUrl; } else { return writeToStream(repoInitBytes, () -> new FileOutputStream(cacheFile)) .flatMap(constantly1(() -> cacheFileUrl)); } }); } }
Options { static Result<URL> cacheRepoInits(final @NotNull File cacheDir, final @NotNull List<String> repoInits) { if (repoInits.isEmpty()) { return Result.failure("refusing to cache empty repoinit script"); } final byte[] repoInitBytes = getRepoInitBytes(repoInits); final File parentDir = cacheDir.toPath().resolve("repoinits").toFile(); parentDir.mkdirs(); return fileNameForRepoInitBytes(repoInitBytes) .map(fileName -> new File(parentDir, fileName)) .flatMap(cacheFile -> { final Result<URL> cacheFileUrl = compose1(File::toURI, result1(URI::toURL)).apply(cacheFile); if (cacheFile.exists()) { return cacheFileUrl; } else { return writeToStream(repoInitBytes, () -> new FileOutputStream(cacheFile)) .flatMap(constantly1(() -> cacheFileUrl)); } }); } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); }
Options { static Result<URL> cacheRepoInits(final @NotNull File cacheDir, final @NotNull List<String> repoInits) { if (repoInits.isEmpty()) { return Result.failure("refusing to cache empty repoinit script"); } final byte[] repoInitBytes = getRepoInitBytes(repoInits); final File parentDir = cacheDir.toPath().resolve("repoinits").toFile(); parentDir.mkdirs(); return fileNameForRepoInitBytes(repoInitBytes) .map(fileName -> new File(parentDir, fileName)) .flatMap(cacheFile -> { final Result<URL> cacheFileUrl = compose1(File::toURI, result1(URI::toURL)).apply(cacheFile); if (cacheFile.exists()) { return cacheFileUrl; } else { return writeToStream(repoInitBytes, () -> new FileOutputStream(cacheFile)) .flatMap(constantly1(() -> cacheFileUrl)); } }); } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); boolean isJustHelp(); boolean isJustVersion(); boolean isStoreBlobs(); boolean isNoHooks(); URL getPlanUrl(); ClassLoader getScanClassLoader(); File getCacheDir(); @Nullable File getOpearFile(); @Nullable String getPlanName(); @Nullable File getPlanFile(); @Nullable File getPlanFileBaseDir(); @NotNull List<File> getPreInstallFiles(); @NotNull List<File> getRepoInitFiles(); @NotNull List<String> getRunModes(); boolean isNoRunModes(); @NotNull List<File> getExtendedClassPathFiles(); List<File> getScanFiles(); Function<StructuredMessage, IO<Nothing>> getPrinter(); Severity getFailOnSeverity(); OakpalPlan applyOverrides(final @NotNull OakpalPlan basePlan); }
Options { static Result<URL> cacheRepoInits(final @NotNull File cacheDir, final @NotNull List<String> repoInits) { if (repoInits.isEmpty()) { return Result.failure("refusing to cache empty repoinit script"); } final byte[] repoInitBytes = getRepoInitBytes(repoInits); final File parentDir = cacheDir.toPath().resolve("repoinits").toFile(); parentDir.mkdirs(); return fileNameForRepoInitBytes(repoInitBytes) .map(fileName -> new File(parentDir, fileName)) .flatMap(cacheFile -> { final Result<URL> cacheFileUrl = compose1(File::toURI, result1(URI::toURL)).apply(cacheFile); if (cacheFile.exists()) { return cacheFileUrl; } else { return writeToStream(repoInitBytes, () -> new FileOutputStream(cacheFile)) .flatMap(constantly1(() -> cacheFileUrl)); } }); } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); boolean isJustHelp(); boolean isJustVersion(); boolean isStoreBlobs(); boolean isNoHooks(); URL getPlanUrl(); ClassLoader getScanClassLoader(); File getCacheDir(); @Nullable File getOpearFile(); @Nullable String getPlanName(); @Nullable File getPlanFile(); @Nullable File getPlanFileBaseDir(); @NotNull List<File> getPreInstallFiles(); @NotNull List<File> getRepoInitFiles(); @NotNull List<String> getRunModes(); boolean isNoRunModes(); @NotNull List<File> getExtendedClassPathFiles(); List<File> getScanFiles(); Function<StructuredMessage, IO<Nothing>> getPrinter(); Severity getFailOnSeverity(); OakpalPlan applyOverrides(final @NotNull OakpalPlan basePlan);  }