ArchiveFileUtils { public static URI toReplayUri(URI requestUri) { String originSsp = StringUtils.substringBetween(requestUri.toString(), SSP_DELIMITER, "!"); String scheme = StringUtils.substringBefore(requestUri.toString(), SSP_DELIMITER); if (originSsp != null) { return URI.create(StringUtils.substringAfterLast(scheme, COLON) + SSP_DELIMITER + originSsp); } return requestUri; } private  ArchiveFileUtils(); static URI toZipUri(URI parent, String zipEntry); static URI toIsoImageUri(URI parent, String imageEntry); static URI toRarUri(URI parent, String rarEntry); static URI toTarUri(URI parent, String tarEntry); static URI toSevenZUri(URI parent, String sevenZipEntry); static URI toFatImageUri(URI parent, String fatEntry); static URI toWebArchiveUri(String archiveType, URI parent, String warcEntry); static Path writeEntryToTemp(final Path tempDir, final ByteBuffer buffer,
                                        final ReadableByteChannel channel); static Path writeFsFileToTemp(final FsDirectoryEntry fsFile, final Path tempDir); static Path writeEntryToTemp(final Path tempDir, final byte[] buffer,
                                        final InputStream in); static URI toGZipUri(URI parent); static URI toBZipUri(URI parent); static URI toReplayUri(URI requestUri); static List<String> getAncestorPaths(String path); static int copyToBuffer(final WindowReader reader, final long position,
                                   final byte[] buffer, final int offset, final int length); static int copyToBuffer(final WindowReader reader, final long position,
                                   final ByteBuffer buffer);  }
@Test public void testToReplayUri() { URI uri = URI.create("zip:file:/C:/anyhost/dir/my%20zip.zip!/my/zip%20entry"); assertEquals("file:/C:/anyhost/dir/my%20zip.zip", ArchiveFileUtils.toReplayUri(uri).toString()); uri = URI.create("file:/C:/anyhost/dir/my%20zip.zip"); assertEquals("file:/C:/anyhost/dir/my%20zip.zip", ArchiveFileUtils.toReplayUri(uri).toString()); uri = URI.create("tar:gz:file:/C:/anyhost/dir/my%20zip.gz!/mytar.tar!/myfile"); assertEquals("file:/C:/anyhost/dir/my%20zip.gz", ArchiveFileUtils.toReplayUri(uri).toString()); }