jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r816343 [3/4] - in /jackrabbit/trunk: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-...
Date Thu, 17 Sep 2009 19:20:36 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java Thu Sep 17 19:20:33 2009
@@ -17,12 +17,7 @@
 package org.apache.jackrabbit.core.nodetype.xml;
 
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.ItemDef;
-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 +29,14 @@
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 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();
+            QPropertyDefinitionBuilder def = getPropDef();
             def.setDeclaringNodeType(type.getName());
-            properties.add(def);
+            properties.add(def.build());
         }
-        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();
+            QNodeDefinitionBuilder def = getChildNodeDef();
             def.setDeclaringNodeType(type.getName());
-            nodes.add(def);
+            nodes.add(def.build());
         }
-        type.setChildNodeDefs(nodes.toArray(new NodeDef[nodes.size()]));
+        type.setChildNodeDefs(nodes.toArray(new QNodeDefinition[nodes.size()]));
 
         return type;
     }
@@ -212,26 +212,23 @@
      *                                     illegal name
      * @throws NamespaceException if a namespace is not defined
      */
-    private PropDefImpl getPropDef()
+    private QPropertyDefinitionBuilder getPropDef()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
-        PropDefImpl def = new PropDefImpl();
+        QPropertyDefinitionBuilder def = new QPropertyDefinitionBuilder();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
-            def.setName(ItemDef.ANY_NAME);
+            def.setName(NameConstants.ANY_NAME);
         } else {
             def.setName(resolver.getQName(name));
         }
 
         // 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,25 +317,22 @@
      * @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 QNodeDefinitionBuilder getChildNodeDef() throws NameException, NamespaceException {
+        QNodeDefinitionBuilder def = new QNodeDefinitionBuilder();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
-            def.setName(ItemDef.ANY_NAME);
+            def.setName(NameConstants.ANY_NAME);
         } else {
             def.setName(resolver.getQName(name));
         }
 
         // 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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java Thu Sep 17 19:20:33 2009
@@ -16,11 +16,8 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.util.DOMBuilder;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.value.InternalValueFactory;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
@@ -30,6 +27,9 @@
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PropertyType;
@@ -165,14 +165,14 @@
         }
 
         // property definitions
-        PropDef[] properties = def.getPropertyDefs();
-        for (PropDef property : properties) {
+        QPropertyDefinition[] properties = def.getPropertyDefs();
+        for (QPropertyDefinition property : properties) {
             addPropDef(property);
         }
 
         // child node definitions
-        NodeDef[] nodes = def.getChildNodeDefs();
-        for (NodeDef node : nodes) {
+        QNodeDefinition[] nodes = def.getChildNodeDefs();
+        for (QNodeDefinition node : nodes) {
             addChildNodeDef(node);
         }
 
@@ -188,7 +188,7 @@
      * @throws NamespaceException if the property definition contains
      *                                   invalid namespace references
      */
-    private void addPropDef(PropDef def)
+    private void addPropDef(QPropertyDefinition def)
             throws NamespaceException, RepositoryException {
         builder.startElement(Constants.PROPERTYDEFINITION_ELEMENT);
 
@@ -261,10 +261,10 @@
         }
 
         // default values
-        InternalValue[] defaults = def.getDefaultValues();
+        QValue[] defaults = def.getDefaultValues();
         if (defaults != null && defaults.length > 0) {
             builder.startElement(Constants.DEFAULTVALUES_ELEMENT);
-            for (InternalValue v : defaults) {
+            for (QValue v : defaults) {
                 builder.addContentElement(
                         Constants.DEFAULTVALUE_ELEMENT,
                         factory.createValue(v).getString());
@@ -282,7 +282,7 @@
      * @throws NamespaceException if the child node definition contains
      *                                   invalid namespace references
      */
-    private void addChildNodeDef(NodeDef def)
+    private void addChildNodeDef(QNodeDefinition def)
             throws NamespaceException {
         builder.startElement(Constants.CHILDNODEDEFINITION_ELEMENT);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java Thu Sep 17 19:20:33 2009
@@ -24,7 +24,6 @@
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.data.DataStore;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 
@@ -158,7 +157,7 @@
         // parentUUID
         state.setParentId(readID(in));
         // definitionId
-        state.setDefinitionId(NodeDefId.valueOf(in.readUTF()));
+        in.readUTF();
 
         // mixin types
         int count = in.readInt();   // count
@@ -210,7 +209,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 +260,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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java Thu Sep 17 19:20:33 2009
@@ -20,8 +20,6 @@
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -82,7 +80,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 +129,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 +180,7 @@
         // multiValued
         out.writeBoolean(state.isMultiValued());
         // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
+        out.writeUTF("");
         // modCount
         out.writeShort(state.getModCount());
         // values
@@ -259,8 +256,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 +266,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 +298,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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java Thu Sep 17 19:20:33 2009
@@ -19,8 +19,8 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistryListener;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,9 +87,9 @@
     public void nodeTypeRegistered(Name ntName) {
         try {
             NodeTypeDef def = registry.getNodeTypeDef(ntName);
-            PropDef[] propDefs = def.getPropertyDefs();
+            QPropertyDefinition[] propDefs = def.getPropertyDefs();
             synchronized (typeMapping) {
-                for (PropDef propDef : propDefs) {
+                for (QPropertyDefinition propDef : propDefs) {
                     int type = propDef.getRequiredType();
                     if (!propDef.definesResidual() && type != PropertyType.UNDEFINED) {
                         Name name = propDef.getName();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java Thu Sep 17 19:20:33 2009
@@ -28,10 +28,10 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
-import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
 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.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.query.AndQueryNode;
@@ -43,6 +43,7 @@
 import org.apache.jackrabbit.spi.commons.query.QueryParser;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
 import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 import org.apache.lucene.search.Query;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -174,9 +175,9 @@
             NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
             PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
             for (PropertyDefinition pd : propDefs) {
-                PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) pd;
+                QPropertyDefinition propDef = ((PropertyDefinitionImpl) pd).unwrap();
                 if (!propDef.definesResidual() && !propDef.isMultiple()) {
-                    columns.put(propDef.getQName(), columnForName(propDef.getQName()));
+                    columns.put(propDef.getName(), columnForName(propDef.getName()));
                 }
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java Thu Sep 17 19:20:33 2009
@@ -29,7 +29,6 @@
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
-import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
 import org.apache.jackrabbit.core.query.lucene.constraint.Constraint;
 import org.apache.jackrabbit.core.query.lucene.constraint.ConstraintBuilder;
@@ -39,6 +38,7 @@
 import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
 import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 
 /**
  * <code>QueryObjectModelImpl</code>...
@@ -123,7 +123,7 @@
                 NodeTypeImpl nt = ntMgr.getNodeType(selector.getNodeTypeQName());
                 for (PropertyDefinition pd : nt.getPropertyDefinitions()) {
                     PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) pd;
-                    if (!propDef.definesResidual() && !propDef.isMultiple()) {
+                    if (!propDef.unwrap().definesResidual() && !propDef.isMultiple()) {
                         String sn = selector.getSelectorName();
                         String pn = propDef.getName();
                         columns.add((ColumnImpl) qomFactory.column(sn, pn, sn + "." + pn));

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java Thu Sep 17 19:20:33 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
 
 import java.util.ArrayList;
@@ -56,11 +55,6 @@
     private NodeId parentId;
 
     /**
-     * id of this node's definition
-     */
-    private NodeDefId defId;
-
-    /**
      * insertion-ordered collection of ChildNodeEntry objects
      */
     private ChildNodeEntries childNodeEntries = new ChildNodeEntries();
@@ -127,7 +121,6 @@
             parentId = nodeState.parentId;
             nodeTypeName = nodeState.nodeTypeName;
             mixinTypeNames = (NameSet) nodeState.mixinTypeNames.clone();
-            defId = nodeState.defId;
             propertyNames = (NameSet) nodeState.propertyNames.clone();
             childNodeEntries = (ChildNodeEntries) nodeState.childNodeEntries.clone();
             if (syncModCount) {
@@ -211,24 +204,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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Thu Sep 17 19:20: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;
@@ -35,10 +36,12 @@
 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.NodeDef;
 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -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;
                                     }
-                                    NodeDef def = ntReg.getNodeDef(ns.getDefinitionId());
-                                    return def != null ? def.allowsSameNameSiblings() : false;
                                 }
                             };
                     if (NodeStateMerger.merge((NodeState) transientState, context)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Thu Sep 17 19:20: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,11 +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.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.observation.EventState;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
@@ -47,6 +43,7 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -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;
                                             }
-                                            NodeDef 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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java Thu Sep 17 19:20:33 2009
@@ -242,6 +242,18 @@
         }
     }
 
+    public static InternalValue[] create(QValue[] values)
+            throws RepositoryException {
+        if (values == null) {
+            return null;
+        }
+        InternalValue[] tmp = new InternalValue[values.length];
+        for (int i = 0; i < values.length; i++) {
+            tmp[i] = InternalValue.create(values[i]);
+        }
+        return tmp;
+    }
+
     static InternalValue getInternalValue(DataIdentifier identifier, DataStore store) throws DataStoreException {
         // access the record to ensure it is not garbage collected
         if (store.getRecordIfStored(identifier) != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java Thu Sep 17 19:20: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;
@@ -42,6 +40,8 @@
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
 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.name.NameConstants;
 
 /**
@@ -70,6 +70,11 @@
     private Name name;
 
     /**
+     * the cached node definition
+     */
+    private QNodeDefinition def;
+
+    /**
      * Creates a new persistent node
      *
      * @param stateMgr state manager
@@ -280,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
@@ -560,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));
@@ -589,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);
@@ -611,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 {
@@ -646,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);
             }
@@ -823,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 NodeDef 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 PropDef 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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java Thu Sep 17 19:20:33 2009
@@ -34,7 +34,6 @@
 import org.apache.jackrabbit.core.ItemValidator;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -43,6 +42,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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -428,7 +428,7 @@
         }
 
         // add 'auto-create' properties that do not exist yet
-        for (PropDef def: state.getEffectiveNodeType().getAutoCreatePropDefs()) {
+        for (QPropertyDefinition def: state.getEffectiveNodeType().getAutoCreatePropDefs()) {
             if (!state.hasProperty(def.getName())) {
                 InternalValue[] values = computeAutoValues(state, def, true);
                 if (values != null) {
@@ -644,14 +644,16 @@
      * @param def property definition
      * @param useDefaultValues if <code>true</code> the default values are respected
      * @return the values or <code>null</code>
+     * @throws RepositoryException if the values cannot be computed.
      */
-    private InternalValue[] computeAutoValues(NodeStateEx state, PropDef def,
-                                                     boolean useDefaultValues) {
+    private InternalValue[] computeAutoValues(NodeStateEx state, QPropertyDefinition def,
+                                              boolean useDefaultValues)
+            throws RepositoryException {
         // compute system generated values if necessary
         InternalValue[] values = session.getNodeTypeInstanceHandler().
                 computeSystemGeneratedPropertyValues(state.getState(), def);
         if (values == null && useDefaultValues) {
-            values = def.getDefaultValues();
+            values = InternalValue.create(def.getDefaultValues());
         }
         // avoid empty value array for single value property
         if (values != null && values.length == 0 && !def.isMultiple()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java Thu Sep 17 19:20: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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java Thu Sep 17 19:20:33 2009
@@ -20,9 +20,9 @@
 
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 
 /**
  * Default implementation that isn't able to handle any protected properties.
@@ -46,18 +46,18 @@
     /**
      * Always returns <code>false</code>.
      *
-     * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.NodeImpl, PropInfo, org.apache.jackrabbit.core.nodetype.PropDef)
+     * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.NodeImpl, PropInfo, QPropertyDefinition)
      */
-    public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, PropDef def) {
+    public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def) {
         return false;
     }
 
     /**
      * Always returns <code>false</code>.
      *
-     * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.state.NodeState, PropInfo, PropDef)
+     * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.state.NodeState, PropInfo, QPropertyDefinition)
      */
-    public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, PropDef def) throws RepositoryException {
+    public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws RepositoryException {
         return false;
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java Thu Sep 17 19:20:33 2009
@@ -23,12 +23,10 @@
 
 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;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Information about a property being imported. This class is used
@@ -79,7 +77,7 @@
         }
     }
 
-    public int getTargetType(PropDef def) {
+    public int getTargetType(QPropertyDefinition def) {
         int target = def.getRequiredType();
         if (target != PropertyType.UNDEFINED) {
             return target;
@@ -90,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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java Thu Sep 17 19:20:33 2009
@@ -19,12 +19,12 @@
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 
 /**
  * <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.
@@ -42,7 +42,7 @@
      * <code>false</code> otherwise.
      * @throws RepositoryException If an error occurs.
      */
-    boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, PropDef def)
+    boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def)
             throws RepositoryException;
 
     /**
@@ -56,7 +56,7 @@
      * <code>false</code> otherwise.
      * @throws RepositoryException If an error occurs.
      */
-    boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, PropDef def)
+    boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def)
             throws RepositoryException;
 
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java Thu Sep 17 19:20:33 2009
@@ -35,10 +35,10 @@
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.util.ReferenceChangeTracker;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -153,7 +153,7 @@
     }
 
 
-    protected void createProperty(NodeImpl node, PropInfo pInfo, PropDef def) throws RepositoryException {
+    protected void createProperty(NodeImpl node, PropInfo pInfo, QPropertyDefinition def) throws RepositoryException {
         // convert serialized values to Value objects
         Value[] va = pInfo.getValues(pInfo.getTargetType(def), session);
 
@@ -369,7 +369,7 @@
 
         for (PropInfo pi : propInfos) {
             // find applicable definition
-            PropDef def = pi.getApplicablePropertyDef(node.getEffectiveNodeType());
+            QPropertyDefinition def = pi.getApplicablePropertyDef(node.getEffectiveNodeType());
             if (def.isProtected()) {
                 // skip protected property
                 log.debug("Skipping protected property " + pi.getName());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java Thu Sep 17 19:20: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;
@@ -50,6 +48,8 @@
 import org.apache.jackrabbit.core.version.VersionHistoryInfo;
 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;
@@ -348,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();
@@ -357,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 "
@@ -429,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);
@@ -492,7 +492,8 @@
                         parent.getChildNodeEntry(nodeName, 1);
                 NodeId idExisting = entry.getId();
                 NodeState existing = (NodeState) itemOps.getItemState(idExisting);
-                NodeDef def = ntReg.getNodeDef(existing.getDefinitionId());
+                QNodeDefinition def = itemOps.findApplicableNodeDefinition(
+                        nodeName, existing.getNodeTypeName(), parent);
 
                 if (!def.allowsSameNameSiblings()) {
                     // existing doesn't allow same-name siblings,
@@ -528,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
@@ -561,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

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java?rev=816343&r1=816342&r2=816343&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java Thu Sep 17 19:20:33 2009
@@ -18,9 +18,13 @@
 
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -118,18 +122,18 @@
         bar.setName(nameFactory.create("", "bar"));
         bar.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        NodeDefImpl myBarInFoo = new NodeDefImpl();
+        QNodeDefinitionBuilder myBarInFoo = new QNodeDefinitionBuilder();
         myBarInFoo.setRequiredPrimaryTypes(new Name[]{bar.getName()});
         myBarInFoo.setName(nameFactory.create("", "myBarInFoo"));
         myBarInFoo.setDeclaringNodeType(foo.getName());
 
-        NodeDefImpl myFooInBar = new NodeDefImpl();
+        QNodeDefinitionBuilder myFooInBar = new QNodeDefinitionBuilder();
         myFooInBar.setRequiredPrimaryTypes(new Name[]{foo.getName()});
         myFooInBar.setName(nameFactory.create("", "myFooInBar"));
         myFooInBar.setDeclaringNodeType(bar.getName());
 
-        foo.setChildNodeDefs(new NodeDefImpl[]{myBarInFoo});
-        bar.setChildNodeDefs(new NodeDefImpl[]{myFooInBar});
+        foo.setChildNodeDefs(new QNodeDefinition[]{myBarInFoo.build()});
+        bar.setChildNodeDefs(new QNodeDefinition[]{myFooInBar.build()});
         ntDefCollection = new LinkedList();
         ntDefCollection.add(foo);
         ntDefCollection.add(bar);
@@ -163,12 +167,12 @@
         foo.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
 
-        NodeDefImpl myBarInFoo = new NodeDefImpl();
+        QNodeDefinitionBuilder myBarInFoo = new QNodeDefinitionBuilder();
         myBarInFoo.setRequiredPrimaryTypes(new Name[]{nameFactory.create("", "I_am_an_invalid_required_primary_type")});
         myBarInFoo.setName(nameFactory.create("", "myNTInFoo"));
         myBarInFoo.setDeclaringNodeType(foo.getName());
 
-        foo.setChildNodeDefs(new NodeDefImpl[]{myBarInFoo});
+        foo.setChildNodeDefs(new QNodeDefinition[]{myBarInFoo.build()});
         ntDefCollection = new LinkedList();
         ntDefCollection.add(foo);
 
@@ -208,36 +212,38 @@
         final NodeTypeDef cmsObject = new NodeTypeDef();
         cmsObject.setName(nameFactory.create("", "CmsObject"));
         cmsObject.setSupertypes(new Name[]{NameConstants.NT_BASE});
-        NodeDefImpl parentFolder = new NodeDefImpl();
+
+        QNodeDefinitionBuilder parentFolder = new QNodeDefinitionBuilder();
         parentFolder.setRequiredPrimaryTypes(new Name[]{folder.getName()});
         parentFolder.setName(nameFactory.create("", "parentFolder"));
         parentFolder.setDeclaringNodeType(cmsObject.getName());
-        cmsObject.setChildNodeDefs(new NodeDefImpl[]{parentFolder});
+        cmsObject.setChildNodeDefs(new QNodeDefinition[]{parentFolder.build()});
 
 
         final NodeTypeDef document = new NodeTypeDef();
         document.setName(nameFactory.create("", "Document"));
         document.setSupertypes(new Name[]{cmsObject.getName()});
-        PropDefImpl sizeProp = new PropDefImpl();
+        QPropertyDefinitionBuilder sizeProp = new QPropertyDefinitionBuilder();
         sizeProp.setName(nameFactory.create("", "size"));
         sizeProp.setRequiredType(PropertyType.LONG);
         sizeProp.setDeclaringNodeType(document.getName());
-        document.setPropertyDefs(new PropDef[]{sizeProp});
+        document.setPropertyDefs(new QPropertyDefinition[]{sizeProp.build()});
 
 
         folder.setSupertypes(new Name[]{cmsObject.getName()});
 
-        NodeDefImpl folders = new NodeDefImpl();
+        QNodeDefinitionBuilder folders = new QNodeDefinitionBuilder();
         folders.setRequiredPrimaryTypes(new Name[]{folder.getName()});
         folders.setName(nameFactory.create("", "folders"));
         folders.setDeclaringNodeType(folder.getName());
 
-        NodeDefImpl documents = new NodeDefImpl();
+        QNodeDefinitionBuilder documents = new QNodeDefinitionBuilder();
         documents.setRequiredPrimaryTypes(new Name[]{document.getName()});
         documents.setName(nameFactory.create("", "documents"));
         documents.setDeclaringNodeType(folder.getName());
 
-        folder.setChildNodeDefs(new NodeDefImpl[]{folders, documents});
+        folder.setChildNodeDefs(new QNodeDefinition[]{
+                folders.build(), documents.build()});
         ntDefCollection = new LinkedList();
         ntDefCollection.add(folder);
         ntDefCollection.add(document);



Mime
View raw message