@Test(expected = ImportException.class) public void extractJudgmentContent_NOT_FOUND() throws IOException { String archivePath = PathResolver.resolveToAbsolutePath("import/content/judgmentContent.zip"); judgmentContentFileExtractor.extractJudgmentContent(new File(archivePath), "notExistingSourceId"); }
public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); }
JudgmentContentFileExtractor { public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); } }
JudgmentContentFileExtractor { public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); }  }
JudgmentContentFileExtractor { public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); }  InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId); }
JudgmentContentFileExtractor { public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); }  InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId);  }