pnever 2003/03/14 07:49:09
Modified: src/share/org/apache/slide/lock Lock.java LockImpl.java
src/webdav/server/org/apache/slide/webdav/method
AbstractWebdavMethod.java
Added: src/share/org/apache/slide/lock UnlockListener.java
src/webdav/server/org/apache/slide/webdav/util
UnlockListenerImpl.java
Log:
Fixed bug reported by Michael Smith. With auto-versioning turned on in
"checkin-unlocked-checkout" mode resources get 'stuck' checked-out when the lock
expires. RFC3253 states that the implicit CHECKIN must occur not only on an explicit
UNLOCK request but also when the lock expires.
Revision Changes Path
1.14 +5 -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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Lock.java 25 Apr 2002 21:30:14 -0000 1.13
+++ Lock.java 14 Mar 2003 15:49:08 -0000 1.14
@@ -323,4 +323,5 @@
boolean tryToLock)
throws ServiceAccessException, ObjectNotFoundException;
+ public void clearExpiredLocks( SlideToken slideToken, String objectUri,
UnlockListener listener ) throws SlideException;
}
1.28 +25 -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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- LockImpl.java 23 Oct 2002 06:54:15 -0000 1.27
+++ LockImpl.java 14 Mar 2003 15:49:08 -0000 1.28
@@ -494,6 +494,27 @@
}
+ public void clearExpiredLocks( SlideToken slideToken, String objectUri,
UnlockListener listener ) throws SlideException {
+
+ Uri uri =
+ namespace.getUri(slideToken, objectUri);
+ Enumeration currentLocks =
+ uri.getStore().enumerateLocks(uri);
+ while (currentLocks.hasMoreElements()) {
+ NodeLock currentLockToken =
+ (NodeLock) currentLocks.nextElement();
+ if (currentLockToken.hasExpired()) {
+ try {
+ uri.getStore().removeLock(uri, currentLockToken);
+ if( listener != null )
+ listener.afterUnlock( objectUri );
+ }
+ catch (LockTokenNotFoundException ex) {
+ // ignore
+ }
+ }
+ }
+ }
// -------------------------------------------------------- Private Methods
1.1
jakarta-slide/src/share/org/apache/slide/lock/UnlockListener.java
Index: UnlockListener.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/lock/UnlockListener.java,v 1.1
2003/03/14 15:49:08 pnever Exp $
* $Revision: 1.1 $
* $Date: 2003/03/14 15:49:08 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 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", "Slide", 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 [EMAIL PROTECTED]
*
* 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.slide.lock;
import org.apache.slide.common.SlideException;
/**
* An UnlockListener may be passed to the Lock helper in order to have more
* control on the unlock operation. The UnlockListener will be notified
* before and after unlocking any single resource.
*
* @version $Revision: 1.1 $
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Nevermann</a>
**/
public interface UnlockListener {
/**
* This method is called before unlocking the resource.
*
* @param uri the uri of the resource that will be unlocked.
* @throws SlideException
*/
public void beforeUnlock( String uri ) throws SlideException;
/**
* This method is called after unlocking the resource.
*
* @param uri the uri of the resource that has been unlocked.
* @throws SlideException
*/
public void afterUnlock( String uri ) throws SlideException;
}
1.7 +42 -30
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractWebdavMethod.java 17 Sep 2002 12:52:55 -0000 1.6
+++ AbstractWebdavMethod.java 14 Mar 2003 15:49:08 -0000 1.7
@@ -63,44 +63,47 @@
package org.apache.slide.webdav.method;
-import java.security.Principal;
+import java.io.IOException;
+import java.io.StringReader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.io.*;
-import java.util.*;
-import java.net.URLDecoder;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-import org.apache.util.URLUtil;
-import org.apache.util.MD5Encoder;
-import org.apache.util.WebdavStatus;
-import org.apache.slide.common.*;
-import org.apache.slide.authenticate.*;
-import org.apache.slide.structure.*;
-import org.apache.slide.content.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.slide.common.NamespaceAccessToken;
+import org.apache.slide.common.ServiceAccessException;
+import org.apache.slide.common.SlideException;
+import org.apache.slide.common.SlideToken;
+import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty.NamespaceCache;
-import org.apache.slide.lock.*;
-import org.apache.slide.search.*;
-import org.apache.slide.macro.*;
-import org.apache.slide.security.*;
+import org.apache.slide.content.NodeRevisionContent;
+import org.apache.slide.lock.Lock;
+import org.apache.slide.lock.ObjectLockedException;
+import org.apache.slide.lock.UnlockListener;
+import org.apache.slide.macro.ConflictException;
+import org.apache.slide.macro.ForbiddenException;
+import org.apache.slide.macro.Macro;
+import org.apache.slide.search.Search;
+import org.apache.slide.security.AccessDeniedException;
+import org.apache.slide.security.Security;
+import org.apache.slide.structure.ObjectAlreadyExistsException;
+import org.apache.slide.structure.ObjectNotFoundException;
+import org.apache.slide.structure.Structure;
import org.apache.slide.util.Messages;
-import org.apache.slide.webdav.*;
-import org.apache.slide.webdav.util.WebdavUtils;
+import org.apache.slide.util.logger.Logger;
+import org.apache.slide.webdav.WebdavException;
+import org.apache.slide.webdav.WebdavMethod;
+import org.apache.slide.webdav.WebdavServletConfig;
import org.apache.slide.webdav.util.PreconditionViolationException;
+import org.apache.slide.webdav.util.UnlockListenerImpl;
import org.apache.slide.webdav.util.ViolatedPrecondition;
import org.apache.slide.webdav.util.WebdavConstants;
-import org.apache.slide.webdav.util.DeltavConstants;
-
-import org.apache.slide.util.logger.Logger;
-
+import org.apache.slide.webdav.util.WebdavUtils;
+import org.apache.util.MD5Encoder;
+import org.apache.util.WebdavStatus;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
-
import org.jdom.input.SAXBuilder;
-
import org.jdom.output.XMLOutputter;
/**
@@ -321,6 +324,15 @@
token.begin();
transactionIsStarted = true;
}
+
+ // clear expired lock-tokens
+ try {
+ UnlockListener listener =
+ new UnlockListenerImpl( slideToken, token, config, req, resp );
+ lock.clearExpiredLocks( slideToken, requestUri, listener );
+ }
+ catch (SlideException e) {}
+
executeRequest();
if (methodNeedsTransactionSupport()) {
token.commit();
1.1
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UnlockListenerImpl.java
Index: UnlockListenerImpl.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UnlockListenerImpl.java,v
1.1 2003/03/14 15:49:09 pnever Exp $
* $Revision: 1.1 $
* $Date: 2003/03/14 15:49:09 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 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", "Slide", 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 [EMAIL PROTECTED]
*
* 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.slide.webdav.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.SlideException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.lock.UnlockListener;
import org.apache.slide.util.Configuration;
import org.apache.slide.webdav.WebdavServletConfig;
import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
import org.apache.slide.webdav.util.resourcekind.CheckedOutVersionControlled;
import org.apache.slide.webdav.util.resourcekind.ResourceKind;
/**
* Implements UnlockListener
*/
public class UnlockListenerImpl implements UnlockListener {
SlideToken slideToken;
NamespaceAccessToken token;
WebdavServletConfig config;
HttpServletRequest req;
HttpServletResponse resp;
/**
* Constructor
*/
public UnlockListenerImpl( SlideToken slideToken, NamespaceAccessToken token,
WebdavServletConfig config, HttpServletRequest req, HttpServletResponse resp ) {
this.slideToken = slideToken;
this.token = token;
this.config = config;
this.req = req;
this.resp = resp;
}
/**
* This method is called before unlocking the resource.
*
* @param uri the uri of the resource that will be unlocked.
* @throws SlideException
*/
public void beforeUnlock(String uri) throws SlideException {
}
/**
* This method is called after unlocking the resource.
*
* @param uri the uri of the resource that has been unlocked.
* @throws SlideException
*/
public void afterUnlock(String uri) throws SlideException {
// Check whether the resource must be checked-in due to auto-versioning
semantics.
Content content = token.getContentHelper();
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slideToken, uri);
NodeRevisionDescriptor revisionDescriptor =
content.retrieve(slideToken, revisionDescriptors);
ResourceKind resourceKind =
AbstractResourceKind.determineResourceKind(token, uri, revisionDescriptor);
if( Configuration.useVersionControl() &&
(resourceKind instanceof CheckedOutVersionControlled) ) {
NodeProperty checkinLocktokenProperty =
revisionDescriptor.getProperty(DeltavConstants.I_CHECKIN_LOCKTOKEN,
NodeProperty.NamespaceCache.SLIDE_URI);
if (checkinLocktokenProperty == null) {
// retry with default (DAV:) namespace which was the
// former namespace of this property
checkinLocktokenProperty =
revisionDescriptor.getProperty(DeltavConstants.I_CHECKIN_LOCKTOKEN);
}
if ( (checkinLocktokenProperty != null) &&
(checkinLocktokenProperty.getValue() != null)
// &&
slideToken.checkLockToken(checkinLocktokenProperty.getValue().toString())
) {
VersioningHelper versionHelper =
VersioningHelper.getVersioningHelper(slideToken, token, req, resp, config);
try {
versionHelper.checkin(revisionDescriptors, revisionDescriptor,
false, false, true);
}
catch (java.io.IOException e) {}
catch (org.jdom.JDOMException e) {}
}
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]