jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1484820 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java
Date Tue, 21 May 2013 14:41:36 GMT
Author: mreutegg
Date: Tue May 21 14:41:36 2013
New Revision: 1484820

URL: http://svn.apache.org/r1484820
Log:
OAK-168: Basic JCR VersionManager support
- Throw VersionException when a property is set on a checked in node

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1484820&r1=1484819&r2=1484820&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Tue May 21 14:41:36 2013
@@ -1332,6 +1332,14 @@ public class NodeImpl<T extends NodeDele
         checkNotNull(value);
         return perform(new ItemWriteOperation<Property>() {
             @Override
+            protected void checkPreconditions() throws RepositoryException {
+                super.checkPreconditions();
+                if (!isCheckedOut()) {
+                    throw new VersionException("Cannot set property. Node is checked in.");
+                }
+            }
+
+            @Override
             public Property perform() throws RepositoryException {
                 // TODO: Avoid extra JCR method calls (OAK-672)
                 PropertyDefinition definition = getEffectiveNodeType()

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java?rev=1484820&r1=1484819&r2=1484820&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionableTest.java
Tue May 21 14:41:36 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.jcr.ve
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
@@ -38,4 +39,19 @@ public class VersionableTest extends Abs
         assertEquals(PropertyType.nameFromValue(PropertyType.REFERENCE),
                 PropertyType.nameFromValue(node.getProperty(jcrPredecessors).getType()));
     }
+
+    public void testReadOnlyAfterCheckin() throws RepositoryException {
+        Node node = testRootNode.addNode(nodeName1, testNodeType);
+        node.addMixin(mixVersionable);
+        superuser.save();
+        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
+        vMgr.checkin(node.getPath());
+        try {
+            node.setProperty(propertyName1, "value");
+            fail("setProperty() must fail on a checked-in node");
+        } catch (VersionException e) {
+            // expected
+        }
+
+    }
 }



Mime
View raw message