commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r754741 - in /commons/proper/vfs/trunk: core/ core/src/main/java/org/apache/commons/vfs/provider/ core/src/main/java/org/apache/commons/vfs/provider/webdav/ core/src/test/java/org/apache/commons/vfs/provider/webdav/test/ core/src/test/java/...
Date Sun, 15 Mar 2009 20:11:20 GMT
Author: rgoers
Date: Sun Mar 15 20:11:19 2009
New Revision: 754741

URL: http://svn.apache.org/viewvc?rev=754741&view=rev
Log:
Add versioning support to webdav

Added:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
Modified:
    commons/proper/vfs/trunk/core/pom.xml
    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/webdav/WebdavFileContentInfoFactory.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/AbstractProviderTestCase.java
    commons/proper/vfs/trunk/xdocs/filesystems.xml
    commons/proper/vfs/trunk/xdocs/index.xml

Modified: commons/proper/vfs/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/pom.xml?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/pom.xml (original)
+++ commons/proper/vfs/trunk/core/pom.xml Sun Mar 15 20:11:19 2009
@@ -88,7 +88,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-webdav</artifactId>
-      <version>1.4</version>
+      <version>1.5.2</version>
       <optional>true</optional>
     </dependency>
     <dependency>

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=754741&r1=754740&r2=754741&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
Sun Mar 15 20:11:19 2009
@@ -60,6 +60,7 @@
     private final FileContentInfoFactory fileContentInfoFactory;
 
     private final ThreadLocal threadData = new ThreadLocal();
+    private boolean resetAttributes;
 
     /**
      * open streams counter for this file
@@ -219,12 +220,16 @@
         {
             throw new FileSystemException("vfs.provider/get-attributes-no-exist.error", file);
         }
-        if (roAttrs == null)
+        if (resetAttributes || roAttrs == null)
         {
             try
             {
-                attrs = file.doGetAttributes();
-                roAttrs = Collections.unmodifiableMap(attrs);
+                synchronized(this)
+                {
+                    attrs = file.doGetAttributes();
+                    roAttrs = Collections.unmodifiableMap(attrs);
+                    resetAttributes = false;
+                }
             }
             catch (final Exception e)
             {
@@ -235,6 +240,15 @@
     }
 
     /**
+     * Used internally to flag situations where the file attributes should be
+     * reretrieved.
+     */
+    public void resetAttributes()
+    {
+        resetAttributes = true;
+    }
+
+    /**
      * Lists the attributes of this file.
      */
     public String[] getAttributeNames() throws FileSystemException

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileContentInfoFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileContentInfoFactory.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileContentInfoFactory.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileContentInfoFactory.java
Sun Mar 15 20:11:19 2009
@@ -36,7 +36,7 @@
 /**
  * Description
  *
- * @author
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$
  */
 public class WebdavFileContentInfoFactory implements FileContentInfoFactory

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
Sun Mar 15 20:11:19 2009
@@ -23,6 +23,7 @@
 
 /**
  * Implementation for http. set default port to 80
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  */
 public class WebdavFileNameParser extends HttpFileNameParser
 {

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
Sun Mar 15 20:11:19 2009
@@ -24,6 +24,7 @@
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.httpclient.util.DateUtil;
 import org.apache.commons.vfs.provider.URLFileName;
+import org.apache.commons.vfs.provider.DefaultFileContent;
 import org.apache.commons.vfs.provider.http.HttpFileObject;
 import org.apache.commons.vfs.util.FileObjectUtils;
 import org.apache.commons.vfs.util.MonitorOutputStream;
@@ -41,10 +42,17 @@
 import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
 import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
 import org.apache.jackrabbit.webdav.client.methods.PutMethod;
+import org.apache.jackrabbit.webdav.client.methods.CheckoutMethod;
+import org.apache.jackrabbit.webdav.client.methods.CheckinMethod;
+import org.apache.jackrabbit.webdav.client.methods.UncheckoutMethod;
+import org.apache.jackrabbit.webdav.client.methods.VersionControlMethod;
+import org.apache.jackrabbit.webdav.client.methods.PropPatchMethod;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.version.VersionControlledResource;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
@@ -65,7 +73,7 @@
 /**
  * A WebDAV file.
  *
- * @author
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$
  */
 public class WebdavFileObject
@@ -75,13 +83,16 @@
     private final WebdavFileSystem fileSystem;
     private final String urlCharset;
     public static final DavPropertyName RESPONSE_CHARSET = DavPropertyName.create("response-charset");
+    public final WebdavFileSystemConfigBuilder builder;
 
     protected WebdavFileObject(final FileName name,
                                final WebdavFileSystem fileSystem)
     {
         super(name, fileSystem);
         this.fileSystem = fileSystem;
-        this.urlCharset = WebdavFileSystemConfigBuilder.getInstance().getUrlCharset(getFileSystem().getFileSystemOptions());
+        builder =
+            (WebdavFileSystemConfigBuilder)WebdavFileSystemConfigBuilder.getInstance();
+        this.urlCharset = builder.getUrlCharset(getFileSystem().getFileSystemOptions());
     }
 
     protected void configureMethod(HttpMethodBase httpMethod)
@@ -264,21 +275,25 @@
         final Map attributes = new HashMap();
         try
         {
-            String url = urlString((URLFileName)getName());
-            PropFindMethod method = new PropFindMethod(url, DavConstants.PROPFIND_ALL_PROP,
-                    DavConstants.DEPTH_0);
-            execute( method );
-            if ( method.succeeded() )
+            URLFileName fileName = (URLFileName)getName();
+            DavPropertySet properties = getProperties(fileName, PropFindMethod.PROPFIND_ALL_PROP,
+                    new DavPropertyNameSet(), false);
+            Iterator iter = properties.iterator();
+            while (iter.hasNext())
             {
-                MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
-                MultiStatusResponse response = multiStatus.getResponses()[0];
-                DavPropertySet properties = response.getProperties( HttpStatus.SC_OK );
-                Iterator iter = properties.iterator();
-                while (iter.hasNext())
+                DavProperty property = (DavProperty)iter.next();
+                attributes.put(property.getName().toString(), property.getValue());
+            }
+            properties = getPropertyNames(fileName);
+            iter = properties.iterator();
+            while (iter.hasNext())
+            {
+                DavProperty property = (DavProperty)iter.next();
+                if (!attributes.containsKey(property.getName()))
                 {
-                    DavProperty property = (DavProperty)iter.next();
-                    attributes.put(property.getName(), property.getValue());
-                }
+                    property = getProperty(fileName, property.getName());
+                    attributes.put(property.getName().toString(), property.getValue());
+                }               
             }
             return attributes;
         }
@@ -290,7 +305,7 @@
 
     protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
     {
-        return new WebdavOutputStream();
+        return new WebdavOutputStream(this);
     }
 
     protected FileContentInfoFactory getFileContentInfoFactory()
@@ -380,21 +395,44 @@
     DavProperty getProperty(URLFileName fileName, String property)
             throws FileSystemException
     {
+        return getProperty(fileName, DavPropertyName.create(property));
+    }
+
+    DavProperty getProperty(URLFileName fileName, DavPropertyName name)
+            throws FileSystemException
+    {
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
-        DavPropertyName name = DavPropertyName.create(property);
         nameSet.add(name);
         DavPropertySet propertySet = getProperties(fileName, nameSet, false);
         return propertySet.get(name);
     }
 
-
     DavPropertySet getProperties(URLFileName name, DavPropertyNameSet nameSet, boolean addEncoding)
             throws FileSystemException
     {
+        return getProperties(name, PropFindMethod.PROPFIND_BY_PROPERTY, nameSet, addEncoding);
+    }
+
+    DavPropertySet getProperties(URLFileName name) throws FileSystemException
+    {
+        return getProperties(name, PropFindMethod.PROPFIND_ALL_PROP, new DavPropertyNameSet(),
false);
+    }
+
+
+    DavPropertySet getPropertyNames(URLFileName name) throws FileSystemException
+    {
+        return getProperties(name, PropFindMethod.PROPFIND_PROPERTY_NAMES,
+                new DavPropertyNameSet(), false);
+    }
+
+    DavPropertySet getProperties(URLFileName name, int type, DavPropertyNameSet nameSet,
+                                 boolean addEncoding)
+            throws FileSystemException
+    {
         try
         {
             String urlStr = urlString(name);
-            PropFindMethod method = new PropFindMethod(urlStr, nameSet, DavConstants.DEPTH_0);
+            PropFindMethod method = new PropFindMethod(urlStr, type, nameSet, DavConstants.DEPTH_0);
             setupMethod(method);
             execute( method );
             if ( method.succeeded() )
@@ -507,10 +545,12 @@
     private class WebdavOutputStream extends MonitorOutputStream
     {
         private ByteArrayOutputStream stream;
+        private WebdavFileObject file;
 
-        public WebdavOutputStream() throws FileSystemException
+        public WebdavOutputStream(WebdavFileObject file) throws FileSystemException
         {
             super(new ByteArrayOutputStream());
+            this.file = file;
         }
 
         /**
@@ -519,12 +559,150 @@
         protected void onClose() throws IOException
         {
             RequestEntity entity = new StringRequestEntity(out.toString());
-            String urlStr = urlString((URLFileName)getName());
-            PutMethod method = new PutMethod(urlStr);
-            method.setRequestEntity(entity);
+            URLFileName fileName = (URLFileName)getName();
+            String urlStr = urlString(fileName);
+            if (builder.isVersioning(getFileSystem().getFileSystemOptions()))
+            {
+                DavPropertySet set = null;
+                boolean fileExists = true;
+                boolean isCheckedIn = true;
+                try
+                {
+                    set = getPropertyNames(fileName);
+                }
+                catch (FileNotFoundException fnfe)
+                {
+                    fileExists = false;
+                }
+                if (fileExists && set != null)
+                {
+                    if (set.contains(VersionControlledResource.CHECKED_OUT))
+                    {
+                        isCheckedIn = false;
+                    }
+                    else if (!set.contains(VersionControlledResource.CHECKED_IN))
+                    {
+                        DavProperty prop = set.get(VersionControlledResource.AUTO_VERSION);
+                        if (prop != null)
+                        {
+                            prop = getProperty(fileName, VersionControlledResource.AUTO_VERSION);
+                            if (DeltaVConstants.XML_CHECKOUT_CHECKIN.equals(prop.getValue()))
+                            {
+                                createVersion(urlStr);
+                            }
+                        }
+                    }
+                }
+                if (fileExists && isCheckedIn)
+                {
+                    try
+                    {
+                        CheckoutMethod checkout = new CheckoutMethod(urlStr);
+                        setupMethod(checkout);
+                        execute(checkout);
+                        isCheckedIn = false;
+                    }
+                    catch (FileSystemException ex)
+                    {
+                        //
+                    }
+                }
+
+                try
+                {
+                    PutMethod method = new PutMethod(urlStr);
+                    method.setRequestEntity(entity);
+                    setupMethod(method);
+                    execute(method);
+                    setUserName(fileName, urlStr);
+                }
+                catch (FileSystemException ex)
+                {
+                    if (!isCheckedIn)
+                    {
+                        try
+                        {
+                            UncheckoutMethod method = new UncheckoutMethod(urlStr);
+                            setupMethod(method);
+                            execute(method);
+                            isCheckedIn = true;
+                        }
+                        catch (Exception e)
+                        {
+                            // Ignore the exception. Going to throw original.
+                        }
+                        throw ex;
+                    }
+                }
+                if (fileExists)
+                {
+                    if (!isCheckedIn)
+                    {
+                        CheckinMethod checkin = new CheckinMethod(urlStr);
+                        setupMethod(checkin);
+                        execute(checkin);
+                    }
+                }
+                else
+                {
+                    createVersion(urlStr);       
+                }
+            }
+            else
+            {
+                PutMethod method = new PutMethod(urlStr);
+                method.setRequestEntity(entity);
+                setupMethod(method);
+                execute(method);
+                try
+                {
+                    setUserName(fileName, urlStr);
+                }
+                catch (IOException e)
+                {
+
+                }
+            }
+            ((DefaultFileContent)this.file.getContent()).resetAttributes();
+        }
+
+        private void setUserName(URLFileName fileName, String urlStr)
+            throws IOException
+        {
+            List list = new ArrayList();
+            String name = builder.getCreatorName(getFileSystem().getFileSystemOptions());
+            String userName = fileName.getUserName();
+            if (name == null)
+            {
+                name = userName;
+            }
+            else
+            {
+                if (userName != null)
+                {
+                    String comment = "Modified by user " + userName;
+                    list.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment));
+                }
+            }
+            list.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name));
+            PropPatchMethod method = new PropPatchMethod(urlStr, list);
             setupMethod(method);
             execute(method);
         }
-    }
 
+        private boolean createVersion(String urlStr)
+        {
+            try
+            {
+                VersionControlMethod method = new VersionControlMethod(urlStr);
+                setupMethod(method);
+                execute(method);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                return false;
+            }
+        }
+    }
 }
\ No newline at end of file

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
Sun Mar 15 20:11:19 2009
@@ -36,7 +36,7 @@
 /**
  * A provider for WebDAV.
  *
- * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$ $Date$
  */
 public class WebdavFileProvider
@@ -77,12 +77,13 @@
     {
         // Create the file system
         final GenericFileName rootName = (GenericFileName) name;
+        FileSystemOptions fsOpts = (fileSystemOptions == null) ? new FileSystemOptions()
: fileSystemOptions;
 
 		UserAuthenticationData authData = null;
 		HttpClient httpClient;
 		try
 		{
-			authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
+			authData = UserAuthenticatorUtils.authenticate(fsOpts, AUTHENTICATOR_TYPES);
 
 			httpClient = HttpClientFactory.createConnection(
                 WebdavFileSystemConfigBuilder.getInstance(),
@@ -91,14 +92,14 @@
 				rootName.getPort(),
 				UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
UserAuthenticatorUtils.toChar(rootName.getUserName()))),
 				UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
UserAuthenticatorUtils.toChar(rootName.getPassword()))),
-				fileSystemOptions);
+				fsOpts);
 		}
 		finally
 		{
 			UserAuthenticatorUtils.cleanup(authData);
 		}
 
-		return new WebdavFileSystem(rootName, httpClient, fileSystemOptions);
+		return new WebdavFileSystem(rootName, httpClient, fsOpts);
     }
 
     public FileSystemConfigBuilder getConfigBuilder()

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
Sun Mar 15 20:11:19 2009
@@ -34,7 +34,7 @@
 /**
  * A WebDAV file system.
  *
- * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$ $Date$
  */
 public class WebdavFileSystem

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
Sun Mar 15 20:11:19 2009
@@ -26,7 +26,7 @@
 /**
  * Configuration options for WebDav
  * 
- * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$ $Date$
  */
 public class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder
@@ -42,6 +42,42 @@
     {
         super("webdav.");
     }
+
+    /**
+     * The user name to be associated with changes to the file.
+     * @param opts
+     * @param creatorName
+     */
+    public void setCreatorName(FileSystemOptions opts, String creatorName)
+    {
+        setParam(opts, "creatorName", creatorName);
+    }
+
+    /**
+     * Return the user name to be associated with changes to the file.
+     * @param opts
+     * @return
+     */
+    public String getCreatorName(FileSystemOptions opts)
+    {
+        return getString(opts, "creatorName");
+    }
+
+    /**
+     * Whether to use versioning
+     */
+    public void setVersioning(FileSystemOptions opts, boolean versioning)
+    {
+        setParam(opts, "versioning", new Boolean(versioning));
+    }
+
+    /**
+     * The cookies to add to the reqest
+     */
+    public boolean isVersioning(FileSystemOptions opts)
+    {
+        return getBoolean(opts, "versioning", false);
+    }
     
     protected Class getConfigClass()
     {

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java
Sun Mar 15 20:11:19 2009
@@ -26,7 +26,7 @@
  * A retry handler which will retry a failed webdav method one time.<br />
  * Now that webdavlib didnt support adding a MethodRetryHandler only a few operations are
restartable yet.
  *
- * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
  * @version $Revision$ $Date$
  */
 public class WebdavMethodRetryHandler implements MethodRetryHandler

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
Sun Mar 15 20:11:19 2009
@@ -39,7 +39,9 @@
     {
         if (System.getProperty(TEST_URI) != null)
         {
-            return new ProviderTestSuite(new WebdavProviderTestCase());
+            ProviderTestSuite suite = new ProviderTestSuite(new WebdavProviderTestCase());
+            suite.addTests(WebdavVersioningTests.class);
+            return suite;
         }
         else
         {

Added: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java?rev=754741&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
(added)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
Sun Mar 15 20:11:19 2009
@@ -0,0 +1,136 @@
+package org.apache.commons.vfs.provider.webdav.test;
+
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FilesCache;
+import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.provider.webdav.WebdavFileSystemConfigBuilder;
+import org.apache.commons.vfs.test.AbstractProviderTestCase;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.version.VersionControlledResource;
+
+import java.util.Map;
+import java.io.OutputStream;
+
+/**
+ * Test to verify Webdav Versioning support
+ */
+public class WebdavVersioningTests extends AbstractProviderTestCase
+{
+    /**
+     *
+     */
+    public void testVersioning() throws Exception
+    {
+        FileObject scratchFolder = createScratchFolder();
+        FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
+        WebdavFileSystemConfigBuilder builder =
+            (WebdavFileSystemConfigBuilder)getManager().getFileSystemConfigBuilder("webdav");
+        builder.setVersioning(opts, true);
+        FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
+        FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
+        assertTrue(opts == newOpts);
+        assertTrue(builder.isVersioning(newOpts));
+        assertTrue(!file.exists());
+        file.createFile();
+        assertTrue(file.exists());
+        assertSame(FileType.FILE, file.getType());
+        assertEquals(0, file.getContent().getSize());
+        assertFalse(file.isHidden());
+        assertTrue(file.isReadable());
+        assertTrue(file.isWriteable());
+        Map map = file.getContent().getAttributes();
+        assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
+        assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"admin");
+        assertTrue(map.containsKey(VersionControlledResource.CHECKED_OUT.toString()));
+
+        // Create the source file
+        final String content = "Here is some sample content for the file.  Blah Blah Blah.";
+        final String contentAppend = content + content;
+
+        final OutputStream os = file.getContent().getOutputStream();
+        try
+        {
+            os.write(content.getBytes("utf-8"));
+        }
+        finally
+        {
+            os.close();
+        }
+        assertSameContent(content, file);
+        map = file.getContent().getAttributes();
+        assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
+        assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"admin");
+        assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
+        builder.setVersioning(opts, false);
+    }
+    /**
+     *
+     */
+    public void testVersioningWithCreator() throws Exception
+    {
+        FileObject scratchFolder = createScratchFolder();
+        FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
+        WebdavFileSystemConfigBuilder builder =
+            (WebdavFileSystemConfigBuilder)getManager().getFileSystemConfigBuilder("webdav");
+        builder.setVersioning(opts, true);
+        builder.setCreatorName(opts, "testUser");
+        FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
+        FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
+        assertTrue(opts == newOpts);
+        assertTrue(builder.isVersioning(newOpts));
+        assertTrue(!file.exists());
+        file.createFile();
+        assertTrue(file.exists());
+        assertSame(FileType.FILE, file.getType());
+        assertEquals(0, file.getContent().getSize());
+        assertFalse(file.isHidden());
+        assertTrue(file.isReadable());
+        assertTrue(file.isWriteable());
+        Map map = file.getContent().getAttributes();
+        assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
+        assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"testUser");
+        assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
+        assertEquals(map.get(DeltaVConstants.COMMENT.toString()),"Modified by user admin");
+        assertTrue(map.containsKey(VersionControlledResource.CHECKED_OUT.toString()));
+
+        // Create the source file
+        final String content = "Here is some sample content for the file.  Blah Blah Blah.";
+        final String contentAppend = content + content;
+
+        final OutputStream os = file.getContent().getOutputStream();
+        try
+        {
+            os.write(content.getBytes("utf-8"));
+        }
+        finally
+        {
+            os.close();
+        }
+        assertSameContent(content, file);
+        map = file.getContent().getAttributes();
+        assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
+        assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"testUser");
+        assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
+        assertEquals(map.get(DeltaVConstants.COMMENT.toString()),"Modified by user admin");
+        assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
+        builder.setVersioning(opts, false);
+        builder.setCreatorName(opts, null);
+    }  
+        /**
+     * Sets up a scratch folder for the test to use.
+     */
+    protected FileObject createScratchFolder() throws Exception
+    {
+        FileObject scratchFolder = getWriteFolder();
+
+        // Make sure the test folder is empty
+        scratchFolder.delete(Selectors.EXCLUDE_SELF);
+        scratchFolder.createFolder();
+
+        return scratchFolder;
+    }
+
+}

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/AbstractProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/AbstractProviderTestCase.java?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/AbstractProviderTestCase.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/test/AbstractProviderTestCase.java
Sun Mar 15 20:11:19 2009
@@ -158,6 +158,15 @@
     }
 
     /**
+     * Sets the write test folder.
+     * @param folder
+     */
+    protected void setWriteFolder(FileObject folder)
+    {
+        writeFolder = folder;
+    }
+
+    /**
      * Returns the capabilities required by the tests of this test case.  The
      * tests are not run if the provider being tested does not support all
      * the required capabilities.  Return null or an empty array to always

Modified: commons/proper/vfs/trunk/xdocs/filesystems.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/xdocs/filesystems.xml?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/xdocs/filesystems.xml (original)
+++ commons/proper/vfs/trunk/xdocs/filesystems.xml Sun Mar 15 20:11:19 2009
@@ -57,8 +57,8 @@
                     <a href="#mime">mime</a>
                 </li>
                 <li>
-					<a href="#WebDAV">WebDAV</a><br />
-				</li>
+					          <a href="#WebDAV">WebDAV</a><br />
+			        	</li>
             </ul>
         </section>
 
@@ -312,6 +312,15 @@
             </p>
 
             <p>
+                <b>File System Options</b>
+                <ul>
+                  <li><b>versioning</b> true if versioning should be enabled</li>
+                  <li><b>creatorName</b> the user name to be identified
with changes to a file. If
+                      not set the user name used to authenticate will be used.</li>
+                </ul>
+            </p>
+
+            <p>
                 <b>Examples</b>
             </p>
             <ul>

Modified: commons/proper/vfs/trunk/xdocs/index.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/xdocs/index.xml?rev=754741&r1=754740&r2=754741&view=diff
==============================================================================
--- commons/proper/vfs/trunk/xdocs/index.xml (original)
+++ commons/proper/vfs/trunk/xdocs/index.xml Sun Mar 15 20:11:19 2009
@@ -66,7 +66,7 @@
 
 		<section name="News">
 			<p>
-				VFS is splitted into core, examples and sandbox now.
+				VFS is split into core, examples and sandbox now.
 			</p>
 			<p>
 				Due to some technical reasons we had to move the jcifs (smb) filesystem to
@@ -74,7 +74,7 @@
 			</p>
 			<p>
 				To build VFS, it will be best to check-it-out from svn and use maven 2 to
-				build all at once - Notice: the ant and maven 1 build will just build the core.
+				build.
 			</p>
 			<p>
 				And - we have a new filesystem: mime (read only for sure)<br/>



Mime
View raw message