luetzkendorf 2004/09/17 09:19:17
Modified: src/webdav/server/org/apache/slide/webdav/method
AbstractWebdavMethod.java PropFindMethod.java
src/webdav/server/org/apache/slide/webdav/util
UnlockListenerImpl.java
Log:
fix for bug 31156; merge with release branch
Revision Changes Path
1.48 +13 -27
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
Index: AbstractWebdavMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- AbstractWebdavMethod.java 12 Sep 2004 17:47:50 -0000 1.47
+++ AbstractWebdavMethod.java 17 Sep 2004 16:19:16 -0000 1.48
@@ -45,6 +45,7 @@
import org.apache.commons.transaction.locking.GenericLock;
import org.apache.commons.transaction.locking.MultiLevelLock;
import org.apache.commons.transaction.util.PrintWriterLogger;
+
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.common.Domain;
import org.apache.slide.common.NamespaceAccessToken;
@@ -57,11 +58,9 @@
import org.apache.slide.content.NodeRevisionContent;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
-import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.content.NodeProperty.NamespaceCache;
import org.apache.slide.lock.Lock;
import org.apache.slide.lock.NodeLock;
-import org.apache.slide.lock.UnlockListener;
import org.apache.slide.macro.Macro;
import org.apache.slide.search.Search;
import org.apache.slide.security.Security;
@@ -361,29 +360,16 @@
}
// clear expired lock-tokens
- UnlockListener listener = new UnlockListenerImpl(slideToken, token,
config, req, resp);
+ UnlockListenerImpl listener = new UnlockListenerImpl(slideToken, token,
config, req, resp);
lock.clearExpiredLocks(slideToken, requestUri, listener);
-
- // if the URI has no more locks associated to it and is
- // a lock-null resource, we must attempt to delete it
-
- Enumeration locks = lock.enumerateLocks(slideToken, requestUri);
- if (!locks.hasMoreElements()) {
- try {
- NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slideToken, requestUri);
- NodeRevisionDescriptor revisionDescriptor =
content.retrieve(slideToken, revisionDescriptors);
- if (isLockNull(revisionDescriptor)) {
- content.remove(slideToken, requestUri, revisionDescriptor);
- content.remove(slideToken, revisionDescriptors);
- ObjectNode node = structure.retrieve(slideToken,
requestUri);
- structure.remove(slideToken, node);
- }
- } catch (ObjectNotFoundException onfe) {
- } catch (RevisionDescriptorNotFoundException e) {
- // this happens e.g. if some one tries to create a resource
- // in the history that looks like a version
- // e.g. PUT /history/221/7.1 (cf VcPutVHR)
- }
+
+ if (listener.getUnlockCount() > 0) {
+ // If we have have cleared any lock or any lock-null resource in
+ // the prevois step we commit this changes, otherwise they will
+ // be lost ifexecuteRequest() exits with an exception (e.g.
+ // because of Not Found 404)
+ token.commit();
+ token.begin();
}
executeRequest();
1.106 +15 -4
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- PropFindMethod.java 2 Aug 2004 16:36:01 -0000 1.105
+++ PropFindMethod.java 17 Sep 2004 16:19:16 -0000 1.106
@@ -54,6 +54,7 @@
import org.apache.slide.webdav.util.DeltavConstants;
import org.apache.slide.webdav.util.LabeledRevisionNotFoundException;
import org.apache.slide.webdav.util.PropertyRetrieverImpl;
+import org.apache.slide.webdav.util.UnlockListenerImpl;
import org.apache.slide.webdav.util.VersioningHelper;
import org.apache.slide.webdav.util.WebdavStatus;
import org.apache.slide.webdav.util.WebdavUtils;
@@ -352,7 +353,17 @@
}
while (enum.hasMoreElements()) {
- stackBelow.push(enum.nextElement());
+ // PROPFIND must not list Lock-Null resources that
+ // are timed out
+ ObjectNode node = (ObjectNode)enum.nextElement();
+ UnlockListenerImpl listener = new UnlockListenerImpl(
+ slideToken, token, config, req, resp);
+ try {
+ lock.clearExpiredLocks(slideToken, node.getUri(),
listener);
+ if (!listener.isRemovedLockResource(node.getUri()))
{
+ stackBelow.push(node);
+ }
+ } catch (SlideException e) { /* ignore */}
}
}
1.4 +48 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UnlockListenerImpl.java
Index: UnlockListenerImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UnlockListenerImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UnlockListenerImpl.java 5 Aug 2004 14:43:31 -0000 1.3
+++ UnlockListenerImpl.java 17 Sep 2004 16:19:17 -0000 1.4
@@ -23,6 +23,9 @@
package org.apache.slide.webdav.util;
+import java.util.Enumeration;
+import java.util.HashSet;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -33,7 +36,10 @@
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
+import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.lock.UnlockListener;
+import org.apache.slide.structure.ObjectNotFoundException;
+import org.apache.slide.structure.Structure;
import org.apache.slide.util.Configuration;
import org.apache.slide.webdav.WebdavServletConfig;
import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
@@ -49,6 +55,10 @@
WebdavServletConfig config;
HttpServletRequest req;
HttpServletResponse resp;
+ // counts the locks this listner is called for
+ int unlockCount = 0;
+ // set ot uris that are Lock-Null resources anre removed by this listener
+ HashSet removedLockNullResources = new HashSet();
/**
* Constructor
@@ -77,8 +87,11 @@
* @throws SlideException
*/
public void afterUnlock(String uri) throws SlideException {
+ unlockCount++;
+
// Check whether the resource must be checked-in due to auto-versioning
semantics.
Content content = token.getContentHelper();
+ Structure structure = token.getStructureHelper();
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slideToken, uri);
NodeRevisionDescriptor revisionDescriptor =
@@ -106,6 +119,38 @@
catch (org.jdom.JDOMException e) {}
}
}
+
+ // if the URI has no more locks associated to it and is
+ // a lock-null resource, we must attempt to delete it
+ try {
+ Enumeration locks = token.getLockHelper().enumerateLocks(slideToken,
uri);
+ if (!locks.hasMoreElements() && isLockNull(revisionDescriptor)) {
+ this.removedLockNullResources.add(uri);
+ content.remove(slideToken, uri, revisionDescriptor);
+ content.remove(slideToken, revisionDescriptors);
+ structure.remove(slideToken, structure.retrieve(slideToken, uri));
+ }
+ } catch (ObjectNotFoundException onfe) {
+ } catch (RevisionDescriptorNotFoundException e) {
+ // this happens e.g. if some one tries to create a resource
+ // in the history that looks like a version
+ // e.g. PUT /history/221/7.1 (cf VcPutVHR)
+ }
+ }
+
+ /**
+ * Returns the number on unlocks processed be this listener.
+ */
+ public int getUnlockCount() {
+ return this.unlockCount;
+ }
+ public boolean isRemovedLockResource(String uri) {
+ return this.removedLockNullResources.contains(uri);
+ }
+
+ private boolean isLockNull( NodeRevisionDescriptor nrd ) {
+ return nrd.propertyValueContains(WebdavConstants.P_RESOURCETYPE,
+ WebdavConstants.E_LOCKNULL);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]