private void addCacheEntry( FileName rootName, FileSystem fs ) throws FileSystemException { addFileSystem( getFileSystemKey( rootName.toString(), fs.getFileSystemOptions() ), fs ); String embeddedMetastoreKey = getEmbeddedMetastoreKey( fs.getFileSystemOptions() ); Set<FileSystem> fsSet = cacheEntries.get( embeddedMetastoreKey ); if ( fsSet == null ) { fsSet = Collections.synchronizedSet( new HashSet<FileSystem>() ); cacheEntries.put( embeddedMetastoreKey, fsSet ); } fsSet.add( fs ); }
/** * Resolves a URI, relative to a base file. * * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile.getFileSystem().getFileSystemOptions()); }
/** * Resolves a URI, relative to a base file. * * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile.getFileSystem().getFileSystemOptions()); }
/** * Resolves a URI, relative to a base file. * * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile.getFileSystem().getFileSystemOptions()); }
/** * Resolves a URI, relative to a base file. * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile .getFileSystem().getFileSystemOptions()); }
/** * Creates a layered file system. * * @param scheme The scheme to use. * @param file The FileObject. * @return The layered FileObject. * @throws FileSystemException if an error occurs. */ @Override public FileObject createFileSystem(final String scheme, final FileObject file) throws FileSystemException { final FileProvider provider = providers.get(scheme); FileSystemException.requireNonNull(provider, "vfs.impl/unknown-provider.error", scheme, file); return provider.createFileSystem(scheme, file, file.getFileSystem().getFileSystemOptions()); }
/** * Creates a layered file system. * * @param scheme The scheme to use. * @param file The FileObject. * @return The layered FileObject. * @throws FileSystemException if an error occurs. */ @Override public FileObject createFileSystem(final String scheme, final FileObject file) throws FileSystemException { final FileProvider provider = providers.get(scheme); if (provider == null) { throw new FileSystemException("vfs.impl/unknown-provider.error", scheme, file); } return provider.createFileSystem(scheme, file, file.getFileSystem().getFileSystemOptions()); }
/** * Creates a virtual file system, with the supplied file as its root. * * @param rootFile The root of the file system. * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager() .resolveName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); return fs.getRoot(); }
/** * Creates a virtual file system, with the supplied file as its root. * * @param rootFile The root of the file system. * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager() .resolveName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); return fs.getRoot(); }
/** * Creates a virtual file system, with the supplied file as its root. * * @param rootFile The root of the file system. * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager() .resolveName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); return fs.getRoot(); }
/** * Creates a virtual file system, with the supplied file as its root. * * @param rootFile The root of the file system. * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager().resolveName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); return fs.getRoot(); }
/** * Tests the contents of root of file system can be listed. */ public void testRoot() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fs = getFileSystem(); final String uri = fs.getRootURI(); final FileObject file = getManager().resolveFile(uri, fs.getFileSystemOptions()); file.getChildren(); }
/** * Tests root of file system exists. */ public void testRootURI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fileSystem = getFileSystem(); final String uri = fileSystem.getRootURI(); testRoot(getManager().resolveFile(uri, fileSystem.getFileSystemOptions())); }
/** * Tests root of file system exists. */ public void testRootURI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fileSystem = getFileSystem(); final String uri = fileSystem.getRootURI(); testRoot(getManager().resolveFile(uri, fileSystem.getFileSystemOptions())); }
/** * Tests the contents of root of file system can be listed. */ public void testRoot() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fs = getFileSystem(); final String uri = fs.getRootURI(); final FileObject file = getManager().resolveFile(uri, fs.getFileSystemOptions()); file.getChildren(); }
/** * Tests the contents of root of file system can be listed. */ public void testRoot() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fs = getFileSystem(); final String uri = fs.getRootURI(); final FileObject file = getManager().resolveFile(uri, fs.getFileSystemOptions()); file.getChildren(); }
/** * Tests root of file system exists. */ public void testRootURI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fileSystem = getFileSystem(); final String uri = fileSystem.getRootURI(); testRoot(getManager().resolveFile(uri, fileSystem.getFileSystemOptions())); }
/** * Tests content. */ public void testURLContentProvider() throws Exception { // Test non-empty file final FileObject file = getReadFolder().resolveFile("file1.txt"); assertTrue(file.exists()); final String uri = file.getURL().toExternalForm(); final FileSystemOptions options = getReadFolder().getFileSystem().getFileSystemOptions(); final FileObject f1 = getManager().resolveFile(uri, options); final FileObject f2 = getManager().resolveFile(uri, options); assertEquals("Two files resolved by URI must be equals on " + uri, f1, f2); assertSame("Resolving two times should not produce new filesystem on " + uri, f1.getFileSystem(), f2.getFileSystem()); }
/** * Tests content. */ public void testURLContentProvider() throws Exception { // Test non-empty file final FileObject file = getReadFolder().resolveFile("file1.txt"); assertTrue(file.exists()); final String uri = file.getURL().toExternalForm(); final FileSystemOptions options = getReadFolder().getFileSystem().getFileSystemOptions(); final FileObject f1 = getManager().resolveFile(uri, options); final FileObject f2 = getManager().resolveFile(uri, options); assertEquals("Two files resolved by URI must be equals on " + uri, f1, f2); assertSame("Resolving two times should not produce new filesystem on " + uri, f1.getFileSystem(), f2.getFileSystem()); }
/** * Tests resolution of absolute URI. */ public void testAbsoluteURI() throws Exception { final FileObject readFolder = getReadFolder(); // Try fetching base folder again by its URI final String uri = readFolder.getName().getURI(); FileObject file = getManager().resolveFile(uri, readFolder.getFileSystem().getFileSystemOptions()); assertSame("file object", readFolder, file); // Try fetching the filesystem root by its URI final String rootUri = readFolder.getName().getRootURI(); file = getManager().resolveFile(rootUri, readFolder.getFileSystem().getFileSystemOptions()); assertSame(readFolder.getFileSystem().getRoot(), file); assertEquals(rootUri, file.getName().getRootURI()); assertEquals(rootUri, file.getName().getURI()); assertEquals(FileName.ROOT_PATH, file.getName().getPath()); } }