@Test public void testPathsAreSanitizedWhenRemovingUnreferencedFiles() { SW360Release release = new SW360Release(); release.setName("org.apache.commons/commons-lang3"); release.setVersion("3.*"); Path delPath1 = sourcePath.resolve("org.apache.commons"); Path delPath2 = delPath1.resolve("commons-lang3"); Path delPath3 = createTestFile(delPath2.resolve("lang-source.zip")); Path validPath1 = sourcePath.resolve("org.apache.commons_commons-lang3").resolve("3._"); Path validPath2 = createTestFile(validPath1.resolve("lang-source.zip")); Set<SW360SparseAttachment> attachments = createAttachments(1, 1); initAttachments(release, attachments); ReleaseWithSources releaseWithSources = createReleaseWithSources(release, attachments); sourcesExporter.removeUnreferencedFiles(Collections.singleton(releaseWithSources)); assertThat(checkFileExists(validPath1)).isTrue(); assertThat(checkFileExists(validPath2)).isTrue(); assertThat(checkFileExists(delPath3)).isFalse(); assertThat(checkFileExists(delPath2)).isFalse(); assertThat(checkFileExists(delPath1)).isFalse(); }
public void removeUnreferencedFiles(Collection<ReleaseWithSources> releases) { RemoveUnreferencedFilesVisitor visitor = new RemoveUnreferencedFilesVisitor(releases); try { Files.walkFileTree(sourcePath, visitor); } catch (IOException e) { LOG.error("Could not traverse sources directory {}", sourcePath, e); } }
SourcesExporter { public void removeUnreferencedFiles(Collection<ReleaseWithSources> releases) { RemoveUnreferencedFilesVisitor visitor = new RemoveUnreferencedFilesVisitor(releases); try { Files.walkFileTree(sourcePath, visitor); } catch (IOException e) { LOG.error("Could not traverse sources directory {}", sourcePath, e); } } }
SourcesExporter { public void removeUnreferencedFiles(Collection<ReleaseWithSources> releases) { RemoveUnreferencedFilesVisitor visitor = new RemoveUnreferencedFilesVisitor(releases); try { Files.walkFileTree(sourcePath, visitor); } catch (IOException e) { LOG.error("Could not traverse sources directory {}", sourcePath, e); } } SourcesExporter(Path sourcePath); }
SourcesExporter { public void removeUnreferencedFiles(Collection<ReleaseWithSources> releases) { RemoveUnreferencedFilesVisitor visitor = new RemoveUnreferencedFilesVisitor(releases); try { Files.walkFileTree(sourcePath, visitor); } catch (IOException e) { LOG.error("Could not traverse sources directory {}", sourcePath, e); } } SourcesExporter(Path sourcePath); Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter,
                                                          Collection<SW360Release> releases); void removeUnreferencedFiles(Collection<ReleaseWithSources> releases); }
SourcesExporter { public void removeUnreferencedFiles(Collection<ReleaseWithSources> releases) { RemoveUnreferencedFilesVisitor visitor = new RemoveUnreferencedFilesVisitor(releases); try { Files.walkFileTree(sourcePath, visitor); } catch (IOException e) { LOG.error("Could not traverse sources directory {}", sourcePath, e); } } SourcesExporter(Path sourcePath); Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter,
                                                          Collection<SW360Release> releases); void removeUnreferencedFiles(Collection<ReleaseWithSources> releases);  }