You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/07/22 05:10:27 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods LockMethod.java UnlockMethod.java
remm 01/07/21 20:10:27
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavResource.java WebdavSession.java
src/webdav/client/src/org/apache/webdav/lib/methods
LockMethod.java UnlockMethod.java
Added: src/webdav/client/src/org/apache/webdav/lib WebdavState.java
Log:
- Move some Webdav specific code (the lock storage in the state) away from the
core HTTP client.
- The locks are now stored in the WebdavState, which is a subclass of State.
Revision Changes Path
1.18 +5 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WebdavResource.java 2001/07/16 18:33:20 1.17
+++ WebdavResource.java 2001/07/22 03:10:26 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v 1.17 2001/07/16 18:33:20 remm Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/16 18:33:20 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v 1.18 2001/07/22 03:10:26 remm Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/07/22 03:10:26 $
*
* ====================================================================
*
@@ -3024,7 +3024,7 @@
method.setDebug(debug);
client.executeMethod(method);
String lock = method.getLockToken();
- State state = client.getState();
+ WebdavState state = (WebdavState) client.getState();
if (state != null) {
state.addLock(path, lock);
}
@@ -3074,7 +3074,7 @@
setClient();
// Get the lock for the given path.
- State state = client.getState();
+ WebdavState state = (WebdavState) client.getState();
// Check the given path is alright.
path = HttpURL.getPath(path);
Enumeration locks = state.getLocks(path);
1.13 +5 -3 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
Index: WebdavSession.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebdavSession.java 2001/05/16 16:51:38 1.12
+++ WebdavSession.java 2001/07/22 03:10:27 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.12 2001/05/16 16:51:38 jericho Exp $
- * $Revision: 1.12 $
- * $Date: 2001/05/16 16:51:38 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.13 2001/07/22 03:10:27 remm Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/07/22 03:10:27 $
*
* ====================================================================
*
@@ -165,6 +165,8 @@
HttpClient client = (HttpClient) clientInfo.get(authority);
if (client == null) {
client = new HttpClient();
+ // Set a state which allows lock tracking
+ client.setState(new WebdavState());
client.startSession(httpURL.getHost(), httpURL.getPort());
String userName = httpURL.getUserName();
if (userName != null && userName.length() > 0) {
1.1 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavState.java
Index: WebdavState.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavState.java,v 1.1 2001/07/22 03:10:27 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/07/22 03:10:27 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib;
import java.io.IOException;
import java.util.HashMap;
import java.util.Vector;
import java.util.Enumeration;
import org.apache.commons.httpclient.State;
/**
* Session state.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*/
public class WebdavState extends State {
// ----------------------------------------------------- Instance Variables
/**
* Lock tokens.
*/
protected HashMap lockTokens = new HashMap();
// ------------------------------------------------------------- Properties
/**
* Add a lock token.
*
* @param uri Uri
* @param value Lock token value
*/
public void addLock(String uri, String value) {
Vector currentLocks = (Vector) lockTokens.get(uri);
if (currentLocks == null)
currentLocks = new Vector();
currentLocks.addElement(value);
lockTokens.put(uri, currentLocks);
}
/**
* Remove a lock.
*
* @param uri Uri
* @param value LockToken value
*/
public void removeLock(String uri, String value) {
Vector currentLocks = (Vector) lockTokens.get(uri);
if (currentLocks == null)
return;
currentLocks.removeElement(value);
}
/**
* Remove locks.
*
* @param uri Uri
*/
public void removeLocks(String uri) {
lockTokens.remove(uri);
}
/**
* Get locks
*
* @param uri Uri
* @return Enumeration of lock tokens
*/
public Enumeration getLocks(String uri) {
Vector result = (Vector) lockTokens.get(uri);
if (result == null)
result = new Vector();
return result.elements();
}
/**
* Get all locks scoped to that uri.
*
* @param uri Uri
* @return Enumeration of lock tokens
*/
public Enumeration getAllLocks(String uri) {
// FIXME: Won't support collection locks
return getLocks(uri);
}
}
1.22 +6 -4 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- LockMethod.java 2001/07/18 07:54:01 1.21
+++ LockMethod.java 2001/07/22 03:10:27 1.22
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v 1.21 2001/07/18 07:54:01 juergen Exp $
- * $Revision: 1.21 $
- * $Date: 2001/07/18 07:54:01 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v 1.22 2001/07/22 03:10:27 remm Exp $
+ * $Revision: 1.22 $
+ * $Date: 2001/07/22 03:10:27 $
*
* ====================================================================
*
@@ -76,6 +76,7 @@
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
+import org.apache.webdav.lib.WebdavState;
import org.apache.webdav.lib.properties.LockEntryProperty;
import org.apache.util.DOMUtils;
@@ -516,7 +517,8 @@
prefix + "href");
if (list2.getLength() == 1) {
this.lockToken = DOMUtils.getTextValue(list2.item(0));
- this.state.addLock(getPath(), this.lockToken);
+ ((WebdavState) this.state).addLock
+ (getPath(), this.lockToken);
}
}
}
1.11 +5 -7 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java
Index: UnlockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- UnlockMethod.java 2001/05/01 21:28:00 1.10
+++ UnlockMethod.java 2001/07/22 03:10:27 1.11
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java,v 1.10 2001/05/01 21:28:00 remm Exp $
- * $Revision: 1.10 $
- * $Date: 2001/05/01 21:28:00 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java,v 1.11 2001/07/22 03:10:27 remm Exp $
+ * $Revision: 1.11 $
+ * $Date: 2001/07/22 03:10:27 $
*
* ====================================================================
*
@@ -71,6 +71,7 @@
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.webdav.lib.WebdavState;
/**
* UNLOCK Method.
@@ -87,9 +88,7 @@
private String lockToken = null;
- private State state = null;
-
// ----------------------------------------------------------- Constructors
@@ -162,7 +161,6 @@
super.setHeader("Lock-Token", "<" + lockToken + ">");
- this.state = state;
}
@@ -174,7 +172,7 @@
public void parseResponse(InputStream is)
throws IOException {
if (getStatusCode() == HttpStatus.SC_NO_CONTENT) {
- state.removeLock(getPath(), lockToken);
+ ((WebdavState) state).removeLock(getPath(), lockToken);
}
}