1 16 package org.apache.commons.vfs.provider; 17 18 import org.apache.commons.vfs.FileName; 19 import org.apache.commons.vfs.FileObject; 20 import org.apache.commons.vfs.FileSystem; 21 import org.apache.commons.vfs.FileSystemException; 22 import org.apache.commons.vfs.FileSystemOptions; 23 24 31 public abstract class AbstractOriginatingFileProvider 32 extends AbstractFileProvider 33 { 34 public AbstractOriginatingFileProvider() 35 { 36 super(); 37 } 38 39 44 public FileObject findFile(final FileObject baseFile, 45 final String uri, 46 final FileSystemOptions fileSystemOptions) throws FileSystemException 47 { 48 final FileName name; 50 try 51 { 52 name = parseUri(baseFile!=null?baseFile.getName():null, uri); 53 } 54 catch (FileSystemException exc) 55 { 56 throw new FileSystemException("vfs.provider/invalid-absolute-uri.error", uri, exc); 57 } 58 59 return findFile(name, fileSystemOptions); 61 } 62 63 66 protected synchronized FileObject findFile(final FileName name, final FileSystemOptions fileSystemOptions) 67 throws FileSystemException 68 { 69 final FileName rootName = getContext().getFileSystemManager().resolveName(name, FileName.ROOT_PATH); 71 FileSystem fs = findFileSystem(rootName, fileSystemOptions); 72 if (fs == null) 73 { 74 fs = doCreateFileSystem(rootName, fileSystemOptions); 76 addFileSystem(rootName, fs); 77 } 78 79 return fs.resolveFile(name.getPath()); 81 } 82 83 89 protected abstract FileSystem doCreateFileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions) 90 throws FileSystemException; 91 } 92 | Popular Tags |