jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1384683 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java oak-jcr/pom.xml
Date Fri, 14 Sep 2012 08:27:23 GMT
Author: mduerig
Date: Fri Sep 14 08:27:22 2012
New Revision: 1384683

URL: http://svn.apache.org/viewvc?rev=1384683&view=rev
Log:
OAK-66: JCR Node Type Management
NodeTypeTemplate.getDeclaredPropertyDefinitions and getDeclaredNodeDefinitions must return
null for an "empty" template

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java?rev=1384683&r1=1384682&r2=1384683&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
Fri Sep 14 08:27:22 2012
@@ -274,16 +274,22 @@ public class NodeTypeManagerImpl extends
         }
 
         // TODO fail on invalid item definitions. See 3.7.6.8 Item Definitions in Subtypes
-        int pdn = 1;
-        for (PropertyDefinition pd : ntd.getDeclaredPropertyDefinitions()) {
-            NodeUtil def = node.addChild(JCR_PROPERTYDEFINITION + pdn++, NT_PROPERTYDEFINITION);
-            internalRegisterPropertyDefinition(def, pd);
+        PropertyDefinition[] propertyDefinitions = ntd.getDeclaredPropertyDefinitions();
+        if (propertyDefinitions != null) {
+            int pdn = 1;
+            for (PropertyDefinition pd : propertyDefinitions) {
+                NodeUtil def = node.addChild(JCR_PROPERTYDEFINITION + pdn++, NT_PROPERTYDEFINITION);
+                internalRegisterPropertyDefinition(def, pd);
+            }
         }
 
-        int ndn = 1;
-        for (NodeDefinition nd : ntd.getDeclaredChildNodeDefinitions()) {
-            NodeUtil def = node.addChild(JCR_CHILDNODEDEFINITION + ndn++, NT_CHILDNODEDEFINITION);
-            internalRegisterNodeDefinition(def, nd);
+        NodeDefinition[] nodeDefinitions = ntd.getDeclaredChildNodeDefinitions();
+        if (nodeDefinitions != null) {
+            int ndn = 1;
+            for (NodeDefinition nd : nodeDefinitions) {
+                NodeUtil def = node.addChild(JCR_CHILDNODEDEFINITION + ndn++, NT_CHILDNODEDEFINITION);
+                internalRegisterNodeDefinition(def, nd);
+            }
         }
 
         return new NodeTypeImpl(this, this.factory, node);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java?rev=1384683&r1=1384682&r2=1384683&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
Fri Sep 14 08:27:22 2012
@@ -48,11 +48,9 @@ final class NodeTypeTemplateImpl
 
     private String[] superTypeNames = new String[0];
 
-    private final List<PropertyDefinitionTemplate> propertyDefinitionTemplates =
-            new ArrayList<PropertyDefinitionTemplate>();
+    private List<PropertyDefinitionTemplate> propertyDefinitionTemplates;
 
-    private final List<NodeDefinitionTemplate> nodeDefinitionTemplates =
-            new ArrayList<NodeDefinitionTemplate>();
+    private List<NodeDefinitionTemplate> nodeDefinitionTemplates;
 
     public NodeTypeTemplateImpl(NodeTypeManager manager, ValueFactory factory) {
         this.manager = manager;
@@ -79,6 +77,7 @@ final class NodeTypeTemplateImpl
         }
         setDeclaredSuperTypeNames(ntd.getDeclaredSupertypeNames());
 
+        getPropertyDefinitionTemplates();  // Make sure propertyDefinitionTemplates is initialised
         for (PropertyDefinition pd : ntd.getDeclaredPropertyDefinitions()) {
             PropertyDefinitionTemplateImpl pdt = newPropertyDefinitionBuilder();
             pdt.setDeclaringNodeType(pd.getDeclaringNodeType().getName());
@@ -97,6 +96,7 @@ final class NodeTypeTemplateImpl
             pdt.build();
         }
 
+        getNodeDefinitionTemplates();   // Make sure nodeDefinitionTemplates is initialised
         for (NodeDefinition nd : ntd.getDeclaredChildNodeDefinitions()) {
             NodeDefinitionTemplateImpl ndt = newNodeDefinitionBuilder();
             ndt.setDeclaringNodeType(nd.getDeclaringNodeType().getName());
@@ -126,7 +126,7 @@ final class NodeTypeTemplateImpl
             }
             @Override
             public void build() {
-                propertyDefinitionTemplates.add(this);
+                getPropertyDefinitionTemplates().add(this);
             }
         };
     }
@@ -145,7 +145,7 @@ final class NodeTypeTemplateImpl
             }
             @Override
             public void build() {
-                nodeDefinitionTemplates.add(this);
+                getNodeDefinitionTemplates().add(this);
             }
         };
     }
@@ -236,23 +236,33 @@ final class NodeTypeTemplateImpl
 
     @Override
     public List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates() {
+        if (propertyDefinitionTemplates == null) {
+            propertyDefinitionTemplates = new ArrayList<PropertyDefinitionTemplate>();
+        }
         return propertyDefinitionTemplates;
     }
 
     @Override
     public List<NodeDefinitionTemplate> getNodeDefinitionTemplates() {
+        if (nodeDefinitionTemplates == null) {
+            nodeDefinitionTemplates = new ArrayList<NodeDefinitionTemplate>();
+        }
         return nodeDefinitionTemplates;
     }
 
     @Override
     public PropertyDefinition[] getDeclaredPropertyDefinitions() {
-        return propertyDefinitionTemplates.toArray(
+        return propertyDefinitionTemplates == null
+            ? null
+            : propertyDefinitionTemplates.toArray(
                 new PropertyDefinition[propertyDefinitionTemplates.size()]);
     }
 
     @Override
     public NodeDefinition[] getDeclaredChildNodeDefinitions() {
-        return nodeDefinitionTemplates.toArray(
+        return nodeDefinitionTemplates == null
+            ? null
+            : nodeDefinitionTemplates.toArray(
                 new NodeDefinition[nodeDefinitionTemplates.size()]);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1384683&r1=1384682&r2=1384683&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Fri Sep 14 08:27:22 2012
@@ -69,7 +69,6 @@ org.apache.jackrabbit.test.api.nodetype.
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyLongTest#testConversionsMultiple  
 <!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyNameTest#testConversions          
 <!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyNameTest#testConversionsMultiple  
 <!-- OAK-66 -->
-org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest#testEmptyNodeTypeTemplate  
 <!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest#testNewNodeTypeTemplate    
 <!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest#testPropertyDefinitionTemplate
      <!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest#testNodeDefinitionTemplate 
 <!-- OAK-66 -->



Mime
View raw message