jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r813753 [2/3] - in /jackrabbit/sandbox/JCR-2170/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/lock/ main/java/org/apache/jackrabbit/core/nodetype/ main/java/org/apache/jackrabbit/core/nodety...
Date Fri, 11 Sep 2009 10:05:35 GMT
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java Fri Sep 11 10:05:33 2009
@@ -100,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();
 
     /**
@@ -252,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();
-            QPropertyDefinition def1 = (QPropertyDefinition) entry.getValue();
-            QPropertyDefinition def2 = (QPropertyDefinition) 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();
-            QPropertyDefinition def = (QPropertyDefinition) 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();
@@ -311,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]);
         }
 
         /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java Fri Sep 11 10:05:33 2009
@@ -35,6 +35,7 @@
 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;
@@ -124,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;
     }
@@ -142,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;
     }
@@ -160,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;
     }
@@ -178,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;
     }
@@ -350,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;
     }
@@ -398,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;
     }
@@ -410,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;
     }
@@ -608,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/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Fri Sep 11 10:05:33 2009
@@ -60,7 +60,7 @@
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QItemDefinition;
+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;
@@ -70,6 +70,8 @@
 import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -110,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;
 
@@ -146,7 +148,7 @@
 
         rootNodeDef =
             new NodeDefinitionImpl(ntReg.getRootNodeDef(), this, session);
-        ndCache.put(rootNodeDef.unwrap().getId(), rootNodeDef);
+        ndCache.put(rootNodeDef.unwrap(), rootNodeDef);
     }
 
     /**
@@ -157,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) {
-                QItemDefinition 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) {
-                QPropertyDefinition 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;
         }
@@ -694,9 +690,9 @@
         // 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();
+                QNodeDefinitionImpl qndef = new QNodeDefinitionImpl();
                 // declaring node type
                 qndef.setDeclaringNodeType(def.getName());
                 // name
@@ -754,9 +750,9 @@
         // 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();
+                QPropertyDefinitionImpl qpdef = new QPropertyDefinitionImpl();
                 // declaring node type
                 qpdef.setDeclaringNodeType(def.getName());
                 // name

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java Fri Sep 11 10:05:33 2009
@@ -54,6 +54,7 @@
 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.QNodeDefinitionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -89,12 +90,12 @@
     private final Map<Name, NodeTypeDef> registeredNTDefs;
 
     // definition of the root node
-    private final NodeDef rootNodeDef;
+    private final QNodeDefinition rootNodeDef;
 
     // map of id's and property definitions
-    private final Map<PropDefId, PropDef> propDefs;
+    private final Map<PropDefId, QPropertyDefinition> propDefs;
     // map of id's and node definitions
-    private final Map<NodeDefId, NodeDef> nodeDefs;
+    private final Map<NodeDefId, QNodeDefinition> nodeDefs;
 
     /**
      * namespace registry for resolving prefixes and namespace URI's;
@@ -566,14 +567,6 @@
     }
 
     /**
-     * @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 +606,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);
@@ -652,10 +645,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) {
@@ -745,7 +738,7 @@
 
         // setup definition of root node
         rootNodeDef = createRootNodeDef();
-        nodeDefs.put(rootNodeDef.getId(), rootNodeDef);
+        nodeDefs.put(new NodeDefId(rootNodeDef), rootNodeDef);
 
         // load and register pre-defined (i.e. built-in) node types
         builtInNTDefs = new NodeTypeDefStore();
@@ -978,7 +971,7 @@
     /**
      * @return the definition of the root node
      */
-    public NodeDef getRootNodeDef() {
+    public QNodeDefinition getRootNodeDef() {
         return rootNodeDef;
     }
 
@@ -1224,13 +1217,13 @@
         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);
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
+        for (QPropertyDefinition aPda : pda) {
+            propDefs.put(new PropDefId(aPda), aPda);
+        }
+        QNodeDefinition[] nda = ntd.getChildNodeDefs();
+        for (QNodeDefinition aNda : nda) {
+            nodeDefs.put(new NodeDefId(aNda), aNda);
         }
 
         return ent;
@@ -1309,13 +1302,13 @@
             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);
+            QPropertyDefinition[] pda = ntd.getPropertyDefs();
+            for (QPropertyDefinition aPda : pda) {
+                propDefs.put(new PropDefId(aPda), aPda);
+            }
+            QNodeDefinition[] nda = ntd.getChildNodeDefs();
+            for (QNodeDefinition aNda : nda) {
+                nodeDefs.put(new NodeDefId(aNda), aNda);
             }
         }
 
@@ -1332,13 +1325,13 @@
         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());
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
+        for (QPropertyDefinition aPda : pda) {
+            propDefs.remove(new PropDefId(aPda));
+        }
+        QNodeDefinition[] nda = ntd.getChildNodeDefs();
+        for (QNodeDefinition aNda : nda) {
+            nodeDefs.remove(new NodeDefId(aNda));
         }
     }
 
@@ -1815,8 +1808,8 @@
         return ent;
     }
 
-    private static NodeDef createRootNodeDef() {
-        NodeDefImpl def = new NodeDefImpl();
+    private static QNodeDefinition createRootNodeDef() {
+        QNodeDefinitionImpl def = new QNodeDefinitionImpl();
 
         // FIXME need a fake declaring node type:
         // rep:root is not quite correct but better than a non-existing node type

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java Fri Sep 11 10:05:33 2009
@@ -21,10 +21,10 @@
 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 {
@@ -36,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(QPropertyDefinition 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/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java Fri Sep 11 10:05:33 2009
@@ -33,7 +33,7 @@
 
 /**
  * This class implements the <code>PropertyDefinition</code> interface.
- * All method calls are delegated to the wrapped {@link PropDef},
+ * All method calls are delegated to the wrapped {@link QPropertyDefinition},
  * performing the translation from <code>Name</code>s to JCR names
  * (and vice versa) where necessary.
  */
@@ -66,8 +66,8 @@
      *
      * @return the wrapped property definition.
      */
-    public PropDef unwrap() {
-        return (PropDef) itemDef;
+    public QPropertyDefinition unwrap() {
+        return (QPropertyDefinition) itemDef;
     }
 
     //---------------------------------------------------< PropertyDefinition >

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Fri Sep 11 10:05:33 2009
@@ -74,9 +74,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]);

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java Fri Sep 11 10:05:33 2009
@@ -17,11 +17,7 @@
 package org.apache.jackrabbit.core.nodetype.xml;
 
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
-import org.apache.jackrabbit.core.nodetype.NodeDefImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.nodetype.PropDefImpl;
 import org.apache.jackrabbit.core.util.DOMWalker;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.value.InternalValueFactory;
@@ -34,9 +30,13 @@
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.value.ValueHelper;
 
 import javax.jcr.PropertyType;
@@ -183,22 +183,22 @@
         }
 
         // property definitions
-        List<PropDef> properties = new ArrayList<PropDef>();
+        List<QPropertyDefinition> properties = new ArrayList<QPropertyDefinition>();
         while (walker.iterateElements(Constants.PROPERTYDEFINITION_ELEMENT)) {
-            PropDefImpl def = getPropDef();
+            QPropertyDefinitionImpl def = getPropDef();
             def.setDeclaringNodeType(type.getName());
             properties.add(def);
         }
-        type.setPropertyDefs(properties.toArray(new PropDef[properties.size()]));
+        type.setPropertyDefs(properties.toArray(new QPropertyDefinition[properties.size()]));
 
         // child node definitions
-        List<NodeDef> nodes = new ArrayList<NodeDef>();
+        List<QNodeDefinition> nodes = new ArrayList<QNodeDefinition>();
         while (walker.iterateElements(Constants.CHILDNODEDEFINITION_ELEMENT)) {
-            NodeDefImpl def = getChildNodeDef();
+            QNodeDefinitionImpl def = getChildNodeDef();
             def.setDeclaringNodeType(type.getName());
             nodes.add(def);
         }
-        type.setChildNodeDefs(nodes.toArray(new NodeDef[nodes.size()]));
+        type.setChildNodeDefs(nodes.toArray(new QNodeDefinition[nodes.size()]));
 
         return type;
     }
@@ -212,9 +212,9 @@
      *                                     illegal name
      * @throws NamespaceException if a namespace is not defined
      */
-    private PropDefImpl getPropDef()
+    private QPropertyDefinitionImpl getPropDef()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
-        PropDefImpl def = new PropDefImpl();
+        QPropertyDefinitionImpl def = new QPropertyDefinitionImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
             def.setName(NameConstants.ANY_NAME);
@@ -224,14 +224,11 @@
 
         // simple attributes
         def.setAutoCreated(Boolean.valueOf(
-                walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE)));
         def.setMandatory(Boolean.valueOf(
-                walker.getAttribute(Constants.MANDATORY_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.MANDATORY_ATTRIBUTE)));
         def.setProtected(Boolean.valueOf(
-                walker.getAttribute(Constants.PROTECTED_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.PROTECTED_ATTRIBUTE)));
         def.setOnParentVersion(OnParentVersionAction.valueFromName(
                 walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
         def.setMultiple(Boolean.valueOf(
@@ -320,8 +317,8 @@
      * @throws NameException if the definition contains an illegal name
      * @throws NamespaceException if a namespace is not defined
      */
-    private NodeDefImpl getChildNodeDef() throws NameException, NamespaceException {
-        NodeDefImpl def = new NodeDefImpl();
+    private QNodeDefinitionImpl getChildNodeDef() throws NameException, NamespaceException {
+        QNodeDefinitionImpl def = new QNodeDefinitionImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
             def.setName(NameConstants.ANY_NAME);
@@ -331,14 +328,11 @@
 
         // simple attributes
         def.setAutoCreated(Boolean.valueOf(
-                walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE)));
         def.setMandatory(Boolean.valueOf(
-                walker.getAttribute(Constants.MANDATORY_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.MANDATORY_ATTRIBUTE)));
         def.setProtected(Boolean.valueOf(
-                walker.getAttribute(Constants.PROTECTED_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.PROTECTED_ATTRIBUTE)));
         def.setOnParentVersion(OnParentVersionAction.valueFromName(
                 walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
         def.setAllowsSameNameSiblings(Boolean.valueOf(

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java Fri Sep 11 10:05:33 2009
@@ -132,7 +132,6 @@
             // Copy the node state
             NodeState targetNode = target.createNew(sourceNode.getNodeId());
             targetNode.setParentId(sourceNode.getParentId());
-            targetNode.setDefinitionId(sourceNode.getDefinitionId());
             targetNode.setNodeTypeName(sourceNode.getNodeTypeName());
             targetNode.setMixinTypeNames(sourceNode.getMixinTypeNames());
             targetNode.setPropertyNames(sourceNode.getPropertyNames());
@@ -148,7 +147,6 @@
                 PropertyId id = new PropertyId(sourceNode.getNodeId(), name);
                 PropertyState sourceState = source.load(id);
                 PropertyState targetState = target.createNew(id);
-                targetState.setDefinitionId(sourceState.getDefinitionId());
                 targetState.setType(sourceState.getType());
                 targetState.setMultiValued(sourceState.isMultiValued());
                 InternalValue[] values = sourceState.getValues();

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java Fri Sep 11 10:05:33 2009
@@ -31,7 +31,6 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
 import org.apache.jackrabbit.core.persistence.PMContext;
@@ -109,15 +108,6 @@
     /** the cache of non-existent bundles */
     private LRUNodeIdCache missing;
 
-    /** definition id of the jcr:uuid property */
-    private PropDefId idJcrUUID;
-
-    /** definition id of the jcr:primaryType property */
-    private PropDefId idJcrPrimaryType;
-
-    /** definition id of the jcr:mixinTypes property */
-    private PropDefId idJcrMixinTypes;
-
     /** the persistence manager context */
     protected PMContext context;
 
@@ -397,18 +387,6 @@
         // init bundle cache
         bundles = new BundleCache(bundleCacheSize);
         missing = new LRUNodeIdCache();
-
-        // init property definitions
-        if (context.getNodeTypeRegistry() != null) {
-            idJcrUUID = context.getNodeTypeRegistry()
-                .getEffectiveNodeType(NameConstants.MIX_REFERENCEABLE)
-                .getApplicablePropertyDef(NameConstants.JCR_UUID, PropertyType.STRING, false)
-                .getId();
-            idJcrPrimaryType = context.getNodeTypeRegistry().getEffectiveNodeType(NameConstants.NT_BASE).getApplicablePropertyDef(
-                    NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId();
-            idJcrMixinTypes = context.getNodeTypeRegistry().getEffectiveNodeType(NameConstants.NT_BASE).getApplicablePropertyDef(
-                    NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true).getId();
-        }
     }
     
     /**
@@ -453,22 +431,19 @@
             if (id.getName().equals(NameConstants.JCR_UUID)) {
                 state = createNew(id);
                 state.setType(PropertyType.STRING);
-                state.setDefinitionId(idJcrUUID);
                 state.setMultiValued(false);
                 state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
             } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
                 state = createNew(id);
                 state.setType(PropertyType.NAME);
-                state.setDefinitionId(idJcrPrimaryType);
                 state.setMultiValued(false);
                 state.setValues(new InternalValue[]{InternalValue.create(bundle.getNodeTypeName())});
             } else if (id.getName().equals(NameConstants.JCR_MIXINTYPES)) {
                 Set<Name> mixins = bundle.getMixinTypeNames();
                 state = createNew(id);
                 state.setType(PropertyType.NAME);
-                state.setDefinitionId(idJcrMixinTypes);
                 state.setMultiValued(true);
-                state.setValues(InternalValue.create((Name[]) mixins.toArray(new Name[mixins.size()])));
+                state.setValues(InternalValue.create(mixins.toArray(new Name[mixins.size()])));
             } else {
                 throw new NoSuchItemStateException(id.toString());
             }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Fri Sep 11 10:05:33 2009
@@ -26,8 +26,6 @@
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.data.DataStore;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -100,7 +98,7 @@
         bundle.setParentId(readID(in));
 
         // definitionId
-        bundle.setNodeDefId(NodeDefId.valueOf(in.readUTF()));
+        in.readUTF();
 
         // mixin types
         Set<Name> mixinTypeNames = new HashSet<Name>();
@@ -273,7 +271,7 @@
         writeID(out, bundle.getParentId());
 
         // definitionId
-        out.writeUTF(bundle.getNodeDefId().toString());
+        out.writeUTF("");
 
         // mixin types
         for (Name name : bundle.getMixinTypeNames()) {
@@ -342,7 +340,7 @@
         // multiValued
         entry.setMultiValued(in.readBoolean());
         // definitionId
-        entry.setPropDefId(PropDefId.valueOf(in.readUTF()));
+        in.readUTF();
         // values
         int count = in.readInt();   // count
         InternalValue[] values = new InternalValue[count];
@@ -598,7 +596,7 @@
         // multiValued
         out.writeBoolean(state.isMultiValued());
         // definitionId
-        out.writeUTF(state.getPropDefId().toString());
+        out.writeUTF("");
         // values
         InternalValue[] values = state.getValues();
         out.writeInt(values.length); // count
@@ -736,7 +734,7 @@
      * Write a small binary value and return the data.
      *
      * @param out the output stream to write
-     * @param blobVal the binary value
+     * @param value the binary value
      * @param state the property state (for error messages)
      * @param i the index (for error messages)
      * @return the data

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java Fri Sep 11 10:05:33 2009
@@ -158,7 +158,7 @@
         // parentUUID
         state.setParentId(readID(in));
         // definitionId
-        state.setDefinitionId(NodeDefId.valueOf(in.readUTF()));
+        in.readUTF();
 
         // mixin types
         int count = in.readInt();   // count
@@ -210,7 +210,7 @@
         // parentUUID
         writeID(out, state.getParentId());
         // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
+        out.writeUTF("");
         // mixin types
         Collection<Name> c = state.getMixinTypeNames();
         out.writeInt(c.size()); // count
@@ -261,7 +261,7 @@
     /**
      * Serializes a node identifier
      * @param out the output stream
-     * @param uuid the node id
+     * @param id the node id
      * @throws IOException in an I/O error occurs.
      */
     public void writeNodeId(DataOutputStream out, String id) throws IOException {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java Fri Sep 11 10:05:33 2009
@@ -32,8 +32,6 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
@@ -76,11 +74,6 @@
     private Set<Name> mixinTypeNames;
 
     /**
-     * the nodedef id
-     */
-    private NodeDefId nodeDefId;
-
-    /**
      * the child node entries
      */
     private LinkedList<NodePropBundle.ChildNodeEntry> childNodeEntries = new LinkedList<NodePropBundle.ChildNodeEntry>();
@@ -148,7 +141,6 @@
         parentId = state.getParentId();
         nodeTypeName = state.getNodeTypeName();
         mixinTypeNames = state.getMixinTypeNames();
-        nodeDefId = state.getDefinitionId();
         isReferenceable = state.hasPropertyName(NameConstants.JCR_UUID);
         modCount = state.getModCount();
         List<org.apache.jackrabbit.core.state.ChildNodeEntry> list = state.getChildNodeEntries();
@@ -169,7 +161,6 @@
         state.setParentId(parentId);
         state.setNodeTypeName(nodeTypeName);
         state.setMixinTypeNames(mixinTypeNames);
-        state.setDefinitionId(nodeDefId);
         state.setModCount(modCount);
         for (ChildNodeEntry e : childNodeEntries) {
             state.addChildNodeEntry(e.getName(), e.getId());
@@ -203,7 +194,6 @@
             return null;
         }
         PropertyState ps = pMgr.createNew(new PropertyId(id, name));
-        ps.setDefinitionId(p.getPropDefId());
         ps.setMultiValued(p.isMultiValued());
         ps.setType(p.getType());
         ps.setValues(p.getValues());
@@ -284,22 +274,6 @@
     }
 
     /**
-     * Returns the node def id of this bundle.
-     * @return the node def id.
-     */
-    public NodeDefId getNodeDefId() {
-        return nodeDefId;
-    }
-
-    /**
-     * Sets the node def id.
-     * @param nodeDefId the node def id.
-     */
-    public void setNodeDefId(NodeDefId nodeDefId) {
-        this.nodeDefId = nodeDefId;
-    }
-
-    /**
      * Checks if this bundle is referenceable.
      * @return <code>true</code> if this bundle is referenceable;
      *         <code>false</code> otherwise.
@@ -549,11 +523,6 @@
         private boolean multiValued;
 
         /**
-         * the propedef id
-         */
-        private PropDefId propDefId;
-
-        /**
          * the blob ids
          */
         private String[] blobIds;
@@ -581,7 +550,6 @@
             values = state.getValues();
             type = state.getType();
             multiValued = state.isMultiValued();
-            propDefId = state.getDefinitionId();
             modCount = state.getModCount();
             if (type == PropertyType.BINARY) {
                 blobIds = new String[values.length];
@@ -653,22 +621,6 @@
         }
 
         /**
-         * Returns the propdef id.
-         * @return the propdef id.
-         */
-        public PropDefId getPropDefId() {
-            return propDefId;
-        }
-
-        /**
-         * Sets the propdef id
-         * @param propDefId the propdef id
-         */
-        public void setPropDefId(PropDefId propDefId) {
-            this.propDefId = propDefId;
-        }
-
-        /**
          * Returns the n<sup>th</sup> blob id.
          * @param n the index of the blob id
          * @return the blob id

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java Fri Sep 11 10:05:33 2009
@@ -82,7 +82,7 @@
             out.write(state.getParentId().getRawBytes());
         }
         // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
+        out.writeUTF("");
         // mixin types
         Collection<Name> c = state.getMixinTypeNames();
         out.writeInt(c.size()); // count
@@ -131,8 +131,7 @@
             state.setParentId(new NodeId(uuidBytes));
         }
         // definitionId
-        s = in.readUTF();
-        state.setDefinitionId(NodeDefId.valueOf(s));
+        in.readUTF();
         // mixin types
         int count = in.readInt();   // count
         Set<Name> set = new HashSet<Name>(count);
@@ -183,7 +182,7 @@
         // multiValued
         out.writeBoolean(state.isMultiValued());
         // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
+        out.writeUTF("");
         // modCount
         out.writeShort(state.getModCount());
         // values
@@ -259,8 +258,7 @@
         boolean multiValued = in.readBoolean();
         state.setMultiValued(multiValued);
         // definitionId
-        String s = in.readUTF();
-        state.setDefinitionId(PropDefId.valueOf(s));
+        in.readUTF();
         // modCount
         short modCount = in.readShort();
         state.setModCount(modCount);
@@ -270,7 +268,7 @@
         for (int i = 0; i < count; i++) {
             InternalValue val;
             if (type == PropertyType.BINARY) {
-                s = in.readUTF();   // value (i.e. blobId)
+                String s = in.readUTF();   // value (i.e. blobId)
                 // special handling required for binary value:
                 // the value stores the id of the BLOB data
                 // in the BLOB store
@@ -302,7 +300,7 @@
                 int len = in.readInt(); // lenght of byte[]
                 byte[] bytes = new byte[len];
                 in.readFully(bytes); // byte[]
-                s = new String(bytes, ENCODING);
+                String s = new String(bytes, ENCODING);
                 val = InternalValue.valueOf(s, type);
             }
             values[i] = val;

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java Fri Sep 11 10:05:33 2009
@@ -24,8 +24,6 @@
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.persistence.AbstractPersistenceManager;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -87,7 +85,6 @@
     private static final String UUID_ATTRIBUTE = "uuid";
     private static final String NODETYPE_ATTRIBUTE = "nodeType";
     private static final String PARENTUUID_ATTRIBUTE = "parentUUID";
-    private static final String DEFINITIONID_ATTRIBUTE = "definitionId";
     private static final String MODCOUNT_ATTRIBUTE = "modCount";
 
     private static final String MIXINTYPES_ELEMENT = "mixinTypes";
@@ -243,10 +240,6 @@
             state.setParentId(NodeId.valueOf(parentUUID));
         }
 
-        // definition id
-        String definitionId = walker.getAttribute(DEFINITIONID_ATTRIBUTE);
-        state.setDefinitionId(NodeDefId.valueOf(definitionId));
-
         // modification count
         String modCount = walker.getAttribute(MODCOUNT_ATTRIBUTE);
         state.setModCount(Short.parseShort(modCount));
@@ -324,10 +317,6 @@
         String multiValued = walker.getAttribute(MULTIVALUED_ATTRIBUTE);
         state.setMultiValued(Boolean.getBoolean(multiValued));
 
-        // definition id
-        String definitionId = walker.getAttribute(DEFINITIONID_ATTRIBUTE);
-        state.setDefinitionId(PropDefId.valueOf(definitionId));
-
         // modification count
         String modCount = walker.getAttribute(MODCOUNT_ATTRIBUTE);
         state.setModCount(Short.parseShort(modCount));
@@ -567,7 +556,6 @@
                 writer.write("<" + NODE_ELEMENT + " "
                         + UUID_ATTRIBUTE + "=\"" + id + "\" "
                         + PARENTUUID_ATTRIBUTE + "=\"" + parentId + "\" "
-                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                         + NODETYPE_ATTRIBUTE + "=\"" + encodedNodeType + "\">\n");
 
@@ -650,7 +638,6 @@
                         + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
                         + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
                         + MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
-                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                         + TYPE_ATTRIBUTE + "=\"" + typeName + "\">\n");
                 // values

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java Fri Sep 11 10:05:33 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -61,6 +62,11 @@
     private NodeDefId defId;
 
     /**
+     * this node's definition
+     */
+    private QNodeDefinition def;
+
+    /**
      * insertion-ordered collection of ChildNodeEntry objects
      */
     private ChildNodeEntries childNodeEntries = new ChildNodeEntries();
@@ -211,24 +217,6 @@
     }
 
     /**
-     * Returns the id of the definition applicable to this node state.
-     *
-     * @return the id of the definition
-     */
-    public NodeDefId getDefinitionId() {
-        return defId;
-    }
-
-    /**
-     * Sets the id of the definition applicable to this node state.
-     *
-     * @param defId the id of the definition
-     */
-    public void setDefinitionId(NodeDefId defId) {
-        this.defId = defId;
-    }
-
-    /**
      * Determines if there are any child node entries.
      *
      * @return <code>true</code> if there are child node entries,

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java Fri Sep 11 10:05:33 2009
@@ -19,9 +19,9 @@
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.ItemId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 
 import javax.jcr.PropertyType;
 
@@ -51,9 +51,9 @@
     private boolean multiValued;
 
     /**
-     * the property definition id
+     * the property definition
      */
-    private PropDefId defId;
+    private QPropertyDefinition def;
 
     /**
      * Constructs a new property state that is initially connected to an
@@ -92,7 +92,7 @@
             PropertyState propState = (PropertyState) state;
             id = propState.id;
             type = propState.type;
-            defId = propState.defId;
+            def = propState.def;
             values = propState.values;
             multiValued = propState.multiValued;
             if (syncModCount) {
@@ -183,24 +183,6 @@
     }
 
     /**
-     * Returns the id of the definition applicable to this property state.
-     *
-     * @return the id of the definition
-     */
-    public PropDefId getDefinitionId() {
-        return defId;
-    }
-
-    /**
-     * Sets the id of the definition applicable to this property state.
-     *
-     * @param defId the id of the definition
-     */
-    public void setDefinitionId(PropDefId defId) {
-        this.defId = defId;
-    }
-
-    /**
      * Sets the value(s) of this property.
      *
      * @param values the new values

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Fri Sep 11 10:05:33 2009
@@ -27,6 +27,7 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.commons.collections.iterators.IteratorChain;
 import org.apache.jackrabbit.core.CachingHierarchyManager;
@@ -36,6 +37,8 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
+import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeDefinition;
@@ -782,7 +785,7 @@
      *
      * @return attic
      */
-    ItemStateManager getAttic() {
+    public ItemStateManager getAttic() {
         if (attic == null) {
             attic = new AtticItemStateManager();
         }
@@ -861,14 +864,19 @@
                                 }
 
                                 public boolean allowsSameNameSiblings(NodeId id) {
-                                    NodeState ns;
                                     try {
-                                        ns = (NodeState) getItemState(id);
-                                    } catch (ItemStateException e) {
+                                        NodeState ns = (NodeState) getItemState(id);
+                                        NodeState parent = (NodeState) getItemState(ns.getParentId());
+                                        Name name = parent.getChildNodeEntry(id).getName();
+                                        EffectiveNodeType ent = ntReg.getEffectiveNodeType(
+                                                parent.getNodeTypeName(),
+                                                parent.getMixinTypeNames());
+                                        QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg);
+                                        return def != null ? def.allowsSameNameSiblings() : false;
+                                    } catch (Exception e) {
+                                        log.warn("Unable to get node definition", e);
                                         return false;
                                     }
-                                    QNodeDefinition def = ntReg.getNodeDef(ns.getDefinitionId());
-                                    return def != null ? def.allowsSameNameSiblings() : false;
                                 }
                             };
                     if (NodeStateMerger.merge((NodeState) transientState, context)) {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Fri Sep 11 10:05:33 2009
@@ -24,7 +24,6 @@
 import javax.jcr.PropertyType;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.jackrabbit.core.RepositoryImpl;
@@ -33,10 +32,8 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
@@ -621,18 +618,28 @@
                                         }
 
                                         public boolean allowsSameNameSiblings(NodeId id) {
-                                            NodeState ns;
                                             try {
-                                                if (local.has(id)) {
-                                                    ns = (NodeState) local.get(id);
-                                                } else {
-                                                    ns = (NodeState) getItemState(id);
-                                                }
-                                            } catch (ItemStateException e) {
+                                                NodeState ns = getNodeState(id);
+                                                NodeState parent = getNodeState(ns.getParentId());
+                                                Name name = parent.getChildNodeEntry(id).getName();
+                                                EffectiveNodeType ent = ntReg.getEffectiveNodeType(
+                                                        parent.getNodeTypeName(),
+                                                        parent.getMixinTypeNames());
+                                                QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg);
+                                                return def != null ? def.allowsSameNameSiblings() : false;
+                                            } catch (Exception e) {
+                                                log.warn("Unable to get node definition", e);
                                                 return false;
                                             }
-                                            QNodeDefinition def = ntReg.getNodeDef(ns.getDefinitionId());
-                                            return def != null ? def.allowsSameNameSiblings() : false;
+                                        }
+
+                                        protected NodeState getNodeState(NodeId id)
+                                                throws ItemStateException {
+                                            if (local.has(id)) {
+                                                return (NodeState) local.get(id);
+                                            } else {
+                                                return (NodeState) getItemState(id);
+                                            }
                                         }
                                     };
 
@@ -1248,47 +1255,21 @@
         // FIXME need to manually setup root node by creating mandatory jcr:primaryType property
         // @todo delegate setup of root node to NodeTypeInstanceHandler
 
-        // id of the root node's definition
-        NodeDefId nodeDefId;
-        // definition of jcr:primaryType property
-        PropDef propDef;
-        // id of the jcr:system node's definition
-        NodeDefId jcrSystemDefId;
-        try {
-            nodeDefId = ntReg.getRootNodeDef().getId();
-            EffectiveNodeType ent = ntReg.getEffectiveNodeType(NameConstants.REP_ROOT);
-            propDef = ent.getApplicablePropertyDef(NameConstants.JCR_PRIMARYTYPE,
-                    PropertyType.NAME, false);
-            jcrSystemDefId = ent.getApplicableChildNodeDef(NameConstants.JCR_SYSTEM, NameConstants.REP_SYSTEM, ntReg).getId();
-        } catch (NoSuchNodeTypeException nsnte) {
-            String msg = "internal error: failed to create root node";
-            log.error(msg, nsnte);
-            throw new ItemStateException(msg, nsnte);
-        } catch (ConstraintViolationException cve) {
-            String msg = "internal error: failed to create root node";
-            log.error(msg, cve);
-            throw new ItemStateException(msg, cve);
-        }
-        rootState.setDefinitionId(nodeDefId);
-        jcrSystemState.setDefinitionId(jcrSystemDefId);
-
         // create jcr:primaryType property on root node state
-        rootState.addPropertyName(propDef.getName());
+        rootState.addPropertyName(NameConstants.JCR_PRIMARYTYPE);
 
-        PropertyState prop = createInstance(propDef.getName(), rootNodeId);
+        PropertyState prop = createInstance(NameConstants.JCR_PRIMARYTYPE, rootNodeId);
         prop.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ROOT)});
-        prop.setType(propDef.getRequiredType());
-        prop.setMultiValued(propDef.isMultiple());
-        prop.setDefinitionId(propDef.getId());
+        prop.setType(PropertyType.NAME);
+        prop.setMultiValued(false);
 
         // create jcr:primaryType property on jcr:system node state
-        jcrSystemState.addPropertyName(propDef.getName());
+        jcrSystemState.addPropertyName(NameConstants.JCR_PRIMARYTYPE);
 
-        PropertyState primaryTypeProp = createInstance(propDef.getName(), jcrSystemState.getNodeId());
+        PropertyState primaryTypeProp = createInstance(NameConstants.JCR_PRIMARYTYPE, jcrSystemState.getNodeId());
         primaryTypeProp.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_SYSTEM)});
-        primaryTypeProp.setType(propDef.getRequiredType());
-        primaryTypeProp.setMultiValued(propDef.isMultiple());
-        primaryTypeProp.setDefinitionId(propDef.getId());
+        primaryTypeProp.setType(PropertyType.NAME);
+        primaryTypeProp.setMultiValued(false);
 
         // add child node entry for jcr:system node
         rootState.addChildNodeEntry(NameConstants.JCR_SYSTEM, RepositoryImpl.SYSTEM_ROOT_NODE_ID);

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java Fri Sep 11 10:05:33 2009
@@ -190,12 +190,8 @@
             if (false && !pMgr.exists(systemId)) {
                 NodeState root = pMgr.createNew(systemId);
                 root.setParentId(RepositoryImpl.ROOT_NODE_ID);
-                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_ROOT).getApplicableChildNodeDef(
-                        NameConstants.JCR_SYSTEM, NameConstants.REP_SYSTEM, ntReg).getId());
                 root.setNodeTypeName(NameConstants.REP_SYSTEM);
                 PropertyState pt = pMgr.createNew(new PropertyId(systemId, NameConstants.JCR_PRIMARYTYPE));
-                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicablePropertyDef(
-                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
                 pt.setMultiValued(false);
                 pt.setType(PropertyType.NAME);
                 pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_SYSTEM)});
@@ -215,12 +211,8 @@
             if (!pMgr.exists(historiesId)) {
                 NodeState root = pMgr.createNew(historiesId);
                 root.setParentId(systemId);
-                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
-                        NameConstants.JCR_VERSIONSTORAGE, NameConstants.REP_VERSIONSTORAGE, ntReg).getId());
                 root.setNodeTypeName(NameConstants.REP_VERSIONSTORAGE);
                 PropertyState pt = pMgr.createNew(new PropertyId(historiesId, NameConstants.JCR_PRIMARYTYPE));
-                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_VERSIONSTORAGE).getApplicablePropertyDef(
-                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
                 pt.setMultiValued(false);
                 pt.setType(PropertyType.NAME);
                 pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
@@ -235,12 +227,8 @@
             if (!pMgr.exists(activitiesId)) {
                 NodeState root = pMgr.createNew(activitiesId);
                 root.setParentId(systemId);
-                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
-                        NameConstants.JCR_ACTIVITIES, NameConstants.REP_ACTIVITIES, ntReg).getId());
                 root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
                 PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
-                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_ACTIVITIES).getApplicablePropertyDef(
-                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
                 pt.setMultiValued(false);
                 pt.setType(PropertyType.NAME);
                 pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java Fri Sep 11 10:05:33 2009
@@ -30,10 +30,8 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -43,7 +41,7 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 /**
@@ -72,6 +70,11 @@
     private Name name;
 
     /**
+     * the cached node definition
+     */
+    private QNodeDefinition def;
+
+    /**
      * Creates a new persistent node
      *
      * @param stateMgr state manager
@@ -282,13 +285,9 @@
                 throw new RepositoryException("Unable to create property: " + e.toString());
             }
         } else {
-
-            PropDef pd = getEffectiveNodeType().getApplicablePropertyDef(name, type, multiple);
-
             PropertyState propState = stateMgr.createNew(name, nodeState.getNodeId());
             propState.setType(type);
             propState.setMultiValued(multiple);
-            propState.setDefinitionId(pd.getId());
             propState.setValues(values);
 
             // need to store node state
@@ -562,10 +561,6 @@
         }
         NodeState state = stateMgr.createNew(id, nodeTypeName, parentId);
 
-        NodeDef cnd =
-                getEffectiveNodeType().getApplicableChildNodeDef(name, nodeTypeName, ntReg);
-        state.setDefinitionId(cnd.getId());
-
         // create Node instance wrapping new node state
         NodeStateEx node = new NodeStateEx(stateMgr, ntReg, state, name);
         node.setPropertyValue(NameConstants.JCR_PRIMARYTYPE, InternalValue.create(nodeTypeName));
@@ -591,10 +586,11 @@
         if (name == null) {
             name = src.getName();
         }
+        EffectiveNodeType ent = getEffectiveNodeType();
         // (4) check for name collisions
-        NodeDef def;
+        QNodeDefinition def;
         try {
-            def = getEffectiveNodeType().getApplicableChildNodeDef(name, nodeState.getNodeTypeName(), ntReg);
+            def = ent.getApplicableChildNodeDef(name, nodeState.getNodeTypeName(), ntReg);
         } catch (RepositoryException re) {
             String msg = "no definition found in parent node's node type for new node";
             throw new ConstraintViolationException(msg, re);
@@ -613,7 +609,9 @@
             } catch (ItemStateException e) {
                 throw new RepositoryException(e);
             }
-            if (!ntReg.getNodeDef(existingChild.getDefinitionId()).allowsSameNameSiblings()) {
+            QNodeDefinition existingChildDef = ent.getApplicableChildNodeDef(
+                    cne.getName(), existingChild.getNodeTypeName(), ntReg);
+            if (!existingChildDef.allowsSameNameSiblings()) {
                 throw new ItemExistsException(existingChild.toString());
             }
         } else {
@@ -648,8 +646,7 @@
             }
             NodeState srcState = src.getState();
             srcState.setParentId(getNodeId());
-            srcState.setDefinitionId(def.getId());
-            
+
             if (srcState.getStatus() == ItemState.STATUS_EXISTING) {
                 srcState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
             }
@@ -825,20 +822,29 @@
     }
 
     /**
-     * Returns the NodeDef for this state
+     * Returns the QNodeDefinition for this state
      * @return the node def
+     * @throws RepositoryException if an error occurs
      */
-    public QItemDefinition getDefinition() {
-        return ntReg.getNodeDef(nodeState.getDefinitionId());
+    public QNodeDefinition getDefinition() throws RepositoryException {
+        if (def == null) {
+            EffectiveNodeType ent = getParent().getEffectiveNodeType();
+            def = ent.getApplicableChildNodeDef(getName(),
+                    nodeState.getNodeTypeName(), ntReg);
+        }
+        return def;
     }
 
     /**
      * Returns the property definition for the property state
      * @param prop the property state
      * @return the prop def
+     * @throws RepositoryException if an error occurs
      */
-    public QPropertyDefinition getDefinition(PropertyState prop) {
-        return ntReg.getPropDef(prop.getDefinitionId());
+    public QPropertyDefinition getDefinition(PropertyState prop)
+            throws RepositoryException {
+        return getEffectiveNodeType().getApplicablePropertyDef(
+                prop.getName(), prop.getType(), prop.isMultiValued());
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java Fri Sep 11 10:05:33 2009
@@ -20,11 +20,8 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -34,8 +31,9 @@
 import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.util.WeakIdentityCollection;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -262,12 +260,10 @@
                                                     Name name, int type,
                                                     boolean multiValued)
             throws RepositoryException {
-        PropDef def = getApplicablePropertyDef(parent, name, type, multiValued);
         PropertyId id = new PropertyId(parent.getNodeId(), name);
         VirtualPropertyState prop = new VirtualPropertyState(id);
         prop.setType(type);
         prop.setMultiValued(multiValued);
-        prop.setDefinitionId(def.getId());
         return prop;
     }
 
@@ -278,25 +274,12 @@
                                             NodeId id, Name nodeTypeName)
             throws RepositoryException {
 
-        NodeDefId def;
-        try {
-            def = getApplicableChildNodeDef(parent, name, nodeTypeName).getId();
-        } catch (RepositoryException re) {
-            // hack, use nt:unstructured as parent
-            NodeTypeRegistry ntReg = getNodeTypeRegistry();
-            EffectiveNodeType ent = ntReg.getEffectiveNodeType(NameConstants.NT_UNSTRUCTURED);
-            NodeDef cnd = ent.getApplicableChildNodeDef(name, nodeTypeName, ntReg);
-            ntReg.getNodeDef(cnd.getId());
-            def = cnd.getId();
-        }
-
         // create a new node state
         VirtualNodeState state;
         if (id == null) {
             id = new NodeId();
         }
         state = new VirtualNodeState(this, parent.getNodeId(), id, nodeTypeName, new Name[0]);
-        state.setDefinitionId(def);
 
         cache(state);
         return state;
@@ -385,7 +368,7 @@
      * @return
      * @throws RepositoryException
      */
-    protected PropDef getApplicablePropertyDef(NodeState parent, Name propertyName,
+    protected QPropertyDefinition getApplicablePropertyDef(NodeState parent, Name propertyName,
                                                int type, boolean multiValued)
             throws RepositoryException {
         return getEffectiveNodeType(parent).getApplicablePropertyDef(propertyName, type, multiValued);
@@ -400,7 +383,7 @@
      * @return
      * @throws RepositoryException
      */
-    protected NodeDef getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName)
+    protected QNodeDefinition getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName)
             throws RepositoryException {
         return getEffectiveNodeType(parent).getApplicableChildNodeDef(
                 nodeName, nodeTypeName, getNodeTypeRegistry());

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java Fri Sep 11 10:05:33 2009
@@ -23,7 +23,6 @@
 
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
@@ -89,7 +88,7 @@
         }
     }
 
-    public PropDef getApplicablePropertyDef(EffectiveNodeType ent)
+    public QPropertyDefinition getApplicablePropertyDef(EffectiveNodeType ent)
             throws ConstraintViolationException {
         if (values.length == 1) {
             // could be single- or multi-valued (n == 1)

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java Fri Sep 11 10:05:33 2009
@@ -24,7 +24,7 @@
 
 /**
  * <code>ProtectedPropertyImporter</code> is in charge of importing single
- * properties whith a protected <code>PropDef</code>.
+ * properties whith a protected <code>QPropertyDefinition</code>.
  *
  * @see ProtectedNodeImporter for an abstract class used to import protected
  * nodes and the subtree below them.

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java Fri Sep 11 10:05:33 2009
@@ -38,9 +38,7 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -51,6 +49,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
@@ -349,7 +348,7 @@
 
     protected void processProperty(NodeState node, PropInfo pInfo) throws RepositoryException {
         PropertyState prop;
-        PropDef def;
+        QPropertyDefinition def;
 
         Name name = pInfo.getName();
         int type = pInfo.getType();
@@ -358,7 +357,7 @@
             // a property with that name already exists...
             PropertyId idExisting = new PropertyId(node.getNodeId(), name);
             prop = (PropertyState) itemOps.getItemState(idExisting);
-            def = ntReg.getPropDef(prop.getDefinitionId());
+            def = itemOps.findApplicablePropertyDefinition(prop.getName(), prop.getType(), prop.isMultiValued(), node);
             if (def.isProtected()) {
                 // skip protected property
                 log.debug("skipping protected property "
@@ -430,7 +429,7 @@
             InternalValue value)
             throws RepositoryException {
         if (!node.hasPropertyName(name)) {
-            PropDef def = itemOps.findApplicablePropertyDefinition(
+            QPropertyDefinition def = itemOps.findApplicablePropertyDefinition(
                     name, type, multiple, node);
             PropertyState prop = itemOps.createPropertyState(
                     node, name, type, def);
@@ -493,7 +492,8 @@
                         parent.getChildNodeEntry(nodeName, 1);
                 NodeId idExisting = entry.getId();
                 NodeState existing = (NodeState) itemOps.getItemState(idExisting);
-                QNodeDefinition def = ntReg.getNodeDef(existing.getDefinitionId());
+                QNodeDefinition def = itemOps.findApplicableNodeDefinition(
+                        nodeName, existing.getNodeTypeName(), parent);
 
                 if (!def.allowsSameNameSiblings()) {
                     // existing doesn't allow same-name siblings,
@@ -529,7 +529,7 @@
                 // there's no node with that name...
                 if (id == null) {
                     // no potential uuid conflict, always create new node
-                    NodeDef def = itemOps.findApplicableNodeDefinition(
+                    QNodeDefinition def = itemOps.findApplicableNodeDefinition(
                             nodeName, ntName, parent);
                     if (def.isProtected()) {
                         // skip protected node
@@ -562,7 +562,7 @@
                         }
                     } catch (ItemNotFoundException e) {
                         // create new with given uuid
-                        NodeDef def = itemOps.findApplicableNodeDefinition(
+                        QNodeDefinition def = itemOps.findApplicableNodeDefinition(
                                 nodeName, ntName, parent);
                         if (def.isProtected()) {
                             // skip protected node



Mime
View raw message