adammurdoch    2002/11/16 19:39:21

  Modified:    vfs/src/java/org/apache/commons/vfs FileObject.java
                        FileSystem.java Resources.properties
               vfs/src/java/org/apache/commons/vfs/provider
                        AbstractFileObject.java AbstractFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/local
                        LocalFile.java LocalFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/zip
                        ZipFileSystem.java
  Log:
  Moved FileObject.replicateFile() to FileSystem.
  
  Revision  Changes    Path
  1.12      +0 -21     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileObject.java
  
  Index: FileObject.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileObject.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FileObject.java   28 Oct 2002 02:05:06 -0000      1.11
  +++ FileObject.java   17 Nov 2002 03:39:20 -0000      1.12
  @@ -55,7 +55,6 @@
    */
   package org.apache.commons.vfs;
   
  -import java.io.File;
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.List;
  @@ -330,26 +329,6 @@
        */
       void copyFrom( FileObject srcFile, FileSelector selector )
           throws FileSystemException;
  -
  -    /**
  -     * Creates a temporary local copy of this file, and its descendents.  If
  -     * this file is a local file, a copy is not made.
  -     *
  -     * <p>Note that the local copy may include additonal files, that were
  -     * not selected by the given selector.
  -     *
  -     * @todo Add options to indicate whether the caller is happy to deal with
  -     *       extra files being present locally (eg if the file has been
  -     *       replicated previously), or whether the caller expects only
  -     *       the selected files to be present.
  -     *
  -     * @param selector the selector to use to select the files to replicate.
  -     * @return The local copy of this file.
  -     *
  -     * @throws FileSystemException
  -     *      If this file does not exist, or on error replicating the file.
  -     */
  -    File replicateFile( FileSelector selector ) throws FileSystemException;
   
       /**
        * Returns this file's content.  The {@link FileContent} returned by this
  
  
  
  1.7       +26 -1     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystem.java
  
  Index: FileSystem.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystem.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FileSystem.java   31 Oct 2002 10:35:18 -0000      1.6
  +++ FileSystem.java   17 Nov 2002 03:39:20 -0000      1.7
  @@ -55,6 +55,8 @@
    */
   package org.apache.commons.vfs;
   
  +import java.io.File;
  +
   /**
    * A file system, made up of a hierarchy of files.
    *
  @@ -176,4 +178,27 @@
        *      On error removing the junction.
        */
       void removeJuntion( FileName junctionPoint ) throws FileSystemException;
  +
  +    /**
  +     * Creates a temporary local copy of a file and its descendents.  If
  +     * this file is already a local file, a copy is not made.
  +     *
  +     * <p>Note that the local copy may include additonal files, that were
  +     * not selected by the given selector.
  +     *
  +     * @todo Add options to indicate whether the caller is happy to deal with
  +     *       extra files being present locally (eg if the file has been
  +     *       replicated previously), or whether the caller expects only
  +     *       the selected files to be present.
  +     *
  +     * @param file The file to replicate.
  +     * @param selector The selector to use to select the files to replicate.
  +     * @return The local copy of this file.
  +     *
  +     * @throws FileSystemException
  +     *      If this file does not exist, or on error replicating the file.
  +     */
  +    File replicateFile( FileObject file, FileSelector selector )
  +        throws FileSystemException;
  +
   }
  
  
  
  1.12      +2 -0      
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Resources.properties      1 Nov 2002 03:29:31 -0000       1.11
  +++ Resources.properties      17 Nov 2002 03:39:20 -0000      1.12
  @@ -58,6 +58,8 @@
   vfs.provider/mismatched-fs-for-name.error=Incorrect file system URI for in name 
"{0}", was expecting "{1}".
   vfs.provider/junctions-not-supported.error=Junctions not supported for file system 
"{0}".
   vfs.provider/notify-listener.warn=Could not notify listener of change to "{0}".
  +vfs.provider/replicate-missing-file.error=Could not replicate "{0}" as it does not 
exist.
  +vfs.provider/replicate-file.error=Could not replicate "{0}".
   
   # UriParser
   vfs.provider/missing-double-slashes.error=Expecting // to follow the scheme in URI 
"{0}".
  
  
  
  1.18      +0 -24     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
  
  Index: AbstractFileObject.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AbstractFileObject.java   31 Oct 2002 10:35:18 -0000      1.17
  +++ AbstractFileObject.java   17 Nov 2002 03:39:21 -0000      1.18
  @@ -55,7 +55,6 @@
    */
   package org.apache.commons.vfs.provider;
   
  -import java.io.File;
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.net.MalformedURLException;
  @@ -187,15 +186,6 @@
       }
   
       /**
  -     * Creates a local copy of this file.
  -     */
  -    protected File doReplicateFile( final FileSelector selector ) throws 
FileSystemException
  -    {
  -        final FileReplicator replicator = fs.getContext().getReplicator();
  -        return replicator.replicateFile( this, selector );
  -    }
  -
  -    /**
        * Called when the children of this file change.
        */
       protected void onChildrenChanged()
  @@ -754,20 +744,6 @@
           final ArrayList list = new ArrayList();
           findFiles( selector, true, list );
           return list;
  -    }
  -
  -    /**
  -     * Creates a temporary local copy of this file, and its descendents.
  -     */
  -    public File replicateFile( final FileSelector selector )
  -        throws FileSystemException
  -    {
  -        if ( !exists() )
  -        {
  -            throw new FileSystemException( "vfs.provider/copy-missing-file.error", 
name );
  -        }
  -
  -        return doReplicateFile( selector );
       }
   
       /**
  
  
  
  1.14      +34 -0     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
  
  Index: AbstractFileSystem.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AbstractFileSystem.java   1 Nov 2002 03:18:48 -0000       1.13
  +++ AbstractFileSystem.java   17 Nov 2002 03:39:21 -0000      1.14
  @@ -58,12 +58,14 @@
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Map;
  +import java.io.File;
   import org.apache.commons.vfs.FileChangeEvent;
   import org.apache.commons.vfs.FileListener;
   import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.FileObject;
   import org.apache.commons.vfs.FileSystem;
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileSelector;
   import org.apache.commons.vfs.util.Messages;
   
   /**
  @@ -194,6 +196,38 @@
               files.put( name, file );
           }
           return file;
  +    }
  +
  +    /**
  +     * Creates a temporary local copy of a file and its descendents.
  +     */
  +    public File replicateFile( final FileObject file,
  +                               final FileSelector selector )
  +        throws FileSystemException
  +    {
  +        if ( !file.exists() )
  +        {
  +            throw new FileSystemException( 
"vfs.provider/replicate-missing-file.error", file.getName() );
  +        }
  +
  +        try
  +        {
  +            return doReplicateFile( file, selector );
  +        }
  +        catch ( final Exception e )
  +        {
  +            throw new FileSystemException( "vfs.provider/replicate-file.error", 
file.getName(), e );
  +        }
  +    }
  +
  +    /**
  +     * Creates a temporary local copy of a file and its descendents.
  +     */
  +    protected File doReplicateFile( final FileObject file,
  +                                    final FileSelector selector )
  +        throws Exception
  +    {
  +        return getContext().getReplicator().replicateFile( file, selector );
       }
   
       /**
  
  
  
  1.8       +8 -19     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
  
  Index: LocalFile.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFile.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalFile.java    25 Oct 2002 11:01:33 -0000      1.7
  +++ LocalFile.java    17 Nov 2002 03:39:21 -0000      1.8
  @@ -58,16 +58,13 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
  -import java.io.FilePermission;
   import java.io.InputStream;
   import java.io.OutputStream;
   import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.FileSelector;
   import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.FileType;
   import org.apache.commons.vfs.provider.AbstractFileObject;
  -import org.apache.commons.vfs.provider.DefaultFileContent;
   
   /**
    * A file object implementation which uses direct file access.
  @@ -81,7 +78,6 @@
   {
       private File file;
       private final String fileName;
  -    private FilePermission requiredPerm;
   
       /**
        * Creates a non-root file.
  @@ -95,6 +91,14 @@
       }
   
       /**
  +     * Returns the local file that this file object represents.
  +     */
  +    public File getLocalFile()
  +    {
  +        return file;
  +    }
  +
  +    /**
        * Attaches this file object to its file resource.
        */
       protected void doAttach()
  @@ -103,7 +107,6 @@
           if ( file == null )
           {
               file = new File( fileName );
  -            requiredPerm = new FilePermission( file.getAbsolutePath(), "read" );
           }
       }
   
  @@ -220,19 +223,5 @@
           throws Exception
       {
           return file.length();
  -    }
  -
  -    /**
  -     * Creates a temporary local copy of this file, and its descendents.
  -     */
  -    protected File doReplicateFile( final FileSelector selector )
  -        throws FileSystemException
  -    {
  -        final SecurityManager sm = System.getSecurityManager();
  -        if ( sm != null )
  -        {
  -            sm.checkPermission( requiredPerm );
  -        }
  -        return file;
       }
   }
  
  
  
  1.10      +22 -0     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
  
  Index: LocalFileSystem.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocalFileSystem.java      25 Oct 2002 11:07:39 -0000      1.9
  +++ LocalFileSystem.java      17 Nov 2002 03:39:21 -0000      1.10
  @@ -59,7 +59,10 @@
   import org.apache.commons.vfs.FileObject;
   import org.apache.commons.vfs.FileSystem;
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileSelector;
   import org.apache.commons.vfs.provider.AbstractFileSystem;
  +import java.io.File;
  +import java.io.FilePermission;
   
   /**
    * A local file system.
  @@ -90,4 +93,23 @@
           final String fileName = rootFile + name.getPath();
           return new LocalFile( this, fileName, name );
       }
  +
  +    /**
  +     * Creates a temporary local copy of a file and its descendents.
  +     */
  +    protected File doReplicateFile( final FileObject fileObject,
  +                                    final FileSelector selector )
  +        throws Exception
  +    {
  +        final LocalFile localFile = (LocalFile)fileObject;
  +        final File file = localFile.getLocalFile();
  +        final SecurityManager sm = System.getSecurityManager();
  +        if ( sm != null )
  +        {
  +            final FilePermission requiredPerm = new FilePermission( 
file.getAbsolutePath(), "read" );
  +            sm.checkPermission( requiredPerm );
  +        }
  +        return file;
  +    }
  +
   }
  
  
  
  1.15      +1 -3      
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
  
  Index: ZipFileSystem.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ZipFileSystem.java        27 Oct 2002 08:18:46 -0000      1.14
  +++ ZipFileSystem.java        17 Nov 2002 03:39:21 -0000      1.15
  @@ -88,9 +88,7 @@
           super( rootName, parentLayer );
   
           // Make a local copy of the file
  -        final File file = parentLayer.replicateFile( Selectors.SELECT_SELF );
  -
  -        this.file = file;
  +        file = parentLayer.getFileSystem().replicateFile( parentLayer, 
Selectors.SELECT_SELF );
   
           // Open the Zip file
           if ( !file.exists() )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to