commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl VirtualFileSystem.java
Date Wed, 30 Jun 2004 19:06:39 GMT
imario      2004/06/30 12:06:39

  Modified:    vfs/src/java/org/apache/commons/vfs/provider
                        AbstractFileObject.java AbstractFileSystem.java
               vfs/src/java/org/apache/commons/vfs Capability.java
                        FileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/local
                        DefaultLocalFileProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/ftp
                        FtpFileProvider.java
               vfs/src/test/org/apache/commons/vfs/test
                        LastModifiedTests.java
               vfs/src/java/org/apache/commons/vfs/provider/sftp
                        SftpFileProvider.java SftpFileSystem.java
               vfs/src/java/org/apache/commons/vfs/impl
                        VirtualFileSystem.java
  Log:
  PR: 29469
  Submitted By: rami.ojares -at- elisa.fi (Rami Ojares)
  
  Not fully implemented yet (the main part is missing in this commit as we have to wait for
the jsch-0.1.16 release)
  
  Modified to honor the fact that sftp (jsch) cant set the lastmodtime on folders.
  Split Capability.SET_LAST_MODIFICATION_TIME into
  Capability.SET_LAST_MODIFICATION_TIME_FILE and
  Capability.SET_LAST_MODIFICATION_TIME_FOLDER
  Added a getLastModTimeAccuracy, mainly for the testcase-check.
  
  Revision  Changes    Path
  1.48      +2 -1      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.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- AbstractFileObject.java	23 Jun 2004 18:17:44 -0000	1.47
  +++ AbstractFileObject.java	30 Jun 2004 19:06:38 -0000	1.48
  @@ -856,7 +856,8 @@
   
               destFile.copyFrom(this, Selectors.SELECT_SELF);
   
  -            if (destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED) &&
  +            if (((destFile.getType() == FileType.FILE && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE))
||
  +                (destFile.getType() == FileType.FOLDER && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)))
&&
                   getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED))
               {
                   destFile.getContent().setLastModifiedTime(this.getContent().getLastModifiedTime());
  
  
  
  1.27      +10 -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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AbstractFileSystem.java	17 May 2004 20:13:20 -0000	1.26
  +++ AbstractFileSystem.java	30 Jun 2004 19:06:38 -0000	1.27
  @@ -286,6 +286,16 @@
       }
   
       /**
  +     * Returns the accuracy of the last modification time
  +     *
  +     * @return ms 0 perfectly accurate, >0 might be off by this value e.g. sftp 1000ms
  +     */
  +    public double getLastModTimeAccuracy()
  +    {
  +        return 0;
  +    }
  +
  +    /**
        * Creates a temporary local copy of a file and its descendents.
        */
       protected File doReplicateFile(final FileObject file,
  
  
  
  1.12      +7 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Capability.java
  
  Index: Capability.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Capability.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Capability.java	17 Jun 2004 19:29:28 -0000	1.11
  +++ Capability.java	30 Jun 2004 19:06:38 -0000	1.12
  @@ -66,7 +66,12 @@
       /**
        * File set last-modified time is supported.
        */
  -    public static final Capability SET_LAST_MODIFIED = new Capability("SET_LAST_MODIFIED");
  +    public static final Capability SET_LAST_MODIFIED_FILE = new Capability("SET_LAST_MODIFIED_FILE");
  +
  +    /**
  +     * folder set last-modified time is supported.
  +     */
  +    public static final Capability SET_LAST_MODIFIED_FOLDER = new Capability("SET_LAST_MODIFIED_FOLDER");
   
       /**
        * File content signing is supported.
  
  
  
  1.17      +8 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FileSystem.java	21 May 2004 20:43:29 -0000	1.16
  +++ FileSystem.java	30 Jun 2004 19:06:38 -0000	1.17
  @@ -160,4 +160,11 @@
        * Returns a reference to the FileSytemManager
        */
       FileSystemManager getFileSystemManager();
  +
  +    /**
  +     * Returns the accuracy of the last modification time
  +     *
  +     * @return ms 0 perfectly accurate, >0 might be off by this value e.g. sftp 1000ms
  +     */
  +    double getLastModTimeAccuracy();
   }
  
  
  
  1.9       +3 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
  
  Index: DefaultLocalFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultLocalFileProvider.java	17 Jun 2004 19:29:28 -0000	1.8
  +++ DefaultLocalFileProvider.java	30 Jun 2004 19:06:38 -0000	1.9
  @@ -47,7 +47,8 @@
           Capability.RENAME,
           Capability.GET_TYPE,
           Capability.GET_LAST_MODIFIED,
  -        Capability.SET_LAST_MODIFIED,
  +        Capability.SET_LAST_MODIFIED_FILE,
  +        Capability.SET_LAST_MODIFIED_FOLDER,
           Capability.LIST_CHILDREN,
           Capability.READ_CONTENT,
           Capability.URI,
  
  
  
  1.9       +3 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
  
  Index: FtpFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FtpFileProvider.java	26 May 2004 08:20:27 -0000	1.8
  +++ FtpFileProvider.java	30 Jun 2004 19:06:38 -0000	1.9
  @@ -49,7 +49,8 @@
           Capability.GET_TYPE,
           Capability.LIST_CHILDREN,
           Capability.READ_CONTENT,
  -        Capability.SET_LAST_MODIFIED,
  +        Capability.SET_LAST_MODIFIED_FILE,
  +        Capability.SET_LAST_MODIFIED_FOLDER,
           Capability.GET_LAST_MODIFIED,
           Capability.URI,
           Capability.WRITE_CONTENT,
  
  
  
  1.5       +15 -14    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/LastModifiedTests.java
  
  Index: LastModifiedTests.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/LastModifiedTests.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LastModifiedTests.java	10 May 2004 20:09:44 -0000	1.4
  +++ LastModifiedTests.java	30 Jun 2004 19:06:38 -0000	1.5
  @@ -57,21 +57,22 @@
        */
       public void testSetLastModified() throws Exception
       {
  -        if (!getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED))
  -        {
  -            // Can't set last modified
  -            return;
  -        }
           final long now = System.currentTimeMillis();
   
  -        // Try a file
  -        final FileObject file = getReadFolder().resolveFile("file1.txt");
  -        file.getContent().setLastModifiedTime(now);
  -        assertEquals(now, file.getContent().getLastModifiedTime());
  +        if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE))
  +        {
  +            // Try a file
  +            final FileObject file = getReadFolder().resolveFile("file1.txt");
  +            file.getContent().setLastModifiedTime(now);
  +            assertEquals(now, file.getContent().getLastModifiedTime(), file.getFileSystem().getLastModTimeAccuracy());
  +        }
   
  -        // Try a folder
  -        final FileObject folder = getReadFolder().resolveFile("dir1");
  -        folder.getContent().setLastModifiedTime(now);
  -        assertEquals(now, folder.getContent().getLastModifiedTime());
  +        if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER))
  +        {
  +            // Try a folder
  +            final FileObject folder = getReadFolder().resolveFile("dir1");
  +            folder.getContent().setLastModifiedTime(now);
  +            assertEquals(now, folder.getContent().getLastModifiedTime(), folder.getFileSystem().getLastModTimeAccuracy());
  +        }
       }
   }
  
  
  
  1.13      +4 -3      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
  
  Index: SftpFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SftpFileProvider.java	27 May 2004 19:09:37 -0000	1.12
  +++ SftpFileProvider.java	30 Jun 2004 19:06:38 -0000	1.13
  @@ -31,7 +31,7 @@
   
   /**
    * A provider for accessing files over SFTP.
  - * 
  + *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @author Gary D. Gregory
    * @version $Id$
  @@ -48,7 +48,8 @@
           Capability.READ_CONTENT,
           Capability.URI,
           Capability.WRITE_CONTENT,
  -        Capability.GET_LAST_MODIFIED
  +        Capability.GET_LAST_MODIFIED,
  +        Capability.SET_LAST_MODIFIED_FILE
       }));
   
       public final static String ATTR_USER_INFO = "UI";
  
  
  
  1.12      +11 -1     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
  
  Index: SftpFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SftpFileSystem.java	27 May 2004 19:09:37 -0000	1.11
  +++ SftpFileSystem.java	30 Jun 2004 19:06:38 -0000	1.12
  @@ -146,4 +146,14 @@
       {
           return new SftpFileObject(name, this);
       }
  +
  +    /**
  +     * last mod time is only a int and in seconds, thus can be off by 999
  +     *
  +     * @return 1000
  +     */
  +    public double getLastModTimeAccuracy()
  +    {
  +        return 1000L;
  +    }
   }
  
  
  
  1.16      +3 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java
  
  Index: VirtualFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- VirtualFileSystem.java	10 May 2004 20:09:47 -0000	1.15
  +++ VirtualFileSystem.java	30 Jun 2004 19:06:38 -0000	1.16
  @@ -59,7 +59,8 @@
           caps.add(Capability.GET_TYPE);
           caps.add(Capability.JUNCTIONS);
           caps.add(Capability.GET_LAST_MODIFIED);
  -        caps.add(Capability.SET_LAST_MODIFIED);
  +        caps.add(Capability.SET_LAST_MODIFIED_FILE);
  +        caps.add(Capability.SET_LAST_MODIFIED_FOLDER);
           caps.add(Capability.LIST_CHILDREN);
           caps.add(Capability.READ_CONTENT);
           caps.add(Capability.SIGNING);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message