The patch I submitted a few hours ago was missing an important
line. So here is the corrected version.
Index: src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.66
diff -u -r1.66 WebdavResource.java
--- src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java 15 Jul 2003
12:02:21 -0000 1.66
+++ src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java 18 Jul 2003
13:48:52 -0000
@@ -298,6 +298,23 @@
* The constructor.
*
* @param httpURL The specified http URL.
+ * @param state the WebdavState to use
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(HttpURL httpURL, WebdavState state)
+ throws HttpException, IOException {
+
+ setState(state);
+ setHttpURL(httpURL);
+ }
+
+
+ /**
+ * The constructor.
+ *
+ * @param httpURL The specified http URL.
* @param proxyHost The hostname of the proxy to use.
* @param proxyPort The port number of the proxy to use.
* @exception HttpException
@@ -318,6 +335,27 @@
* @param httpURL The specified http URL.
* @param proxyHost The hostname of the proxy to use.
* @param proxyPort The port number of the proxy to use.
+ * @param state the WebdavState to use
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(HttpURL httpURL, String proxyHost, int proxyPort,
+ WebdavState state)
+ throws HttpException, IOException {
+
+ setProxy(proxyHost, proxyPort);
+ setState(state);
+ setHttpURL(httpURL);
+ }
+
+
+ /**
+ * The constructor.
+ *
+ * @param httpURL The specified http URL.
+ * @param proxyHost The hostname of the proxy to use.
+ * @param proxyPort The port number of the proxy to use.
* @param proxyCredentials Credentials to use for proxy authentication.
* @exception HttpException
* @exception IOException
@@ -354,6 +392,24 @@
* It must be put an escaped http URL as an arguement.
*
* @param escapedHttpURL The escaped http URL string.
+ * @param state the WebdavState to use
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(String escapedHttpURL, WebdavState state)
+ throws HttpException, IOException {
+
+ setState(state);
+ setHttpURL(escapedHttpURL);
+ }
+
+
+ /**
+ * The constructor.
+ * It must be put an escaped http URL as an arguement.
+ *
+ * @param escapedHttpURL The escaped http URL string.
* @param proxyHost The hostname of the proxy to use.
* @param proxyPort The port number of the proxy to use.
* @exception HttpException
@@ -367,6 +423,29 @@
setHttpURL(escapedHttpURL);
}
+
+ /**
+ * The constructor.
+ * It must be put an escaped http URL as an arguement.
+ *
+ * @param escapedHttpURL The escaped http URL string.
+ * @param proxyHost The hostname of the proxy to use.
+ * @param proxyPort The port number of the proxy to use.
+ * @param state the WebdavState to use
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(String escapedHttpURL, String proxyHost,
+ int proxyPort, WebdavState state)
+ throws HttpException, IOException {
+
+ setProxy(proxyHost, proxyPort);
+ setState(state);
+ setHttpURL(escapedHttpURL);
+ }
+
+
/**
* The constructor.
* It must be put an escaped http URL as an arguement.
@@ -4227,6 +4306,7 @@
WebdavResource resource = new WebdavResource(client);
resource.setProxy(proxyHost, proxyPort);
resource.setProxyCredentials(proxyCredentials);
+ resource.setState(state);
return resource;
}
Index: src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.29
diff -u -r1.29 WebdavSession.java
--- src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java 15 Jul 2003
12:55:57 -0000 1.29
+++ src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java 18 Jul 2003
13:48:52 -0000
@@ -126,6 +126,10 @@
*/
protected Credentials proxyCredentials = null;
+ /**
+ * Custom WebdavState set by the user
+ */
+ protected WebdavState state = null;
/**
* Debug level.
@@ -179,31 +183,40 @@
if (reset || client == null) {
client = new HttpClient();
// Set a state which allows lock tracking
- client.setState(new WebdavState());
+ if (state != null) {
+ state.removeAllLocks();
+ client.setState(state);
+ } else {
+ client.setState(new WebdavState());
+
+ String userName = httpURL.getUserName();
+ if (userName != null && userName.length() > 0) {
+ String password = httpURL.getPassword();
+ client.getState().setCredentials(null, httpURL.getHost(),
+ new UsernamePasswordCredentials(userName, password));
+ }
+
+ if (proxyCredentials != null) {
+ client.getState().setProxyCredentials(null, proxyHost,
+ proxyCredentials);
+ }
+ }
+
HostConfiguration hostConfig = client.getHostConfiguration();
hostConfig.setHost(httpURL.getHost(), httpURL.getPort(),
httpURL.getScheme());
if (proxyHost != null && proxyPort > 0)
hostConfig.setProxy(proxyHost, proxyPort);
-
- String userName = httpURL.getUserName();
- if (userName != null && userName.length() > 0) {
- String password = httpURL.getPassword();
- client.getState().setCredentials(null, httpURL.getHost(),
- new UsernamePasswordCredentials(userName, password));
-
- }
-
- if (proxyCredentials != null) {
- client.getState().setProxyCredentials(null, proxyHost,
- proxyCredentials);
- }
}
return client;
}
- /** Set proxy info, to use proxying.
+ /**
+ * Set proxy info, to use proxying.
+ *
+ * @param host the name of the proxy
+ * @param port the port to connect to
*/
public void setProxy(String host, int port)
{
@@ -218,6 +231,15 @@
*/
public void setProxyCredentials(Credentials credentials) {
proxyCredentials = credentials;
+ }
+
+ /**
+ * Set a custom state for the client.
+ *
+ * @param state The WebdavState the client shall use.
+ */
+ public void setState(WebdavState state) {
+ this.state = state;
}
/**
Index: src/webdav/client/src/org/apache/webdav/lib/WebdavState.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavState.java,v
retrieving revision 1.7
diff -u -r1.7 WebdavState.java
--- src/webdav/client/src/org/apache/webdav/lib/WebdavState.java 4 Apr 2003
15:25:20 -0000 1.7
+++ src/webdav/client/src/org/apache/webdav/lib/WebdavState.java 18 Jul 2003
13:48:52 -0000
@@ -155,6 +155,15 @@
/**
+ * Remove all locks.
+ */
+ public void removeAllLocks() {
+ locks.clear();
+ lockTokens.clear();
+ }
+
+
+ /**
* Get lock
*
* @param uri Uri
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]