jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r816343 [2/4] - in /jackrabbit/trunk: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-...
Date Thu, 17 Sep 2009 19:20:36 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Thu Sep 17 19:20:33 2009
@@ -19,6 +19,9 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,6 +35,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
+import java.util.Set;
+import java.util.HashSet;
 
 /**
  * An <code>EffectiveNodeType</code> represents one or more
@@ -51,9 +56,9 @@
     // (through inheritance) included node types.
     private final TreeSet<Name> allNodeTypes;
     // map of named item definitions (maps name to list of definitions)
-    private final HashMap<Name, List<ItemDef>> namedItemDefs;
+    private final HashMap<Name, List<QItemDefinition>> namedItemDefs;
     // list of unnamed item definitions (i.e. residual definitions)
-    private final ArrayList<ItemDef> unnamedItemDefs;
+    private final ArrayList<QItemDefinition> unnamedItemDefs;
 
     // flag indicating whether any included node type supports orderable child nodes
     private boolean orderableChildNodes;
@@ -67,8 +72,8 @@
         mergedNodeTypes = new TreeSet<Name>();
         inheritedNodeTypes = new TreeSet<Name>();
         allNodeTypes = new TreeSet<Name>();
-        namedItemDefs = new HashMap<Name, List<ItemDef>>();
-        unnamedItemDefs = new ArrayList<ItemDef>();
+        namedItemDefs = new HashMap<Name, List<QItemDefinition>>();
+        unnamedItemDefs = new ArrayList<QItemDefinition>();
         orderableChildNodes = false;
         primaryItemName = null;
     }
@@ -104,13 +109,13 @@
         // map of all item definitions (maps id to definition)
         // used to effectively detect ambiguous child definitions where
         // ambiguity is defined in terms of definition identity
-        HashMap<Object, ItemDef> itemDefIds = new HashMap<Object, ItemDef>();
+        Set<QItemDefinition> itemDefs = new HashSet<QItemDefinition>();
 
-        NodeDef[] cnda = ntd.getChildNodeDefs();
-        for (NodeDef aCnda : cnda) {
+        QNodeDefinition[] cnda = ntd.getChildNodeDefs();
+        for (QNodeDefinition aCnda : cnda) {
             // check if child node definition would be ambiguous within
             // this node type definition
-            if (itemDefIds.containsKey(aCnda.getId())) {
+            if (itemDefs.contains(aCnda)) {
                 // conflict
                 String msg;
                 if (aCnda.definesResidual()) {
@@ -122,7 +127,7 @@
                 log.debug(msg);
                 throw new NodeTypeConflictException(msg);
             } else {
-                itemDefIds.put(aCnda.getId(), aCnda);
+                itemDefs.add(aCnda);
             }
             if (aCnda.definesResidual()) {
                 // residual node definition
@@ -130,9 +135,9 @@
             } else {
                 // named node definition
                 Name name = aCnda.getName();
-                List<ItemDef> defs = ent.namedItemDefs.get(name);
+                List<QItemDefinition> defs = ent.namedItemDefs.get(name);
                 if (defs == null) {
-                    defs = new ArrayList<ItemDef>();
+                    defs = new ArrayList<QItemDefinition>();
                     ent.namedItemDefs.put(name, defs);
                 }
                 if (defs.size() > 0) {
@@ -140,7 +145,7 @@
                      * there already exists at least one definition with that
                      * name; make sure none of them is auto-create
                      */
-                    for (ItemDef def : defs) {
+                    for (QItemDefinition def : defs) {
                         if (aCnda.isAutoCreated() || def.isAutoCreated()) {
                             // conflict
                             String msg = "There are more than one 'auto-create' item definitions for '"
@@ -153,11 +158,11 @@
                 defs.add(aCnda);
             }
         }
-        PropDef[] pda = ntd.getPropertyDefs();
-        for (PropDef aPda : pda) {
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
+        for (QPropertyDefinition aPda : pda) {
             // check if property definition would be ambiguous within
             // this node type definition
-            if (itemDefIds.containsKey(aPda.getId())) {
+            if (itemDefs.contains(aPda)) {
                 // conflict
                 String msg;
                 if (aPda.definesResidual()) {
@@ -169,7 +174,7 @@
                 log.debug(msg);
                 throw new NodeTypeConflictException(msg);
             } else {
-                itemDefIds.put(aPda.getId(), aPda);
+                itemDefs.add(aPda);
             }
             if (aPda.definesResidual()) {
                 // residual property definition
@@ -177,9 +182,9 @@
             } else {
                 // named property definition
                 Name name = aPda.getName();
-                List<ItemDef> defs = ent.namedItemDefs.get(name);
+                List<QItemDefinition> defs = ent.namedItemDefs.get(name);
                 if (defs == null) {
-                    defs = new ArrayList<ItemDef>();
+                    defs = new ArrayList<QItemDefinition>();
                     ent.namedItemDefs.put(name, defs);
                 }
                 if (defs.size() > 0) {
@@ -187,7 +192,7 @@
                      * there already exists at least one definition with that
                      * name; make sure none of them is auto-create
                      */
-                    for (ItemDef def : defs) {
+                    for (QItemDefinition def : defs) {
                         if (aPda.isAutoCreated() || def.isAutoCreated()) {
                             // conflict
                             String msg = "There are more than one 'auto-create' item definitions for '"
@@ -276,280 +281,280 @@
         return allNodeTypes.toArray(new Name[allNodeTypes.size()]);
     }
 
-    public ItemDef[] getAllItemDefs() {
+    public QItemDefinition[] getAllItemDefs() {
         if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        ArrayList<ItemDef> defs = new ArrayList<ItemDef>(namedItemDefs.size() + unnamedItemDefs.size());
-        for (List<ItemDef> itemDefs : namedItemDefs.values()) {
+        ArrayList<QItemDefinition> defs = new ArrayList<QItemDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
+        for (List<QItemDefinition> itemDefs : namedItemDefs.values()) {
             defs.addAll(itemDefs);
         }
         defs.addAll(unnamedItemDefs);
         if (defs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new ItemDef[defs.size()]);
+        return defs.toArray(new QItemDefinition[defs.size()]);
     }
 
-    public ItemDef[] getNamedItemDefs() {
+    public QItemDefinition[] getNamedItemDefs() {
         if (namedItemDefs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        ArrayList<ItemDef> defs = new ArrayList<ItemDef>(namedItemDefs.size());
-        for (List<ItemDef> itemDefs : namedItemDefs.values()) {
+        ArrayList<QItemDefinition> defs = new ArrayList<QItemDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> itemDefs : namedItemDefs.values()) {
             defs.addAll(itemDefs);
         }
         if (defs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new ItemDef[defs.size()]);
+        return defs.toArray(new QItemDefinition[defs.size()]);
     }
 
-    public ItemDef[] getUnnamedItemDefs() {
+    public QItemDefinition[] getUnnamedItemDefs() {
         if (unnamedItemDefs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        return unnamedItemDefs.toArray(new ItemDef[unnamedItemDefs.size()]);
+        return unnamedItemDefs.toArray(new QItemDefinition[unnamedItemDefs.size()]);
     }
 
     public boolean hasNamedItemDef(Name name) {
         return namedItemDefs.containsKey(name);
     }
 
-    public ItemDef[] getNamedItemDefs(Name name) {
-        List<ItemDef> defs = namedItemDefs.get(name);
+    public QItemDefinition[] getNamedItemDefs(Name name) {
+        List<QItemDefinition> defs = namedItemDefs.get(name);
         if (defs == null || defs.size() == 0) {
-            return ItemDef.EMPTY_ARRAY;
+            return QItemDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new ItemDef[defs.size()]);
+        return defs.toArray(new QItemDefinition[defs.size()]);
     }
 
-    public NodeDef[] getAllNodeDefs() {
+    public QNodeDefinition[] getAllNodeDefs() {
         if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(namedItemDefs.size() + unnamedItemDefs.size());
-        for (ItemDef def : unnamedItemDefs) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
+        for (QItemDefinition def : unnamedItemDefs) {
             if (def.definesNode()) {
-                defs.add((NodeDef) def);
+                defs.add((QNodeDefinition) def);
             }
         }
-        for (List<ItemDef> list: namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        for (List<QItemDefinition> list: namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (def.definesNode()) {
-                    defs.add((NodeDef) def);
+                    defs.add((QNodeDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
-    public NodeDef[] getNamedNodeDefs() {
+    public QItemDefinition[] getNamedNodeDefs() {
         if (namedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (def.definesNode()) {
-                    defs.add((NodeDef) def);
+                    defs.add((QNodeDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
-    public NodeDef[] getNamedNodeDefs(Name name) {
-        List<ItemDef> list = namedItemDefs.get(name);
+    public QItemDefinition[] getNamedNodeDefs(Name name) {
+        List<QItemDefinition> list = namedItemDefs.get(name);
         if (list == null || list.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(list.size());
-        for (ItemDef def : list) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(list.size());
+        for (QItemDefinition def : list) {
             if (def.definesNode()) {
-                defs.add((NodeDef) def);
+                defs.add((QNodeDefinition) def);
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
-    public NodeDef[] getUnnamedNodeDefs() {
+    public QNodeDefinition[] getUnnamedNodeDefs() {
         if (unnamedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(unnamedItemDefs.size());
-        for (ItemDef def : unnamedItemDefs) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(unnamedItemDefs.size());
+        for (QItemDefinition def : unnamedItemDefs) {
             if (def.definesNode()) {
-                defs.add((NodeDef) def);
+                defs.add((QNodeDefinition) def);
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
-    public NodeDef[] getAutoCreateNodeDefs() {
+    public QNodeDefinition[] getAutoCreateNodeDefs() {
         // since auto-create items must have a name,
         // we're only searching the named item definitions
         if (namedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (def.definesNode() && def.isAutoCreated()) {
-                    defs.add((NodeDef) def);
+                    defs.add((QNodeDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
-    public PropDef[] getAllPropDefs() {
+    public QPropertyDefinition[] getAllPropDefs() {
         if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(namedItemDefs.size() + unnamedItemDefs.size());
-        for (ItemDef def : unnamedItemDefs) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
+        for (QItemDefinition def : unnamedItemDefs) {
             if (!def.definesNode()) {
-                defs.add((PropDef) def);
+                defs.add((QPropertyDefinition) def);
             }
         }
-        for (List<ItemDef> list: namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        for (List<QItemDefinition> list: namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (!def.definesNode()) {
-                    defs.add((PropDef) def);
+                    defs.add((QPropertyDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public PropDef[] getNamedPropDefs() {
+    public QPropertyDefinition[] getNamedPropDefs() {
         if (namedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (!def.definesNode()) {
-                    defs.add((PropDef) def);
+                    defs.add((QPropertyDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public PropDef[] getNamedPropDefs(Name name) {
-        List<ItemDef> list = namedItemDefs.get(name);
+    public QPropertyDefinition[] getNamedPropDefs(Name name) {
+        List<QItemDefinition> list = namedItemDefs.get(name);
         if (list == null || list.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(list.size());
-        for (ItemDef def : list) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(list.size());
+        for (QItemDefinition def : list) {
             if (!def.definesNode()) {
-                defs.add((PropDef) def);
+                defs.add((QPropertyDefinition) def);
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public PropDef[] getUnnamedPropDefs() {
+    public QPropertyDefinition[] getUnnamedPropDefs() {
         if (unnamedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(unnamedItemDefs.size());
-        for (ItemDef def : unnamedItemDefs) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(unnamedItemDefs.size());
+        for (QItemDefinition def : unnamedItemDefs) {
             if (!def.definesNode()) {
-                defs.add((PropDef) def);
+                defs.add((QPropertyDefinition) def);
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public PropDef[] getAutoCreatePropDefs() {
+    public QPropertyDefinition[] getAutoCreatePropDefs() {
         // since auto-create items must have a name,
         // we're only searching the named item definitions
         if (namedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (!def.definesNode() && def.isAutoCreated()) {
-                    defs.add((PropDef) def);
+                    defs.add((QPropertyDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public PropDef[] getMandatoryPropDefs() {
+    public QPropertyDefinition[] getMandatoryPropDefs() {
         // since mandatory items must have a name,
         // we're only searching the named item definitions
         if (namedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (!def.definesNode() && def.isMandatory()) {
-                    defs.add((PropDef) def);
+                    defs.add((QPropertyDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new PropDef[defs.size()]);
+        return defs.toArray(new QPropertyDefinition[defs.size()]);
     }
 
-    public NodeDef[] getMandatoryNodeDefs() {
+    public QNodeDefinition[] getMandatoryNodeDefs() {
         // since mandatory items must have a name,
         // we're only searching the named item definitions
         if (namedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(namedItemDefs.size());
-        for (List<ItemDef> list : namedItemDefs.values()) {
-            for (ItemDef def : list) {
+        ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
+        for (List<QItemDefinition> list : namedItemDefs.values()) {
+            for (QItemDefinition def : list) {
                 if (def.definesNode() && def.isMandatory()) {
-                    defs.add((NodeDef) def);
+                    defs.add((QNodeDefinition) def);
                 }
             }
         }
         if (defs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return defs.toArray(new NodeDef[defs.size()]);
+        return defs.toArray(new QNodeDefinition[defs.size()]);
     }
 
     /**
@@ -591,7 +596,7 @@
      *                                      by the the specified values
      * @throws RepositoryException          if another error occurs
      */
-    public static void checkSetPropertyValueConstraints(PropDef pd,
+    public static void checkSetPropertyValueConstraints(QPropertyDefinition pd,
                                                         InternalValue[] values)
             throws ConstraintViolationException, RepositoryException {
         // check multi-value flag
@@ -661,7 +666,7 @@
                 throw new ConstraintViolationException(nodeTypeName + " is mixin.");
             }
         }
-        NodeDef nd = getApplicableChildNodeDef(name, nodeTypeName, ntReg);
+        QItemDefinition nd = getApplicableChildNodeDef(name, nodeTypeName, ntReg);
         if (nd.isProtected()) {
             throw new ConstraintViolationException(name + " is protected");
         }
@@ -683,7 +688,7 @@
      * @throws ConstraintViolationException if no applicable child node definition
      *                                      could be found
      */
-    public NodeDef getApplicableChildNodeDef(Name name, Name nodeTypeName,
+    public QNodeDefinition getApplicableChildNodeDef(Name name, Name nodeTypeName,
                                              NodeTypeRegistry ntReg)
             throws NoSuchNodeTypeException, ConstraintViolationException {
         EffectiveNodeType entTarget;
@@ -694,10 +699,10 @@
         }
 
         // try named node definitions first
-        ItemDef[] defs = getNamedItemDefs(name);
-        for (ItemDef def : defs) {
+        QItemDefinition[] defs = getNamedItemDefs(name);
+        for (QItemDefinition def : defs) {
             if (def.definesNode()) {
-                NodeDef nd = (NodeDef) def;
+                QNodeDefinition nd = (QNodeDefinition) def;
                 Name[] types = nd.getRequiredPrimaryTypes();
                 // node definition with that name exists
                 if (entTarget != null && types != null) {
@@ -715,8 +720,8 @@
 
         // no item with that name defined;
         // try residual node definitions
-        NodeDef[] nda = getUnnamedNodeDefs();
-        for (NodeDef nd : nda) {
+        QNodeDefinition[] nda = getUnnamedNodeDefs();
+        for (QNodeDefinition nd : nda) {
             if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
                 // check 'required primary types' constraint
                 if (!entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
@@ -755,11 +760,11 @@
      * @throws ConstraintViolationException if no applicable property definition
      *                                      could be found
      */
-    public PropDef getApplicablePropertyDef(Name name, int type,
+    public QPropertyDefinition getApplicablePropertyDef(Name name, int type,
                                             boolean multiValued)
             throws ConstraintViolationException {
         // try named property definitions first
-        PropDef match =
+        QPropertyDefinition match =
                 getMatchingPropDef(getNamedPropDefs(name), type, multiValued);
         if (match != null) {
             return match;
@@ -797,10 +802,10 @@
      * @throws ConstraintViolationException if no applicable property definition
      *                                      could be found
      */
-    public PropDef getApplicablePropertyDef(Name name, int type)
+    public QPropertyDefinition getApplicablePropertyDef(Name name, int type)
             throws ConstraintViolationException {
         // try named property definitions first
-        PropDef match = getMatchingPropDef(getNamedPropDefs(name), type);
+        QPropertyDefinition match = getMatchingPropDef(getNamedPropDefs(name), type);
         if (match != null) {
             return match;
         }
@@ -816,9 +821,9 @@
         throw new ConstraintViolationException("no matching property definition found for " + name);
     }
 
-    private PropDef getMatchingPropDef(PropDef[] defs, int type) {
-        PropDef match = null;
-        for (PropDef pd : defs) {
+    private QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type) {
+        QPropertyDefinition match = null;
+        for (QPropertyDefinition pd : defs) {
             int reqType = pd.getRequiredType();
             // match type
             if (reqType == PropertyType.UNDEFINED
@@ -851,10 +856,10 @@
         return match;
     }
 
-    private PropDef getMatchingPropDef(PropDef[] defs, int type,
+    private QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type,
                                        boolean multiValued) {
-        PropDef match = null;
-        for (PropDef pd : defs) {
+        QPropertyDefinition match = null;
+        for (QPropertyDefinition pd : defs) {
             int reqType = pd.getRequiredType();
             // match type
             if (reqType == PropertyType.UNDEFINED
@@ -886,9 +891,9 @@
          * as there might be multiple definitions with the same name and we
          * don't know which one is applicable, we check all of them
          */
-        ItemDef[] defs = getNamedItemDefs(name);
+        QItemDefinition[] defs = getNamedItemDefs(name);
         if (defs != null) {
-            for (ItemDef def : defs) {
+            for (QItemDefinition def : defs) {
                 if (def.isMandatory()) {
                     throw new ConstraintViolationException("can't remove mandatory item");
                 }
@@ -908,9 +913,9 @@
          * as there might be multiple definitions with the same name and we
          * don't know which one is applicable, we check all of them
          */
-        ItemDef[] defs = getNamedNodeDefs(name);
+        QItemDefinition[] defs = getNamedNodeDefs(name);
         if (defs != null) {
-            for (ItemDef def : defs) {
+            for (QItemDefinition def : defs) {
                 if (def.isMandatory()) {
                     throw new ConstraintViolationException("can't remove mandatory node");
                 }
@@ -930,9 +935,9 @@
          * as there might be multiple definitions with the same name and we
          * don't know which one is applicable, we check all of them
          */
-        ItemDef[] defs = getNamedPropDefs(name);
+        QItemDefinition[] defs = getNamedPropDefs(name);
         if (defs != null) {
-            for (ItemDef def : defs) {
+            for (QItemDefinition def : defs) {
                 if (def.isMandatory()) {
                     throw new ConstraintViolationException("can't remove mandatory property");
                 }
@@ -992,18 +997,18 @@
         }
 
         // named item definitions
-        ItemDef[] defs = other.getNamedItemDefs();
-        for (ItemDef def : defs) {
+        QItemDefinition[] defs = other.getNamedItemDefs();
+        for (QItemDefinition def : defs) {
             if (includesNodeType(def.getDeclaringNodeType())) {
                 // ignore redundant definitions
                 continue;
             }
             Name name = def.getName();
-            List<ItemDef> existingDefs = namedItemDefs.get(name);
+            List<QItemDefinition> existingDefs = namedItemDefs.get(name);
             if (existingDefs != null) {
                 if (existingDefs.size() > 0) {
                     // there already exists at least one definition with that name
-                    for (ItemDef existingDef : existingDefs) {
+                    for (QItemDefinition existingDef : existingDefs) {
                         // make sure none of them is auto-create
                         if (def.isAutoCreated() || existingDef.isAutoCreated()) {
                             // conflict
@@ -1020,8 +1025,8 @@
                         if (def.definesNode() == existingDef.definesNode()) {
                             if (!def.definesNode()) {
                                 // property definition
-                                PropDef pd = (PropDef) def;
-                                PropDef epd = (PropDef) existingDef;
+                                QPropertyDefinition pd = (QPropertyDefinition) def;
+                                QPropertyDefinition epd = (QPropertyDefinition) existingDef;
                                 // compare type & multiValued flag
                                 if (pd.getRequiredType() == epd.getRequiredType()
                                         && pd.isMultiple() == epd.isMultiple()) {
@@ -1051,7 +1056,7 @@
                     }
                 }
             } else {
-                existingDefs = new ArrayList<ItemDef>();
+                existingDefs = new ArrayList<QItemDefinition>();
                 namedItemDefs.put(name, existingDefs);
             }
             existingDefs.add(def);
@@ -1059,18 +1064,18 @@
 
         // residual item definitions
         defs = other.getUnnamedItemDefs();
-        for (ItemDef def : defs) {
+        for (QItemDefinition def : defs) {
             if (includesNodeType(def.getDeclaringNodeType())) {
                 // ignore redundant definitions
                 continue;
             }
-            for (ItemDef existing : unnamedItemDefs) {
+            for (QItemDefinition existing : unnamedItemDefs) {
                 // compare with existing definition
                 if (def.definesNode() == existing.definesNode()) {
                     if (!def.definesNode()) {
                         // property definition
-                        PropDef pd = (PropDef) def;
-                        PropDef epd = (PropDef) existing;
+                        QPropertyDefinition pd = (QPropertyDefinition) def;
+                        QPropertyDefinition epd = (QPropertyDefinition) existing;
                         // compare type & multiValued flag
                         if (pd.getRequiredType() == epd.getRequiredType()
                                 && pd.isMultiple() == epd.isMultiple()) {
@@ -1085,8 +1090,8 @@
                         }
                     } else {
                         // child node definition
-                        NodeDef nd = (NodeDef) def;
-                        NodeDef end = (NodeDef) existing;
+                        QNodeDefinition nd = (QNodeDefinition) def;
+                        QNodeDefinition end = (QNodeDefinition) existing;
                         // compare required & default primary types
                         if (Arrays.equals(nd.getRequiredPrimaryTypes(), end.getRequiredPrimaryTypes())
                                 && (nd.getDefaultPrimaryType() == null
@@ -1146,8 +1151,8 @@
         clone.inheritedNodeTypes.addAll(inheritedNodeTypes);
         clone.allNodeTypes.addAll(allNodeTypes);
         for (Name name : namedItemDefs.keySet()) {
-            List<ItemDef> list = namedItemDefs.get(name);
-            clone.namedItemDefs.put(name, new ArrayList<ItemDef>(list));
+            List<QItemDefinition> list = namedItemDefs.get(name);
+            clone.namedItemDefs.put(name, new ArrayList<QItemDefinition>(list));
         }
         clone.unnamedItemDefs.addAll(unnamedItemDefs);
         clone.orderableChildNodes = orderableChildNodes;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java Thu Sep 17 19:20:33 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.nodetype;
 
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 
 import java.io.Serializable;
 import java.util.Arrays;
@@ -25,7 +26,7 @@
  * <code>NodeDefId</code> uniquely identifies a <code>NodeDef</code> in the
  * node type registry.
  */
-public class NodeDefId implements Serializable {
+class NodeDefId implements Serializable {
 
     /**
      * Serialization UID of this class.
@@ -45,7 +46,7 @@
      *
      * @param def <code>NodeDef</code> to create identifier for
      */
-    NodeDefId(NodeDef def) {
+    public NodeDefId(QNodeDefinition def) {
         if (def == null) {
             throw new IllegalArgumentException("NodeDef argument can not be null");
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java Thu Sep 17 19:20:33 2009
@@ -54,8 +54,8 @@
     private boolean abstractStatus;
     private Name primaryItemName;
 
-    private Set<PropDef> propDefs;
-    private Set<NodeDef> nodeDefs;
+    private Set<QPropertyDefinition> propDefs;
+    private Set<QNodeDefinition> nodeDefs;
     private Set<Name> dependencies;
 
     /**
@@ -70,8 +70,8 @@
         orderableChildNodes = false;
         abstractStatus = false;
         queryable = true;
-        nodeDefs = new HashSet<NodeDef>();
-        propDefs = new HashSet<PropDef>();
+        nodeDefs = new HashSet<QNodeDefinition>();
+        propDefs = new HashSet<QPropertyDefinition>();
     }
 
     /**
@@ -86,13 +86,13 @@
         orderableChildNodes = def.hasOrderableChildNodes();
         abstractStatus = def.isAbstract();
         queryable = def.isQueryable();
-        nodeDefs = new HashSet<NodeDef>();
+        nodeDefs = new HashSet<QNodeDefinition>();
         for (QNodeDefinition nd: def.getChildNodeDefs()) {
-            nodeDefs.add(new NodeDefImpl(nd));
+            nodeDefs.add(nd);
         }
-        propDefs = new HashSet<PropDef>();
+        propDefs = new HashSet<QPropertyDefinition>();
         for (QPropertyDefinition pd: def.getPropertyDefs()) {
-            propDefs.add(new PropDefImpl(pd));
+            propDefs.add(pd);
         }
     }
 
@@ -101,17 +101,6 @@
      * @return the QNodeTypeDefintion
      */
     public QNodeTypeDefinition getQNodeTypeDefinition() {
-        QNodeDefinition[] qNodeDefs = new QNodeDefinition[nodeDefs.size()];
-        int i=0;
-        for (NodeDef nd: nodeDefs) {
-            qNodeDefs[i++] = ((NodeDefImpl) nd).getQNodeDefinition();
-        }
-        QPropertyDefinition[] qPropDefs = new QPropertyDefinition[propDefs.size()];
-        i=0;
-        for (PropDef pd: propDefs) {
-            qPropDefs[i++] = ((PropDefImpl) pd).getQPropertyDefinition();
-        }
-
         return new QNodeTypeDefinitionImpl(
                 getName(),
                 getSupertypes(),
@@ -121,8 +110,8 @@
                 isQueryable(),
                 hasOrderableChildNodes(),
                 getPrimaryItemName(),
-                qPropDefs,
-                qNodeDefs
+                propDefs.toArray(new QPropertyDefinition[propDefs.size()]),
+                nodeDefs.toArray(new QNodeDefinition[nodeDefs.size()])
         );
     }
 
@@ -144,7 +133,7 @@
             // supertypes
             dependencies.addAll(Arrays.asList(supertypes));
             // child node definitions
-            for (NodeDef nd: nodeDefs) {
+            for (QNodeDefinition nd: nodeDefs) {
                 // default primary type
                 Name ntName = nd.getDefaultPrimaryType();
                 if (ntName != null && !name.equals(ntName)) {
@@ -159,7 +148,7 @@
                 }
             }
             // property definitions
-            for (PropDef pd : propDefs) {
+            for (QPropertyDefinition pd : propDefs) {
                 // [WEAK]REFERENCE value constraints
                 if (pd.getRequiredType() == PropertyType.REFERENCE
                         || pd.getRequiredType() == PropertyType.WEAKREFERENCE) {
@@ -263,7 +252,7 @@
      *
      * @param defs An array of <code>PropertyDef</code> objects.
      */
-    public void setPropertyDefs(PropDef[] defs) {
+    public void setPropertyDefs(QPropertyDefinition[] defs) {
         resetDependencies();
         propDefs.clear();
         propDefs.addAll(Arrays.asList(defs));
@@ -272,9 +261,9 @@
     /**
      * Sets the child node definitions.
      *
-     * @param defs An array of <code>NodeDef</code> objects
+     * @param defs An array of <code>QNodeDefinition</code> objects
      */
-    public void setChildNodeDefs(NodeDef[] defs) {
+    public void setChildNodeDefs(QNodeDefinition[] defs) {
         resetDependencies();
         nodeDefs.clear();
         nodeDefs.addAll(Arrays.asList(defs));
@@ -362,11 +351,11 @@
      * @return an array containing the property definitions or
      *         <code>null</code> if not set.
      */
-    public PropDef[] getPropertyDefs() {
+    public QPropertyDefinition[] getPropertyDefs() {
         if (propDefs.isEmpty()) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        return propDefs.toArray(new PropDef[propDefs.size()]);
+        return propDefs.toArray(new QPropertyDefinition[propDefs.size()]);
     }
 
     /**
@@ -376,11 +365,11 @@
      * @return an array containing the child node definitions or
      *         <code>null</code> if not set.
      */
-    public NodeDef[] getChildNodeDefs() {
+    public QNodeDefinition[] getChildNodeDefs() {
         if (nodeDefs.isEmpty()) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        return nodeDefs.toArray(new NodeDef[nodeDefs.size()]);
+        return nodeDefs.toArray(new QNodeDefinition[nodeDefs.size()]);
     }
 
     //-------------------------------------------< java.lang.Object overrides >
@@ -393,10 +382,10 @@
         clone.orderableChildNodes = orderableChildNodes;
         clone.abstractStatus = abstractStatus;
         clone.queryable = queryable;
-        clone.nodeDefs = new HashSet<NodeDef>();
+        clone.nodeDefs = new HashSet<QNodeDefinition>();
         // todo: itemdefs should be cloned as well, since mutable
-        clone.nodeDefs = new HashSet<NodeDef>(nodeDefs);
-        clone.propDefs = new HashSet<PropDef>(propDefs);
+        clone.nodeDefs = new HashSet<QNodeDefinition>(nodeDefs);
+        clone.propDefs = new HashSet<QPropertyDefinition>(propDefs);
         return clone;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java Thu Sep 17 19:20:33 2009
@@ -27,6 +27,9 @@
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 
 /**
  * A <code>NodeTypeDefDiff</code> represents the result of the comparison of
@@ -97,7 +100,7 @@
     private final NodeTypeDef newDef;
     private int type;
 
-    private List propDefDiffs = new ArrayList();
+    private List<PropDefDiff> propDefDiffs = new ArrayList<PropDefDiff>();
     private List childNodeDefDiffs = new ArrayList();
 
     /**
@@ -249,45 +252,38 @@
          */
 
         int maxType = NONE;
-        PropDef[] pda1 = oldDef.getPropertyDefs();
-        HashMap defs1 = new HashMap();
-        for (int i = 0; i < pda1.length; i++) {
-            defs1.put(pda1[i].getId(), pda1[i]);
+        Map<PropDefId, QPropertyDefinition> oldDefs = new HashMap<PropDefId, QPropertyDefinition>();
+        for (QPropertyDefinition def : oldDef.getPropertyDefs()) {
+            oldDefs.put(new PropDefId(def), def);
         }
 
-        PropDef[] pda2 = newDef.getPropertyDefs();
-        HashMap defs2 = new HashMap();
-        for (int i = 0; i < pda2.length; i++) {
-            defs2.put(pda2[i].getId(), pda2[i]);
+        Map<PropDefId, QPropertyDefinition> newDefs = new HashMap<PropDefId, QPropertyDefinition>();
+        for (QPropertyDefinition def : newDef.getPropertyDefs()) {
+            newDefs.put(new PropDefId(def), def);
         }
 
         /**
          * walk through defs1 and process all entries found in
          * both defs1 & defs2 and those found only in defs1
          */
-        Iterator iter = defs1.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            PropDefId id = (PropDefId) entry.getKey();
-            PropDef def1 = (PropDef) entry.getValue();
-            PropDef def2 = (PropDef) defs2.get(id);
+        for (Map.Entry<PropDefId, QPropertyDefinition> entry : oldDefs.entrySet()) {
+            PropDefId id = entry.getKey();
+            QPropertyDefinition def1 = entry.getValue();
+            QPropertyDefinition def2 = newDefs.get(id);
             PropDefDiff diff = new PropDefDiff(def1, def2);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
             }
             propDefDiffs.add(diff);
-            defs2.remove(id);
+            newDefs.remove(id);
         }
 
         /**
          * defs2 by now only contains entries found in defs2 only;
          * walk through defs2 and process all remaining entries
          */
-        iter = defs2.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            PropDefId id = (PropDefId) entry.getKey();
-            PropDef def = (PropDef) entry.getValue();
+        for (Map.Entry<PropDefId, QPropertyDefinition> entry : newDefs.entrySet()) {
+            QPropertyDefinition def = entry.getValue();
             PropDefDiff diff = new PropDefDiff(null, def);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -308,16 +304,16 @@
          */
 
         int maxType = NONE;
-        NodeDef[] cnda1 = oldDef.getChildNodeDefs();
+        QNodeDefinition[] cnda1 = oldDef.getChildNodeDefs();
         HashMap defs1 = new HashMap();
         for (int i = 0; i < cnda1.length; i++) {
-            defs1.put(cnda1[i].getId(), cnda1[i]);
+            defs1.put(new NodeDefId(cnda1[i]), cnda1[i]);
         }
 
-        NodeDef[] cnda2 = newDef.getChildNodeDefs();
+        QNodeDefinition[] cnda2 = newDef.getChildNodeDefs();
         HashMap defs2 = new HashMap();
         for (int i = 0; i < cnda2.length; i++) {
-            defs2.put(cnda2[i].getId(), cnda2[i]);
+            defs2.put(new NodeDefId(cnda2[i]), cnda2[i]);
         }
 
         /**
@@ -328,8 +324,8 @@
         while (iter.hasNext()) {
             Map.Entry entry = (Map.Entry) iter.next();
             NodeDefId id = (NodeDefId) entry.getKey();
-            NodeDef def1 = (NodeDef) entry.getValue();
-            NodeDef def2 = (NodeDef) defs2.get(id);
+            QItemDefinition def1 = (QItemDefinition) entry.getValue();
+            QItemDefinition def2 = (QItemDefinition) defs2.get(id);
             ChildNodeDefDiff diff = new ChildNodeDefDiff(def1, def2);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -346,7 +342,7 @@
         while (iter.hasNext()) {
             Map.Entry entry = (Map.Entry) iter.next();
             NodeDefId id = (NodeDefId) entry.getKey();
-            NodeDef def = (NodeDef) entry.getValue();
+            QItemDefinition def = (QItemDefinition) entry.getValue();
             ChildNodeDefDiff diff = new ChildNodeDefDiff(null, def);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -408,11 +404,11 @@
     //--------------------------------------------------------< inner classes >
 
     abstract class ChildItemDefDiff {
-        protected final ItemDef oldDef;
-        protected final ItemDef newDef;
+        protected final QItemDefinition oldDef;
+        protected final QItemDefinition newDef;
         protected int type;
 
-        ChildItemDefDiff(ItemDef oldDef, ItemDef newDef) {
+        ChildItemDefDiff(QItemDefinition oldDef, QItemDefinition newDef) {
             this.oldDef = oldDef;
             this.newDef = newDef;
             init();
@@ -495,7 +491,7 @@
                 operationString = "NONE";
             }
 
-            ItemDef itemDefinition = (oldDef != null) ? oldDef : newDef;
+            QItemDefinition itemDefinition = (oldDef != null) ? oldDef : newDef;
 
             return getClass().getName() + "[itemName="
                     + itemDefinition.getName() + ", type=" + typeString
@@ -506,16 +502,16 @@
 
     public class PropDefDiff extends ChildItemDefDiff {
 
-        PropDefDiff(PropDef oldDef, PropDef newDef) {
+        PropDefDiff(QPropertyDefinition oldDef, QPropertyDefinition newDef) {
             super(oldDef, newDef);
         }
 
-        public PropDef getOldDef() {
-            return (PropDef) oldDef;
+        public QPropertyDefinition getOldDef() {
+            return (QPropertyDefinition) oldDef;
         }
 
-        public PropDef getNewDef() {
-            return (PropDef) newDef;
+        public QPropertyDefinition getNewDef() {
+            return (QPropertyDefinition) newDef;
         }
 
         protected void init() {
@@ -584,16 +580,16 @@
 
     public class ChildNodeDefDiff extends ChildItemDefDiff {
 
-        ChildNodeDefDiff(NodeDef oldDef, NodeDef newDef) {
+        ChildNodeDefDiff(QItemDefinition oldDef, QItemDefinition newDef) {
             super(oldDef, newDef);
         }
 
-        public NodeDef getOldDef() {
-            return (NodeDef) oldDef;
+        public QNodeDefinition getOldDef() {
+            return (QNodeDefinition) oldDef;
         }
 
-        public NodeDef getNewDef() {
-            return (NodeDef) newDef;
+        public QNodeDefinition getNewDef() {
+            return (QNodeDefinition) newDef;
         }
 
         protected void init() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java Thu Sep 17 19:20:33 2009
@@ -18,7 +18,11 @@
 
 import javax.jcr.nodetype.NodeTypeDefinition;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -163,7 +167,7 @@
      * {@inheritDoc}
      */
     public NodeDefinition[] getDeclaredChildNodeDefinitions() {
-        NodeDef[] cnda = ntd.getChildNodeDefs();
+        QItemDefinition[] cnda = ntd.getChildNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
             nodeDefs[i] = new NodeDefinitionImpl(cnda[i], null, resolver);
@@ -175,7 +179,7 @@
      * {@inheritDoc}
      */
     public PropertyDefinition[] getDeclaredPropertyDefinitions() {
-        PropDef[] pda = ntd.getPropertyDefs();
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
             propDefs[i] = new PropertyDefinitionImpl(pda[i], null, resolver, valueFactory);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java Thu Sep 17 19:20:33 2009
@@ -34,6 +34,8 @@
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeType;
@@ -123,10 +125,10 @@
      * @see NodeDefinition#isAutoCreated
      */
     public NodeDefinition[] getAutoCreatedNodeDefinitions() {
-        NodeDef[] cnda = ent.getAutoCreateNodeDefs();
+        QNodeDefinition[] cnda = ent.getAutoCreateNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i]);
         }
         return nodeDefs;
     }
@@ -141,10 +143,10 @@
      * @see PropertyDefinition#isAutoCreated
      */
     public PropertyDefinition[] getAutoCreatedPropertyDefinitions() {
-        PropDef[] pda = ent.getAutoCreatePropDefs();
+        QPropertyDefinition[] pda = ent.getAutoCreatePropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }
@@ -159,10 +161,10 @@
      * @see PropertyDefinition#isMandatory
      */
     public PropertyDefinition[] getMandatoryPropertyDefinitions() {
-        PropDef[] pda = ent.getMandatoryPropDefs();
+        QPropertyDefinition[] pda = ent.getMandatoryPropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }
@@ -177,10 +179,10 @@
      * @see NodeDefinition#isMandatory
      */
     public NodeDefinition[] getMandatoryNodeDefinitions() {
-        NodeDef[] cnda = ent.getMandatoryNodeDefs();
+        QNodeDefinition[] cnda = ent.getMandatoryNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i]);
         }
         return nodeDefs;
     }
@@ -349,10 +351,10 @@
      * {@inheritDoc}
      */
     public NodeDefinition[] getDeclaredChildNodeDefinitions() {
-        NodeDef[] cnda = ntd.getChildNodeDefs();
+        QNodeDefinition[] cnda = ntd.getChildNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i]);
         }
         return nodeDefs;
     }
@@ -397,10 +399,10 @@
      * {@inheritDoc}
      */
     public NodeDefinition[] getChildNodeDefinitions() {
-        NodeDef[] cnda = ent.getAllNodeDefs();
+        QNodeDefinition[] cnda = ent.getAllNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i]);
         }
         return nodeDefs;
     }
@@ -409,10 +411,10 @@
      * {@inheritDoc}
      */
     public PropertyDefinition[] getPropertyDefinitions() {
-        PropDef[] pda = ent.getAllPropDefs();
+        QPropertyDefinition[] pda = ent.getAllPropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }
@@ -427,7 +429,7 @@
         }
         try {
             Name name = resolver.getQName(propertyName);
-            PropDef def;
+            QPropertyDefinition def;
             try {
                 // try to get definition that matches the given value type
                 def = ent.getApplicablePropertyDef(name, value.getType(), false);
@@ -498,7 +500,7 @@
                     return false;
                 }
             }
-            PropDef def;
+            QPropertyDefinition def;
             try {
                 // try to get definition that matches the given value type
                 def = ent.getApplicablePropertyDef(name, type, true);
@@ -607,10 +609,10 @@
      * {@inheritDoc}
      */
     public PropertyDefinition[] getDeclaredPropertyDefinitions() {
-        PropDef[] pda = ntd.getPropertyDefs();
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Thu Sep 17 19:20:33 2009
@@ -61,13 +61,17 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
-import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager;
-import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.nodetype.*;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -108,13 +112,13 @@
      * A cache for <code>PropertyDefinition</code> instances created by this
      * <code>NodeTypeManager</code>
      */
-    private final Map<PropDefId, PropertyDefinitionImpl> pdCache;
+    private final Map<QPropertyDefinition, PropertyDefinitionImpl> pdCache;
 
     /**
      * A cache for <code>NodeDefinition</code> instances created by this
      * <code>NodeTypeManager</code>
      */
-    private final Map<NodeDefId, NodeDefinitionImpl> ndCache;
+    private final Map<QNodeDefinition, NodeDefinitionImpl> ndCache;
 
     private final DataStore store;
 
@@ -144,7 +148,7 @@
 
         rootNodeDef =
             new NodeDefinitionImpl(ntReg.getRootNodeDef(), this, session);
-        ndCache.put(rootNodeDef.unwrap().getId(), rootNodeDef);
+        ndCache.put(rootNodeDef.unwrap(), rootNodeDef);
     }
 
     /**
@@ -155,36 +159,30 @@
     }
 
     /**
-     * @param id node def id
+     * @param def the QNodeDefinition
      * @return the node definition
      */
-    public NodeDefinitionImpl getNodeDefinition(NodeDefId id) {
+    public NodeDefinitionImpl getNodeDefinition(QNodeDefinition def) {
         synchronized (ndCache) {
-            NodeDefinitionImpl ndi = ndCache.get(id);
+            NodeDefinitionImpl ndi = ndCache.get(def);
             if (ndi == null) {
-                NodeDef nd = ntReg.getNodeDef(id);
-                if (nd != null) {
-                    ndi = new NodeDefinitionImpl(nd, this, session);
-                    ndCache.put(id, ndi);
-                }
+                ndi = new NodeDefinitionImpl(def, this, session);
+                ndCache.put(def, ndi);
             }
             return ndi;
         }
     }
 
     /**
-     * @param id prop def id
+     * @param def prop def
      * @return the property definition
      */
-    public PropertyDefinitionImpl getPropertyDefinition(PropDefId id) {
+    public PropertyDefinitionImpl getPropertyDefinition(QPropertyDefinition def) {
         synchronized (pdCache) {
-            PropertyDefinitionImpl pdi = pdCache.get(id);
+            PropertyDefinitionImpl pdi = pdCache.get(def);
             if (pdi == null) {
-                PropDef pd = ntReg.getPropDef(id);
-                if (pd != null) {
-                    pdi = new PropertyDefinitionImpl(pd, this, session, valueFactory);
-                    pdCache.put(id, pdi);
-                }
+                pdi = new PropertyDefinitionImpl(def, this, session, valueFactory);
+                pdCache.put(def, pdi);
             }
             return pdi;
         }
@@ -351,7 +349,7 @@
         synchronized (ndCache) {
             Iterator iter = ndCache.values().iterator();
             while (iter.hasNext()) {
-                NodeDefinitionImpl nd = (NodeDefinitionImpl) iter.next();
+                NodeDefinitionImpl nd = (org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl) iter.next();
                 if (ntName.equals(nd.unwrap().getDeclaringNodeType())) {
                     iter.remove();
                 }
@@ -695,16 +693,16 @@
         // child nodes
         NodeDefinition[] ndefs = definition.getDeclaredChildNodeDefinitions();
         if (ndefs != null) {
-            NodeDef[] qndefs = new NodeDef[ndefs.length];
+            QNodeDefinition[] qndefs = new QNodeDefinition[ndefs.length];
             for (int i = 0; i < ndefs.length; i++) {
-                NodeDefImpl qndef = new NodeDefImpl();
+                QNodeDefinitionBuilder qndef = new QNodeDefinitionBuilder();
                 // declaring node type
                 qndef.setDeclaringNodeType(def.getName());
                 // name
                 name = ndefs[i].getName();
                 if (name != null) {
                     if (name.equals("*")) {
-                        qndef.setName(ItemDef.ANY_NAME);
+                        qndef.setName(NameConstants.ANY_NAME);
                     } else {
                         try {
                             qndef.setName(session.getQName(name));
@@ -747,7 +745,7 @@
                 qndef.setOnParentVersion(ndefs[i].getOnParentVersion());
                 qndef.setAllowsSameNameSiblings(ndefs[i].allowsSameNameSiblings());
 
-                qndefs[i] = qndef;
+                qndefs[i] = qndef.build();
             }
             def.setChildNodeDefs(qndefs);
         }
@@ -755,16 +753,16 @@
         // properties
         PropertyDefinition[] pdefs = definition.getDeclaredPropertyDefinitions();
         if (pdefs != null) {
-            PropDef[] qpdefs = new PropDef[pdefs.length];
+            QPropertyDefinition[] qpdefs = new QPropertyDefinition[pdefs.length];
             for (int i = 0; i < pdefs.length; i++) {
-                PropDefImpl qpdef = new PropDefImpl();
+                QPropertyDefinitionBuilder qpdef = new QPropertyDefinitionBuilder();
                 // declaring node type
                 qpdef.setDeclaringNodeType(def.getName());
                 // name
                 name = pdefs[i].getName();
                 if (name != null) {
                     if (name.equals("*")) {
-                        qpdef.setName(ItemDef.ANY_NAME);
+                        qpdef.setName(NameConstants.ANY_NAME);
                     } else {
                         try {
                             qpdef.setName(session.getQName(name));
@@ -812,7 +810,7 @@
                     qpdef.setDefaultValues(qvalues);
                 }
 
-                qpdefs[i] = qpdef;
+                qpdefs[i] = qpdef.build();
             }
             def.setPropertyDefs(qpdefs);
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java Thu Sep 17 19:20:33 2009
@@ -47,11 +47,14 @@
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.util.Dumpable;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,8 +72,6 @@
     private static final String CUSTOM_NODETYPES_RESOURCE_NAME =
             "custom_nodetypes.xml";
 
-    // file system where node type registrations are persisted
-    private final FileSystem ntStore;
     /**
      * resource holding custom node type definitions which are represented as
      * nodes in the repository; it is needed in order to make the registrations
@@ -89,12 +90,7 @@
     private final Map<Name, NodeTypeDef> registeredNTDefs;
 
     // definition of the root node
-    private final NodeDef rootNodeDef;
-
-    // map of id's and property definitions
-    private final Map<PropDefId, PropDef> propDefs;
-    // map of id's and node definitions
-    private final Map<NodeDefId, NodeDef> nodeDefs;
+    private final QNodeDefinition rootNodeDef;
 
     /**
      * namespace registry for resolving prefixes and namespace URI's;
@@ -558,22 +554,6 @@
     }
 
     /**
-     * @param id node def id
-     * @return the node definition for the given id.
-     */
-    public NodeDef getNodeDef(NodeDefId id) {
-        return nodeDefs.get(id);
-    }
-
-    /**
-     * @param id property def id
-     * @return the property definition for the given id.
-     */
-    public PropDef getPropDef(PropDefId id) {
-        return propDefs.get(id);
-    }
-
-    /**
      * Add a <code>NodeTypeRegistryListener</code>
      *
      * @param listener the new listener to be informed on (un)registration
@@ -613,10 +593,10 @@
             ps.println("\tMixin\t" + ntd.isMixin());
             ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
             ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>" : ntd.getPrimaryItemName().toString()));
-            PropDef[] pd = ntd.getPropertyDefs();
-            for (PropDef aPd : pd) {
+            QPropertyDefinition[] pd = ntd.getPropertyDefs();
+            for (QPropertyDefinition aPd : pd) {
                 ps.print("\tPropertyDefinition");
-                ps.println(" (declared in " + aPd.getDeclaringNodeType() + ") id=" + aPd.getId());
+                ps.println(" (declared in " + aPd.getDeclaringNodeType() + ")");
                 ps.println("\t\tName\t\t" + (aPd.definesResidual() ? "*" : aPd.getName().toString()));
                 String type = aPd.getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(aPd.getRequiredType());
                 ps.println("\t\tRequiredType\t" + type);
@@ -633,12 +613,12 @@
                     }
                 }
                 ps.println("\t\tValueConstraints\t" + constraints.toString());
-                InternalValue[] defVals = aPd.getDefaultValues();
+                QValue[] defVals = aPd.getDefaultValues();
                 StringBuffer defaultValues = new StringBuffer();
                 if (defVals == null) {
                     defaultValues.append("<null>");
                 } else {
-                    for (InternalValue defVal : defVals) {
+                    for (QValue defVal : defVals) {
                         if (defaultValues.length() > 0) {
                             defaultValues.append(", ");
                         }
@@ -652,10 +632,10 @@
                 ps.println("\t\tProtected\t" + aPd.isProtected());
                 ps.println("\t\tMultiple\t" + aPd.isMultiple());
             }
-            NodeDef[] nd = ntd.getChildNodeDefs();
-            for (NodeDef aNd : nd) {
+            QNodeDefinition[] nd = ntd.getChildNodeDefs();
+            for (QNodeDefinition aNd : nd) {
                 ps.print("\tNodeDefinition");
-                ps.println(" (declared in " + aNd.getDeclaringNodeType() + ") id=" + aNd.getId());
+                ps.println(" (declared in " + aNd.getDeclaringNodeType() + ")");
                 ps.println("\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString()));
                 Name[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                 if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
@@ -721,9 +701,8 @@
     protected NodeTypeRegistry(NamespaceRegistry nsReg, FileSystem ntStore)
             throws RepositoryException {
         this.nsReg = nsReg;
-        this.ntStore = ntStore;
         customNodeTypesResource =
-                new FileSystemResource(this.ntStore, CUSTOM_NODETYPES_RESOURCE_NAME);
+                new FileSystemResource(ntStore, CUSTOM_NODETYPES_RESOURCE_NAME);
         try {
             // make sure path to resource exists
             if (!customNodeTypesResource.exists()) {
@@ -741,12 +720,9 @@
         // for the old one)
         entCache = new BitsetENTCacheImpl();
         registeredNTDefs = new ConcurrentReaderHashMap();
-        propDefs = new ConcurrentReaderHashMap();
-        nodeDefs = new ConcurrentReaderHashMap();
 
         // setup definition of root node
         rootNodeDef = createRootNodeDef();
-        nodeDefs.put(rootNodeDef.getId(), rootNodeDef);
 
         // load and register pre-defined (i.e. built-in) node types
         builtInNTDefs = new NodeTypeDefStore();
@@ -979,7 +955,7 @@
     /**
      * @return the definition of the root node
      */
-    public NodeDef getRootNodeDef() {
+    public QNodeDefinition getRootNodeDef() {
         return rootNodeDef;
     }
 
@@ -1183,8 +1159,8 @@
             }
         }
 
-        NodeDef[] nodeDefs = childNodeENT.getAutoCreateNodeDefs();
-        for (NodeDef nodeDef : nodeDefs) {
+        QNodeDefinition[] nodeDefs = childNodeENT.getAutoCreateNodeDefs();
+        for (QNodeDefinition nodeDef : nodeDefs) {
             Name dnt = nodeDef.getDefaultPrimaryType();
             Name definingNT = nodeDef.getDeclaringNodeType();
             try {
@@ -1224,16 +1200,6 @@
         ntd = (NodeTypeDef) ntd.clone();
         registeredNTDefs.put(name, ntd);
 
-        // store property & child node definitions of new node type by id
-        PropDef[] pda = ntd.getPropertyDefs();
-        for (PropDef aPda : pda) {
-            propDefs.put(aPda.getId(), aPda);
-        }
-        NodeDef[] nda = ntd.getChildNodeDefs();
-        for (NodeDef aNda : nda) {
-            nodeDefs.put(aNda.getId(), aNda);
-        }
-
         return ent;
     }
 
@@ -1309,15 +1275,6 @@
             // register clone of node type definition
             ntd = (NodeTypeDef) ntd.clone();
             registeredNTDefs.put(ntd.getName(), ntd);
-            // store property & child node definitions of new node type by id
-            PropDef[] pda = ntd.getPropertyDefs();
-            for (PropDef aPda : pda) {
-                propDefs.put(aPda.getId(), aPda);
-            }
-            NodeDef[] nda = ntd.getChildNodeDefs();
-            for (NodeDef aNda : nda) {
-                nodeDefs.put(aNda.getId(), aNda);
-            }
         }
 
         // finally add newly created effective node types to entCache
@@ -1331,16 +1288,6 @@
         }
         registeredNTDefs.remove(name);
         entCache.invalidate(name);
-
-        // remove property & child node definitions
-        PropDef[] pda = ntd.getPropertyDefs();
-        for (PropDef aPda : pda) {
-            propDefs.remove(aPda.getId());
-        }
-        NodeDef[] nda = ntd.getChildNodeDefs();
-        for (NodeDef aNda : nda) {
-            nodeDefs.remove(aNda.getId());
-        }
     }
 
     private void internalUnregister(Collection<Name> ntNames)
@@ -1525,8 +1472,8 @@
         checkNamespace(ntd.getPrimaryItemName(), nsReg);
 
         // validate property definitions
-        PropDef[] pda = ntd.getPropertyDefs();
-        for (PropDef pd : pda) {
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
+        for (QPropertyDefinition pd : pda) {
             /**
              * sanity check:
              * make sure declaring node type matches name of node type definition
@@ -1557,10 +1504,10 @@
              * check default values:
              * make sure type of value is consistent with required property type
              */
-            InternalValue[] defVals = pd.getDefaultValues();
+            QValue[] defVals = pd.getDefaultValues();
             if (defVals != null && defVals.length != 0) {
                 int reqType = pd.getRequiredType();
-                for (InternalValue defVal : defVals) {
+                for (QValue defVal : defVals) {
                     if (reqType == PropertyType.UNDEFINED) {
                         reqType = defVal.getType();
                     } else {
@@ -1590,7 +1537,7 @@
             if (constraints != null && constraints.length > 0) {
                 if (defVals != null && defVals.length > 0) {
                     // check value constraints on every value
-                    for (InternalValue defVal : defVals) {
+                    for (QValue defVal : defVals) {
                         // constraints are OR-ed together
                         boolean satisfied = false;
                         ConstraintViolationException cve = null;
@@ -1638,8 +1585,8 @@
         }
 
         // validate child-node definitions
-        NodeDef[] cnda = ntd.getChildNodeDefs();
-        for (NodeDef cnd : cnda) {
+        QNodeDefinition[] cnda = ntd.getChildNodeDefs();
+        for (QNodeDefinition cnd : cnda) {
             /**
              * sanity check:
              * make sure declaring node type matches name of node type definition
@@ -1816,8 +1763,8 @@
         return ent;
     }
 
-    private static NodeDef createRootNodeDef() {
-        NodeDefImpl def = new NodeDefImpl();
+    private static QNodeDefinition createRootNodeDef() {
+        QNodeDefinitionBuilder def = new QNodeDefinitionBuilder();
 
         // FIXME need a fake declaring node type:
         // rep:root is not quite correct but better than a non-existing node type
@@ -1829,7 +1776,7 @@
         def.setOnParentVersion(OnParentVersionAction.VERSION);
         def.setAllowsSameNameSiblings(false);
         def.setAutoCreated(true);
-        return def;
+        return def.build();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java Thu Sep 17 19:20:33 2009
@@ -18,14 +18,16 @@
 
 import java.io.Serializable;
 
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+
 /**
- * <code>PropDefId</code> serves as identifier for a given <code>PropDef</code>.
+ * <code>PropDefId</code> serves as identifier for a given <code>QPropertyDefinition</code>.
  *
  *
- * uniquely identifies a <code>PropDef</code> in the
+ * uniquely identifies a <code>QPropertyDefinition</code> in the
  * node type registry.
  */
-public class PropDefId implements Serializable {
+class PropDefId implements Serializable {
 
     /**
      * Serialization UID of this class.
@@ -34,20 +36,20 @@
 
     /**
      * The internal id is computed based on the characteristics of the
-     * <code>PropDef</code> that this <code>PropDefId</code> identifies.
+     * <code>QPropertyDefinition</code> that this <code>PropDefId</code> identifies.
      */
     private final int id;
 
     /**
      * Creates a new <code>PropDefId</code> that serves as identifier for
-     * the given <code>PropDef</code>. An internal id is computed based on
-     * the characteristics of the <code>PropDef</code> that it identifies.
+     * the given <code>QPropertyDefinition</code>. An internal id is computed based on
+     * the characteristics of the <code>QPropertyDefinition</code> that it identifies.
      *
-     * @param def <code>PropDef</code> to create identifier for
+     * @param def <code>QPropertyDefinition</code> to create identifier for
      */
-    PropDefId(PropDef def) {
+    public PropDefId(QPropertyDefinition def) {
         if (def == null) {
-            throw new IllegalArgumentException("PropDef argument can not be null");
+            throw new IllegalArgumentException("QPropertyDefinition argument can not be null");
         }
         // build key (format: <declaringNodeType>/<name>/<requiredType>/<multiple>)
         StringBuffer sb = new StringBuffer();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Thu Sep 17 19:20:33 2009
@@ -25,11 +25,8 @@
 import javax.jcr.version.OnParentVersionAction;
 
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -38,6 +35,8 @@
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 /**
@@ -74,9 +73,6 @@
      */
     protected VirtualNodeState createRootNodeState() throws RepositoryException {
         VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null);
-        NodeDefId id = ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
-                NameConstants.JCR_NODETYPES, NameConstants.REP_NODETYPES, ntReg).getId();
-        root.setDefinitionId(id);
         Name[] ntNames = ntReg.getRegisteredNodeTypes();
         for (int i = 0; i < ntNames.length; i++) {
             NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntNames[i]);
@@ -168,7 +164,7 @@
         }
 
         // add property defs
-        PropDef[] propDefs = ntDef.getPropertyDefs();
+        QPropertyDefinition[] propDefs = ntDef.getPropertyDefs();
         for (int i = 0; i < propDefs.length; i++) {
             VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i);
             ntState.addChildNodeEntry(NameConstants.JCR_PROPERTYDEFINITION, pdState.getNodeId());
@@ -177,7 +173,7 @@
         }
 
         // add child node defs
-        NodeDef[] cnDefs = ntDef.getChildNodeDefs();
+        QNodeDefinition[] cnDefs = ntDef.getChildNodeDefs();
         for (int i = 0; i < cnDefs.length; i++) {
             VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i);
             ntState.addChildNodeEntry(NameConstants.JCR_CHILDNODEDEFINITION, cnState.getNodeId());
@@ -197,7 +193,7 @@
      * @throws RepositoryException
      */
     private VirtualNodeState createPropertyDefState(VirtualNodeState parent,
-                                                    PropDef propDef,
+                                                    QPropertyDefinition propDef,
                                                     NodeTypeDef ntDef, int n)
             throws RepositoryException {
         NodeId id = calculateStableId(
@@ -218,7 +214,7 @@
         pState.setPropertyValue(
                 NameConstants.JCR_REQUIREDTYPE,
                 InternalValue.create(PropertyType.nameFromValue(propDef.getRequiredType()).toUpperCase()));
-        InternalValue[] defVals = propDef.getDefaultValues();
+        InternalValue[] defVals = InternalValue.create(propDef.getDefaultValues());
         // retrieve the property type from the first default value present with
         // the property definition. in case no default values are defined,
         // fallback to PropertyType.STRING in order to avoid creating a property
@@ -227,7 +223,9 @@
         if (defVals != null && defVals.length > 0) {
             defValsType = defVals[0].getType();
         }
-        pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
+        if (defVals != null) {
+            pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
+        }
         QValueConstraint[] vc = propDef.getValueConstraints();
         InternalValue[] vals = new InternalValue[vc.length];
         for (int i = 0; i < vc.length; i++) {
@@ -246,7 +244,7 @@
      * @throws RepositoryException
      */
     private VirtualNodeState createChildNodeDefState(VirtualNodeState parent,
-                                                     NodeDef cnDef,
+                                                     QNodeDefinition cnDef,
                                                      NodeTypeDef ntDef, int n)
             throws RepositoryException {
         NodeId id = calculateStableId(



Mime
View raw message