cmlenz 01/09/08 12:50:37
Modified: src/share/org/apache/slide/lock Lock.java LockImpl.java
Log:
- added new Lock.enumerateLocks() variant with an added boolean 'inherited'
parameter, that lets you exclude locks inherited from parent subjects.
- updated the implementation to reflect that change
Revision Changes Path
1.10 +40 -10 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Lock.java 2001/05/16 12:04:46 1.9
+++ Lock.java 2001/09/08 19:50:37 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v 1.9
2001/05/16 12:04:46 juergen Exp $
- * $Revision: 1.9 $
- * $Date: 2001/05/16 12:04:46 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v
1.10 2001/09/08 19:50:37 cmlenz Exp $
+ * $Revision: 1.10 $
+ * $Date: 2001/09/08 19:50:37 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Lock helper class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public interface Lock {
@@ -186,16 +186,46 @@
/**
- * Enumerate locks on a subject.
+ * Enumerate locks on a subject, including any locks inherited from parent
+ * subjects.
*
- * @param slideToken Credentials token
- * @param objectUri Object on which we want to enumerate locks
- * @exception ServiceAccessException Low level service access exception
- * @exception ObjectNotFoundException One of the objects referenced in
- * the lock token were not found
+ * @param slideToken the slide token
+ * @param objectUri the URI of the object of which we want to enumerate
+ * active locks
+ *
+ * @return an Enumeration of NodeLock objects
+ *
+ * @exception ServiceAccessException low level service access exception
+ * @exception ObjectNotFoundException one of the objects referenced in
+ * the lock token were not found
*/
Enumeration enumerateLocks(SlideToken slideToken,
String objectUri)
+ throws ServiceAccessException, ObjectNotFoundException,
+ LockTokenNotFoundException;
+
+
+ /**
+ * Enumerate locks on a subject, optionally excluding locks inherited
+ * from parent subjects.
+ *
+ * @param slideToken the slide token
+ * @param objectUri the URI of the object of which we want to enumerate
+ * active locks
+ * @param inherited if true, locks inherited from parent objects will be
+ * included in the result, otherwise, only locks that
+ * explicitly lock the object will be returned
+ *
+ * @return an Enumeration of NodeLock objects
+ *
+ * @exception ServiceAccessException low level service access exception
+ * @exception ObjectNotFoundException one of the objects referenced in
+ * the lock token were not found
+ * @exception LockTokenNotFoundException cannot find the lock in the
+ * lock store service
+ */
+ Enumeration enumerateLocks(SlideToken slideToken, String objectUri,
+ boolean inherited)
throws ServiceAccessException, ObjectNotFoundException,
LockTokenNotFoundException;
1.18 +40 -34 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- LockImpl.java 2001/07/24 06:42:20 1.17
+++ LockImpl.java 2001/09/08 19:50:37 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v
1.17 2001/07/24 06:42:20 remm Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/24 06:42:20 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v
1.18 2001/09/08 19:50:37 cmlenz Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/09/08 19:50:37 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Lock helper class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.17 $
+ * @version $Revision: 1.18 $
*/
public final class LockImpl implements Lock {
@@ -306,44 +306,50 @@
}
- /**
- * Enumerate locks on a subject.
- *
- * @param slideToken Credentials token
- * @param objectUri Object on which we want to enumerate locks
- * @exception ServiceAccessException Low level service access exception
- * @exception ObjectNotFoundException One of the objects referenced
- * in the lock token were not found
- */
- public Enumeration enumerateLocks(SlideToken slideToken,
- String objectUri)
+ public Enumeration enumerateLocks(SlideToken slideToken, String objectUri)
throws ServiceAccessException, ObjectNotFoundException,
LockTokenNotFoundException {
- // We retrieve the LockStore service from the namespace.
- Vector locksVector = new Vector();
+ return enumerateLocks(slideToken, objectUri, false);
+ }
+
+
+ public Enumeration enumerateLocks(SlideToken slideToken, String objectUri,
+ boolean inherited)
+ throws ServiceAccessException, ObjectNotFoundException,
+ LockTokenNotFoundException {
+
+ // We retrieve the LockStore service from the namespace.
Uri subjectUri = namespace.getUri(slideToken, objectUri);
- Enumeration scopes = subjectUri.getScopes();
- while (scopes.hasMoreElements()) {
- String currentScope = (String) scopes.nextElement();
- Uri currentScopeUri = namespace.getUri(slideToken, currentScope);
- Enumeration currentLocks =
- currentScopeUri.getStore()
- .enumerateLocks(currentScopeUri);
- while (currentLocks.hasMoreElements()) {
- NodeLock currentLockToken =
- (NodeLock) currentLocks.nextElement();
- if (currentLockToken.hasExpired()) {
- currentScopeUri.getStore()
- .removeLock(currentScopeUri, currentLockToken);
- } else {
- locksVector.addElement(currentLockToken);
+ if (inherited) {
+ // traverse the namespace up to the root node, and add any locks
+ // found in the process
+ Vector locksVector = new Vector();
+ Enumeration scopes = subjectUri.getScopes();
+ while (scopes.hasMoreElements()) {
+ String currentScope = (String) scopes.nextElement();
+ Uri currentScopeUri =
+ namespace.getUri(slideToken, currentScope);
+ Enumeration currentLocks =
+ currentScopeUri.getStore().enumerateLocks(currentScopeUri);
+ while (currentLocks.hasMoreElements()) {
+ NodeLock currentLockToken =
+ (NodeLock) currentLocks.nextElement();
+ if (currentLockToken.hasExpired()) {
+ currentScopeUri.getStore()
+ .removeLock(currentScopeUri, currentLockToken);
+ } else {
+ locksVector.addElement(currentLockToken);
+ }
}
}
+ return locksVector.elements();
+ } else {
+ // only return the locks that explicitly and directly lock the
+ // given subject
+ return subjectUri.getStore().enumerateLocks(subjectUri);
}
-
- return locksVector.elements();
}