jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1485183 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Wed, 22 May 2013 12:22:58 GMT
Author: jukka
Date: Wed May 22 12:22:58 2013
New Revision: 1485183

URL: http://svn.apache.org/r1485183
Log:
OAK-826: NodeDefinition#getRequiredPrimaryTypes throws IllegalStateException

The node definitions can be at different depths of the /jcr:system/jcr:nodeTypes subtree,
so we need a more flexible way to find the root of that subtree

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java?rev=1485183&r1=1485182&r2=1485183&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeDefinitionImpl.java
Wed May 22 12:22:58 2013
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.plugins.nodetype;
 
 import static com.google.common.base.Preconditions.checkState;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
 
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
@@ -85,7 +86,11 @@ class NodeDefinitionImpl extends ItemDef
     public NodeType getDefaultPrimaryType() {
         String oakName = getName(JcrConstants.JCR_DEFAULTPRIMARYTYPE);
         if (oakName != null) {
-            Tree type = definition.getParent().getParent().getChild(oakName);
+            Tree types = definition.getParent();
+            while (!JCR_NODE_TYPES.equals(types.getName())) {
+                types = types.getParent();
+            }
+            Tree type = types.getChild(oakName);
             checkState(type.exists());
             return new NodeTypeImpl(type, mapper);
         } else {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1485183&r1=1485182&r2=1485183&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Wed May 22 12:22:58 2013
@@ -19,6 +19,7 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import static java.util.Arrays.asList;
+import static org.apache.jackrabbit.commons.JcrUtils.getChildNodes;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -64,6 +65,7 @@ import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
@@ -74,7 +76,6 @@ import javax.jcr.observation.Observation
 
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.junit.Before;
@@ -2157,9 +2158,9 @@ public class RepositoryTest extends Abst
         Session session = getAdminSession();
         Node node = session.getNode("/jcr:system/jcr:nodeTypes/nt:file");
         // TODO: use getNode("jcr:childNodeDefinition[1]") once that works
-        for (Node definition
-                : JcrUtils.getChildNodes(node, "jcr:childNodeDefinition")) {
-            definition.getDefinition(); // should not throw
+        for (Node child : getChildNodes(node, "jcr:childNodeDefinition")) {
+            NodeDefinition definition = child.getDefinition(); // OAK-829
+            definition.getDefaultPrimaryType();                // OAK-826
         }
     }
 



Mime
View raw message