// TODO refactor this class to make lookups simpler
// probably read everything and keep in-memory map of stuff we need
private InputStream findSamplesFile(@Nonnull ZipFile zipFile) {
if (zipFile.entries() == null) {
throw new ScanFileUnavailableException("No zip entries were found in the zip file.");
}
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().endsWith("samples.js")) {
try {
return zipFile.getInputStream(entry);
} catch (IOException e) {
log.error("IOException thrown when reading entries from zip file.", e);
}
}
}
throw new ScanFileUnavailableException("Samples.js was not found in the zip file.");
}