@Override public ZipArchiveEntry getEntry(String path) { return zipFile.getEntry(path); }
@Override public ZipArchiveEntry getEntry(final String path) { String normalizedPath = path.replace('\\', '/'); final ZipArchiveEntry entry = zipArchive.getEntry(normalizedPath); if (entry != null) { return entry; } // the opc spec allows case-insensitive filename matching (see #49609) for (final ZipArchiveEntry ze : asIterable(asIterator(zipArchive.getEntries()))) { if (normalizedPath.equalsIgnoreCase(ze.getName().replace('\\','/'))) { return ze; } } return null; } }
private static MediaType detectIWork13(ZipFile zip) { if (zip.getEntry(IWork13PackageParser.IWORK13_COMMON_ENTRY) != null) { return IWork13PackageParser.IWork13DocumentType.detect(zip); } return null; }
private static MediaType detectJar(ZipFile zip) { if (zip.getEntry("META-INF/MANIFEST.MF") != null) { // It's a Jar file, or something based on Jar // Is it an Android APK? if (zip.getEntry("AndroidManifest.xml") != null) { return MediaType.application("vnd.android.package-archive"); } // Check for WAR and EAR if (zip.getEntry("WEB-INF/") != null) { return MediaType.application("x-tika-java-web-archive"); } if (zip.getEntry("META-INF/application.xml") != null) { return MediaType.application("x-tika-java-enterprise-archive"); } // Looks like a regular Jar Archive return MediaType.application("java-archive"); } else { // Some Android APKs miss the default Manifest if (zip.getEntry("AndroidManifest.xml") != null) { return MediaType.application("vnd.android.package-archive"); } return null; } }
private static MediaType detectIWork(ZipFile zip) { if (zip.getEntry(IWorkPackageParser.IWORK_COMMON_ENTRY) != null) { // Locate the appropriate index file entry, and reads from that // the root element of the document. That is used to the identify // the correct type of the keynote container. for (String entryName : IWorkPackageParser.IWORK_CONTENT_ENTRIES) { IWORKDocumentType type = IWORKDocumentType.detectType(zip.getEntry(entryName), zip); if (type != null) { return type.getType(); } } // Not sure, fallback to the container type return MediaType.application("vnd.apple.iwork"); } else { return null; } }
/** * OpenDocument files, along with EPub files and ASiC ones, have a * mimetype entry in the root of their Zip file. This entry contains * the mimetype of the overall file, stored as a single string. */ private static MediaType detectOpenDocument(ZipFile zip) { try { ZipArchiveEntry mimetype = zip.getEntry("mimetype"); if (mimetype != null) { try (InputStream stream = zip.getInputStream(mimetype)) { return MediaType.parse(IOUtils.toString(stream, UTF_8)); } } else { return null; } } catch (IOException e) { return null; } }
protected String readArchiveText(InputStream inputStream) throws IOException { Path tempFile = writeTemporaryArchiveFile(inputStream, "zip"); ZipFile zip = new ZipFile(tempFile.toFile()); zip.getEntry(UnpackerResource.TEXT_FILENAME); ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zip.getInputStream(zip.getEntry(UnpackerResource.TEXT_FILENAME)), bos); zip.close(); Files.delete(tempFile); return bos.toString(UTF_8.name()); }
/** * Checks for the existence of the Manifest. * TODO not sure if this properly handles case-sensitive entries? * @param zipfile * @return true if the zip file has a manifest */ public static boolean hasManifest(ZipFile zipfile){ return zipfile.getEntry(IW3CXMLConfiguration.MANIFEST_FILE)!=null; }
@Override public ZipArchiveEntry getEntry(String path) { return zipFile.getEntry(path); }
public static MediaType detect(ZipFile zipFile) { ZipArchiveEntry entry = zipFile.getEntry("Index/MasterSlide.iwa"); if (zipFile.getEntry("Index/MasterSlide.iwa") != null || zipFile.getEntry("Index/Slide.iwa") != null) { return KEYNOTE13.getType(); } //TODO: figure out how to distinguish numbers from pages return UNKNOWN13.getType(); } }
private static MediaType detectIWork13(ZipFile zip) { if (zip.getEntry(IWork13PackageParser.IWORK13_COMMON_ENTRY) != null) { return IWork13PackageParser.IWork13DocumentType.detect(zip); } return null; }
/** * Retrieves the Manifest entry as a String * @param zipFile the zip file from which to extract the manifest * @return a String representing the manifest contents * @throws IOException */ public static String extractManifest(ZipFile zipFile) throws IOException{ ZipArchiveEntry entry = zipFile.getEntry(IW3CXMLConfiguration.MANIFEST_FILE); return IOUtils.toString(zipFile.getInputStream(entry), "UTF-8"); }
@Override protected InputStream getSourceMetaDataStream (String basePath) throws IOException { String location = basePath+"/"+PyramidIO.METADATA_FILENAME; ZipArchiveEntry entry = _tileSetArchive.getEntry(location); return _tileSetArchive.getInputStream(entry); } }
private static MediaType detectIWork13(ZipFile zip) { if (zip.getEntry(IWork13PackageParser.IWORK13_COMMON_ENTRY) != null) { return IWork13PackageParser.IWork13DocumentType.detect(zip); } return null; }
@Override public InputStream asStream(ArchiveEntry entry) throws IOException { return zFile.getInputStream(zFile.getEntry(entry.getName())); } }
@Override public InputStream asStream(ArchiveEntry entry) throws IOException { return zFile.getInputStream(zFile.getEntry(entry.getName())); } }
@Override public boolean canReadEntryData(ArchiveEntry entry) { return zFile.canReadEntryData(zFile.getEntry(entry.getName())); }
/** * @param reference the reference of the page * @return an input stream to the page XML * @throws IOException when failing to open a stream to the page XML */ public InputStream getInputStream(LocalDocumentReference reference) throws IOException { XarEntry entry = this.xarPackage.getEntry(reference); if (entry == null) { throw new IOException("Failed to find entry for referenc [" + reference + "]"); } return this.zipFile.getInputStream(this.zipFile.getEntry(entry.getEntryName())); }
@Override protected InputStream getSourceTileStream (String basePath, TileIndex tile) throws IOException { String tileLocation = String.format("%s/"+PyramidIO.TILES_FOLDERNAME+"/%d/%d/%d." + _tileExtension, basePath, tile.getLevel(), tile.getX(), tile.getY()); ZipArchiveEntry entry = _tileSetArchive.getEntry(tileLocation); return _tileSetArchive.getInputStream(entry); }