@Test(expected=ParseException.class) public void testUnpackSfxRarArchive() throws Exception { HotColdFileCache unpackCache = new HotColdFileCache(20); FileFactory fileFactory = new FileFactory(unpackCache); IndexingConfig config = new IndexingConfig(); fileFactory.createFile(config, new Path(TestFiles.sfx_rar.getPath() + "/test.txt")); }
@NotNull @ThreadSafe public FileResource createFile( @NotNull IndexingConfig config, @NotNull Path path) throws ParseException, FileNotFoundException { Util.checkNotNull(config, path); try { PathParts pathParts = path.splitAtExistingFile(); File leftFile = pathParts.getLeft().getCanonicalFile(); if (pathParts.getRight().isEmpty()) return new PermanentFileResource(leftFile); final FileResource[] cachedResource = new FileResource[1]; PathParts cacheSplitParts = path.splitFromRight(new Predicate<Path>() { public boolean apply(Path path) { cachedResource[0] = unpackCache.get(path); return cachedResource[0] != null; } }); if (cacheSplitParts == null) { FileResource archiveResource = new PermanentFileResource(leftFile); Path archivePath = pathParts.getLeft(); String entryPath = pathParts.getRight(); return unpackFromArchive( config, archivePath, archiveResource, entryPath); } if (cacheSplitParts.getRight().isEmpty()) return cachedResource[0]; Path archivePath = cacheSplitParts.getLeft(); String entryPath = cacheSplitParts.getRight(); return unpackFromArchive( config, archivePath, cachedResource[0], entryPath); } catch (FileNotFoundException e) { String msg = Msg.file_not_found.get() + " " + path.getPath(); throw new FileNotFoundException(msg); } catch (ArchiveEncryptedException e) { String msg = Msg.archive_encrypted.get(); throw new ParseException(msg, e); } catch (DiskSpaceException e) { throw new ParseException(e); } catch (IOException e) { throw new ParseException(e); } }
FileFactory { @NotNull @ThreadSafe public FileResource createFile( @NotNull IndexingConfig config, @NotNull Path path) throws ParseException, FileNotFoundException { Util.checkNotNull(config, path); try { PathParts pathParts = path.splitAtExistingFile(); File leftFile = pathParts.getLeft().getCanonicalFile(); if (pathParts.getRight().isEmpty()) return new PermanentFileResource(leftFile); final FileResource[] cachedResource = new FileResource[1]; PathParts cacheSplitParts = path.splitFromRight(new Predicate<Path>() { public boolean apply(Path path) { cachedResource[0] = unpackCache.get(path); return cachedResource[0] != null; } }); if (cacheSplitParts == null) { FileResource archiveResource = new PermanentFileResource(leftFile); Path archivePath = pathParts.getLeft(); String entryPath = pathParts.getRight(); return unpackFromArchive( config, archivePath, archiveResource, entryPath); } if (cacheSplitParts.getRight().isEmpty()) return cachedResource[0]; Path archivePath = cacheSplitParts.getLeft(); String entryPath = cacheSplitParts.getRight(); return unpackFromArchive( config, archivePath, cachedResource[0], entryPath); } catch (FileNotFoundException e) { String msg = Msg.file_not_found.get() + " " + path.getPath(); throw new FileNotFoundException(msg); } catch (ArchiveEncryptedException e) { String msg = Msg.archive_encrypted.get(); throw new ParseException(msg, e); } catch (DiskSpaceException e) { throw new ParseException(e); } catch (IOException e) { throw new ParseException(e); } } }
FileFactory { @NotNull @ThreadSafe public FileResource createFile( @NotNull IndexingConfig config, @NotNull Path path) throws ParseException, FileNotFoundException { Util.checkNotNull(config, path); try { PathParts pathParts = path.splitAtExistingFile(); File leftFile = pathParts.getLeft().getCanonicalFile(); if (pathParts.getRight().isEmpty()) return new PermanentFileResource(leftFile); final FileResource[] cachedResource = new FileResource[1]; PathParts cacheSplitParts = path.splitFromRight(new Predicate<Path>() { public boolean apply(Path path) { cachedResource[0] = unpackCache.get(path); return cachedResource[0] != null; } }); if (cacheSplitParts == null) { FileResource archiveResource = new PermanentFileResource(leftFile); Path archivePath = pathParts.getLeft(); String entryPath = pathParts.getRight(); return unpackFromArchive( config, archivePath, archiveResource, entryPath); } if (cacheSplitParts.getRight().isEmpty()) return cachedResource[0]; Path archivePath = cacheSplitParts.getLeft(); String entryPath = cacheSplitParts.getRight(); return unpackFromArchive( config, archivePath, cachedResource[0], entryPath); } catch (FileNotFoundException e) { String msg = Msg.file_not_found.get() + " " + path.getPath(); throw new FileNotFoundException(msg); } catch (ArchiveEncryptedException e) { String msg = Msg.archive_encrypted.get(); throw new ParseException(msg, e); } catch (DiskSpaceException e) { throw new ParseException(e); } catch (IOException e) { throw new ParseException(e); } } FileFactory(@NotNull HotColdFileCache unpackCache); }
FileFactory { @NotNull @ThreadSafe public FileResource createFile( @NotNull IndexingConfig config, @NotNull Path path) throws ParseException, FileNotFoundException { Util.checkNotNull(config, path); try { PathParts pathParts = path.splitAtExistingFile(); File leftFile = pathParts.getLeft().getCanonicalFile(); if (pathParts.getRight().isEmpty()) return new PermanentFileResource(leftFile); final FileResource[] cachedResource = new FileResource[1]; PathParts cacheSplitParts = path.splitFromRight(new Predicate<Path>() { public boolean apply(Path path) { cachedResource[0] = unpackCache.get(path); return cachedResource[0] != null; } }); if (cacheSplitParts == null) { FileResource archiveResource = new PermanentFileResource(leftFile); Path archivePath = pathParts.getLeft(); String entryPath = pathParts.getRight(); return unpackFromArchive( config, archivePath, archiveResource, entryPath); } if (cacheSplitParts.getRight().isEmpty()) return cachedResource[0]; Path archivePath = cacheSplitParts.getLeft(); String entryPath = cacheSplitParts.getRight(); return unpackFromArchive( config, archivePath, cachedResource[0], entryPath); } catch (FileNotFoundException e) { String msg = Msg.file_not_found.get() + " " + path.getPath(); throw new FileNotFoundException(msg); } catch (ArchiveEncryptedException e) { String msg = Msg.archive_encrypted.get(); throw new ParseException(msg, e); } catch (DiskSpaceException e) { throw new ParseException(e); } catch (IOException e) { throw new ParseException(e); } } FileFactory(@NotNull HotColdFileCache unpackCache); @NotNull @ThreadSafe FileResource createFile(	@NotNull IndexingConfig config,
									@NotNull Path path); }
FileFactory { @NotNull @ThreadSafe public FileResource createFile( @NotNull IndexingConfig config, @NotNull Path path) throws ParseException, FileNotFoundException { Util.checkNotNull(config, path); try { PathParts pathParts = path.splitAtExistingFile(); File leftFile = pathParts.getLeft().getCanonicalFile(); if (pathParts.getRight().isEmpty()) return new PermanentFileResource(leftFile); final FileResource[] cachedResource = new FileResource[1]; PathParts cacheSplitParts = path.splitFromRight(new Predicate<Path>() { public boolean apply(Path path) { cachedResource[0] = unpackCache.get(path); return cachedResource[0] != null; } }); if (cacheSplitParts == null) { FileResource archiveResource = new PermanentFileResource(leftFile); Path archivePath = pathParts.getLeft(); String entryPath = pathParts.getRight(); return unpackFromArchive( config, archivePath, archiveResource, entryPath); } if (cacheSplitParts.getRight().isEmpty()) return cachedResource[0]; Path archivePath = cacheSplitParts.getLeft(); String entryPath = cacheSplitParts.getRight(); return unpackFromArchive( config, archivePath, cachedResource[0], entryPath); } catch (FileNotFoundException e) { String msg = Msg.file_not_found.get() + " " + path.getPath(); throw new FileNotFoundException(msg); } catch (ArchiveEncryptedException e) { String msg = Msg.archive_encrypted.get(); throw new ParseException(msg, e); } catch (DiskSpaceException e) { throw new ParseException(e); } catch (IOException e) { throw new ParseException(e); } } FileFactory(@NotNull HotColdFileCache unpackCache); @NotNull @ThreadSafe FileResource createFile(	@NotNull IndexingConfig config,
									@NotNull Path path);  }