@Test void testGetModuleContentFlat() throws Exception { InputStream mtarStream = ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_FLAT_MTAR); try (InputStream is = ArchiveHandler.getInputStream(mtarStream, "web/", MAX_RESOURCE_FILE_SIZE)) { ZipInputStream zis = (ZipInputStream) is; for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals("web/readme.txt")) { String readmeContent = IOUtils.toString(zis, StandardCharsets.UTF_8); assertEquals("App router code will be packaged in this archive", readmeContent); } } } }
public static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize) { try { ZipInputStream zis = new ZipInputStream(is); for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals(entryName)) { validateZipEntrySize(e, maxEntrySize); return zis; } } throw new ContentException(Messages.CANNOT_FIND_ARCHIVE_ENTRY, entryName); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_ARCHIVE_ENTRY, entryName); } }
ArchiveHandler { public static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize) { try { ZipInputStream zis = new ZipInputStream(is); for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals(entryName)) { validateZipEntrySize(e, maxEntrySize); return zis; } } throw new ContentException(Messages.CANNOT_FIND_ARCHIVE_ENTRY, entryName); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_ARCHIVE_ENTRY, entryName); } } }
ArchiveHandler { public static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize) { try { ZipInputStream zis = new ZipInputStream(is); for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals(entryName)) { validateZipEntrySize(e, maxEntrySize); return zis; } } throw new ContentException(Messages.CANNOT_FIND_ARCHIVE_ENTRY, entryName); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_ARCHIVE_ENTRY, entryName); } }  }
ArchiveHandler { public static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize) { try { ZipInputStream zis = new ZipInputStream(is); for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals(entryName)) { validateZipEntrySize(e, maxEntrySize); return zis; } } throw new ContentException(Messages.CANNOT_FIND_ARCHIVE_ENTRY, entryName); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_ARCHIVE_ENTRY, entryName); } }  static Manifest getManifest(InputStream archiveStream, long maxManifestSize); static String getDescriptor(InputStream archiveStream, long maxMtaDescriptorSize); static byte[] getFileContent(InputStream archiveStream, String fileName, long maxMtaFileSize); static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize); }
ArchiveHandler { public static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize) { try { ZipInputStream zis = new ZipInputStream(is); for (ZipEntry e; (e = zis.getNextEntry()) != null;) { if (e.getName() .equals(entryName)) { validateZipEntrySize(e, maxEntrySize); return zis; } } throw new ContentException(Messages.CANNOT_FIND_ARCHIVE_ENTRY, entryName); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_ARCHIVE_ENTRY, entryName); } }  static Manifest getManifest(InputStream archiveStream, long maxManifestSize); static String getDescriptor(InputStream archiveStream, long maxMtaDescriptorSize); static byte[] getFileContent(InputStream archiveStream, String fileName, long maxMtaFileSize); static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize); static final String MTA_DEPLOYMENT_DESCRIPTOR_NAME; }