commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r659785 - in /commons/proper/vfs/trunk: core/src/main/java/org/apache/commons/vfs/ core/src/main/java/org/apache/commons/vfs/provider/ core/src/main/java/org/apache/commons/vfs/provider/ftp/ core/src/main/java/org/apache/commons/vfs/provide...
Date Sat, 24 May 2008 10:32:43 GMT
Author: imario
Date: Sat May 24 03:32:41 2008
New Revision: 659785

URL: http://svn.apache.org/viewvc?rev=659785&view=rev
Log:
VFS-210: First development iteration. Most important methods now work more like a wrapper, you should already see a major increase in performance with ftp and large directories as long as no method (or your code) calls getFileType(). Hidden and special files should work now too .. as long as you know the path, for sure.

Added:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileTypeHasNoContentException.java
Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Capability.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Resources.properties
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/tar/TarFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/RunTest.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTarTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTbz2TestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTgzTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TarProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/Tbz2ProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TgzProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/ProviderReadTests.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/UrlStructureTests.java
    commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
    commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
    commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Capability.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Capability.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Capability.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Capability.java Sat May 24 03:32:41 2008
@@ -144,6 +144,11 @@
      */
     public static final Capability VIRTUAL = new Capability("VIRTUAL");
 
+    /**
+     * Provides directories which allows you to read its content through {@link org.apache.commons.vfs.FileContent#getInputStream()} 
+     */
+    public static final Capability DIRECTORY_READ_CONTENT = new Capability("DIRECTORY_READ_CONTENT");
+
     private final String name;
 
     private Capability(final String name)

Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java?rev=659785&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java Sat May 24 03:32:41 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs;
+
+/**
+ * delivers a file-not-folder exception which happens when trying to issue {@link FileObject#getChildren()} on a file.
+ */
+public class FileNotFolderException extends FileSystemException
+{
+    public FileNotFolderException(final Object info0)
+    {
+        super("vfs.provider/list-children-not-folder.error", info0);
+    }
+
+    public FileNotFolderException(Object info0, Throwable throwable)
+    {
+        super("vfs.provider/list-children-not-folder.error", info0, throwable);
+    }
+}

Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java?rev=659785&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java Sat May 24 03:32:41 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs;
+
+/**
+ * delivers a file-not-found exception
+ */
+public class FileNotFoundException extends FileSystemException
+{
+    public FileNotFoundException(final Object info0)
+    {
+        super("vfs.provider/read-not-file.error", info0);
+    }
+
+    public FileNotFoundException(Object info0, Throwable throwable)
+    {
+        super("vfs.provider/read-not-file.error", info0, throwable);
+    }
+}
\ No newline at end of file

Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileTypeHasNoContentException.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileTypeHasNoContentException.java?rev=659785&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileTypeHasNoContentException.java (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileTypeHasNoContentException.java Sat May 24 03:32:41 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs;
+
+/**
+ * delivers a file-not-folder exception which happens when trying to issue {@link org.apache.commons.vfs.FileObject#getChildren()} on a file.
+ */
+public class FileTypeHasNoContentException extends FileSystemException
+{
+    public FileTypeHasNoContentException(final Object info0)
+    {
+        super("vfs.provider/read-not-file.error", info0);
+    }
+
+    public FileTypeHasNoContentException(Object info0, Throwable throwable)
+    {
+        super("vfs.provider/read-not-file.error", info0, throwable);
+    }
+}
\ No newline at end of file

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Resources.properties
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Resources.properties?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Resources.properties (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/Resources.properties Sat May 24 03:32:41 2008
@@ -228,6 +228,7 @@
 vfs.provider.ftp/invalid-directory-entry.debug=Invalid directory entry at line "{0}" (directory "{1}").
 vfs.provider.ftp/output-error.debug=Cant open output connection for file "{0}". Reason: "{1}".
 vfs.provider.ftp/input-error.debug=Cant open input connection for file "{0}". Reason: "{1}".
+vfs.provider.ftp.wrapper/change-work-directory-back.error=Could not change back to work directory "{0}".
 
 # URL Provider
 vfs.provider.url/badly-formed-uri.error=Badly formed URI "{0}".
@@ -262,6 +263,7 @@
 vfs.provider.sftp/unknown-modtime.error=Last modification time not fetched.
 vfs.provider.sftp/known-hosts.error=Error during processing known-hosts file "{0}".
 vfs.provider.sftp/StrictHostKeyChecking-arg.error=Illegal argument "{0}" hostKeyChecking can only be "ask", "yes" or "no"
+vfs.provider.sftp/change-work-directory-back.error=Could not change back to work directory "{0}".
 
 # Ant tasks
 vfs.tasks/sync.no-destination.error=No destination file or directory specified.

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java Sat May 24 03:32:41 2008
@@ -16,19 +16,7 @@
  */
 package org.apache.commons.vfs.provider;
 
-import org.apache.commons.vfs.Capability;
-import org.apache.commons.vfs.FileContent;
-import org.apache.commons.vfs.FileContentInfoFactory;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSelector;
-import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.FileUtil;
-import org.apache.commons.vfs.NameScope;
-import org.apache.commons.vfs.RandomAccessContent;
-import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.operations.DefaultFileOperations;
 import org.apache.commons.vfs.operations.FileOperations;
 import org.apache.commons.vfs.util.FileObjectUtils;
@@ -37,6 +25,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.FileNotFoundException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
@@ -159,7 +148,9 @@
     /**
      * Lists the children of this file.  Is only called if {@link #doGetType}
      * returns {@link FileType#FOLDER}.  The return value of this method
-     * is cached, so the implementation can be expensive.
+     * is cached, so the implementation can be expensive.<br />
+     * @return a possible empty String array if the file is a directory or null or an exception if the
+     * file is not a directory or can't be read
      */
     protected abstract String[] doListChildren() throws Exception;
 
@@ -441,6 +432,24 @@
         synchronized (fs)
         {
             attach();
+
+            // VFS-210: get the type only if requested for
+            try
+            {
+                if (type == null)
+                {
+                    setFileType(doGetType());
+                }
+                if (type == null)
+                {
+                    setFileType(FileType.IMAGINARY);
+                }
+            }
+            catch (Exception e)
+            {
+                throw new FileSystemException("vfs.provider/get-type.error", new Object[]{name}, e);
+            }
+
             return type;
         }
     }
@@ -553,10 +562,19 @@
     {
         synchronized (fs)
         {
+            // VFS-210
+            if (!getFileSystem().hasCapability(Capability.LIST_CHILDREN))
+            {
+                throw new FileNotFolderException(name);
+            }
+            
+            /* VFS-210
             if (!getType().hasChildren())
             {
                 throw new FileSystemException("vfs.provider/list-children-not-folder.error", name);
             }
+            */
+            attach();
 
             // Use cached info, if present
             if (children != null)
@@ -571,6 +589,11 @@
                 childrenObjects = doListChildrenResolved();
                 children = extractNames(childrenObjects);
             }
+            catch (FileSystemException exc)
+            {
+                // VFS-210
+                throw exc;
+            }
             catch (Exception exc)
             {
                 throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
@@ -587,6 +610,11 @@
             {
                 files = doListChildren();
             }
+            catch (FileSystemException exc)
+            {
+                // VFS-210
+                throw exc;
+            }
             catch (Exception exc)
             {
                 throw new FileSystemException("vfs.provider/list-children.error", new Object[]{name}, exc);
@@ -594,7 +622,10 @@
 
             if (files == null)
             {
-                return null;
+                // VFS-210
+                // honor the new doListChildren contract
+                // return null;
+                throw new FileNotFolderException(name);
             }
             else if (files.length == 0)
             {
@@ -717,11 +748,13 @@
             }
             */
 
+            /* VFS-210
             if (getType() == FileType.IMAGINARY)
             {
                 // File does not exist
                 return false;
             }
+            */
 
             try
             {
@@ -764,11 +797,13 @@
     {
         int nuofDeleted = 0;
 
+        /* VFS-210
         if (getType() == FileType.IMAGINARY)
         {
             // File does not exist
             return nuofDeleted;
         }
+        */
 
         // Locate all the files to delete
         ArrayList files = new ArrayList();
@@ -781,6 +816,8 @@
             final AbstractFileObject file = FileObjectUtils.getAbstractFileObject((FileObject) files.get(i));
             // file.attach();
 
+            // VFS-210: It seems impossible to me that findFiles will return a list with hidden files/directories
+            // in it, else it would not be hidden. Checking for the file-type seems ok in this case
             // If the file is a folder, make sure all its children have been deleted
             if (file.getType().hasChildren() && file.getChildren().length != 0)
             {
@@ -808,6 +845,7 @@
         {
             try
             {
+                // VFS-210: We do not want to trunc any existing file, checking for its existence is still required
                 if (exists() && !FileType.FILE.equals(getType()))
                 {
                     throw new FileSystemException("vfs.provider/create-file.error", name);
@@ -838,6 +876,7 @@
     {
         synchronized (fs)
         {
+            // VFS-210: we create a folder only if it does not already exist. So this check should be safe.
             if (getType().hasChildren())
             {
                 // Already exists as correct type
@@ -847,10 +886,12 @@
             {
                 throw new FileSystemException("vfs.provider/create-folder-mismatched-type.error", name);
             }
+            /* VFS-210: checking for writeable is not always possible as the security constraint might be more complex
             if (!isWriteable())
             {
                 throw new FileSystemException("vfs.provider/create-folder-read-only.error", name);
             }
+            */
 
             // Traverse up the heirarchy and make sure everything is a folder
             final FileObject parent = getParent();
@@ -888,10 +929,12 @@
         {
             throw new FileSystemException("vfs.provider/copy-missing-file.error", file);
         }
+        /* we do not alway know if a file is writeable
         if (!isWriteable())
         {
             throw new FileSystemException("vfs.provider/copy-read-only.error", new Object[]{file.getType(), file.getName(), this}, null);
         }
+        */
 
         // Locate the files to copy across
         final ArrayList files = new ArrayList();
@@ -1144,6 +1187,7 @@
      */
     public InputStream getInputStream() throws FileSystemException
     {
+        /* VFS-210
         if (!getType().hasContent())
         {
             throw new FileSystemException("vfs.provider/read-not-file.error", name);
@@ -1152,12 +1196,25 @@
         {
             throw new FileSystemException("vfs.provider/read-not-readable.error", name);
         }
+        */
 
         // Get the raw input stream
         try
         {
             return doGetInputStream();
         }
+        catch (final org.apache.commons.vfs.FileNotFoundException exc)
+        {
+            throw new org.apache.commons.vfs.FileNotFoundException(name, exc);
+        }
+        catch (final FileNotFoundException exc)
+        {
+            throw new org.apache.commons.vfs.FileNotFoundException(name, exc);
+        }
+        catch (final FileSystemException exc)
+        {
+            throw exc;
+        }
         catch (final Exception exc)
         {
             throw new FileSystemException("vfs.provider/read.error", name, exc);
@@ -1170,10 +1227,12 @@
      */
     public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
     {
+        /* VFS-210
         if (!getType().hasContent())
         {
             throw new FileSystemException("vfs.provider/read-not-file.error", name);
         }
+        */
 
         if (mode.requestRead())
         {
@@ -1230,6 +1289,7 @@
      */
     public OutputStream getOutputStream(boolean bAppend) throws FileSystemException
     {
+        /* VFS-210
         if (getType() != FileType.IMAGINARY && !getType().hasContent())
         {
             throw new FileSystemException("vfs.provider/write-not-file.error", name);
@@ -1238,6 +1298,8 @@
         {
             throw new FileSystemException("vfs.provider/write-read-only.error", name);
         }
+        */
+        
         if (bAppend && !getFileSystem().hasCapability(Capability.APPEND_CONTENT))
         {
             throw new FileSystemException("vfs.provider/write-append-not-supported.error", name);
@@ -1331,6 +1393,8 @@
                 doAttach();
                 attached = true;
                 // now the type could already be injected by doAttach (e.g from parent to child)
+
+                /* VFS-210: determine the type when really asked fore
                 if (type == null)
                 {
                     setFileType(doGetType());
@@ -1339,6 +1403,7 @@
                 {
                     setFileType(FileType.IMAGINARY);
                 }
+                */
             }
             catch (Exception exc)
             {

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java Sat May 24 03:32:41 2008
@@ -352,6 +352,7 @@
 
         // Get the raw input stream
         final InputStream instr = file.getInputStream();
+
         final InputStream wrappedInstr = new FileContentInputStream(file, instr);
 
         this.getThreadData().addInstr(wrappedInstr);

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java Sat May 24 03:32:41 2008
@@ -16,14 +16,7 @@
  */
 package org.apache.commons.vfs.provider;
 
-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.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.FileContentInfo;
-import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.util.WeakRefFileListener;
 import org.apache.commons.vfs.util.RandomAccessMode;
 
@@ -187,8 +180,19 @@
 	{
 		if (file != null)
 		{
-			final FileObject[] children = file.getChildren();
-			final String[] childNames = new String[children.length];
+            final FileObject[] children;
+
+            try
+            {
+                children = file.getChildren();
+            }
+            // VFS-210
+            catch (FileNotFolderException e)
+            {
+                throw new FileNotFolderException(getName(), e);
+            }
+            
+            final String[] childNames = new String[children.length];
 			for (int i = 0; i < children.length; i++)
 			{
 				childNames[i] = children[i].getName().getBaseName();

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java Sat May 24 03:32:41 2008
@@ -23,10 +23,13 @@
 import org.apache.commons.vfs.UserAuthenticationData;
 import org.apache.commons.vfs.util.UserAuthenticatorUtils;
 import org.apache.commons.vfs.provider.GenericFileName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.FileNotFoundException;
 
 /**
  * A wrapper to the FTPClient to allow automatic reconnect on connection loss.<br />
@@ -109,13 +112,38 @@
     {
         try
         {
-            return getFtpClient().listFiles(relPath);
+            // VFS-210: return getFtpClient().listFiles(relPath);
+            FTPFile[] files = listFilesInDirectory(relPath);
+            return files;
         }
         catch (IOException e)
         {
             disconnect();
-            return getFtpClient().listFiles(relPath);
+
+            FTPFile[] files = listFilesInDirectory(relPath);
+            return files;
+        }
+    }
+
+    private FTPFile[] listFilesInDirectory(String relPath) throws IOException
+    {
+        String workingDirectory = null;
+        if (relPath != null)
+        {
+            workingDirectory = getFtpClient().printWorkingDirectory();
+            if (!getFtpClient().changeWorkingDirectory(relPath))
+            {
+                return null;
+            }
+        }
+
+        FTPFile[] files = getFtpClient().listFiles();
+
+        if (relPath != null && !getFtpClient().changeWorkingDirectory(workingDirectory))
+        {
+            throw new FileSystemException("vfs.provider.ftp.wrapper/change-work-directory-back.error", workingDirectory);
         }
+        return files;
     }
 
     public boolean removeDirectory(String relPath) throws IOException

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java Sat May 24 03:32:41 2008
@@ -35,6 +35,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.FileNotFoundException;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Iterator;
@@ -58,7 +59,8 @@
 	private final String relPath;
 
 	// Cached info
-	private FTPFile fileInfo;
+    private final static FTPFile UNKNOWN = new FTPFile();
+    private FTPFile fileInfo;
 	private Map children;
 	private FileObject linkDestination;
 
@@ -107,7 +109,13 @@
 		// List the children of this file
 		doGetChildren();
 
-		// Look for the requested child
+        // VFS-210
+        if (children == null)
+        {
+            return null;
+        }
+
+        // Look for the requested child
 		FTPFile ftpFile = (FTPFile) children.get(name);
 		return ftpFile;
 	}
@@ -125,8 +133,12 @@
 		final FtpClient client = ftpFs.getClient();
 		try
 		{
-			final FTPFile[] tmpChildren = client.listFiles(relPath);
-			if (tmpChildren == null || tmpChildren.length == 0)
+            final FTPFile[] tmpChildren = client.listFiles(relPath);
+            if (tmpChildren == null)
+            {
+                children = null;
+            }
+            else if (tmpChildren.length == 0)
 			{
 				children = EMPTY_FTP_FILE_MAP;
 			}
@@ -171,7 +183,7 @@
 		throws IOException
 	{
 		// Get the parent folder to find the info for this file
-		getInfo(false);
+		// VFS-210 getInfo(false);
 	}
 
 	/**
@@ -192,8 +204,15 @@
 			newFileInfo.setType(FTPFile.DIRECTORY_TYPE);
 		}
 
-		this.fileInfo = newFileInfo;
-	}
+        if (newFileInfo == null)
+        {
+            this.fileInfo = UNKNOWN;
+        }
+        else
+        {
+            this.fileInfo = newFileInfo;
+        }
+    }
 
 	/**
 	 * @throws FileSystemException
@@ -280,7 +299,13 @@
 	protected FileType doGetType()
 		throws Exception
 	{
-		if (this.fileInfo == null)
+        // VFS-210
+        if (this.fileInfo == null)
+        {
+            getInfo(false);
+        }
+
+        if (this.fileInfo == UNKNOWN)
 		{
 			return FileType.IMAGINARY;
 		}
@@ -319,7 +344,7 @@
 
 	protected FileObject[] doListChildrenResolved() throws Exception
 	{
-		if (this.fileInfo.isSymbolicLink())
+		if (this.fileInfo != null && this.fileInfo.isSymbolicLink())
 		{
 			return getLinkDestination().getChildren();
 		}
@@ -364,7 +389,13 @@
 		// List the children of this file
 		doGetChildren();
 
-		// TODO - get rid of this children stuff
+        // VFS-210
+        if (children == null)
+        {
+            return null;
+        }
+
+        // TODO - get rid of this children stuff
 		final String[] childNames = new String[children.size()];
 		int childNum = -1;
 		Iterator iterChildren = children.values().iterator();
@@ -505,7 +536,12 @@
 	{
 		final FtpClient client = ftpFs.getClient();
 		final InputStream instr = client.retrieveFileStream(relPath);
-		return new FtpInputStream(client, instr);
+        // VFS-210
+        if (instr == null)
+        {
+            throw new FileNotFoundException(getName().toString());
+        }
+        return new FtpInputStream(client, instr);
 	}
 
 	protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileObject.java Sat May 24 03:32:41 2008
@@ -24,11 +24,7 @@
 import org.apache.commons.httpclient.methods.HeadMethod;
 import org.apache.commons.httpclient.util.DateParser;
 import org.apache.commons.httpclient.util.URIUtil;
-import org.apache.commons.vfs.FileContentInfoFactory;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.provider.AbstractFileObject;
 import org.apache.commons.vfs.provider.URLFileName;
 import org.apache.commons.vfs.util.MonitorInputStream;
@@ -152,6 +148,10 @@
         final GetMethod getMethod = new GetMethod();
         setupMethod(getMethod);
         final int status = fileSystem.getClient().executeMethod(getMethod);
+        if (status == HttpURLConnection.HTTP_NOT_FOUND)
+        {
+            throw new FileNotFoundException(getName());
+        }
         if (status != HttpURLConnection.HTTP_OK)
         {
             throw new FileSystemException("vfs.provider.http/get.error", getName());

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java Sat May 24 03:32:41 2008
@@ -49,7 +49,8 @@
         Capability.URI,
         Capability.GET_LAST_MODIFIED,
         Capability.ATTRIBUTES,
-        Capability.RANDOM_ACCESS_READ
+        Capability.RANDOM_ACCESS_READ,
+        Capability.DIRECTORY_READ_CONTENT,
     }));
 
 	public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java Sat May 24 03:32:41 2008
@@ -124,7 +124,8 @@
         for (Iterator iterator = src.entrySet().iterator(); iterator.hasNext();)
         {
             final Map.Entry entry = (Map.Entry) iterator.next();
-            final String name = entry.getKey().toString().toLowerCase();
+            // final String name = entry.getKey().toString().toLowerCase();
+            final String name = entry.getKey().toString();
             dest.put(name, entry.getValue());
         }
     }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java Sat May 24 03:32:41 2008
@@ -98,7 +98,13 @@
 	 */
 	protected InputStream doGetInputStream() throws Exception
 	{
-		return new ByteArrayInputStream(this.data.getBuffer());
+        // VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway.
+        if (!getType().hasContent())
+        {
+            throw new FileSystemException("vfs.provider/read-not-file.error", getName());
+        }
+
+        return new ByteArrayInputStream(this.data.getBuffer());
 	}
 
 	/*

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java Sat May 24 03:32:41 2008
@@ -89,7 +89,11 @@
 	String[] listChildren(FileName name)
 	{
         RamFileData data = (RamFileData) this.cache.get(name);
-		Collection children = data.getChildren();
+        if (data == null || !data.getType().hasChildren())
+        {
+            return null;
+        }
+        Collection children = data.getChildren();
         
         String[] names = new String[children.size()];
         

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java Sat May 24 03:32:41 2008
@@ -20,13 +20,7 @@
 import com.jcraft.jsch.ChannelSftp.LsEntry;
 import com.jcraft.jsch.SftpATTRS;
 import com.jcraft.jsch.SftpException;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.NameScope;
-import org.apache.commons.vfs.RandomAccessContent;
-import org.apache.commons.vfs.VFS;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.provider.AbstractFileObject;
 import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.util.FileObjectUtils;
@@ -289,10 +283,38 @@
 		// List the contents of the folder
 		final Vector vector;
 		final ChannelSftp channel = fileSystem.getChannel();
+
+        String workingDirectory = null;
 		try
 		{
-			vector = channel.ls(relPath);
-		}
+            try
+            {
+                if (relPath != null)
+                {
+                    workingDirectory = channel.pwd();
+                    channel.cd(relPath);
+                }
+            }
+            catch (SftpException e)
+            {
+                // VFS-210: seems not to be a directory
+                return null;
+            }
+
+            vector = channel.ls(".");
+
+            try
+            {
+                if (relPath != null)
+                {
+                    channel.cd(workingDirectory);
+                }
+            }
+            catch (SftpException e)
+            {
+                throw new FileSystemException("vfs.provider.sftp/change-work-directory-back.error", workingDirectory);
+            }
+        }
 		finally
 		{
 			fileSystem.putChannel(channel);
@@ -424,7 +446,30 @@
 				outstr.close();
 				return new ByteArrayInputStream(outstr.toByteArray());
 				*/
-				return new SftpInputStream(channel, channel.get(relPath));
+
+                InputStream is;
+                try
+                {
+                    // VFS-210: sftp allows to gather an input stream even from a directory and will
+                    // fail on first read. So we need to check the type anyway
+                    if (!getType().hasContent())
+                    {
+                        throw new FileSystemException("vfs.provider/read-not-file.error", getName());
+                    }
+
+                    is = channel.get(relPath);
+                }
+                catch (SftpException e)
+                {
+                    if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
+                    {
+                        throw new FileNotFoundException(getName());
+                    }
+
+                    throw new FileSystemException(e);
+                }
+
+                return new SftpInputStream(channel, is);
 
 			}
 			finally

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/tar/TarFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/tar/TarFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/tar/TarFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/tar/TarFileObject.java Sat May 24 03:32:41 2008
@@ -106,6 +106,19 @@
      */
     protected String[] doListChildren()
     {
+        try
+        {
+            if (!getType().hasChildren())
+            {
+                return null;
+            }
+        }
+        catch (FileSystemException e)
+        {
+            // should not happen as the type has already been cached.
+            throw new RuntimeException(e);
+        }
+
         return (String[]) children.toArray(new String[children.size()]);
     }
 
@@ -144,6 +157,14 @@
      */
     protected InputStream doGetInputStream() throws Exception
     {
+        // VFS-210: zip allows to gather an input stream even from a directory and will
+        // return -1 on the first read. getType should not be expensive and keeps the tests
+        // running
+        if (!getType().hasContent())
+        {
+            throw new FileSystemException("vfs.provider/read-not-file.error", getName());
+        }
+
         return fs.getInputStream(entry);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java Sat May 24 03:32:41 2008
@@ -109,6 +109,19 @@
      */
     protected String[] doListChildren()
     {
+        try
+        {
+            if (!getType().hasChildren())
+            {
+                return null;
+            }
+        }
+        catch (FileSystemException e)
+        {
+            // should not happen as the type has already been cached.
+            throw new RuntimeException(e);
+        }
+
         return (String[]) children.toArray(new String[children.size()]);
     }
 
@@ -137,6 +150,14 @@
      */
     protected InputStream doGetInputStream() throws Exception
     {
+        // VFS-210: zip allows to gather an input stream even from a directory and will
+        // return -1 on the first read. getType should not be expensive and keeps the tests
+        // running
+        if (!getType().hasContent())
+        {
+            throw new FileSystemException("vfs.provider/read-not-file.error", getName());
+        }
+
         return fs.getZipFile().getInputStream(entry);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java Sat May 24 03:32:41 2008
@@ -103,7 +103,7 @@
 
                 // Make sure all ancestors exist
                 // TODO - create these on demand
-                ZipFileObject parent = null;
+                ZipFileObject parent;
                 for (FileName parentName = name.getParent();
                      parentName != null;
                      fileObj = parent, parentName = parentName.getParent())

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/RunTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/RunTest.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/RunTest.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/RunTest.java Sat May 24 03:32:41 2008
@@ -20,6 +20,20 @@
 import junit.framework.Test;
 import junit.framework.TestResult;
 import org.apache.commons.vfs.provider.sftp.test.SftpProviderTestCase;
+import org.apache.commons.vfs.provider.local.test.LocalProviderTestCase;
+import org.apache.commons.vfs.provider.ftp.test.FtpProviderTestCase;
+import org.apache.commons.vfs.provider.url.test.UrlProviderHttpTestCase;
+import org.apache.commons.vfs.provider.url.test.UrlProviderTestCase;
+import org.apache.commons.vfs.provider.test.VirtualProviderTestCase;
+import org.apache.commons.vfs.provider.temp.test.TemporaryProviderTestCase;
+import org.apache.commons.vfs.provider.res.test.ResourceProviderTestCase;
+import org.apache.commons.vfs.provider.http.test.HttpProviderTestCase;
+import org.apache.commons.vfs.provider.jar.test.JarProviderTestCase;
+import org.apache.commons.vfs.provider.jar.test.NestedJarTestCase;
+import org.apache.commons.vfs.provider.ram.test.RamProviderTestCase;
+import org.apache.commons.vfs.provider.zip.test.ZipProviderTestCase;
+import org.apache.commons.vfs.provider.zip.test.NestedZipTestCase;
+import org.apache.commons.vfs.provider.tar.test.*;
 
 import java.util.Properties;
 
@@ -27,55 +41,49 @@
 {
 	public static void main(String[] args) throws Exception
 	{
-		Properties props = System.getProperties();
+        final String ip = "192.168.0.128";
+
+        Properties props = System.getProperties();
 		props.setProperty("test.data.src", "src/test-data");
 		props.setProperty("test.basedir", "core/target/test-classes/test-data");
 		props.setProperty("test.basedir.res", "test-data");
 		props.setProperty("test.policy", "src/test-data/test.policy");
 		props.setProperty("test.secure", "false");
 		props.setProperty("test.smb.uri",
-				"smb://HOME\\vfsusr:vfs%2f%25\\te:st@172.16.110.129/vfsusr/vfstest");
+				"smb://HOME\\vfsusr:vfs%2f%25\\te:st@" + ip  + "/vfsusr/vfstest");
 		props.setProperty("test.ftp.uri",
-				"ftp://vfsusr:vfs%2f%25\\te:st@172.16.110.129/vfstest");
-		props.setProperty("test.http.uri", "http://172.16.110.129/vfstest");
+				"ftp://vfsusr:vfs%2f%25\\te:st@" + ip + "/vfstest");
+		props.setProperty("test.http.uri", "http://" + ip + "/vfstest");
 		props.setProperty("test.webdav.uri",
-				"webdav://vfsusr:vfs%2f%25\\te:st@172.16.110.129/vfstest");
+				"webdav://vfsusr:vfs%2f%25\\te:st@" + ip + "/vfstest");
 		props.setProperty("test.sftp.uri",
-				"sftp://vfsusr:vfs%2f%25\\te:st@192.168.72.128/vfstest");
+				"sftp://vfsusr:vfs%2f%25\\te:st@" + ip + "/vfstest");
 
 		Test tests[] = new Test[]
 		{
-			// RamProviderTestCase.suite(),
-
-			// SmbProviderTestCase.suite(),
-
-		// LocalProviderTestCase.suite(),
-			
-		// FtpProviderTestCase.suite(),
-
-		// UrlProviderHttpTestCase.suite(),
-
-		// VirtualProviderTestCase.suite(),
-		// TemporaryProviderTestCase.suite(),
-		// UrlProviderTestCase.suite(),
-		// ResourceProviderTestCase.suite(),
-
-		// HttpProviderTestCase.suite(),
-
-		// WebdavProviderTestCase.suite(),
-
-		SftpProviderTestCase.suite(),
+//          LocalProviderTestCase.suite(),
+//          FtpProviderTestCase.suite(),
+//          UrlProviderHttpTestCase.suite(),
+//          VirtualProviderTestCase.suite(),
+//          TemporaryProviderTestCase.suite(),
+//          UrlProviderTestCase.suite(),
+//          ResourceProviderTestCase.suite(),
+//          HttpProviderTestCase.suite(),
+//          SftpProviderTestCase.suite(),
+//          JarProviderTestCase.suite(),
+//  		NestedJarTestCase.suite(),
+//  		ZipProviderTestCase.suite(),
+//  		NestedZipTestCase.suite(),
+//          TarProviderTestCase.suite(),
+//          TgzProviderTestCase.suite(),
+//          Tbz2ProviderTestCase.suite(),
+//          NestedTarTestCase.suite(),
+//          NestedTgzTestCase.suite(),
+//          NestedTbz2TestCase.suite(),
+//          RamProviderTestCase.suite(),
 
-		// JarProviderTestCase.suite(),
-//		NestedJarTestCase.suite(),
-//		ZipProviderTestCase.suite(),
-//		NestedZipTestCase.suite(),
-//		TarProviderTestCase.suite(),
-//		TgzProviderTestCase.suite(),
-//		Tbz2ProviderTestCase.suite(),
-//		NestedTarTestCase.suite(),
-//		NestedTgzTestCase.suite(),
-//		NestedTbz2TestCase.suite(),
+// SmbProviderTestCase.suite(),
+// WebdavProviderTestCase.suite(),
 		};
 
 		TestResult result = new TestResult()

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java Sat May 24 03:32:41 2008
@@ -60,7 +60,7 @@
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
     {
         final File jarFile = AbstractVfsTestCase.getTestResource("test.jar");
-        final String uri = "jar:" + jarFile.getAbsolutePath() + "!/";
+        final String uri = "jar:file:" + jarFile.getAbsolutePath() + "!/";
         return manager.resolveFile(uri);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java Sat May 24 03:32:41 2008
@@ -62,7 +62,7 @@
     {
         // Locate the Jar file
         final File outerFile = AbstractVfsTestCase.getTestResource("nested.jar");
-        final String uri = "jar:" + outerFile.getAbsolutePath() + "!/test.jar";
+        final String uri = "jar:file:" + outerFile.getAbsolutePath() + "!/test.jar";
         final FileObject jarFile = manager.resolveFile(uri);
 
         // Now build the nested file system

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTarTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTarTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTarTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTarTestCase.java Sat May 24 03:32:41 2008
@@ -59,7 +59,7 @@
     {
         // Locate the base Tar file
         final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath();
-        String uri = "tar:" + tarFilePath + "!/test.tar";
+        String uri = "tar:file:" + tarFilePath + "!/test.tar";
         final FileObject tarFile = manager.resolveFile(uri);
 
         // Now build the nested file system

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTbz2TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTbz2TestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTbz2TestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTbz2TestCase.java Sat May 24 03:32:41 2008
@@ -59,7 +59,7 @@
     {
         // Locate the base Tar file
         final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tbz2").getAbsolutePath();
-        String uri = "tbz2:" + tarFilePath + "!/test.tbz2";
+        String uri = "tbz2:file:" + tarFilePath + "!/test.tbz2";
         final FileObject tarFile = manager.resolveFile(uri);
 
         // Now build the nested file system

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTgzTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTgzTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTgzTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/NestedTgzTestCase.java Sat May 24 03:32:41 2008
@@ -59,7 +59,7 @@
     {
         // Locate the base Tar file
         final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tgz").getAbsolutePath();
-        String uri = "tgz:" + tarFilePath + "!/test.tgz";
+        String uri = "tgz:file:" + tarFilePath + "!/test.tgz";
         final FileObject tarFile = manager.resolveFile(uri);
 
         // Now build the nested file system

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TarProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TarProviderTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TarProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TarProviderTestCase.java Sat May 24 03:32:41 2008
@@ -58,7 +58,7 @@
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
     {
         final File tarFile = AbstractVfsTestCase.getTestResource("test.tar");
-        final String uri = "tar:" + tarFile.getAbsolutePath() + "!/";
+        final String uri = "tar:file:" + tarFile.getAbsolutePath() + "!/";
         return manager.resolveFile(uri);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/Tbz2ProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/Tbz2ProviderTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/Tbz2ProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/Tbz2ProviderTestCase.java Sat May 24 03:32:41 2008
@@ -58,7 +58,7 @@
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
     {
         final File tarFile = AbstractVfsTestCase.getTestResource("test.tbz2");
-        final String uri = "tbz2:" + tarFile.getAbsolutePath() + "!/";
+        final String uri = "tbz2:file:" + tarFile.getAbsolutePath() + "!/";
         return manager.resolveFile(uri);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TgzProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TgzProviderTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TgzProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/TgzProviderTestCase.java Sat May 24 03:32:41 2008
@@ -59,7 +59,7 @@
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
     {
         final File tarFile = AbstractVfsTestCase.getTestResource("test.tgz");
-        final String uri = "tgz:" + tarFile.getAbsolutePath() + "!/";
+        final String uri = "tgz:file:" + tarFile.getAbsolutePath() + "!/";
         return manager.resolveFile(uri);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java Sat May 24 03:32:41 2008
@@ -61,7 +61,7 @@
     {
         // Locate the base Zip file
         final String zipFilePath = AbstractVfsTestCase.getTestResource("nested.zip").getAbsolutePath();
-        String uri = "zip:" + zipFilePath + "!/test.zip";
+        String uri = "zip:file:" + zipFilePath + "!/test.zip";
         final FileObject zipFile = manager.resolveFile(uri);
 
         // Now build the nested file system

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java Sat May 24 03:32:41 2008
@@ -61,7 +61,7 @@
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
     {
         final File zipFile = AbstractVfsTestCase.getTestResource("test.zip");
-        final String uri = "zip:" + zipFile.getAbsolutePath() + "!/";
+        final String uri = "zip:file:" + zipFile.getAbsolutePath() + "!/";
         return manager.resolveFile(uri);
     }
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/ProviderReadTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/ProviderReadTests.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/ProviderReadTests.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/ProviderReadTests.java Sat May 24 03:32:41 2008
@@ -141,6 +141,12 @@
      */
     public void testFolderContent() throws Exception
     {
+        if (getReadFolder().getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT))
+        {
+            // test wont fail
+            return;
+        }
+
         // Try getting the content of a folder
         FileObject folder = getReadFolder().resolveFile("dir1");
         try

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/UrlStructureTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/UrlStructureTests.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/UrlStructureTests.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/UrlStructureTests.java Sat May 24 03:32:41 2008
@@ -49,9 +49,9 @@
     public void testFolderURL() throws Exception
     {
         final FileObject folder = getReadFolder().resolveFile("dir1");
-        if (folder.getFileSystem() instanceof HttpFileSystem)
+        if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT))
         {
-            // bad hack, but this test might not fail on HttpFileSystem as there are no direcotries.
+            // test might not fail on e.g. HttpFileSystem as there are no direcotries.
             // A Directory do have a content on http. e.g a generated directory listing or the index.html page.
             return;
         }

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java (original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java Sat May 24 03:32:41 2008
@@ -21,12 +21,7 @@
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileInputStream;
 import jcifs.smb.SmbFileOutputStream;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.RandomAccessContent;
-import org.apache.commons.vfs.UserAuthenticationData;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.provider.AbstractFileObject;
 import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.util.RandomAccessMode;
@@ -147,6 +142,12 @@
      */
     protected String[] doListChildren() throws Exception
     {
+        // VFS-210: do not try to get listing for anything else than directories
+        if (!file.isDirectory())
+        {
+            return null;
+        }
+
         return UriParser.encode(file.list());
     }
 
@@ -202,7 +203,23 @@
      */
     protected InputStream doGetInputStream() throws Exception
     {
-        return new SmbFileInputStream(file);
+        try
+        {
+            return new SmbFileInputStream(file);
+        }
+        catch (SmbException e)
+        {
+            if (e.getErrorCode() == SmbException.ERRbadfile)
+            {
+                throw new FileNotFoundException(getName());
+            }
+            else if (file.isDirectory())
+            {
+                throw new FileTypeHasNoContentException(getName());
+            }
+
+            throw e;
+        }
     }
 
     /**

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Sat May 24 03:32:41 2008
@@ -20,11 +20,7 @@
 import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpURL;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.NameScope;
-import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.*;
 import org.apache.commons.vfs.provider.AbstractFileObject;
 import org.apache.commons.vfs.provider.AbstractRandomAccessContent;
 import org.apache.commons.vfs.provider.GenericFileName;
@@ -303,7 +299,7 @@
     {
         doAttach();
 
-        WebdavResource[] children = new org.apache.webdav.lib.WebdavResource[0];
+        WebdavResource[] children;
         try
         {
             children = resource.listWebdavResources();
@@ -315,12 +311,23 @@
                 resolveRedirection();
                 children = resource.listWebdavResources();
             }
+            else if (e.getReasonCode() == HttpStatus.SC_NOT_FOUND)
+            {
+                // throw new FileNotFoundException(getName());
+                throw new FileNotFolderException(getName());
+            }
             else
             {
                 throw e;
             }
         }
 
+        if (children != null && children.length < 1 && !getType().hasChildren())
+        {
+            throw new FileNotFolderException(getName());
+        }
+
+
         if (children == null)
         {
             throw new FileSystemException("vfs.provider.webdav/list-children.error", resource.getStatusMessage());
@@ -413,7 +420,19 @@
      */
     protected InputStream doGetInputStream() throws Exception
     {
-        return resource.getMethodData();
+        try
+        {
+            return resource.getMethodData();
+        }
+        catch (IOException e)
+        {
+            if (!resource.exists())
+            {
+                throw new FileNotFoundException(getName());
+            }
+
+            throw e;
+        }
     }
 
     /**

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java?rev=659785&r1=659784&r2=659785&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java (original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java Sat May 24 03:32:41 2008
@@ -53,7 +53,8 @@
         Capability.WRITE_CONTENT,
         Capability.GET_LAST_MODIFIED,
         Capability.ATTRIBUTES,
-        Capability.RANDOM_ACCESS_READ
+        Capability.RANDOM_ACCESS_READ,
+        Capability.DIRECTORY_READ_CONTENT,
     }));
 
 	public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]



Mime
View raw message