@Test public void findContentFile() throws IOException { File file1 = new File(contentDir, "abc.txt"); File file2 = new File(contentDir, "abc.zip"); File file3 = new File(contentDir, "123.zip"); file1.createNewFile(); file2.createNewFile(); file3.createNewFile(); File file = contentSourceFileFinder.findContentFile(contentDir, new File("abc.tar.gz")); assertEquals(file2.getPath(), file.getPath()); }
public File findContentFile(File contentDir, File correspondingMetadataFile) { String filenameBase = extractFilenameBase(correspondingMetadataFile.getName()); List<String> possibleFileNames = buildPossibleFilenames(filenameBase); Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE); if (foundContentFiles.size() == 0) { throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath()); } if (foundContentFiles.size() > 1) { throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile); } return foundContentFiles.iterator().next(); }
ContentSourceFileFinder { public File findContentFile(File contentDir, File correspondingMetadataFile) { String filenameBase = extractFilenameBase(correspondingMetadataFile.getName()); List<String> possibleFileNames = buildPossibleFilenames(filenameBase); Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE); if (foundContentFiles.size() == 0) { throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath()); } if (foundContentFiles.size() > 1) { throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile); } return foundContentFiles.iterator().next(); } }
ContentSourceFileFinder { public File findContentFile(File contentDir, File correspondingMetadataFile) { String filenameBase = extractFilenameBase(correspondingMetadataFile.getName()); List<String> possibleFileNames = buildPossibleFilenames(filenameBase); Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE); if (foundContentFiles.size() == 0) { throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath()); } if (foundContentFiles.size() > 1) { throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile); } return foundContentFiles.iterator().next(); }  }
ContentSourceFileFinder { public File findContentFile(File contentDir, File correspondingMetadataFile) { String filenameBase = extractFilenameBase(correspondingMetadataFile.getName()); List<String> possibleFileNames = buildPossibleFilenames(filenameBase); Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE); if (foundContentFiles.size() == 0) { throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath()); } if (foundContentFiles.size() > 1) { throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile); } return foundContentFiles.iterator().next(); }  File findContentFile(File contentDir, File correspondingMetadataFile); void setEligibleFileExtensions(String[] eligibleFileExtensions); }
ContentSourceFileFinder { public File findContentFile(File contentDir, File correspondingMetadataFile) { String filenameBase = extractFilenameBase(correspondingMetadataFile.getName()); List<String> possibleFileNames = buildPossibleFilenames(filenameBase); Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE); if (foundContentFiles.size() == 0) { throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath()); } if (foundContentFiles.size() > 1) { throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile); } return foundContentFiles.iterator().next(); }  File findContentFile(File contentDir, File correspondingMetadataFile); void setEligibleFileExtensions(String[] eligibleFileExtensions);  }