Author: imario Date: Tue Oct 3 12:49:25 2006 New Revision: 452605 URL: http://svn.apache.org/viewvc?view=rev&rev=452605 Log: VFS-76: implemented retry operation.
Due to the limitation of the used webdavlib only a handful of operations are restartable yet. Added: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java (with props) Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?view=diff&rev=452605&r1=452604&r2=452605 ============================================================================== --- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original) +++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Tue Oct 3 12:49:25 2006 @@ -16,6 +16,7 @@ package org.apache.commons.vfs.provider.webdav; import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpURL; import org.apache.commons.vfs.FileObject; @@ -27,9 +28,9 @@ import org.apache.commons.vfs.provider.AbstractRandomAccessContent; import org.apache.commons.vfs.provider.GenericFileName; import org.apache.commons.vfs.provider.URLFileName; +import org.apache.commons.vfs.util.FileObjectUtils; import org.apache.commons.vfs.util.MonitorOutputStream; import org.apache.commons.vfs.util.RandomAccessMode; -import org.apache.commons.vfs.util.FileObjectUtils; import org.apache.webdav.lib.BaseProperty; import org.apache.webdav.lib.WebdavResource; import org.apache.webdav.lib.methods.DepthSupport; @@ -134,6 +135,7 @@ /* now fill the dav properties */ String pathEncoded = name.getPathQueryEncoded(urlCharset); final OptionsMethod optionsMethod = new OptionsMethod(pathEncoded); + configureMethod(optionsMethod); try { optionsMethod.setFollowRedirects(true); @@ -203,6 +205,11 @@ } } + protected void configureMethod(HttpMethodBase httpMethod) + { + httpMethod.setMethodRetryHandler(WebdavMethodRetryHandler.getInstance()); + } + private void setAllowedMethods(Enumeration allowedMethods) { this.allowedMethods = new TreeSet(); @@ -236,6 +243,7 @@ } final OptionsMethod optionsMethod = new OptionsMethod(getName().getPath()); + configureMethod(optionsMethod); try { optionsMethod.setFollowRedirects(true); @@ -549,6 +557,7 @@ } final OptionsMethod optionsMethod = new OptionsMethod(getName().getPath()); + configureMethod(optionsMethod); try { optionsMethod.setFollowRedirects(true); Added: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java?view=auto&rev=452605 ============================================================================== --- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java (added) +++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java Tue Oct 3 12:49:25 2006 @@ -0,0 +1,43 @@ +package org.apache.commons.vfs.provider.webdav; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpURL; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.MethodRetryHandler; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpConnection; +import org.apache.commons.httpclient.HttpRecoverableException; +import org.apache.commons.vfs.FileSystemOptions; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.UserAuthenticator; +import org.apache.commons.vfs.UserAuthenticationData; +import org.apache.commons.vfs.util.UserAuthenticatorUtils; +import org.apache.webdav.lib.WebdavResource; + +import java.io.IOException; + +/** + * 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:[EMAIL PROTECTED]">Mario Ivankovits</a> + * @version $Revision$ $Date$ + */ +public class WebdavMethodRetryHandler implements MethodRetryHandler +{ + private final static WebdavMethodRetryHandler INSTANCE = new WebdavMethodRetryHandler(); + + private WebdavMethodRetryHandler() + { + } + + public static WebdavMethodRetryHandler getInstance() + { + return INSTANCE; + } + + public boolean retryMethod(HttpMethod method, HttpConnection connection, HttpRecoverableException recoverableException, int executionCount, boolean requestSent) + { + return executionCount < 2; + } +} Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavMethodRetryHandler.java ------------------------------------------------------------------------------ svn:mime-type = text/plain --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]