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...@locus.apache.org on 2000/09/05 07:38:12 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/webdav/method LockMethod.java MkcolMethod.java PropFindMethod.java PutMethod.java UnlockMethod.java
remm 00/09/04 22:38:12
Modified: src/share/org/apache/slide/lock Lock.java LockImpl.java
NodeLock.java
src/share/org/apache/slide/webdav/method LockMethod.java
MkcolMethod.java PropFindMethod.java PutMethod.java
UnlockMethod.java
Log:
- Added lock linking (enable lock grouping to unlock or renew
multiple locks at once)
- Added back supportedlock DAV property support
- More code cleanups in PROPFIND
- More locking related work still needs to be done
Revision Changes Path
1.2 +49 -4 jakarta-slide/src/share/org/apache/slide/lock/Lock.java
Index: Lock.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Lock.java 2000/05/09 02:47:25 1.1
+++ Lock.java 2000/09/05 05:38:09 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v 1.1 2000/05/09 02:47:25 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/05/09 02:47:25 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v 1.2 2000/09/05 05:38:09 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/09/05 05:38:09 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Lock helper class.
*
* @author <a href="mailto:remm@exoffice.com">Remy Maucherat</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public interface Lock {
@@ -126,6 +126,28 @@
/**
+ * Removes a set of linked locks.
+ *
+ * @param crendentialsToken Credentials token
+ * @param token Object containing all the lock information
+ * @exception ServiceConnectionFailedException Connection to Lock Store
+ * service failed
+ * @exception ServiceAccessException Low level service access exception
+ * @exception LockTokenNotFoundException Cannot find the Lock in the
+ * Lock Store service
+ * @exception ObjectNotFoundException One of the objects referenced
+ * in the lock token were not found
+ * @exception LinkedObjectNotFoundException Broken link encountered
+ * during object retrieval
+ */
+ void unlock(CredentialsToken credentialsToken, String objectUri,
+ String lockId)
+ throws ServiceConnectionFailedException, ServiceAccessException,
+ LockTokenNotFoundException, ObjectNotFoundException,
+ LinkedObjectNotFoundException;
+
+
+ /**
* Renew a lock.
*
* @param crendentialsToken Credentials token
@@ -141,6 +163,29 @@
Date newExpirationDate)
throws ServiceConnectionFailedException, ServiceAccessException,
LockTokenNotFoundException;
+
+
+ /**
+ * Renew a set of linked locks.
+ *
+ * @param crendentialsToken Credentials token
+ * @param token Object containing the lock info, as well as the new
+ * desired expiration date
+ * @exception ServiceConnectionFailedException Connection to Lock Store
+ * service failed
+ * @exception ServiceAccessException Low level service access exception
+ * @exception LockTokenNotFoundException Cannot find the Lock in the
+ * Lock Store service
+ * @exception ObjectNotFoundException One of the objects referenced
+ * in the lock token were not found
+ * @exception LinkedObjectNotFoundException Broken link encountered
+ * during object retrieval
+ */
+ void renew(CredentialsToken credentialsToken, String objectUri,
+ String lockId, Date newExpirationDate)
+ throws ServiceConnectionFailedException, ServiceAccessException,
+ LockTokenNotFoundException, ObjectNotFoundException,
+ LinkedObjectNotFoundException;
/**
1.3 +66 -4 jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java
Index: LockImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LockImpl.java 2000/05/15 21:14:54 1.2
+++ LockImpl.java 2000/09/05 05:38:09 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v 1.2 2000/05/15 21:14:54 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2000/05/15 21:14:54 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v 1.3 2000/09/05 05:38:09 remm Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/09/05 05:38:09 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Lock helper class.
*
* @author <a href="mailto:remm@exoffice.com">Remy Maucherat</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public final class LockImpl implements Lock {
@@ -188,6 +188,37 @@
/**
+ * Removes a set of linked locks.
+ *
+ * @param crendentialsToken Credentials token
+ * @exception ServiceConnectionFailedException Connection to Lock Store
+ * service failed
+ * @exception ServiceAccessException Low level service access exception
+ * @exception LockTokenNotFoundException Cannot find the Lock in the
+ * Lock Store service
+ * @exception ObjectNotFoundException One of the objects referenced
+ * in the lock token were not found
+ * @exception LinkedObjectNotFoundException Broken link encountered
+ * during object retrieval
+ */
+ public void unlock(CredentialsToken credentialsToken, String objectUri,
+ String lockId)
+ throws ServiceConnectionFailedException, ServiceAccessException,
+ LockTokenNotFoundException, ObjectNotFoundException,
+ LinkedObjectNotFoundException {
+
+ Enumeration locksList = enumerateLocks(credentialsToken, objectUri);
+ while (locksList.hasMoreElements()) {
+ NodeLock currentLock = (NodeLock) locksList.nextElement();
+ if (currentLock.getLockId().equals(lockId)) {
+ unlock(credentialsToken, currentLock);
+ }
+ }
+
+ }
+
+
+ /**
* Renew a lock.
*
* @param crendentialsToken Credentials token
@@ -206,6 +237,37 @@
token.setExpirationDate(newExpirationDate);
Uri lockedUri = namespace.getUri(token.getObjectUri());
lockedUri.getDescriptorsStore().renewLock(lockedUri, token);
+ }
+
+
+ /**
+ * Renew a set of linked locks.
+ *
+ * @param crendentialsToken Credentials token
+ * @exception ServiceConnectionFailedException Connection to Lock Store
+ * service failed
+ * @exception ServiceAccessException Low level service access exception
+ * @exception LockTokenNotFoundException Cannot find the Lock in the
+ * Lock Store service
+ * @exception ObjectNotFoundException One of the objects referenced
+ * in the lock token were not found
+ * @exception LinkedObjectNotFoundException Broken link encountered
+ * during object retrieval
+ */
+ public void renew(CredentialsToken credentialsToken, String objectUri,
+ String lockId, Date newExpirationDate)
+ throws ServiceConnectionFailedException, ServiceAccessException,
+ LockTokenNotFoundException, ObjectNotFoundException,
+ LinkedObjectNotFoundException {
+
+ Enumeration locksList = enumerateLocks(credentialsToken, objectUri);
+ while (locksList.hasMoreElements()) {
+ NodeLock currentLock = (NodeLock) locksList.nextElement();
+ if (currentLock.getLockId().equals(lockId)) {
+ renew(credentialsToken, currentLock, newExpirationDate);
+ }
+ }
+
}
1.2 +17 -4 jakarta-slide/src/share/org/apache/slide/lock/NodeLock.java
Index: NodeLock.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/NodeLock.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NodeLock.java 2000/05/09 02:47:26 1.1
+++ NodeLock.java 2000/09/05 05:38:09 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/NodeLock.java,v 1.1 2000/05/09 02:47:26 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/05/09 02:47:26 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/NodeLock.java,v 1.2 2000/09/05 05:38:09 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/09/05 05:38:09 $
*
* ====================================================================
*
@@ -71,7 +71,7 @@
* NodeLock class.
*
* @author <a href="mailto:remm@exoffice.com">Remy Maucherat</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public final class NodeLock implements Cloneable {
@@ -156,6 +156,19 @@
+ typeUri.hashCode() + "_" + expirationDate.getTime() + "_"
+ (new Date()).getTime();
this.exclusive = exclusive;
+ }
+
+
+ /**
+ * Constructor.
+ * Creates a new lock linked to another given lock.
+ *
+ * @param lock Linked lock
+ */
+ public NodeLock(NodeLock lock, String typeUri) {
+ this(lock.getLockId(), lock.getObjectUri(), lock.getSubjectUri(),
+ typeUri, lock.getExpirationDate(), lock.isInheritable(),
+ lock.isExclusive());
}
1.8 +23 -29 jakarta-slide/src/share/org/apache/slide/webdav/method/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/LockMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LockMethod.java 2000/09/04 23:49:12 1.7
+++ LockMethod.java 2000/09/05 05:38:10 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/LockMethod.java,v 1.7 2000/09/04 23:49:12 remm Exp $
- * $Revision: 1.7 $
- * $Date: 2000/09/04 23:49:12 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/LockMethod.java,v 1.8 2000/09/05 05:38:10 remm Exp $
+ * $Revision: 1.8 $
+ * $Date: 2000/09/05 05:38:10 $
*
* ====================================================================
*
@@ -208,7 +208,6 @@
throws WebdavException {
// Show request
- System.out.println("Request");
if (req.getContentLength() > 0) {
System.out.println(new String(requestBody));
}
@@ -260,21 +259,18 @@
}
}
- System.out.println("OK 1");
-
// For some strange reason, IIS doesn't handle properly
// lock expiration.
- if (isMsProprietarySupport()) {
- lockDuration = MAX_TIMEOUT;
- }
+ /*
+ if (isMsProprietarySupport()) {
+ lockDuration = MAX_TIMEOUT;
+ }
+ */
if (req.getContentLength() > 0) {
- System.out.println("Not OK");
lockType = LOCK_CREATION;
- // Workaround : Castor doesn't work, so I use DOM in the meantime
-
Node lockInfoNode = null;
try {
@@ -412,7 +408,6 @@
}
} else {
- System.out.println("Lock refresh");
lockType = LOCK_REFRESH;
}
@@ -466,33 +461,33 @@
lock.lock(credToken, lockToken);
lockToken = new NodeLock
- (toLockSubject, credentialsSubject,
- namespaceConfig.getModifyRevisionMetadataAction(),
- lockDate, inheritance, exclusive);
+ (lockToken,
+ namespaceConfig.getModifyRevisionMetadataAction()
+ .getUri());
lock.lock(credToken, lockToken);
lockToken = new NodeLock
- (toLockSubject, credentialsSubject,
- namespaceConfig.getRemoveRevisionMetadataAction(),
- lockDate, inheritance, exclusive);
+ (lockToken,
+ namespaceConfig.getRemoveRevisionMetadataAction()
+ .getUri());
lock.lock(credToken, lockToken);
lockToken = new NodeLock
- (toLockSubject, credentialsSubject,
- namespaceConfig.getModifyRevisionContentAction(),
- lockDate, inheritance, exclusive);
+ (lockToken,
+ namespaceConfig.getModifyRevisionContentAction()
+ .getUri());
lock.lock(credToken, lockToken);
lockToken = new NodeLock
- (toLockSubject, credentialsSubject,
- namespaceConfig.getRemoveRevisionContentAction(),
- lockDate, inheritance, exclusive);
+ (lockToken,
+ namespaceConfig.getRemoveRevisionContentAction()
+ .getUri());
lock.lock(credToken, lockToken);
lockToken =
- new NodeLock(toLockSubject, credentialsSubject,
- namespaceConfig.getRemoveObjectAction(),
- lockDate, inheritance, exclusive);
+ new NodeLock(lockToken,
+ namespaceConfig.getRemoveObjectAction()
+ .getUri());
lock.lock(credToken, lockToken);
resp.setStatus(WebdavStatus.SC_OK);
@@ -523,7 +518,6 @@
new Date((new Date()).getTime() + (lockDuration * 1000));
while (lockTokens.hasMoreElements()) {
currentLockToken = (NodeLock) lockTokens.nextElement();
- System.out.println("Renew lock " + currentLockToken);
lock.renew(credToken, currentLockToken, newExpirationDate);
}
1.5 +3 -17 jakarta-slide/src/share/org/apache/slide/webdav/method/MkcolMethod.java
Index: MkcolMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/MkcolMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MkcolMethod.java 2000/09/04 23:49:12 1.4
+++ MkcolMethod.java 2000/09/05 05:38:10 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/MkcolMethod.java,v 1.4 2000/09/04 23:49:12 remm Exp $
- * $Revision: 1.4 $
- * $Date: 2000/09/04 23:49:12 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/MkcolMethod.java,v 1.5 2000/09/05 05:38:10 remm Exp $
+ * $Revision: 1.5 $
+ * $Date: 2000/09/05 05:38:10 $
*
* ====================================================================
*
@@ -173,20 +173,6 @@
// Source
property = new NodeProperty("source", "", true);
revisionDescriptor.setProperty(property);
-
- // Supported locks
- /*
- String supportedLocks = "<d:lockentry>"
- + "<d:lockscope><d:exclusive/></d:lockscope>"
- + "<d:locktype><d:write/></d:locktype>"
- + "</d:lockentry>"
- + "<d:lockentry>"
- + "<d:lockscope><d:shared/></d:lockscope>"
- + "<d:locktype><d:write/></d:locktype>"
- + "</d:lockentry>";
- property = new NodeProperty("suportedlock", supportedLocks, true);
- revisionDescriptor.setProperty(property);
- */
if (isMsProprietarySupport()) {
1.6 +48 -26 jakarta-slide/src/share/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropFindMethod.java 2000/09/04 23:49:12 1.5
+++ PropFindMethod.java 2000/09/05 05:38:10 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PropFindMethod.java,v 1.5 2000/09/04 23:49:12 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2000/09/04 23:49:12 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PropFindMethod.java,v 1.6 2000/09/05 05:38:10 remm Exp $
+ * $Revision: 1.6 $
+ * $Date: 2000/09/05 05:38:10 $
*
* ====================================================================
*
@@ -119,6 +119,19 @@
private static final int FIND_PROPERTY_NAMES = 2;
+ /**
+ * Supported locks property value.
+ */
+ private static final String SUPPORTED_LOCK = "<lockentry>"
+ + "<lockscope><exclusive/></lockscope>"
+ + "<locktype><write/></locktype>"
+ + "</lockentry>"
+ + "<lockentry>"
+ + "<lockscope><shared/></lockscope>"
+ + "<locktype><write/></locktype>"
+ + "</lockentry>";
+
+
// ----------------------------------------------------- Instance Variables
@@ -371,7 +384,6 @@
generatedXML.writeElement(null, "multistatus",
WebdavXMLPrinter.CLOSING);
-
try {
//System.out.println("Query result");
//System.out.println(generatedXML.toString());
@@ -484,7 +496,6 @@
}
Vector propertiesParser = null;
- String supportedLocks = null;
switch (propFindType) {
case FIND_ALL_PROP :
@@ -499,20 +510,24 @@
(WebdavStatus.SC_OK));
// Lock information, which is dynamically generated
-
if (objectLockToken != null) {
showLockDiscoveryInfo(objectLockToken, generatedXML);
}
- // Custom properties
+ // Supported locks
+ generatedXML.writeElement(null, "supportedlock",
+ WebdavXMLPrinter.OPENING);
+ generatedXML.writeText(SUPPORTED_LOCK);
+ generatedXML.writeElement(null, "supportedlock",
+ WebdavXMLPrinter.CLOSING);
+
+ // Other properties
Enumeration propertyList =
revisionDescriptor.enumerateProperties();
while (propertyList.hasMoreElements()) {
NodeProperty currentProperty =
(NodeProperty) propertyList.nextElement();
- //revisionDescriptor.getProperty
- //((String) customPropertiesList.nextElement());
if (currentProperty != null) {
String namespace = currentProperty.getNamespace();
String namespaceAbbrev =
@@ -556,11 +571,11 @@
WebdavXMLPrinter.OPENING);
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.OPENING);
- // First step : find the supported default properties
-
// Lock information
- generatedXML.writeElement(null, "DAV", "lockdiscovery",
+ generatedXML.writeElement(null, "lockdiscovery",
+ WebdavXMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.NO_CONTENT);
// Then, add this resource's custom properties
@@ -605,27 +620,33 @@
Property property = (Property) propertyList.nextElement();
String propertyName = property.name;
String propertyNamespace = property.namespace;
- boolean propertyFound = false;
// Lock information, dynamically generated
- if ((!propertyFound) &&
- (propertyName.equals("lockdiscovery"))) {
- propertyFound = true;
+ if ((propertyName.equals("lockdiscovery")) &&
+ (propertyNamespace.equals
+ (NodeProperty.DEFAULT_NAMESPACE))) {
// Return list of active locks ...
if (objectLockToken != null) {
showLockDiscoveryInfo(objectLockToken, generatedXML);
}
- }
-
- // Search in the custom properties
-
- if (!propertyFound) {
+ } else if ((propertyName.equals("supportedlock")) &&
+ (propertyNamespace.equals
+ (NodeProperty.DEFAULT_NAMESPACE))) {
+ // Supported locks
+ generatedXML.writeElement(null, "supportedlock",
+ WebdavXMLPrinter.OPENING);
+ generatedXML.writeText(SUPPORTED_LOCK);
+ generatedXML.writeElement(null, "supportedlock",
+ WebdavXMLPrinter.CLOSING);
+ } else {
+
+ // Search in the custom properties
+
NodeProperty currentProperty =
revisionDescriptor.getProperty(propertyName,
propertyNamespace);
if (currentProperty != null) {
- propertyFound = true;
Object currentPropertyValue =
currentProperty.getValue();
if ((currentPropertyValue == null) ||
@@ -646,13 +667,11 @@
currentProperty.getName(),
WebdavXMLPrinter.CLOSING);
}
+ } else {
+ propertiesNotFoundVector.addElement(propertyName);
}
}
- if (!propertyFound) {
- propertiesNotFoundVector.addElement(propertyName);
- }
-
}
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.CLOSING);
@@ -730,6 +749,9 @@
}
}
+
+
+ // -------------------------------------------------------- Private Methods
/**
1.5 +3 -18 jakarta-slide/src/share/org/apache/slide/webdav/method/PutMethod.java
Index: PutMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PutMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PutMethod.java 2000/09/04 23:49:12 1.4
+++ PutMethod.java 2000/09/05 05:38:10 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PutMethod.java,v 1.4 2000/09/04 23:49:12 remm Exp $
- * $Revision: 1.4 $
- * $Date: 2000/09/04 23:49:12 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/PutMethod.java,v 1.5 2000/09/05 05:38:10 remm Exp $
+ * $Revision: 1.5 $
+ * $Date: 2000/09/05 05:38:10 $
*
* ====================================================================
*
@@ -215,21 +215,6 @@
// Source
property = new NodeProperty("source", "", true);
revisionDescriptor.setProperty(property);
-
- // Supported locks
- /*
- String supportedLocks = "<d:lockentry>"
- + "<d:lockscope><d:exclusive/></d:lockscope>"
- + "<d:locktype><d:write/></d:locktype>"
- + "</d:lockentry>"
- + "<d:lockentry>"
- + "<d:lockscope><d:shared/></d:lockscope>"
- + "<d:locktype><d:write/></d:locktype>"
- + "</d:lockentry>";
- property = new NodeProperty("supportedlock",
- supportedLocks, true);
- revisionDescriptor.setProperty(property);
- */
// Get content language
property = new NodeProperty("getcontentlanguage", "en", true);
1.3 +7 -4 jakarta-slide/src/share/org/apache/slide/webdav/method/UnlockMethod.java
Index: UnlockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/UnlockMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnlockMethod.java 2000/09/02 03:13:33 1.2
+++ UnlockMethod.java 2000/09/05 05:38:10 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/UnlockMethod.java,v 1.2 2000/09/02 03:13:33 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2000/09/02 03:13:33 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/UnlockMethod.java,v 1.3 2000/09/05 05:38:10 remm Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/09/05 05:38:10 $
*
* ====================================================================
*
@@ -154,6 +154,9 @@
try {
+ lock.unlock(credToken, requestUri, lockId);
+
+ /*
Enumeration lockTokens =
lock.enumerateLocks(credToken, toUnlock);
@@ -194,7 +197,7 @@
}
}
}
-
+ */
resp.setStatus(WebdavStatus.SC_NO_CONTENT);
} catch (SlideException e) {