jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r812570 [20/24] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/ jackrabbit-api/src/main/appended-resources/ jackrabbit-api/src/main/appended-resources/META-INF/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabb...
Date Tue, 08 Sep 2009 16:09:45 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java Tue Sep  8 16:09:28 2009
@@ -71,7 +71,7 @@
     /**
      * Tests the method <code>NodeIterator.getPosition()</code>.
      */
-    public void testGetPosition() throws RepositoryException {
+    public void testGetPosition() throws RepositoryException, NotExecutableException {
         QueryResult rs = execute(xpathRoot + "//*", Query.XPATH);
 
         // getPosition initially returns 0
@@ -89,8 +89,9 @@
     /**
      * Tests the method <code>NodeIterator.getPosition()</code> on an empty
      * <code>NodeIterator</code>.
+     * @throws NotExecutableException 
      */
-    public void testGetPositionEmptyIterator() throws RepositoryException {
+    public void testGetPositionEmptyIterator() throws RepositoryException, NotExecutableException {
         QueryResult rs = execute(xpathRoot + "/" + nodeName4, Query.XPATH);
 
         NodeIterator it = rs.getNodes();
@@ -103,8 +104,9 @@
      * Tests if a {@link java.util.NoSuchElementException} is thrown when {@link
      * javax.jcr.NodeIterator#nextNode()} is called and there are no more nodes
      * available.
+     * @throws NotExecutableException 
      */
-    public void testNoSuchElementException() throws RepositoryException {
+    public void testNoSuchElementException() throws RepositoryException, NotExecutableException {
         NodeIterator it = execute(xpathRoot + "//*", Query.XPATH).getNodes();
         while (it.hasNext()) {
             it.nextNode();
@@ -119,8 +121,9 @@
 
     /**
      * Tests if {@link javax.jcr.NodeIterator#skip(long)} works correctly.
+     * @throws NotExecutableException 
      */
-    public void testSkip() throws RepositoryException {
+    public void testSkip() throws RepositoryException, NotExecutableException {
         String query = xpathRoot + "//*";
         QueryResult rs = execute(query, Query.XPATH);
         NodeIterator it = rs.getNodes();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java Tue Sep  8 16:09:28 2009
@@ -66,7 +66,7 @@
         String queryStatement = "select * from " + nodeTypeName;
 
         // execute the search query
-        Query query = session.getWorkspace().getQueryManager().createQuery(queryStatement, Query.SQL);
+        Query query = super.createQuery(queryStatement, Query.SQL);
         QueryResult result = query.execute();
 
         assertTrue("jcr:path must be present in query result row",

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java Tue Sep  8 16:09:28 2009
@@ -110,7 +110,8 @@
             throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         ensureMixinType(n1, mixReferenceable);
-        Node n2 = testRootNode.addNode(nodeName2, ntBase);
+        String nodetype = testNodeTypeNoChildren == null ? ntBase : testNodeTypeNoChildren;
+        Node n2 = testRootNode.addNode(nodeName2, nodetype);
         ensureMixinType(n2, mixReferenceable);
         testRootNode.save();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java Tue Sep  8 16:09:28 2009
@@ -21,6 +21,9 @@
 import javax.jcr.NodeIterator;
 import javax.jcr.Session;
 import javax.jcr.util.TraversingItemVisitor;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -66,8 +69,9 @@
 
     /**
      * Tests if &lt;somepath>/% returns the descendants of &lt;somepath>.
+     * @throws NotExecutableException 
      */
-    public void testDescendantTestRoot() throws RepositoryException {
+    public void testDescendantTestRoot() throws RepositoryException, NotExecutableException {
         String sql = getStatement(testRoot + "/%");
         executeSqlQuery(session, sql, getDescendants(testRootNode));
     }
@@ -75,8 +79,9 @@
     /**
      * Tests if &lt;somepath>/% returns no nodes if node at &lt;somepath>
      * is a leaf.
+     * @throws NotExecutableException 
      */
-    public void testDescendantLeaf() throws RepositoryException {
+    public void testDescendantLeaf() throws RepositoryException, NotExecutableException {
         // find leaf
         Node leaf = testRootNode;
         while (leaf.hasNodes()) {
@@ -90,8 +95,9 @@
      * Tests if &lt;somepath>/%/&lt;nodename> OR &lt;somepath>/&lt;nodename>
      * returns nodes with name &lt;nodename> which are descendants of
      * node at <code>testroot</code>.
+     * @throws NotExecutableException 
      */
-    public void testDescendantSelfTestRoot() throws RepositoryException {
+    public void testDescendantSelfTestRoot() throws RepositoryException, NotExecutableException {
         // get first node which is two levels deeper than node at testroot
         Node n = null;
         for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
@@ -118,8 +124,9 @@
 
     /**
      * Tests if /% AND NOT /%/% returns the child nodes of the root node.
+     * @throws NotExecutableException 
      */
-    public void testChildAxisRoot() throws RepositoryException {
+    public void testChildAxisRoot() throws RepositoryException, NotExecutableException {
         String sql = getStatement("/%");
         sql += " AND NOT " + jcrPath + " LIKE '/%/%'";
         Node[] nodes = toArray(session.getRootNode().getNodes());
@@ -129,8 +136,9 @@
     /**
      * Tests if &lt;somepath>/% AND NOT &lt;somepath>/%/% returns the child
      * nodes of node at &lt;somepath>.
+     * @throws NotExecutableException 
      */
-    public void testChildAxisTestRoot() throws RepositoryException {
+    public void testChildAxisTestRoot() throws RepositoryException, NotExecutableException {
         String sql = getStatement(testRoot + "/%");
         sql += " AND NOT " + jcrPath + " LIKE '" + testRoot + "/%/%'";
         Node[] nodes = toArray(testRootNode.getNodes());
@@ -140,8 +148,9 @@
     /**
      * Tests if &lt;somepath>/% AND NOT &lt;somepath>/%/% returns no nodes
      * if the node at &lt;somepath> is a leaf.
+     * @throws NotExecutableException 
      */
-    public void testChildAxisLeaf() throws RepositoryException {
+    public void testChildAxisLeaf() throws RepositoryException, NotExecutableException {
         // find leaf
         Node leaf = testRootNode;
         while (leaf.hasNodes()) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java Tue Sep  8 16:09:28 2009
@@ -59,8 +59,9 @@
 
     /**
      * Tests if text() node test is equivalent with jcr:xmltext.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTest() throws RepositoryException {
+    public void testTextNodeTest() throws RepositoryException, NotExecutableException {
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "foo");
         testRootNode.save();
@@ -71,8 +72,9 @@
     /**
      * Tests if text() node test is equivalent with jcr:xmltext and will select
      * multiple nodes with name jcr:xmltext.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTestMultiNodes() throws RepositoryException {
+    public void testTextNodeTestMultiNodes() throws RepositoryException, NotExecutableException {
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "foo");
         Node text2 = testRootNode.addNode(nodeName1, testNodeType).addNode(jcrXMLText);
@@ -85,8 +87,9 @@
     /**
      * Tests if text() node test is equivalent with jcr:xmltext and jcr:contains
      * matches content in jcr:xmlcharacters property.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTestContains() throws RepositoryException {
+    public void testTextNodeTestContains() throws RepositoryException, NotExecutableException {
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "the quick brown fox jumps over the lazy dog.");
         Node text2 = testRootNode.addNode(nodeName1, testNodeType).addNode(jcrXMLText);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java Tue Sep  8 16:09:28 2009
@@ -144,7 +144,7 @@
         }
         try {
             String stmt = "SELECT * FROM [" + testNodeType + "] AS s " +
-                    "WHERE NAME(s) = " + literal.getString();
+                    "WHERE NAME(s) = CAST(" + literal.getString() + " AS LONG)";
             qm.createQuery(stmt, Query.JCR_SQL2).execute();
             fail("NAME() comparison with LONG must fail with InvalidQueryException");
         } catch (InvalidQueryException e) {
@@ -162,7 +162,7 @@
         }
         try {
             String stmt = "SELECT * FROM [" + testNodeType + "] AS s " +
-                    "WHERE NAME(s) = " + literal.getString();
+                    "WHERE NAME(s) = CAST(" + literal.getString() + " AS BOOLEAN)";
             qm.createQuery(stmt, Query.JCR_SQL2).execute();
             fail("NAME() comparison with BOOLEAN must fail with InvalidQueryException");
         } catch (InvalidQueryException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java Tue Sep  8 16:09:28 2009
@@ -40,7 +40,12 @@
 
         super.setUp();
 
-        retentionMgr = getRetentionManager(superuser);
+        try {
+            retentionMgr = getRetentionManager(superuser);
+        } catch (NotExecutableException e) {
+            cleanUp();
+            throw e;
+        }
         testNodePath = testRootNode.getPath();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java Tue Sep  8 16:09:28 2009
@@ -37,7 +37,12 @@
         checkSupportedOption(Repository.OPTION_ACCESS_CONTROL_SUPPORTED);
         
         super.setUp();
-        acMgr = getAccessControlManager(superuser);
+        try {
+            acMgr = getAccessControlManager(superuser);
+        } catch (NotExecutableException e) {
+            cleanUp();
+            throw e;
+        }
     }
 
     protected static AccessControlManager getAccessControlManager(Session s) throws RepositoryException, NotExecutableException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java Tue Sep  8 16:09:28 2009
@@ -98,7 +98,9 @@
     protected void tearDown() throws Exception {
         // remove versionable nodes
         try {
-            versionableNode.remove();
+            if (versionableNode != null) {
+                versionableNode.remove();
+            }
             testRootNode.getSession().save();
         } catch (Exception e) {
             log.println("Exception in tearDown: " + e.toString());

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java Tue Sep  8 16:09:28 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.VersionManager;
 
@@ -106,8 +107,13 @@
             assertTrue("path for activity must be below " + PREFIX + ", but was " + an.getPath(), an.getPath().startsWith(PREFIX));
 
             Node activities = superuser.getNode(PREFIX);
-            
-            assertFalse(activities.getPrimaryNodeType().canAddChildNode("foobar"));
+
+            try {
+                activities.addNode("foobar");
+                fail("/jcr:system/jcr:activities must be protected.");
+            } catch (RepositoryException e) {
+                // ok
+            }
         }
         finally {
             if (an != null) {
@@ -147,6 +153,6 @@
             }
         }
     }
-    
+
 }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java Tue Sep  8 16:09:28 2009
@@ -30,6 +30,7 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.NodeIterator;
+import javax.jcr.Session;
 
 /**
  * <code>RestoreTest</code> covers tests related to the restore methods available
@@ -150,7 +151,7 @@
      */
     public void testRestoreOnCheckedInNodeJcr2_2() throws RepositoryException {
         versionManager.checkin(versionableNode.getPath());
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
     }
 
     /**
@@ -197,7 +198,7 @@
      * @throws RepositoryException
      */
     public void testRestoreOnCheckedOutNodeJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
     }
 
     /**
@@ -244,7 +245,7 @@
      * @throws RepositoryException
      */
     public void testRestoreSetsIsCheckedOutToFalseJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
     }
 
@@ -296,7 +297,7 @@
      * @throws RepositoryException
      */
     public void testRestoreCorrectPropertyJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         String value = versionableNode.getProperty(propertyName1).getString();
         assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
     }
@@ -351,7 +352,7 @@
      * @throws javax.jcr.RepositoryException
      */
     public void testRestoreSetsBaseVersionJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         Version baseV = versionManager.getBaseVersion(versionableNode.getPath());
         assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV));
     }
@@ -421,7 +422,7 @@
         // modify node without calling save()
         try {
             versionableNode.setProperty(propertyName1, propertyValue);
-            versionManager.restore(versionableNode.getPath(), version, true);
+            versionManager.restore(version, true);
 
             fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
         } catch (InvalidItemStateException e) {
@@ -570,21 +571,6 @@
      * @throws RepositoryException
      * @see Node#restore(String, boolean)
      */
-    public void testRestoreNonVersionableNodeJcr2() throws RepositoryException {
-        try {
-            versionManager.restore(nonVersionableNode.getPath(), version, true);
-            fail("trying to restore on a non versionable node must throw UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException e) {
-            //success
-        }
-    }
-
-    /**
-     * Test restoring on a non-versionable node.
-     *
-     * @throws RepositoryException
-     * @see Node#restore(String, boolean)
-     */
     public void testRestoreNonVersionableNodeJcr2_2() throws RepositoryException {
         try {
             versionManager.restore(nonVersionableNode.getPath(), "foo", true);
@@ -632,21 +618,6 @@
      * @throws RepositoryException
      * @see Node#restore(Version, boolean)
      */
-    public void testRestoreNonVersionableNode3Jcr2() throws RepositoryException {
-        try {
-            versionManager.restore(nonVersionableNode.getPath(), version, true);
-            fail("Node.restore(Version, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException e) {
-            //success
-        }
-    }
-
-    /**
-     * Test restoring on a non-versionable node.
-     *
-     * @throws RepositoryException
-     * @see Node#restore(Version, boolean)
-     */
     public void testRestoreNonVersionableNode3Jcr2_2() throws RepositoryException {
         try {
             versionManager.restore(nonVersionableNode.getPath(), version.getName(), true);
@@ -753,7 +724,7 @@
             versionManager.checkout(versionableNode.getPath());
             superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
             superuser.save();
-            versionManager.restore(versionableNode.getPath(), v, false);
+            versionManager.restore(v, false);
 
             fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
         } catch (ItemExistsException e) {
@@ -831,6 +802,37 @@
         }
     }
 
+    public void testRestoreRemoved() throws RepositoryException {
+        Node parent = versionableNode.getParent();
+        String oldName = versionableNode.getName();
+        Version v1 = versionableNode.checkin();
+        versionableNode.remove();
+        versionableNode = null;
+        parent.getSession().save();
+
+        parent.restore(v1, oldName, true);
+
+        versionableNode = parent.getNode(oldName);
+
+        String value = versionableNode.getProperty(propertyName1).getString();
+        assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
+    }
+
+    public void testRestoreRemovedJcr2() throws RepositoryException {
+        String path = versionableNode.getPath();
+        Version v1 = versionManager.checkin(path);
+        versionableNode.remove();
+        versionableNode = null;
+        superuser.save();
+
+        versionManager.restore(path, v1, true);
+
+        versionableNode = superuser.getNode(path);
+
+        String value = versionableNode.getProperty(propertyName1).getString();
+        assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
+    }
+
     public void testRestoreChild1Jcr2() throws RepositoryException {
         versionableNode.addNode("child1");
         versionableNode.getSession().save();
@@ -858,14 +860,14 @@
         versionManager.checkout(versionableNode.getPath());
         Version v2 = versionManager.checkin(versionableNode.getPath());
 
-        versionManager.restore(versionableNode.getPath(), v1, true);
+        versionManager.restore(v1, true);
         assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
 
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
 
         try {
-            versionManager.restore(versionableNode.getPath(), v2, true);
+            versionManager.restore(v2, true);
         } catch (RepositoryException e) {
             fail("Node.restore('1.3') must fail.");
         }
@@ -973,10 +975,21 @@
         child1 = versionableNode.getNode(nodeName4);
         assertEquals("Node.restore('test') must restore child node version 1.0.", v1Child.getName(), child1.getBaseVersion().getName());
 
+        // JSR283 is more clear about restoring versionable OPV=VERSION nodes
+        // and states that an existing one is not restored when the parent
+        // is restored (see 15.7.5 Chained Versions on Restore)
+
+        // Old JSR170 version:
         // restore V2 via name. child should be 1.1
+        // versionableNode.restore(v2, true);
+        // child1 = versionableNode.getNode(nodeName4);
+        // assertEquals("Node.restore('foo') must restore child node version 1.1.", v11Child.getName(), child1.getBaseVersion().getName());
+
+        // New JSR283 version:
+        // restore V2 via name. child should still be be 1.0
         versionableNode.restore(v2, true);
         child1 = versionableNode.getNode(nodeName4);
-        assertEquals("Node.restore('foo') must restore child node version 1.1.", v11Child.getName(), child1.getBaseVersion().getName());
+        assertEquals("Node.restore('foo') must not restore child node and keep version 1.0.", v1Child.getName(), child1.getBaseVersion().getName());
     }
 
     /**
@@ -1129,7 +1142,7 @@
         versionManager.checkout(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();
@@ -1334,7 +1347,7 @@
         versionManager.checkin(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();
@@ -1375,7 +1388,7 @@
         versionManager.checkin(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/TestAll.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/TestAll.java Tue Sep  8 16:09:28 2009
@@ -64,12 +64,15 @@
         suite.addTestSuite(MergeDoneMergeTest.class);
         suite.addTestSuite(MergeNodeIteratorTest.class);
         suite.addTestSuite(MergeNodeTest.class);
+        suite.addTestSuite(MergeShallowTest.class);
+        suite.addTestSuite(MergeActivityTest.class);
         suite.addTestSuite(MergeNonVersionableSubNodeTest.class);
         suite.addTestSuite(MergeSubNodeTest.class);
         
         // JCR 2.0
 
         suite.addTestSuite(ActivitiesTest.class);
+        suite.addTestSuite(ConfigurationsTest.class);
 
         return suite;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java Tue Sep  8 16:09:28 2009
@@ -999,11 +999,6 @@
             fail("VersionHistory.restore(String,boolean) did not throw an UnsupportedRepositoryOperationException");
         } catch (UnsupportedRepositoryOperationException success) {
         }
-        try {
-            versionManager.restore(vHistory.getPath(), version, true);
-            fail("VersionHistory.restore(Version,boolean) did not throw an UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException success) {
-        }
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java Tue Sep  8 16:09:28 2009
@@ -747,11 +747,6 @@
             fail("Version.restore(String,boolean) did not throw an UnsupportedRepositoryOperationException");
         } catch (UnsupportedRepositoryOperationException success) {
         }
-        try {
-            versionManager.restore(version.getPath(), version2, true);
-            fail("Version.restore(Version,boolean) did not throw an UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException success) {
-        }
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java Tue Sep  8 16:09:28 2009
@@ -36,9 +36,14 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
-        String path = versionableNode.getPath();
-        versionManager.checkout(path);
+        try {
+            VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+            String path = versionableNode.getPath();
+            versionManager.checkout(path);
+        } catch (RepositoryException e) {
+            cleanUp();
+            throw e;
+        }
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java Tue Sep  8 16:09:28 2009
@@ -45,8 +45,13 @@
          if (!versionableNode.isCheckedOut()) {
              fail("A versionable node must be checked-out after persistent creation.");
          }
-         versionManager.checkin(path);
-     }
+        try {
+            versionManager.checkin(path);
+        } catch (RepositoryException e) {
+            cleanUp();
+            throw e;
+        }
+    }
 
      /**
       * Test if Node.isCheckedOut() returns true, if the versionable node has

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java Tue Sep  8 16:09:28 2009
@@ -37,9 +37,14 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
-        String path = versionableNode.getPath();
-        versionManager.checkout(path);
+        try {
+            VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+            String path = versionableNode.getPath();
+            versionManager.checkout(path);
+        } catch (RepositoryException e) {
+            cleanUp();
+            throw e;
+        }
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java Tue Sep  8 16:09:28 2009
@@ -60,19 +60,24 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
-        String path = versionableNode.getPath();
-        propertyValue1 = getProperty("propertyValue1");
-        propertyValue2 = getProperty("propertyValue2");
-        versionableNode.setProperty(propertyName1, propertyValue1);
-        versionableNode.getSession().save();
-        version = versionManager.checkin(path);
-        versionManager.checkout(path);
-        versionableNode.setProperty(propertyName1, propertyValue2);
-        versionableNode.getSession().save();
-        version2 = versionManager.checkin(path);
-        versionManager.checkout(path);
-        rootVersion = versionManager.getVersionHistory(path).getRootVersion();
+        try {
+            versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+            String path = versionableNode.getPath();
+            propertyValue1 = getProperty("propertyValue1");
+            propertyValue2 = getProperty("propertyValue2");
+            versionableNode.setProperty(propertyName1, propertyValue1);
+            versionableNode.getSession().save();
+            version = versionManager.checkin(path);
+            versionManager.checkout(path);
+            versionableNode.setProperty(propertyName1, propertyValue2);
+            versionableNode.getSession().save();
+            version2 = versionManager.checkin(path);
+            versionManager.checkout(path);
+            rootVersion = versionManager.getVersionHistory(path).getRootVersion();
+        } catch (RepositoryException e) {
+            cleanUp();
+            fail("Failed to setup test: " + e.getMessage());
+        }
 
         // build a second versionable node below the testroot
         try {
@@ -150,7 +155,13 @@
      */
     public void testRestoreOnCheckedInNodeJcr2_2() throws RepositoryException {
         versionManager.checkin(versionableNode.getPath());
-        versionManager.restore(versionableNode.getPath(), version, true);
+        try {
+            versionManager.restore(versionableNode.getPath(), version, true);
+            fail("VersionManager.restore(String, Version, boolean) must fail on existing nodes.");
+        } catch (RepositoryException e) {
+            // ok
+        }
+        versionManager.restore(version, true);
     }
 
     /**
@@ -197,7 +208,13 @@
      * @throws RepositoryException
      */
     public void testRestoreOnCheckedOutNodeJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        try {
+            versionManager.restore(versionableNode.getPath(), version, true);
+            fail("VersionManager.restore(String, Version, boolean) must fail on existing nodes.");
+        } catch (RepositoryException e) {
+            // ok
+        }
+        versionManager.restore(version, true);
     }
 
     /**
@@ -244,7 +261,13 @@
      * @throws RepositoryException
      */
     public void testRestoreSetsIsCheckedOutToFalseJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        try {
+            versionManager.restore(versionableNode.getPath(), version, true);
+            fail("VersionManager.restore(String, Version, boolean) must fail on existing nodes.");
+        } catch (RepositoryException e) {
+            // ok
+        }
+        versionManager.restore(version, true);
         assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
     }
 
@@ -296,7 +319,13 @@
      * @throws RepositoryException
      */
     public void testRestoreCorrectPropertyJcr2_2() throws RepositoryException {
-        versionManager.restore(versionableNode.getPath(), version, true);
+        try {
+            versionManager.restore(versionableNode.getPath(), version, true);
+            fail("VersionManager.restore(String, Version, boolean) must fail on existing nodes.");
+        } catch (RepositoryException e) {
+            // ok
+        }
+        versionManager.restore(version, true);
         String value = versionableNode.getProperty(propertyName1).getString();
         assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
     }
@@ -366,7 +395,7 @@
         // modify node without calling save()
         try {
             versionableNode.setProperty(propertyName1, propertyValue);
-            versionManager.restore(versionableNode.getPath(), version, true);
+            versionManager.restore(version, true);
 
             fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
         } catch (InvalidItemStateException e) {
@@ -515,21 +544,6 @@
      * @throws RepositoryException
      * @see Node#restore(String, boolean)
      */
-    public void testRestoreNonVersionableNodeJcr2() throws RepositoryException {
-        try {
-            versionManager.restore(nonVersionableNode.getPath(), version, true);
-            fail("trying to restore on a non versionable node must throw UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException e) {
-            //success
-        }
-    }
-
-    /**
-     * Test restoring on a non-versionable node.
-     *
-     * @throws RepositoryException
-     * @see Node#restore(String, boolean)
-     */
     public void testRestoreNonVersionableNodeJcr2_2() throws RepositoryException {
         try {
             versionManager.restore(nonVersionableNode.getPath(), "foo", true);
@@ -577,21 +591,6 @@
      * @throws RepositoryException
      * @see Node#restore(Version, boolean)
      */
-    public void testRestoreNonVersionableNode3Jcr2() throws RepositoryException {
-        try {
-            versionManager.restore(nonVersionableNode.getPath(), version, true);
-            fail("Node.restore(Version, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
-        } catch (UnsupportedRepositoryOperationException e) {
-            //success
-        }
-    }
-
-    /**
-     * Test restoring on a non-versionable node.
-     *
-     * @throws RepositoryException
-     * @see Node#restore(Version, boolean)
-     */
     public void testRestoreNonVersionableNode3Jcr2_2() throws RepositoryException {
         try {
             versionManager.restore(nonVersionableNode.getPath(), version.getName(), true);
@@ -698,7 +697,7 @@
             versionManager.checkout(versionableNode.getPath());
             superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
             superuser.save();
-            versionManager.restore(versionableNode.getPath(), v, false);
+            versionManager.restore(v, false);
 
             fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
         } catch (ItemExistsException e) {
@@ -803,14 +802,14 @@
         versionManager.checkout(versionableNode.getPath());
         Version v2 = versionManager.checkin(versionableNode.getPath());
 
-        versionManager.restore(versionableNode.getPath(), v1, true);
+        versionManager.restore(v1, true);
         assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
 
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
 
         try {
-            versionManager.restore(versionableNode.getPath(), v2, true);
+            versionManager.restore(v2, true);
         } catch (RepositoryException e) {
             fail("Node.restore('1.3') must fail.");
         }
@@ -1074,7 +1073,7 @@
         versionManager.checkout(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();
@@ -1279,7 +1278,7 @@
         versionManager.checkin(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();
@@ -1320,7 +1319,7 @@
         versionManager.checkin(testRoot.getPath());
 
         // restore version 1.0
-        versionManager.restore(testRoot.getPath(), v1, true);
+        versionManager.restore(v1, true);
 
         // check order
         NodeIterator iter = testRoot.getNodes();
@@ -1438,7 +1437,7 @@
             expected.append(iter.nextVersion().getName()).append(",");
         }
         // restore version
-        versionManager.restore(versionableNode.getPath(), version, true);
+        versionManager.restore(version, true);
         // append new base version
         expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/resources/org/apache/jackrabbit/test/api/nodetype/spec/mix-versionable.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/resources/org/apache/jackrabbit/test/api/nodetype/spec/mix-versionable.txt?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/resources/org/apache/jackrabbit/test/api/nodetype/spec/mix-versionable.txt (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/resources/org/apache/jackrabbit/test/api/nodetype/spec/mix-versionable.txt Tue Sep  8 16:09:28 2009
@@ -33,7 +33,7 @@
   DefaultValues null
   AutoCreated false
   Mandatory false
-  OnParentVersion COPY
+  OnParentVersion IGNORE
   Protected true
   Multiple false
 PropertyDefinition
@@ -51,7 +51,7 @@
   DefaultValues null
   AutoCreated false
   Mandatory true
-  OnParentVersion COPY
+  OnParentVersion IGNORE
   Protected true
   Multiple true
 PropertyDefinition
@@ -60,6 +60,6 @@
   DefaultValues null
   AutoCreated false
   Mandatory true
-  OnParentVersion COPY
+  OnParentVersion IGNORE
   Protected true
   Multiple false

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java Tue Sep  8 16:09:28 2009
@@ -16,30 +16,36 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.version.VersionManager;
-import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
-import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import java.util.Iterator;
 
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.VersionHistory;
-import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.AccessDeniedException;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
 import javax.jcr.ItemExistsException;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.NodeIterator;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.AccessDeniedException;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.MergeException;
+import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
-import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.lock.LockException;
-import java.util.Iterator;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.version.VersionManager;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>VersionManagerImpl</code>...
@@ -56,6 +62,12 @@
     private final ItemManager itemManager;
     private final PathResolver resolver;
 
+    /**
+     * The ID of the activity currently in effect for the session this
+     * manager has been created for.
+     */
+    private NodeId activityId;
+
     protected JcrVersionManager(SessionImpl session) {
         this.session = session;
         vMgr = session.getVersionStateManager();
@@ -68,6 +80,8 @@
      * @see javax.jcr.version.VersionManager#checkin(String)
      */
     public Version checkin(String absPath) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
+        session.checkIsAlive();
+        
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.checkin();
     }
@@ -76,6 +90,8 @@
      * @see javax.jcr.version.VersionManager#checkout(String)
      */
     public void checkout(String absPath) throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.checkout();
     }
@@ -85,6 +101,7 @@
      */
     public Version checkpoint(String absPath) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
         session.checkIsAlive();
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         return n.checkpoint();
     }
@@ -93,6 +110,8 @@
      * @see javax.jcr.version.VersionManager#isCheckedOut(String)
      */
     public boolean isCheckedOut(String absPath) throws RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.isCheckedOut();
     }
@@ -101,6 +120,8 @@
      * @see javax.jcr.version.VersionManager#getVersionHistory(String)
      */
     public VersionHistory getVersionHistory(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.getVersionHistory();
     }
@@ -109,6 +130,8 @@
      * @see javax.jcr.version.VersionManager#getBaseVersion(String)
      */
     public Version getBaseVersion(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.getBaseVersion();
     }
@@ -131,6 +154,8 @@
      * @see javax.jcr.version.VersionManager#restore(String, String, boolean)
      */
     public void restore(String absPath, String versionName, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.restore(versionName, removeExisting);
     }
@@ -146,14 +171,21 @@
      * @see javax.jcr.version.VersionManager#restore(String, Version, boolean)
      */
     public void restore(String absPath, Version version, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
-        Node n = itemManager.getNode(resolver.getQPath(absPath));
-        n.restore(version, removeExisting);
+        session.checkIsAlive();
+        // get parent
+        int idx = absPath.lastIndexOf("/");
+        String parent = idx == 0 ? "/" : absPath.substring(0, idx);
+        String name = absPath.substring(idx + 1);
+        Node n = itemManager.getNode(resolver.getQPath(parent));
+        n.restore(version, name, removeExisting);
     }
 
     /**
      * @see javax.jcr.version.VersionManager#restoreByLabel(String, String, boolean)
      */
     public void restoreByLabel(String absPath, String versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.restoreByLabel(versionLabel, removeExisting);
     }
@@ -169,6 +201,8 @@
      * @see javax.jcr.version.VersionManager#merge(String, String, boolean, boolean)
      */
     public NodeIterator merge(String absPath, String srcWorkspace, boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();        
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         n.checkIsWritable();
         session.checkHasPendingChanges();
@@ -188,6 +222,8 @@
      * @see javax.jcr.version.VersionManager#doneMerge(String, Version)
      */
     public void doneMerge(String absPath, Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.doneMerge(version);
     }
@@ -196,17 +232,20 @@
      * @see javax.jcr.version.VersionManager#cancelMerge(String, Version)
      */
     public void cancelMerge(String absPath, Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();                                  
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.cancelMerge(version);
     }
 
     /**
-     * @see javax.jcr.version.VersionManager#createConfiguration(String, Version)
+     * @see javax.jcr.version.VersionManager#createConfiguration(String)
      */
-    public Node createConfiguration(String absPath, Version baseline) throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO: add validation
+    public Node createConfiguration(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
-        NodeEntry entry = vMgr.createConfiguration((NodeState) n.getItemState(), (NodeState) ((NodeImpl) baseline).getItemState());
+        NodeEntry entry = vMgr.createConfiguration((NodeState) n.getItemState());
         return (Node) itemManager.getItem(entry);
     }
 
@@ -214,23 +253,47 @@
      * @see javax.jcr.version.VersionManager#setActivity(Node)
      */
     public Node setActivity(Node activity) throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation missing");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED);
+
+
+        Node oldActivity = getActivity();
+        if (activity == null) {
+            activityId = null;
+        } else {
+            NodeImpl activityNode = getValidActivity(activity, "set");
+            activityId = (NodeId) activityNode.getItemState().getId();
+        }
+        return oldActivity;
     }
 
     /**
      * @see javax.jcr.version.VersionManager#getActivity()
      */
     public Node getActivity() throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation missing");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED);
+
+        if (activityId == null) {
+            return null;
+        } else {
+            try {
+                return (Node) itemManager.getItem(session.getHierarchyManager().getNodeEntry(activityId));
+            } catch (ItemNotFoundException e) {
+                // the activity doesn't exist any more.
+                log.warn("Activity node with id " + activityId + " doesn't exist any more.");
+                activityId = null;
+                return null;
+            }
+        }
     }
 
     /**
      * @see javax.jcr.version.VersionManager#createActivity(String)
      */
     public Node createActivity(String title) throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO: add validation
+        session.checkIsAlive();
+
         NodeEntry entry = vMgr.createActivity(title);
         return (Node) itemManager.getItem(entry);
     }
@@ -239,16 +302,57 @@
      * @see javax.jcr.version.VersionManager#removeActivity(Node)
      */
     public void removeActivity(Node activityNode) throws UnsupportedRepositoryOperationException, RepositoryException {
-        vMgr.removeActivity((NodeState) ((NodeImpl) activityNode).getItemState());
+        session.checkIsAlive();
+        NodeImpl activity = getValidActivity(activityNode, "remove");
+
+        NodeState nState = (NodeState) activity.getItemState();
+        ItemId removeId = nState.getId();
+        vMgr.removeActivity(nState);
+
+        // if the removal succeeded, make sure there is no current activity
+        // setting on this session, that points to the removed activity.
+        if (activityId != null && activityId.equals(removeId)) {
+            activityId = null;
+        }
     }
 
     /**
      * @see javax.jcr.version.VersionManager#merge(Node)
      */
     public NodeIterator merge(Node activityNode) throws VersionException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO: add validation
-        Iterator failedIds = vMgr.mergeActivity((NodeState) ((NodeImpl) activityNode).getItemState());
+        session.checkIsAlive();
+        NodeImpl activity = getValidActivity(activityNode, "merge");
+        Iterator failedIds = vMgr.mergeActivity((NodeState) activity.getItemState());
         return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds);
     }
 
+    /**
+     * Assert that activity nodes passes to any of the activity methods have
+     * been obtained from the session this version manager has been created for.
+     * This is particularly important for workspace operations that are followed
+     * by internal updated of modified items: The hierarchy entries invalidated
+     * after successful completion of the operation must reside within scope
+     * defined by this session.
+     * <br>
+     * In addition this method varifies that the passed node is of type nt:activity.
+     *
+     * @param activityNode
+     * @param methodName
+     * @return
+     * @throws RepositoryException
+     */
+    private NodeImpl getValidActivity(Node activityNode, String methodName) throws UnsupportedRepositoryOperationException, RepositoryException {
+        NodeImpl activity;
+        if (session != activityNode.getSession()) {
+            String msg = "Attempt to " +methodName+ " an activity node that has been retrieved by another session.";
+            log.warn(msg);
+            activity = (NodeImpl) session.getNodeByIdentifier(activityNode.getIdentifier());
+        } else {
+            activity = (NodeImpl) activityNode;
+        }
+        if (!activity.isNodeType(NameConstants.NT_ACTIVITY)) {
+            throw new UnsupportedRepositoryOperationException("Given node is not an activity.");
+        }
+        return activity;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Tue Sep  8 16:09:28 2009
@@ -42,6 +42,7 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.Repository;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -52,8 +53,6 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
 
-import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.lock.LockStateManager;
@@ -79,6 +78,7 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -447,10 +447,8 @@
      */
     public NodeIterator getNodes(String namePattern) throws RepositoryException {
         checkStatus();
-        ArrayList nodes = new ArrayList();
-        // traverse children using a special filtering item visitor
-        accept(new ChildrenCollectorFilter(namePattern, nodes, true, false, 1));
-        return new NodeIteratorAdapter(nodes);
+
+        return ChildrenCollectorFilter.collectChildNodes(this, namePattern);
     }
 
     /**
@@ -458,10 +456,8 @@
      */
     public NodeIterator getNodes(String[] nameGlobs) throws RepositoryException {
         checkStatus();
-        List nodes = new ArrayList();
-        // traverse child nodes using a filtering item visitor
-        accept(new ChildrenCollectorFilter(nameGlobs, nodes, true, false, 1));
-        return new NodeIteratorAdapter(nodes);
+
+        return ChildrenCollectorFilter.collectChildNodes(this, nameGlobs);
     }
 
     /**
@@ -505,10 +501,8 @@
      */
     public PropertyIterator getProperties(String namePattern) throws RepositoryException {
         checkStatus();
-        ArrayList properties = new ArrayList();
-        // traverse children using a filtering item visitor
-        accept(new ChildrenCollectorFilter(namePattern, properties, false, true, 1));
-        return new PropertyIteratorAdapter(properties);
+
+        return ChildrenCollectorFilter.collectProperties(this, namePattern);
     }
 
     /**
@@ -517,10 +511,8 @@
     public PropertyIterator getProperties(String[] nameGlobs)
             throws RepositoryException {
         checkStatus();
-        List properties = new ArrayList();
-        // traverse child properties using a filtering item visitor
-        accept(new ChildrenCollectorFilter(nameGlobs, properties, false, true, 1));
-        return new PropertyIteratorAdapter(properties);
+
+        return ChildrenCollectorFilter.collectProperties(this, nameGlobs);
     }
 
     /**
@@ -886,7 +878,13 @@
         checkIsVersionable();
         checkIsLocked();
         if (!isCheckedOut()) {
-            session.getVersionStateManager().checkout(getNodeState());
+            if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
+                NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
+                NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
+                session.getVersionStateManager().checkout(getNodeState(), activityId);
+            } else {
+                session.getVersionStateManager().checkout(getNodeState());
+            }
         } else {
             // nothing to do
             log.debug("Node " + safeGetJCRPath() + " is already checked out.");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java Tue Sep  8 16:09:28 2009
@@ -19,6 +19,7 @@
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.HashMap;
 
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
@@ -27,6 +28,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.NamespaceException;
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
@@ -40,20 +43,52 @@
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.XASessionInfo;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.value.ValueFactoryImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>RepositoryImpl</code>...
  */
 public class RepositoryImpl extends AbstractRepository implements Referenceable {
 
+    private static Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
+
     // configuration of the repository
     private final RepositoryConfig config;
-    private final Map descriptors;
+    private final Map<String, Value[]> descriptors;
     private Reference reference = null;
 
     private RepositoryImpl(RepositoryConfig config) throws RepositoryException {
         this.config = config;
-        descriptors = config.getRepositoryService().getRepositoryDescriptors();
+
+        // dummy value factory and dummy resolver as descriptors are not
+        // expected contain Name or Path values.
+        ValueFactory vf = ValueFactoryImpl.getInstance(); 
+        NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {
+            public String getURI(String prefix) throws NamespaceException {
+                return prefix;
+            }
+            public String getPrefix(String uri) throws NamespaceException {
+                return uri;
+            }
+        });
+
+        Map<String, QValue[]> descr = config.getRepositoryService().getRepositoryDescriptors();       
+        descriptors = new HashMap(descr.size());
+        for (String key : descr.keySet()) {
+            QValue[] qvs = descr.get(key);
+            Value[] vs = new Value[qvs.length];
+            for (int i = 0; i < qvs.length; i++) {
+                vs[i] = ValueFormat.getJCRValue(qvs[i], resolver, vf);
+            }
+            descriptors.put(key, vs);
+        }
     }
 
     public static Repository create(RepositoryConfig config) throws RepositoryException {
@@ -65,39 +100,39 @@
      * @see Repository#getDescriptorKeys()
      */
     public String[] getDescriptorKeys() {
-        String[] keys = (String[]) descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
-        return keys;
+        return descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
     }
 
     /**
      * @see Repository#getDescriptor(String)
      */
-    public String getDescriptor(String descriptorKey) {
-        return (String) descriptors.get(descriptorKey);
+    public String getDescriptor(String key) {
+        Value v = getDescriptorValue(key);
+        try {
+            return (v == null) ? null : v.getString();
+        } catch (RepositoryException e) {
+            log.error("corrupt descriptor value: " + key, e);
+            return null;
+        }
     }
 
     /**
      * @see Repository#getDescriptorValue(String)
      */
     public Value getDescriptorValue(String key) {
-        String value = getDescriptor(key);
-        if (value != null) {
-            // TODO implementation missing
-            throw new UnsupportedOperationException("not implemented yet - see JCR-2062");
-        } else {
-            return null;
-        }
+        Value[] vs = getDescriptorValues(key);
+        return (vs == null || vs.length != 1) ? null : vs[0];
     }
 
     /**
      * @see Repository#getDescriptorValues(String)
      */
     public Value[] getDescriptorValues(String key) {
-        Value value = getDescriptorValue(key);
-        if (value != null) {
-            return new Value[] { value };
-        } else {
+        if (!descriptors.containsKey(key)) {
             return null;
+        } else {
+            return descriptors.get(key);
+
         }
     }
 
@@ -105,7 +140,8 @@
      * @see Repository#isSingleValueDescriptor(String)
      */
     public boolean isSingleValueDescriptor(String key) {
-        return descriptors.containsKey(key);
+        Value[] vs = descriptors.get(key);
+        return (vs != null && vs.length == 1);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java Tue Sep  8 16:09:28 2009
@@ -537,10 +537,10 @@
     /**
      * @see Session#hasCapability(String, Object, Map)
      */
-    public boolean hasCapability(String methodName, Object target, Map arguments)
+    public boolean hasCapability(String methodName, Object target, Object[] arguments)
             throws RepositoryException {
-        // TODO: implementation missing
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
+        // most trivial implementation allowed by the specification.
+        return true;
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Tue Sep  8 16:09:28 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistryImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeStorage;
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProviderImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
@@ -86,6 +85,7 @@
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -154,6 +154,11 @@
     private final Thread changeFeed;
 
     /**
+     * Flag that indicates that the changeFeed thread should be disposed.
+     */
+    private volatile boolean disposeChangeFeed = false;
+
+    /**
      * List of event listener that are set on this WorkspaceManager to get
      * notifications about local and external changes.
      */
@@ -592,7 +597,9 @@
         try {
             updateSync.acquire();
             if (changeFeed != null) {
+                disposeChangeFeed = true;
                 changeFeed.interrupt();
+                changeFeed.join();
             }
             hierarchyManager.dispose();
             if (subscription != null) {
@@ -956,7 +963,11 @@
          * @see OperationVisitor#visit(Checkout)
          */
         public void visit(Checkout operation) throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
-            service.checkout(sessionInfo, operation.getNodeId());
+            if (operation.supportsActivity()) {
+                service.checkout(sessionInfo, operation.getNodeId(), operation.getActivityId());
+            } else {
+                service.checkout(sessionInfo, operation.getNodeId());
+            }
         }
 
         /**
@@ -1106,7 +1117,7 @@
          * @see OperationVisitor#visit(CreateConfiguration)
          */
         public void visit(CreateConfiguration operation) throws RepositoryException {
-            NodeId configId = service.createConfiguration(sessionInfo, operation.getNodeId(), operation.getBaselineId());
+            NodeId configId = service.createConfiguration(sessionInfo, operation.getNodeId());
             operation.setNewConfigurationId(configId);
         }
     }
@@ -1132,7 +1143,7 @@
         }
 
         public void run() {
-            while (!Thread.interrupted()) {
+            while (!Thread.interrupted() && !disposeChangeFeed) {
                 try {
                     InternalEventListener[] iel;
                     Subscription subscr;
@@ -1151,7 +1162,7 @@
                             sessionInfo.getWorkspaceName());
                     // check if thread had been interrupted while
                     // getting events
-                    if (Thread.interrupted()) {
+                    if (Thread.interrupted() || disposeChangeFeed) {
                         log.debug("Thread interrupted, terminating...");
                         break;
                     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java Tue Sep  8 16:09:28 2009
@@ -23,16 +23,12 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>EntryFactory</code>...
  */
 public class EntryFactory {
 
-    private static Logger log = LoggerFactory.getLogger(EntryFactory.class);
-
     /**
      * IdFactory to create an ItemId based on the parent NodeId.
      */
@@ -43,7 +39,7 @@
     private final NodeEntry rootEntry;
 
     /**
-     *
+     * Listener to creation and uid-changes of node entries.
      */
     private final NodeEntryListener listener;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java Tue Sep  8 16:09:28 2009
@@ -116,7 +116,7 @@
     private RevertInfo revertInfo;
 
     /**
-     * Information regarding the invalidation status of the underyling {@link ItemState}
+     * Information regarding the invalidation status of the underlying {@link ItemState}
      * of this entry. The semantics depend on the {@link EntryFactory.InvalidationStrategy}.
      */
     private long invalidationStatus;
@@ -297,34 +297,48 @@
      * @see NodeEntry#getId()
      */
     public NodeId getId() throws InvalidItemStateException, RepositoryException {
-        IdFactory idFactory = getIdFactory();
-        if (uniqueID != null) {
-            return idFactory.createNodeId(uniqueID);
-        } else {
-            PathFactory pf = getPathFactory();
-            if (parent == null) {
-                // root node
-                return idFactory.createNodeId((String) null, pf.getRootPath());
-            } else {
-                Path p = pf.create(getName(), getIndex());
-                return idFactory.createNodeId(parent.getId(), p);
-            }
-        }
+        return getId(false);
     }
 
     /**
      * @see NodeEntry#getWorkspaceId()
      */
     public NodeId getWorkspaceId() throws InvalidItemStateException, RepositoryException {
-        if (uniqueID != null || parent == null) {
-            // uniqueID and root-node -> internal id is always the same as getId().
-            return getId();
-        } else {
-            NodeId parentId = (revertInfo != null)
-                ? revertInfo.oldParent.getWorkspaceId()
-                : parent.getWorkspaceId();
-            return getIdFactory().createNodeId(parentId,
-                    getPathFactory().create(getName(true), getIndex(true)));
+        return getId(true);
+    }
+
+    private NodeId getId(boolean wspId) throws RepositoryException {
+        if (parent == null) { // shortcut for root
+            return getIdFactory().createNodeId((String) null, getPathFactory().getRootPath());
+        }
+        else if (uniqueID != null) { // shortcut for uniqueID based IDs
+            return getIdFactory().createNodeId(uniqueID);
+        }
+        else {
+            return buildNodeId(this, getPathFactory(), getIdFactory(), wspId);
+        }
+    }
+
+    private static NodeId buildNodeId(NodeEntryImpl entry, PathFactory pathFactory, IdFactory idFactory,
+            boolean wspId) throws RepositoryException {
+
+        PathBuilder pathBuilder = new PathBuilder(pathFactory);
+        while (entry.getParent() != null && entry.getUniqueID() == null) {
+            pathBuilder.addFirst(entry.getName(wspId), entry.getIndex(wspId));
+            entry = (wspId && entry.revertInfo != null)
+                ? entry.revertInfo.oldParent
+                : entry.parent;
+        }
+
+        // We either walked up to an entry below root or up to an uniqueID. In the former
+        // case we construct an NodeId with an absolute path. In the latter case we construct
+        // a NodeId from an uuid and a relative path.
+        if (entry.getParent() == null) {
+            pathBuilder.addRoot();
+            return idFactory.createNodeId((String) null, pathBuilder.getPath());
+        }
+        else {
+            return idFactory.createNodeId(entry.getUniqueID(), pathBuilder.getPath());
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java Tue Sep  8 16:09:28 2009
@@ -496,7 +496,7 @@
                 if (lockHoldingState == nodeState) {
                     return true;
                 } else {
-                    return lockInfo.isDeep();
+                    return lockInfo != null && lockInfo.isDeep();
                 }
             }
         }
@@ -691,14 +691,20 @@
          * @see Lock#getLockOwner()
          */
         public String getLockOwner() {
-            return getLockInfo().getOwner();
+            LockInfo info = getLockInfo();
+            if (info != null) {
+                return info.getOwner();
+            } else {
+                return null;
+            }
         }
 
         /**
          * @see Lock#isDeep()
          */
         public boolean isDeep() {
-            return getLockInfo().isDeep();
+            LockInfo info = getLockInfo();
+            return info != null && info.isDeep();
         }
 
         /**
@@ -719,7 +725,12 @@
             }
 
             updateLockInfo();
-            return getLockInfo().getLockToken();
+            LockInfo info = getLockInfo();
+            if (info != null) {
+                return info.getLockToken();
+            } else {
+                return null;
+            }
         }
 
         /**
@@ -734,7 +745,8 @@
          * @see Lock#isSessionScoped()
          */
         public boolean isSessionScoped() {
-            return getLockInfo().isSessionScoped();
+            LockInfo info = getLockInfo();
+            return info != null && info.isSessionScoped();
         }
 
         /**
@@ -766,7 +778,8 @@
          * @see javax.jcr.lock.Lock#isLockOwningSession()
          */
         public boolean isLockOwningSession(){
-            return lockState.lockInfo.isLockOwner();
+            LockInfo info = getLockInfo();
+            return info != null && info.isLockOwner();
         }
 
         //----------------------------------------------< LockTokenListener >---

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java Tue Sep  8 16:09:28 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;



Mime
View raw message