@Test public void zipFileHasPath() throws FileNotFoundException { AbstractMessageReport report = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); Source source = new JobSource(null); file = IngestionTest.getFile("zip/ZipWithPath.zip"); boolean isValid = zipFileValidator.isValid(file, report, reportStats, source, null); Assert.assertFalse(isValid); }
@Override public boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { boolean isValid = false; LOG.info("Validating zipFile: {}", zipFile.getAbsolutePath()); ZipFile zf = null; try { zf = new ZipFile(zipFile); Enumeration<ZipArchiveEntry> zes = zf.getEntries(); while (zes.hasMoreElements()) { ZipArchiveEntry ze = zes.nextElement(); LOG.debug(" ZipArchiveEntry: name: {}, size {}", ze.getName(), ze.getSize()); if (isDirectory(ze)) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0010, zipFile.getName()); return false; } if (ze.getName().endsWith(".ctl")) { isValid = true; } } if (!isValid) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0009, zipFile.getName()); } } catch (UnsupportedZipFeatureException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0022, zipFile.getName()); isValid = false; } catch (FileNotFoundException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0020, zipFile.getName()); isValid = false; } catch (IOException ex) { LOG.warn("Caught IO exception processing " + zipFile.getAbsolutePath()); report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0021, zipFile.getName()); isValid = false; } finally { ZipFile.closeQuietly(zf); } return isValid; }
ZipFileValidator implements Validator<File> { @Override public boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { boolean isValid = false; LOG.info("Validating zipFile: {}", zipFile.getAbsolutePath()); ZipFile zf = null; try { zf = new ZipFile(zipFile); Enumeration<ZipArchiveEntry> zes = zf.getEntries(); while (zes.hasMoreElements()) { ZipArchiveEntry ze = zes.nextElement(); LOG.debug(" ZipArchiveEntry: name: {}, size {}", ze.getName(), ze.getSize()); if (isDirectory(ze)) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0010, zipFile.getName()); return false; } if (ze.getName().endsWith(".ctl")) { isValid = true; } } if (!isValid) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0009, zipFile.getName()); } } catch (UnsupportedZipFeatureException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0022, zipFile.getName()); isValid = false; } catch (FileNotFoundException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0020, zipFile.getName()); isValid = false; } catch (IOException ex) { LOG.warn("Caught IO exception processing " + zipFile.getAbsolutePath()); report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0021, zipFile.getName()); isValid = false; } finally { ZipFile.closeQuietly(zf); } return isValid; } }
ZipFileValidator implements Validator<File> { @Override public boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { boolean isValid = false; LOG.info("Validating zipFile: {}", zipFile.getAbsolutePath()); ZipFile zf = null; try { zf = new ZipFile(zipFile); Enumeration<ZipArchiveEntry> zes = zf.getEntries(); while (zes.hasMoreElements()) { ZipArchiveEntry ze = zes.nextElement(); LOG.debug(" ZipArchiveEntry: name: {}, size {}", ze.getName(), ze.getSize()); if (isDirectory(ze)) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0010, zipFile.getName()); return false; } if (ze.getName().endsWith(".ctl")) { isValid = true; } } if (!isValid) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0009, zipFile.getName()); } } catch (UnsupportedZipFeatureException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0022, zipFile.getName()); isValid = false; } catch (FileNotFoundException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0020, zipFile.getName()); isValid = false; } catch (IOException ex) { LOG.warn("Caught IO exception processing " + zipFile.getAbsolutePath()); report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0021, zipFile.getName()); isValid = false; } finally { ZipFile.closeQuietly(zf); } return isValid; }  }
ZipFileValidator implements Validator<File> { @Override public boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { boolean isValid = false; LOG.info("Validating zipFile: {}", zipFile.getAbsolutePath()); ZipFile zf = null; try { zf = new ZipFile(zipFile); Enumeration<ZipArchiveEntry> zes = zf.getEntries(); while (zes.hasMoreElements()) { ZipArchiveEntry ze = zes.nextElement(); LOG.debug(" ZipArchiveEntry: name: {}, size {}", ze.getName(), ze.getSize()); if (isDirectory(ze)) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0010, zipFile.getName()); return false; } if (ze.getName().endsWith(".ctl")) { isValid = true; } } if (!isValid) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0009, zipFile.getName()); } } catch (UnsupportedZipFeatureException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0022, zipFile.getName()); isValid = false; } catch (FileNotFoundException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0020, zipFile.getName()); isValid = false; } catch (IOException ex) { LOG.warn("Caught IO exception processing " + zipFile.getAbsolutePath()); report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0021, zipFile.getName()); isValid = false; } finally { ZipFile.closeQuietly(zf); } return isValid; }  @Override boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters); @Override String getStageName(); }
ZipFileValidator implements Validator<File> { @Override public boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { boolean isValid = false; LOG.info("Validating zipFile: {}", zipFile.getAbsolutePath()); ZipFile zf = null; try { zf = new ZipFile(zipFile); Enumeration<ZipArchiveEntry> zes = zf.getEntries(); while (zes.hasMoreElements()) { ZipArchiveEntry ze = zes.nextElement(); LOG.debug(" ZipArchiveEntry: name: {}, size {}", ze.getName(), ze.getSize()); if (isDirectory(ze)) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0010, zipFile.getName()); return false; } if (ze.getName().endsWith(".ctl")) { isValid = true; } } if (!isValid) { report.error(reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0009, zipFile.getName()); } } catch (UnsupportedZipFeatureException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0022, zipFile.getName()); isValid = false; } catch (FileNotFoundException ex) { report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0020, zipFile.getName()); isValid = false; } catch (IOException ex) { LOG.warn("Caught IO exception processing " + zipFile.getAbsolutePath()); report.error(ex, reportStats, new FileSource(zipFile.getName()), BaseMessageCode.BASE_0021, zipFile.getName()); isValid = false; } finally { ZipFile.closeQuietly(zf); } return isValid; }  @Override boolean isValid(File zipFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters); @Override String getStageName();  }