jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r813753 [1/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
Author: mreutegg
Date: Fri Sep 11 10:05:33 2009
New Revision: 813753

URL: http://svn.apache.org/viewvc?rev=813753&view=rev
Log:
JCR-2170: Remove PropDefId and NodeDefId
- removed all usages of PropDef/NodeDefId related to ItemStates
- NodeDef replaced with QNodeDefinition
- PropDef replaced with QPropertyDefinition

Removed:
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDef.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDef.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
Modified:
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java Fri Sep 11 10:05:33 2009
@@ -39,11 +39,8 @@
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.lock.LockManager;
 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.nodetype.PropDefId;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
@@ -108,7 +105,8 @@
                                  LockManager lockMgr,
                                  SessionImpl session,
                                  HierarchyManager hierMgr) throws RepositoryException {
-        super(ntReg, hierMgr, session, lockMgr, session.getAccessManager(), session.getRetentionRegistry());
+        super(ntReg, hierMgr, session, lockMgr, session.getAccessManager(),
+                session.getRetentionRegistry(), session.getItemManager());
         this.stateMgr = stateMgr;
         this.session = session;
     }
@@ -434,12 +432,6 @@
         // add to new parent
         destParentState.addChildNodeEntry(destName.getName(), newState.getNodeId());
 
-        // change definition (id) of new node
-        NodeDef newNodeDef =
-                findApplicableNodeDefinition(destName.getName(),
-                        srcState.getNodeTypeName(), destParentState);
-        newState.setDefinitionId(newNodeDef.getId());
-
         // adjust references that refer to uuid's which have been mapped to
         // newly generated uuid's on copy/clone
         Iterator<Object> iter = refTracker.getProcessedReferences();
@@ -591,12 +583,6 @@
             destParent.addChildNodeEntry(destName.getName(), target.getNodeId());
         }
 
-        // change definition (id) of target node
-        NodeDef newTargetDef =
-                findApplicableNodeDefinition(destName.getName(),
-                        target.getNodeTypeName(), destParent);
-        target.setDefinitionId(newTargetDef.getId());
-
         // store states
         stateMgr.store(target);
         if (renameOnly) {
@@ -727,7 +713,7 @@
         // 4. node type constraints
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
-            QItemDefinition parentDef = ntReg.getNodeDef(parentState.getDefinitionId());
+            QItemDefinition parentDef = itemMgr.getDefinition(parentState).unwrap();
             // make sure parent node is not protected
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(
@@ -758,8 +744,7 @@
                     log.debug(msg);
                     throw new RepositoryException(msg, ise);
                 }
-                QNodeDefinition conflictingTargetDef =
-                        ntReg.getNodeDef(conflictingState.getDefinitionId());
+                QNodeDefinition conflictingTargetDef = itemMgr.getDefinition(conflictingState).unwrap();
                 // check same-name sibling setting of both target and existing node
                 if (!conflictingTargetDef.allowsSameNameSiblings()
                         || !newNodeDef.allowsSameNameSiblings()) {
@@ -902,12 +887,12 @@
         // 4. node type constraints
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
-            QItemDefinition parentDef = ntReg.getNodeDef(parentState.getDefinitionId());
+            QItemDefinition parentDef = itemMgr.getDefinition(parentState).unwrap();
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(safeGetJCRPath(parentId)
                         + ": cannot remove child node of protected parent node");
             }
-            QItemDefinition targetDef = ntReg.getNodeDef(targetState.getDefinitionId());
+            QItemDefinition targetDef = itemMgr.getDefinition(targetState).unwrap();
             if (targetDef.isMandatory()) {
                 throw new ConstraintViolationException(safeGetJCRPath(targetPath)
                         + ": cannot remove mandatory node");
@@ -1073,7 +1058,7 @@
                     + " because manager is not in edit mode");
         }
 
-        NodeDef def = findApplicableNodeDefinition(nodeName, nodeTypeName, parent);
+        QNodeDefinition def = findApplicableNodeDefinition(nodeName, nodeTypeName, parent);
         return createNodeState(parent, nodeName, nodeTypeName, mixinNames, id, def);
     }
 
@@ -1101,7 +1086,7 @@
                                      Name nodeTypeName,
                                      Name[] mixinNames,
                                      NodeId id,
-                                     NodeDef def)
+                                     QNodeDefinition def)
             throws ItemExistsException, ConstraintViolationException,
             RepositoryException, IllegalStateException {
 
@@ -1130,7 +1115,6 @@
         if (mixinNames != null && mixinNames.length > 0) {
             node.setMixinTypeNames(new HashSet<Name>(Arrays.asList(mixinNames)));
         }
-        node.setDefinitionId(def.getId());
 
         // now add new child node entry to parent
         parent.addChildNodeEntry(nodeName, id);
@@ -1144,18 +1128,18 @@
 
         if (!node.getMixinTypeNames().isEmpty()) {
             // create jcr:mixinTypes property
-            PropDef pd = ent.getApplicablePropertyDef(NameConstants.JCR_MIXINTYPES,
+            QPropertyDefinition pd = ent.getApplicablePropertyDef(NameConstants.JCR_MIXINTYPES,
                     PropertyType.NAME, true);
             createPropertyState(node, pd.getName(), pd.getRequiredType(), pd);
         }
 
         // add 'auto-create' properties defined in node type
-        for (PropDef pd : ent.getAutoCreatePropDefs()) {
+        for (QPropertyDefinition pd : ent.getAutoCreatePropDefs()) {
             createPropertyState(node, pd.getName(), pd.getRequiredType(), pd);
         }
 
         // recursively add 'auto-create' child nodes defined in node type
-        for (NodeDef nd : ent.getAutoCreateNodeDefs()) {
+        for (QNodeDefinition nd : ent.getAutoCreateNodeDefs()) {
             createNodeState(node, nd.getName(), nd.getDefaultPrimaryType(),
                     null, null, nd);
         }
@@ -1200,7 +1184,7 @@
         }
 
         // find applicable definition
-        PropDef def;
+        QPropertyDefinition def;
         // multi- or single-valued property?
         if (numValues == 1) {
             // could be single- or multi-valued (n == 1)
@@ -1239,7 +1223,7 @@
     public PropertyState createPropertyState(NodeState parent,
                                              Name propName,
                                              int type,
-                                             PropDef def)
+                                             QPropertyDefinition def)
             throws ItemExistsException, RepositoryException {
 
         // check for name collisions with existing properties
@@ -1251,7 +1235,6 @@
         // create property
         PropertyState prop = stateMgr.createNew(propName, parent.getNodeId());
 
-        prop.setDefinitionId(def.getId());
         if (def.getRequiredType() != PropertyType.UNDEFINED) {
             prop.setType(def.getRequiredType());
         } else if (type != PropertyType.UNDEFINED) {
@@ -1444,8 +1427,7 @@
             throws PathNotFoundException, ConstraintViolationException,
             RepositoryException {
         NodeState node = getNodeState(nodePath);
-        QItemDefinition parentDef = ntReg.getNodeDef(node.getDefinitionId());
-        if (parentDef.isProtected()) {
+        if (itemMgr.getDefinition(node).isProtected()) {
             throw new ConstraintViolationException(safeGetJCRPath(nodePath)
                     + ": node is protected");
         }
@@ -1688,7 +1670,6 @@
             newState = stateMgr.createNew(id, srcState.getNodeTypeName(), destParentId);
             // copy node state
             newState.setMixinTypeNames(srcState.getMixinTypeNames());
-            newState.setDefinitionId(srcState.getDefinitionId());
             if (shareable) {
                 // initialize shared set
                 newState.addShare(destParentId);
@@ -1775,15 +1756,16 @@
                  *
                  * todo FIXME delegate to 'node type instance handler'
                  */
-                PropDefId defId = srcChildState.getDefinitionId();
-                QPropertyDefinition def = ntReg.getPropDef(defId);
+                QPropertyDefinition def = ent.getApplicablePropertyDef(
+                        srcChildState.getName(), srcChildState.getType(),
+                        srcChildState.isMultiValued());
                 if (def.getDeclaringNodeType().equals(NameConstants.MIX_LOCKABLE)) {
                     // skip properties defined by mix:lockable
                     continue;
                 }
 
                 PropertyState newChildState =
-                        copyPropertyState(srcChildState, id, propName);
+                        copyPropertyState(srcChildState, id, propName, def);
 
                 if (history != null) {
                     if (fullVersionable) {
@@ -1832,23 +1814,21 @@
     /**
      * Copies the specified property state.
      *
-     * @param srcState
-     * @param parentId
-     * @param propName
-     * @return
-     * @throws RepositoryException
+     * @param srcState the property state to copy.
+     * @param parentId the id of the parent node.
+     * @param propName the name of the property.
+     * @param def      the definition of the property.
+     * @return a copy of the property state.
+     * @throws RepositoryException if an error occurs while copying.
      */
     private PropertyState copyPropertyState(PropertyState srcState,
                                             NodeId parentId,
-                                            Name propName)
+                                            Name propName,
+                                            QPropertyDefinition def)
             throws RepositoryException {
 
-        PropDefId defId = srcState.getDefinitionId();
-        QPropertyDefinition def = ntReg.getPropDef(defId);
-
         PropertyState newState = stateMgr.createNew(propName, parentId);
 
-        newState.setDefinitionId(defId);
         newState.setType(srcState.getType());
         newState.setMultiValued(srcState.isMultiValued());
         InternalValue[] values = srcState.getValues();
@@ -1860,8 +1840,8 @@
              *
              * todo FIXME delegate to 'node type instance handler'
              */
-            if (def.getDeclaringNodeType().equals(NameConstants.MIX_REFERENCEABLE)
-                    && propName.equals(NameConstants.JCR_UUID)) {
+            if (propName.equals(NameConstants.JCR_UUID)
+                    && def.getDeclaringNodeType().equals(NameConstants.MIX_REFERENCEABLE)) {
                 // set correct value of jcr:uuid property
                 newState.setValues(new InternalValue[]{InternalValue.create(parentId.toString())});
             } else {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Fri Sep 11 10:05:33 2009
@@ -373,9 +373,9 @@
         for (ItemState itemState : dirty) {
             ItemDefinition def;
             if (itemState.isNode()) {
-                def = ntMgr.getNodeDefinition(((NodeState) itemState).getDefinitionId());
+                def = itemMgr.getDefinition((NodeState) itemState);
             } else {
-                def = ntMgr.getPropertyDefinition(((PropertyState) itemState).getDefinitionId());
+                def = itemMgr.getDefinition((PropertyState) itemState);
             }
             /* check permissions for non-protected items. protected items are
                only added through API methods which need to assert that
@@ -579,11 +579,11 @@
 
         // walk through list of removed transient items and check REMOVE permission
         for (ItemState itemState : removed) {
-            ItemDefinition def;
+            QItemDefinition def;
             if (itemState.isNode()) {
-                def = ntMgr.getNodeDefinition(((NodeState) itemState).getDefinitionId());
+                def = itemMgr.getDefinition((NodeState) itemState).unwrap();
             } else {
-                def = ntMgr.getPropertyDefinition(((PropertyState) itemState).getDefinitionId());
+                def = itemMgr.getDefinition((PropertyState) itemState).unwrap();
             }
             if (!def.isProtected()) {
                 Path path = stateMgr.getAtticAwareHierarchyMgr().getPath(itemState.getId());

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java Fri Sep 11 10:05:33 2009
@@ -29,23 +29,21 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
+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.security.AccessManager;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateListener;
-import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -55,6 +53,8 @@
 import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -86,12 +86,12 @@
 
     private static Logger log = LoggerFactory.getLogger(ItemManager.class);
 
-    private final NodeDefinition rootNodeDef;
+    private final NodeDefinitionImpl rootNodeDef;
     private final NodeId rootNodeId;
 
     protected final SessionImpl session;
 
-    private final ItemStateManager itemStateProvider;
+    private final SessionItemStateManager sism;
     private final HierarchyManager hierMgr;
 
     /**
@@ -107,17 +107,19 @@
     /**
      * Creates a new per-session instance <code>ItemManager</code> instance.
      *
-     * @param itemStateProvider the item state provider associated with
-     *                          the new instance
-     * @param hierMgr           the hierarchy manager
-     * @param session           the session associated with the new instance
-     * @param rootNodeDef       the definition of the root node
-     * @param rootNodeId        the id of the root node
-     */
-    protected ItemManager(SessionItemStateManager itemStateProvider, HierarchyManager hierMgr,
-                          SessionImpl session, NodeDefinition rootNodeDef,
+     * @param sism        the item state manager associated with the new
+     *                    instance
+     * @param hierMgr     the hierarchy manager
+     * @param session     the session associated with the new instance
+     * @param rootNodeDef the definition of the root node
+     * @param rootNodeId  the id of the root node
+     */
+    protected ItemManager(SessionItemStateManager sism,
+                          HierarchyManager hierMgr,
+                          SessionImpl session,
+                          NodeDefinitionImpl rootNodeDef,
                           NodeId rootNodeId) {
-        this.itemStateProvider = itemStateProvider;
+        this.sism = sism;
         this.hierMgr = hierMgr;
         this.session = session;
         this.rootNodeDef = rootNodeDef;
@@ -145,7 +147,7 @@
             SessionItemStateManager itemStateProvider,
             HierarchyManager hierMgr,
             SessionImpl session,
-            NodeDefinition rootNodeDef,
+            NodeDefinitionImpl rootNodeDef,
             NodeId rootNodeId) {
         ItemManager mgr = new ItemManager(itemStateProvider, hierMgr,
                 session, rootNodeDef, rootNodeId);
@@ -163,52 +165,76 @@
         shareableNodesCache.clear();
     }
 
-    NodeDefinition getDefinition(NodeState state)
+    NodeDefinitionImpl getDefinition(NodeState state)
             throws RepositoryException {
         if (state.getId().equals(rootNodeId)) {
             // special handling required for root node
             return rootNodeDef;
         }
 
-        NodeDefId defId = state.getDefinitionId();
-        NodeDefinitionImpl def = session.getNodeTypeManager().getNodeDefinition(defId);
-        if (def == null) {
-            /**
-             * todo need proper way of handling inconsistent/corrupt definition
-             * e.g. 'flag' items that refer to non-existent definitions
-             */
-            log.warn("node at " + safeGetJCRPath(state.getNodeId())
-                    + " has invalid definitionId (" + defId + ")");
-
-            // fallback: try finding applicable definition
-            NodeImpl parent = (NodeImpl) getItem(state.getParentId());
-            NodeState parentState = parent.getNodeState();
-            ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());
-            def = parent.getApplicableChildNodeDefinition(cne.getName(), state.getNodeTypeName());
-            state.setDefinitionId(def.unwrap().getId());
+        NodeId parentId = state.getParentId();
+        if (parentId == null) {
+            // removed state has parentId set to null
+            // get from overlayed state
+            parentId = state.getOverlayedState().getParentId();
+        }
+        NodeState parentState;
+        try {
+            NodeImpl parent = (NodeImpl) getItem(parentId);
+            parentState = parent.getNodeState();
+            if (state.getParentId() == null) {
+                // indicates state has been removed, must use
+                // overlayed state of parent, otherwise child node entry
+                // cannot be found
+                parentState = (NodeState) parentState.getOverlayedState();
+            }
+        } catch (ItemNotFoundException e) {
+            // parent probably removed, get it from attic
+            try {
+                // use overlayed state if available
+                parentState = (NodeState) sism.getAttic().getItemState(
+                        parentId).getOverlayedState();
+            } catch (ItemStateException ex) {
+                throw new RepositoryException(ex);
+            }
+        }
+        // get child node entry
+        ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());
+        NodeTypeRegistry ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
+        try {
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType(
+                    parentState.getNodeTypeName(), parentState.getMixinTypeNames());
+            QNodeDefinition def = ent.getApplicableChildNodeDef(
+                    cne.getName(), state.getNodeTypeName(), ntReg);
+            return session.getNodeTypeManager().getNodeDefinition(def);
+        } catch (NodeTypeConflictException e) {
+            throw new RepositoryException(e);
         }
-        return def;
     }
 
-    PropertyDefinition getDefinition(PropertyState state)
+    PropertyDefinitionImpl getDefinition(PropertyState state)
             throws RepositoryException {
-        PropDefId defId = state.getDefinitionId();
-        PropertyDefinitionImpl def = session.getNodeTypeManager().getPropertyDefinition(defId);
-        if (def == null) {
-            /**
-             * todo need proper way of handling inconsistent/corrupt definition
-             * e.g. 'flag' items that refer to non-existent definitions
-             */
-            log.warn("property at " + safeGetJCRPath(state.getPropertyId())
-                    + " has invalid definitionId (" + defId + ")");
-
-            // fallback: try finding applicable definition
+        try {
             NodeImpl parent = (NodeImpl) getItem(state.getParentId());
-            def = parent.getApplicablePropertyDefinition(
+            return parent.getApplicablePropertyDefinition(
                     state.getName(), state.getType(), state.isMultiValued(), true);
-            state.setDefinitionId(def.unwrap().getId());
+        } catch (ItemNotFoundException e) {
+            // parent probably removed, get it from attic
+        }
+        try {
+            NodeState parent = (NodeState) sism.getAttic().getItemState(
+                    state.getParentId()).getOverlayedState();
+            NodeTypeRegistry ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType(
+                    parent.getNodeTypeName(), parent.getMixinTypeNames());
+            QPropertyDefinition def = ent.getApplicablePropertyDef(
+                    state.getName(), state.getType(), state.isMultiValued());
+            return session.getNodeTypeManager().getPropertyDefinition(def);
+        } catch (ItemStateException e) {
+            throw new RepositoryException(e);
+        } catch (NodeTypeConflictException e) {
+            throw new RepositoryException(e);
         }
-        return def;
     }
 
     /**
@@ -228,7 +254,7 @@
             session.sanityCheck();
 
             // shortcut: check if state exists for the given item
-            if (!itemStateProvider.hasItemState(itemId)) {
+            if (!sism.hasItemState(itemId)) {
                 return false;
             }
             getItemData(itemId, path, true);
@@ -310,7 +336,7 @@
             // NOTE: permission check & caching within createItemData
             ItemState state;
             try {
-                state = itemStateProvider.getItemState(itemId);
+                state = sism.getItemState(itemId);
             } catch (NoSuchItemStateException nsise) {
                 throw new ItemNotFoundException(itemId.toString());
             } catch (ItemStateException ise) {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java Fri Sep 11 10:05:33 2009
@@ -31,10 +31,8 @@
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.lock.LockManager;
 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.retention.RetentionRegistry;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.authorization.Permission;
@@ -133,6 +131,8 @@
 
     protected final RetentionRegistry retentionReg;
 
+    protected final ItemManager itemMgr;
+
     /**
      * Creates a new <code>ItemValidator</code> instance.
      *
@@ -143,7 +143,9 @@
     public ItemValidator(NodeTypeRegistry ntReg,
                          HierarchyManager hierMgr,
                          SessionImpl session) throws RepositoryException {
-        this(ntReg, hierMgr, session, session.getLockManager(), session.getAccessManager(), session.getRetentionRegistry());
+        this(ntReg, hierMgr, session, session.getLockManager(),
+                session.getAccessManager(), session.getRetentionRegistry(),
+                session.getItemManager());
     }
 
     /**
@@ -155,19 +157,22 @@
      * @param lockMgr    lockMgr
      * @param accessMgr  accessMgr
      * @param retentionReg
+     * @param itemMgr    the item manager
      */
     public ItemValidator(NodeTypeRegistry ntReg,
                          HierarchyManager hierMgr,
                          PathResolver resolver,
                          LockManager lockMgr,
                          AccessManager accessMgr,
-                         RetentionRegistry retentionReg) {
+                         RetentionRegistry retentionReg,
+                         ItemManager itemMgr) {
         this.ntReg = ntReg;
         this.hierMgr = hierMgr;
         this.resolver = resolver;
         this.lockMgr = lockMgr;
         this.accessMgr = accessMgr;
         this.retentionReg = retentionReg;
+        this.itemMgr = itemMgr;
     }
 
     /**
@@ -193,7 +198,7 @@
                 ntReg.getEffectiveNodeType(nodeState.getNodeTypeName());
         // effective node type (primary type incl. mixins)
         EffectiveNodeType entPrimaryAndMixins = getEffectiveNodeType(nodeState);
-        QNodeDefinition def = ntReg.getNodeDef(nodeState.getDefinitionId());
+        QNodeDefinition def = itemMgr.getDefinition(nodeState).unwrap();
 
         // check if primary type satisfies the 'required node types' constraint
         Name[] requiredPrimaryTypes = def.getRequiredPrimaryTypes();
@@ -249,7 +254,7 @@
      */
     public void validate(PropertyState propState)
             throws ConstraintViolationException, RepositoryException {
-        QPropertyDefinition def = ntReg.getPropDef(propState.getDefinitionId());
+        QPropertyDefinition def = itemMgr.getDefinition(propState).unwrap();
         InternalValue[] values = propState.getValues();
         int type = PropertyType.UNDEFINED;
         for (int i = 0; i < values.length; i++) {
@@ -454,12 +459,12 @@
      * @param name
      * @param nodeTypeName
      * @param parentState
-     * @return a <code>NodeDef</code>
+     * @return a <code>QNodeDefinition</code>
      * @throws ConstraintViolationException if no applicable child node definition
      *                                      could be found
      * @throws RepositoryException          if another error occurs
      */
-    public NodeDef findApplicableNodeDefinition(Name name,
+    public QNodeDefinition findApplicableNodeDefinition(Name name,
                                                 Name nodeTypeName,
                                                 NodeState parentState)
             throws RepositoryException, ConstraintViolationException {
@@ -482,12 +487,12 @@
      * @param type
      * @param multiValued
      * @param parentState
-     * @return a <code>PropDef</code>
+     * @return a <code>QPropertyDefinition</code>
      * @throws ConstraintViolationException if no applicable property definition
      *                                      could be found
      * @throws RepositoryException          if another error occurs
      */
-    public PropDef findApplicablePropertyDefinition(Name name,
+    public QPropertyDefinition findApplicablePropertyDefinition(Name name,
                                                     int type,
                                                     boolean multiValued,
                                                     NodeState parentState)
@@ -513,7 +518,7 @@
      * @param name
      * @param type
      * @param parentState
-     * @return a <code>PropDef</code>
+     * @return a <code>QPropertyDefinition</code>
      * @throws ConstraintViolationException if no applicable property definition
      *                                      could be found
      * @throws RepositoryException          if another error occurs

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Fri Sep 11 10:05:33 2009
@@ -71,14 +71,11 @@
 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.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.core.security.authorization.Permission;
@@ -92,6 +89,8 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -411,13 +410,12 @@
         // create a new property state
         PropertyState propState;
         try {
-            PropDef propDef = def.unwrap();
+            QPropertyDefinition propDef = def.unwrap();
             propState =
                     stateMgr.createTransientPropertyState(getNodeId(), name,
                             ItemState.STATUS_NEW);
             propState.setType(type);
             propState.setMultiValued(propDef.isMultiple());
-            propState.setDefinitionId(propDef.getId());
             // compute system generated values if necessary
             InternalValue[] genValues = session.getNodeTypeInstanceHandler()
                     .computeSystemGeneratedPropertyValues(data.getNodeState(), propDef);
@@ -450,7 +448,6 @@
     }
 
     protected synchronized NodeImpl createChildNode(Name name,
-                                                    NodeDefinitionImpl def,
                                                     NodeTypeImpl nodeType,
                                                     NodeId id)
             throws RepositoryException {
@@ -463,7 +460,6 @@
             nodeState =
                     stateMgr.createTransientNodeState(id, nodeType.getQName(),
                             getNodeId(), ItemState.STATUS_NEW);
-            nodeState.setDefinitionId(def.unwrap().getId());
         } catch (ItemStateException ise) {
             String msg = "failed to add child node " + name + " to " + this;
             log.debug(msg);
@@ -502,8 +498,7 @@
         NodeDefinition[] nda = nodeType.getAutoCreatedNodeDefinitions();
         for (int i = 0; i < nda.length; i++) {
             NodeDefinitionImpl nd = (NodeDefinitionImpl) nda[i];
-            node.createChildNode(nd.getQName(), nd,
-                    (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
+            node.createChildNode(nd.getQName(), (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
         }
 
         return node;
@@ -570,13 +565,12 @@
         }
     }
 
-    protected void onRedefine(NodeDefId defId) throws RepositoryException {
+    protected void onRedefine(QNodeDefinition def) throws RepositoryException {
         NodeDefinitionImpl newDef =
-                session.getNodeTypeManager().getNodeDefinition(defId);
+                session.getNodeTypeManager().getNodeDefinition(def);
         // modify the state of 'this', i.e. the target node
-        NodeState thisState = (NodeState) getOrCreateTransientItemState();
-        // set id of new definition
-        thisState.setDefinitionId(defId);
+        getOrCreateTransientItemState();
+        // set new definition
         data.setDefinition(newDef);
     }
 
@@ -708,9 +702,9 @@
                                                                   Name nodeTypeName)
             throws ConstraintViolationException, RepositoryException {
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-        NodeDef cnd = getEffectiveNodeType().getApplicableChildNodeDef(
+        QNodeDefinition cnd = getEffectiveNodeType().getApplicableChildNodeDef(
                 nodeName, nodeTypeName, ntMgr.getNodeTypeRegistry());
-        return ntMgr.getNodeDefinition(cnd.getId());
+        return ntMgr.getNodeDefinition(cnd);
     }
 
     /**
@@ -731,7 +725,7 @@
                                                                      boolean multiValued,
                                                                      boolean exactTypeMatch)
             throws ConstraintViolationException, RepositoryException {
-        PropDef pd;
+        QPropertyDefinition pd;
         if (exactTypeMatch || type == PropertyType.UNDEFINED) {
             pd = getEffectiveNodeType().getApplicablePropertyDef(
                     propertyName, type, multiValued);
@@ -746,7 +740,7 @@
                         propertyName, PropertyType.UNDEFINED, multiValued);
             }
         }
-        return session.getNodeTypeManager().getPropertyDefinition(pd.getId());
+        return session.getNodeTypeManager().getPropertyDefinition(pd);
     }
 
     protected void makePersistent() throws InvalidItemStateException {
@@ -779,8 +773,6 @@
             persistentState.setNodeTypeName(transientState.getNodeTypeName());
             // mixin types
             persistentState.setMixinTypeNames(transientState.getMixinTypeNames());
-            // id of definition
-            persistentState.setDefinitionId(transientState.getDefinitionId());
             // child node entries
             persistentState.setChildNodeEntries(transientState.getChildNodeEntries());
             // property entries
@@ -816,7 +808,6 @@
         thisState.setParentId(transientState.getParentId());
         thisState.setNodeTypeName(transientState.getNodeTypeName());
         thisState.setMixinTypeNames(transientState.getMixinTypeNames());
-        thisState.setDefinitionId(transientState.getDefinitionId());
         thisState.setChildNodeEntries(transientState.getChildNodeEntries());
         thisState.setPropertyNames(transientState.getPropertyNames());
         thisState.setSharedSet(transientState.getSharedSet());
@@ -914,7 +905,7 @@
                 // or existing mixin's
                 NodeTypeImpl declaringNT = (NodeTypeImpl) nd.getDeclaringNodeType();
                 if (!entExisting.includesNodeType(declaringNT.getQName())) {
-                    createChildNode(nd.getQName(), nd, (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
+                    createChildNode(nd.getQName(), (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
                 }
             }
         } catch (RepositoryException re) {
@@ -1021,7 +1012,7 @@
             for (Name propName : set) {
                 PropertyState propState = (PropertyState) stateMgr.getItemState(new PropertyId(thisState.getNodeId(), propName));
                 // check if property has been defined by mixin type (or one of its supertypes)
-                PropertyDefinition def = ntMgr.getPropertyDefinition(propState.getDefinitionId());
+                PropertyDefinition def = itemMgr.getDefinition(propState);
                 NodeTypeImpl declaringNT = (NodeTypeImpl) def.getDeclaringNodeType();
                 if (!entResulting.includesNodeType(declaringNT.getQName())) {
                     // the resulting effective node type doesn't include the
@@ -1050,7 +1041,7 @@
                                                 pdi.getRequiredType(),
                                                 session.getValueFactory());
                                 // redefine property
-                                prop.onRedefine(pdi.unwrap().getId());
+                                prop.onRedefine(pdi.unwrap());
                                 // set converted values
                                 prop.setValue(values);
                             } else {
@@ -1061,13 +1052,13 @@
                                                 pdi.getRequiredType(),
                                                 session.getValueFactory());
                                 // redefine property
-                                prop.onRedefine(pdi.unwrap().getId());
+                                prop.onRedefine(pdi.unwrap());
                                 // set converted values
                                 prop.setValue(value);
                             }
                         } else {
                             // redefine property
-                            prop.onRedefine(pdi.unwrap().getId());
+                            prop.onRedefine(pdi.unwrap());
                         }
                     } catch (ValueFormatException vfe) {
                         // value conversion failed, remove it
@@ -1085,7 +1076,7 @@
             for (int i = list.size() - 1; i >= 0; i--) {
                 ChildNodeEntry entry = list.get(i);
                 NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
-                NodeDefinition def = ntMgr.getNodeDefinition(nodeState.getDefinitionId());
+                NodeDefinition def = itemMgr.getDefinition(nodeState);
                 // check if node has been defined by mixin type (or one of its supertypes)
                 NodeTypeImpl declaringNT = (NodeTypeImpl) def.getDeclaringNodeType();
                 if (!entResulting.includesNodeType(declaringNT.getQName())) {
@@ -1103,7 +1094,7 @@
                                 entry.getName(),
                                 nodeState.getNodeTypeName());
                         // redefine node
-                        node.onRedefine(ndi.unwrap().getId());
+                        node.onRedefine(ndi.unwrap());
                     } catch (ConstraintViolationException cve) {
                         // no suitable definition found for this child node,
                         // remove it
@@ -1493,7 +1484,7 @@
         session.getValidator().checkModify(this, options, Permission.NONE);
 
         // now do create the child node
-        return createChildNode(nodeName, def, nt, id);
+        return createChildNode(nodeName, nt, id);
     }
 
     /**
@@ -3677,18 +3668,18 @@
         }
 
         // get applicable definition for this node using new primary type
-        NodeDefId defId;
+        QNodeDefinition nodeDef;
         try {
             NodeImpl parent = (NodeImpl) getParent();
-            defId = parent.getApplicableChildNodeDefinition(getQName(), ntName).unwrap().getId();
+            nodeDef = parent.getApplicableChildNodeDefinition(getQName(), ntName).unwrap();
         } catch (RepositoryException re) {
             String msg = this + ": no applicable definition found in parent node's node type";
             log.debug(msg);
             throw new ConstraintViolationException(msg, re);
         }
 
-        if (!defId.equals(state.getDefinitionId())) {
-            onRedefine(defId);
+        if (!nodeDef.equals(itemMgr.getDefinition(state).unwrap())) {
+            onRedefine(nodeDef);
         }
 
         Set<QItemDefinition> oldDefs = new HashSet<QItemDefinition>(Arrays.asList(entOld.getAllItemDefs()));
@@ -3732,7 +3723,7 @@
                 PropertyState propState =
                         (PropertyState) stateMgr.getItemState(
                                 new PropertyId(thisState.getNodeId(), propName));
-                if (!allDefs.contains(ntReg.getPropDef(propState.getDefinitionId()))) {
+                if (!allDefs.contains(itemMgr.getDefinition(propState).unwrap())) {
                     // try to find new applicable definition first and
                     // redefine property if possible
                     try {
@@ -3756,7 +3747,7 @@
                                                 pdi.getRequiredType(),
                                                 session.getValueFactory());
                                 // redefine property
-                                prop.onRedefine(pdi.unwrap().getId());
+                                prop.onRedefine(pdi.unwrap());
                                 // set converted values
                                 prop.setValue(values);
                             } else {
@@ -3767,13 +3758,13 @@
                                                 pdi.getRequiredType(),
                                                 session.getValueFactory());
                                 // redefine property
-                                prop.onRedefine(pdi.unwrap().getId());
+                                prop.onRedefine(pdi.unwrap());
                                 // set converted values
                                 prop.setValue(value);
                             }
                         } else {
                             // redefine property
-                            prop.onRedefine(pdi.unwrap().getId());
+                            prop.onRedefine(pdi.unwrap());
                         }
                         // update collection of added definitions
                         addedDefs.remove(pdi.unwrap());
@@ -3800,7 +3791,7 @@
             ChildNodeEntry entry = list.get(i);
             try {
                 NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
-                if (!allDefs.contains(ntReg.getNodeDef(nodeState.getDefinitionId()))) {
+                if (!allDefs.contains(itemMgr.getDefinition(nodeState).unwrap())) {
                     // try to find new applicable definition first and
                     // redefine node if possible
                     try {
@@ -3814,7 +3805,7 @@
                                 entry.getName(),
                                 nodeState.getNodeTypeName());
                         // redefine node
-                        node.onRedefine(ndi.unwrap().getId());
+                        node.onRedefine(ndi.unwrap());
                         // update collection of added definitions
                         addedDefs.remove(ndi.unwrap());
                     } catch (ConstraintViolationException cve) {
@@ -3832,14 +3823,13 @@
 
         // create items that are defined as auto-created by the new primary node
         // type and at the same time were not present with the old nt
-        for (Iterator<QItemDefinition> iter = addedDefs.iterator(); iter.hasNext();) {
-            QItemDefinition def = iter.next();
+        for (QItemDefinition def : addedDefs) {
             if (def.isAutoCreated()) {
                 if (def.definesNode()) {
-                    NodeDefinitionImpl ndi = ntMgr.getNodeDefinition(((NodeDef) def).getId());
-                    createChildNode(ndi.getQName(), ndi, (NodeTypeImpl) ndi.getDefaultPrimaryType(), null);
+                    NodeDefinitionImpl ndi = ntMgr.getNodeDefinition((QNodeDefinition) def);
+                    createChildNode(ndi.getQName(), (NodeTypeImpl) ndi.getDefaultPrimaryType(), null);
                 } else {
-                    PropertyDefinitionImpl pdi = ntMgr.getPropertyDefinition(((PropDef) def).getId());
+                    PropertyDefinitionImpl pdi = ntMgr.getPropertyDefinition((QPropertyDefinition) def);
                     createChildProperty(pdi.getQName(), pdi.getRequiredType(), pdi);
                 }
             }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Fri Sep 11 10:05:33 2009
@@ -38,7 +38,6 @@
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.state.ItemState;
@@ -47,6 +46,7 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.value.ValueHelper;
@@ -137,7 +137,6 @@
                 throw new InvalidItemStateException(msg);
             }
             // copy state from transient state
-            persistentState.setDefinitionId(transientState.getDefinitionId());
             persistentState.setType(transientState.getType());
             persistentState.setMultiValued(transientState.isMultiValued());
             persistentState.setValues(transientState.getValues());
@@ -162,19 +161,14 @@
             stateMgr.disconnectTransientItemState(thisState);
         }
         // reapply transient changes
-        thisState.setDefinitionId(transientState.getDefinitionId());
         thisState.setType(transientState.getType());
         thisState.setMultiValued(transientState.isMultiValued());
         thisState.setValues(transientState.getValues());
     }
 
-    protected void onRedefine(PropDefId defId) throws RepositoryException {
+    protected void onRedefine(QPropertyDefinition def) throws RepositoryException {
         PropertyDefinitionImpl newDef =
-                session.getNodeTypeManager().getPropertyDefinition(defId);
-        // modify the state of 'this', i.e. the target property
-        PropertyState thisState = (PropertyState) getOrCreateTransientItemState();
-        // set id of new definition
-        thisState.setDefinitionId(defId);
+                session.getNodeTypeManager().getPropertyDefinition(def);
         data.setDefinition(newDef);
     }
 

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java Fri Sep 11 10:05:33 2009
@@ -90,7 +90,7 @@
             }
         }
 
-        return parentImpl.createChildNode(name, def, nodeType, null);
+        return parentImpl.createChildNode(name, nodeType, null);
     }
 
     protected Property setProperty(NodeImpl parentImpl, Name name, Value value) throws RepositoryException {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Fri Sep 11 10:05:33 2009
@@ -1140,7 +1140,7 @@
         }
 
         // change definition of target
-        targetNode.onRedefine(newTargetDef.unwrap().getId());
+        targetNode.onRedefine(newTargetDef.unwrap());
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Fri Sep 11 10:05:33 2009
@@ -20,7 +20,6 @@
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.id.ItemId;
-import org.apache.jackrabbit.core.ItemValidator;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.id.PropertyId;
@@ -34,7 +33,6 @@
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.observation.EventImpl;
 import org.apache.jackrabbit.core.observation.SynchronousEventListener;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -874,7 +872,6 @@
         SessionImpl editingSession = (SessionImpl) node.getSession();
         WorkspaceImpl wsp = (WorkspaceImpl) editingSession.getWorkspace();
         UpdatableItemStateManager stateMgr = wsp.getItemStateManager();
-        ItemValidator helper = new ItemValidator(editingSession.getNodeTypeManager().getNodeTypeRegistry(), wsp.getHierarchyManager(), editingSession);
 
         synchronized (stateMgr) {
             if (stateMgr.inEditMode()) {
@@ -888,9 +885,7 @@
 
                 PropertyState propState;
                 if (!nodeState.hasPropertyName(NameConstants.JCR_LOCKOWNER)) {
-                    PropDef def = helper.findApplicablePropertyDefinition(NameConstants.JCR_LOCKOWNER, PropertyType.STRING, false, nodeState);
                     propState = stateMgr.createNew(NameConstants.JCR_LOCKOWNER, nodeId);
-                    propState.setDefinitionId(def.getId());
                     propState.setType(PropertyType.STRING);
                     propState.setMultiValued(false);
                 } else {
@@ -901,9 +896,7 @@
                 stateMgr.store(nodeState);
 
                 if (!nodeState.hasPropertyName(NameConstants.JCR_LOCKISDEEP)) {
-                    PropDef def = helper.findApplicablePropertyDefinition(NameConstants.JCR_LOCKISDEEP, PropertyType.BOOLEAN, false, nodeState);
                     propState = stateMgr.createNew(NameConstants.JCR_LOCKISDEEP, nodeId);
-                    propState.setDefinitionId(def.getId());
                     propState.setType(PropertyType.BOOLEAN);
                     propState.setMultiValued(false);
                 } else {

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Fri Sep 11 10:05:33 2009
@@ -35,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
@@ -107,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, QItemDefinition> itemDefIds = new HashMap<Object, QItemDefinition>();
+        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()) {
@@ -125,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
@@ -156,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()) {
@@ -172,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
@@ -327,232 +329,232 @@
         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());
+        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<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 QItemDefinition[] getNamedNodeDefs() {
         if (namedItemDefs.size() == 0) {
-            return NodeDef.EMPTY_ARRAY;
+            return QNodeDefinition.EMPTY_ARRAY;
         }
-        ArrayList<NodeDef> defs = new ArrayList<NodeDef>(namedItemDefs.size());
+        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 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());
+        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());
+        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());
+        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());
+        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<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 QPropertyDefinition[] getNamedPropDefs() {
         if (namedItemDefs.size() == 0) {
-            return PropDef.EMPTY_ARRAY;
+            return QPropertyDefinition.EMPTY_ARRAY;
         }
-        ArrayList<PropDef> defs = new ArrayList<PropDef>(namedItemDefs.size());
+        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) {
+    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());
+        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());
+        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());
+        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());
+        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());
+        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()]);
     }
 
     /**
@@ -686,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;
@@ -700,7 +702,7 @@
         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) {
@@ -718,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())) {
@@ -758,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;
@@ -800,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;
         }
@@ -819,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
@@ -854,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

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java Fri Sep 11 10:05:33 2009
@@ -46,7 +46,7 @@
      *
      * @param def <code>NodeDef</code> to create identifier for
      */
-    NodeDefId(QNodeDefinition def) {
+    public NodeDefId(QNodeDefinition def) {
         if (def == null) {
             throw new IllegalArgumentException("NodeDef argument can not be null");
         }

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

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java?rev=813753&r1=813752&r2=813753&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java Fri Sep 11 10:05:33 2009
@@ -31,6 +31,8 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 
@@ -54,8 +56,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 +72,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 +88,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(new QNodeDefinitionImpl(nd));
         }
-        propDefs = new HashSet<PropDef>();
+        propDefs = new HashSet<QPropertyDefinition>();
         for (QPropertyDefinition pd: def.getPropertyDefs()) {
-            propDefs.add(new PropDefImpl(pd));
+            propDefs.add(new QPropertyDefinitionImpl(pd));
         }
     }
 
@@ -252,7 +254,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));
@@ -261,9 +263,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));
@@ -351,11 +353,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()]);
     }
 
     /**
@@ -365,11 +367,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 >
@@ -382,10 +384,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;
     }
 



Mime
View raw message