jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r752841 - in /jackrabbit/trunk/jackrabbit-webdav/src: main/java/org/apache/jackrabbit/webdav/ main/java/org/apache/jackrabbit/webdav/lock/ test/java/org/apache/jackrabbit/webdav/lock/
Date Thu, 12 Mar 2009 12:17:53 GMT
Author: angela
Date: Thu Mar 12 12:17:52 2009
New Revision: 752841

URL: http://svn.apache.org/viewvc?rev=752841&view=rev
Log:
JCR-2021 - WebDAV: add support for DAV:lockroot

Added:
    jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/
    jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
  (with props)
    jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java?rev=752841&r1=752840&r2=752841&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
Thu Mar 12 12:17:52 2009
@@ -102,6 +102,11 @@
     public static final String XML_LOCKTYPE = "locktype";
     public static final String XML_WRITE = "write";
     public static final String XML_OWNER = "owner";
+    /**
+     * The <code>lockroot</code> XML element
+     * @see <a href="http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockroot">RFC
4818</a>
+     */
+    public static final String XML_LOCKROOT = "lockroot";
 
     //-----------------------------------------------------< Property Names >---
     /*

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java?rev=752841&r1=752840&r2=752841&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
Thu Mar 12 12:17:52 2009
@@ -26,6 +26,22 @@
  */
 public abstract class AbstractActiveLock implements ActiveLock, DavConstants {
 
+    private String lockroot;
+    
+    /**
+     * @see ActiveLock#getLockroot()
+     */
+    public String getLockroot() {
+        return lockroot;
+    }
+
+    /**
+     * @see ActiveLock#setLockroot(String)
+     */
+    public void setLockroot(String lockroot) {
+        this.lockroot = lockroot;
+    }
+
     /**
      * Returns the default Xml representation of the 'activelock' element
      * as defined by RFC 2518.
@@ -58,6 +74,12 @@
             Element lToken = DomUtil.addChildElement(activeLock, XML_LOCKTOKEN, NAMESPACE);
             lToken.appendChild(DomUtil.hrefToXml(getToken(), document));
         }
+
+        // lock root
+        if (getLockroot() != null) {
+            Element lroot = DomUtil.addChildElement(activeLock, XML_LOCKROOT, NAMESPACE);
+            lroot.appendChild(DomUtil.hrefToXml(getLockroot(), document));
+        }
         return activeLock;
     }
 

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java?rev=752841&r1=752840&r2=752841&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
Thu Mar 12 12:17:52 2009
@@ -67,7 +67,7 @@
      * or -1 if the timeout is not available (or the client is not allowed
      * to retrieve it).
      *
-     * @return
+     * @return numer of milliseconds.
      */
     public long getTimeout();
 
@@ -93,6 +93,22 @@
     public void setIsDeep(boolean isDeep);
 
     /**
+     * Returns the lockroot.
+     *
+     * @return lockroot
+     * @see <a href="http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockroot">RFC
4818</a>
+     */
+    public String getLockroot();
+
+    /**
+     * Set the lockroot.
+     *
+     * @param lockroot
+     * @see <a href="http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockroot">RFC
4818</a>
+     */
+    public void setLockroot(String lockroot);
+
+    /**
      * Return the type of this lock.
      *
      * @return type

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java?rev=752841&r1=752840&r2=752841&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
Thu Mar 12 12:17:52 2009
@@ -207,6 +207,19 @@
             throw new UnsupportedOperationException("Not implemented");
         }
 
+        public String getLockroot() {
+            Element root = DomUtil.getChildElement(alElement, XML_LOCKROOT, NAMESPACE);
+            if (root != null) {
+                return DomUtil.getChildTextTrim(root, XML_HREF, NAMESPACE);
+            }
+            // no lockroot element
+            return null;
+        }
+
+        public void setLockroot(String lockroot) {
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
         public Type getType() {
             return Type.createFromXml(DomUtil.getChildElement(alElement, XML_LOCKTYPE, NAMESPACE));
         }

Added: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java?rev=752841&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
Thu Mar 12 12:17:52 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.webdav.lock;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import junit.framework.TestCase;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.util.List;
+
+/**
+ * <code>ActiveLockTest</code>...
+ */
+public class ActiveLockTest extends TestCase {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(ActiveLockTest.class);
+
+    public void testGetLockRoot() {
+        ActiveLock lock = new DefaultActiveLock();
+        lock.setLockroot("lockroot");
+
+        assertEquals("lockroot", lock.getLockroot());
+    }
+
+    public void testParsing() throws ParserConfigurationException {
+        Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
+
+        ActiveLock lock = new DefaultActiveLock();
+        lock.setLockroot("lockroot");
+        lock.setOwner("owner");
+        lock.setIsDeep(true);
+
+        LockDiscovery disc = LockDiscovery.createFromXml(new LockDiscovery(lock).toXml(doc));
+        List l  = (List) disc.getValue();
+
+        assertFalse(l.isEmpty());
+        assertEquals(1, l.size());
+        ActiveLock al = (ActiveLock) l.get(0);
+
+        assertEquals("lockroot", al.getLockroot());
+        assertEquals("owner", al.getOwner());
+        assertTrue(al.isDeep());
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/ActiveLockTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java?rev=752841&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
(added)
+++ jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
Thu Mar 12 12:17:52 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.webdav.lock;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestAll extends TestCase {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("WebDAV lock tests");
+
+        suite.addTestSuite(ActiveLockTest.class);
+        
+        return suite;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/lock/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url



Mime
View raw message