juergen 2002/10/22 23:55:43
Modified: src/webdav/server/org/apache/slide/webdav/util
PropertyHelper.java
Log:
Fixed bug in computeLockDiscovery():
Do not show only the first but all active locks.
(ralf)
Revision Changes Path
1.41 +39 -9
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java
Index: PropertyHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- PropertyHelper.java 15 Oct 2002 10:48:43 -0000 1.40
+++ PropertyHelper.java 23 Oct 2002 06:55:42 -0000 1.41
@@ -1155,14 +1155,20 @@
*/
public XMLValue computeLockDiscovery(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ServiceAccessException, LinkedObjectNotFoundException,
ObjectNotFoundException, LockTokenNotFoundException {
+ XMLValue xmlValue = new XMLValue();
Lock lock = nsaToken.getLockHelper();
NodeLock objectLockToken = null;
Enumeration lockTokens = lock.enumerateLocks(new SlideTokenWrapper(sToken,
false), revisionDescriptors.getUri(), true);
- if (lockTokens.hasMoreElements()) {
+ while (lockTokens.hasMoreElements()) {
+
objectLockToken = (NodeLock) lockTokens.nextElement();
+ Element activelock = createActiveLockElement(objectLockToken,serverURL,
contextPath);
+ if (activelock != null) {
+ xmlValue.add(activelock);
+ }
}
- return computeLockDiscovery(objectLockToken, serverURL, contextPath);
+ return xmlValue;
}
/**
@@ -1183,11 +1189,37 @@
public XMLValue computeLockDiscovery(NodeLock objectLockToken, String
serverURL, String contextPath) {
XMLValue xmlValue = new XMLValue();
+ Element activelock = createActiveLockElement(objectLockToken,serverURL,
contextPath);
+
+ if (activelock != null) {
+ xmlValue.add(activelock);
+ }
+ return xmlValue;
+ }
+
+ /**
+ * Returns the <code><activelock></code> element to be used as child
+ * the <code><lockdiscovery></code> property.
+ *
+ * @param objectLockToken the NodeLock for which to compute the value
+ * of the <code><activelock></code>.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
+ *
+ * @return the <code><activelock></code> element.
+ *
+ */
+ private Element createActiveLockElement(NodeLock objectLockToken, String
serverURL, String contextPath) {
+
+ Element activelock = null;
Security security = nsaToken.getSecurityHelper();
if (objectLockToken != null) {
- Element activelock = new Element(E_ACTIVELOCK,
NamespaceCache.DEFAULT_NAMESPACE);
+ activelock = new Element(E_ACTIVELOCK,
NamespaceCache.DEFAULT_NAMESPACE);
Element locktype = new Element(E_LOCKTYPE,
NamespaceCache.DEFAULT_NAMESPACE);
activelock.addContent(locktype);
Element write = new Element(E_WRITE, NamespaceCache.DEFAULT_NAMESPACE);
@@ -1227,10 +1259,8 @@
Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
locktoken.addContent(href);
href.setText("opaquelocktoken:" + objectLockToken.getLockId());
-
- xmlValue.add(activelock);
}
- return xmlValue;
+ return activelock;
}
/**
--
To unsubscribe, e-mail: <mailto:slide-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@;jakarta.apache.org>