jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1415757 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java
Date Fri, 30 Nov 2012 17:36:07 GMT
Author: mduerig
Date: Fri Nov 30 17:36:07 2012
New Revision: 1415757

URL: http://svn.apache.org/viewvc?rev=1415757&view=rev
Log:
OAK-479: Adding a node to a node that doesn't accept children doesn't fail with ConstraintViolationException

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1415757&r1=1415756&r2=1415757&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Fri Nov 30 17:36:07 2012
@@ -169,7 +169,14 @@ abstract class ItemImpl<T extends ItemDe
     }
 
     void checkProtected() throws RepositoryException {
-        ItemDefinition definition = (isNode()) ? ((Node) this).getDefinition() : ((Property)
this).getDefinition();
+        ItemDefinition definition;
+        try {
+            definition = (isNode()) ? ((Node) this).getDefinition() : ((Property) this).getDefinition();
+        }
+        catch (RepositoryException ignore) {
+            // No definition -> not protected but a different error which should be handled
else where
+            return;
+        }
         checkProtected(definition);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java?rev=1415757&r1=1415756&r2=1415757&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java
Fri Nov 30 17:36:07 2012
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.jcr.no
 
 import javax.jcr.Node;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest;
@@ -38,4 +39,21 @@ public class NodeTypeTest extends Abstra
         root.addNode("q1", "nt:query").addNode("q2", "nt:query");
         session.save();
     }
+
+    @Test(expected = ConstraintViolationException.class)
+    public void illegalAddNodeWithProps() throws Exception {
+        Session session = getAdminSession();
+        Node root = session.getRootNode();
+        ValueFactory vf = session.getValueFactory();
+
+        Node n = root.addNode("q1", "nt:query");
+        n.setProperty("jcr:statement", vf.createValue("statement"));
+        n.setProperty("jcr:language", vf.createValue("language"));
+
+        Node n2 = n.addNode("q2", "nt:query");
+        n2.setProperty("jcr:statement", vf.createValue("statement"));
+        n2.setProperty("jcr:language", vf.createValue("language"));
+
+        session.save();
+    }
 }



Mime
View raw message