jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r816551 [1/2] - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ jackrabbit-c...
Date Fri, 18 Sep 2009 09:15:11 GMT
Author: mreutegg
Date: Fri Sep 18 09:15:07 2009
New Revision: 816551

URL: http://svn.apache.org/viewvc?rev=816551&view=rev
Log:
JCR-1483: Move common node type functionality to jackrabbit-spi-commons
- replaced NodeTypeDef (jackrabbit-core) with QNodeTypeDefinition
- QNodeTypeDefinitionImpl is not immutable, hence no cloning needed anymore
- introduced QNodeTypeDefinitionBuilder
- moved constructors of Q*DefinitionImpl classes in spi2jcr to spi-commons
- fixed a bug in RepositoryServiceImpl in spi2jcr

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeTypeDefinitionBuilder.java   (with props)
Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDef.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java Fri Sep 18 09:15:07 2009
@@ -28,10 +28,10 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.persistence.PersistenceCopier;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -229,7 +229,7 @@
         logger.info("Copying registered node types");
         Collection<Name> existing =
             Arrays.asList(targetRegistry.getRegisteredNodeTypes());
-        Collection<NodeTypeDef> register = new ArrayList<NodeTypeDef>();
+        Collection<QNodeTypeDefinition> register = new ArrayList<QNodeTypeDefinition>();
         for (Name name : sourceRegistry.getRegisteredNodeTypes()) {
             // TODO: what about modified node types?
             if (!existing.contains(name)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Fri Sep 18 09:15:07 2009
@@ -33,10 +33,10 @@
 import org.apache.jackrabbit.core.journal.RecordConsumer;
 import org.apache.jackrabbit.core.journal.RecordProducer;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.xml.ClonedInputSource;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -438,7 +438,7 @@
     /**
      * {@inheritDoc}
      */
-    public void reregistered(NodeTypeDef ntDef) {
+    public void reregistered(QNodeTypeDefinition ntDef) {
         if (status != STARTED) {
             log.info("not started: nodetype operation ignored.");
             return;
@@ -888,7 +888,7 @@
                 nodeTypeListener.externalUnregistered(coll);
                 break;
             case NodeTypeRecord.REREGISTER:
-                NodeTypeDef ntd = (NodeTypeDef) coll.iterator().next();
+                QNodeTypeDefinition ntd = (QNodeTypeDefinition) coll.iterator().next();
                 nodeTypeListener.externalReregistered(ntd);
                 break;
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java Fri Sep 18 09:15:07 2009
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.core.cluster;
 
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 import java.util.Collection;
 
@@ -31,14 +31,14 @@
      *
      * @param ntDefs collection of node type definitions
      */
-    void registered(Collection<NodeTypeDef> ntDefs);
+    void registered(Collection<QNodeTypeDefinition> ntDefs);
 
     /**
      * Called when a node types has been re-registered.
      *
      * @param ntDef node type definition
      */
-    void reregistered(NodeTypeDef ntDef);
+    void reregistered(QNodeTypeDefinition ntDef);
 
     /**
      * Called when one or more node types have been unregistered.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java Fri Sep 18 09:15:07 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.cluster;
 
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -36,7 +36,7 @@
      * @throws RepositoryException if an error occurs
      * @throws InvalidNodeTypeDefException if the node type definition is invalid
      */
-    void externalRegistered(Collection<NodeTypeDef> ntDefs)
+    void externalRegistered(Collection<QNodeTypeDefinition> ntDefs)
         throws RepositoryException, InvalidNodeTypeDefException;
 
     /**
@@ -47,7 +47,7 @@
      * @throws NoSuchNodeTypeException if the node type had not yet been registered
      * @throws InvalidNodeTypeDefException if the node type definition is invalid
      */
-    void externalReregistered(NodeTypeDef ntDef)
+    void externalReregistered(QNodeTypeDefinition ntDef)
         throws NoSuchNodeTypeException, InvalidNodeTypeDefException, RepositoryException;
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeRecord.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeRecord.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeRecord.java Fri Sep 18 09:15:07 2009
@@ -24,8 +24,8 @@
 
 import org.apache.jackrabbit.core.journal.JournalException;
 import org.apache.jackrabbit.core.journal.Record;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * Cluster record representing a node type registration, re-registration or
@@ -106,7 +106,7 @@
      * @param ntDef node type definition
      * @param record journal record
      */
-    public NodeTypeRecord(NodeTypeDef ntDef, Record record) {
+    public NodeTypeRecord(QNodeTypeDefinition ntDef, Record record) {
         super(record);
 
         this.collection = new ArrayList();
@@ -173,7 +173,7 @@
             if (operation == UNREGISTER) {
                 record.writeQName((Name) iter.next());
             } else {
-                record.writeNodeTypeDef((NodeTypeDef) iter.next());
+                record.writeNodeTypeDef((QNodeTypeDefinition) iter.next());
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java Fri Sep 18 09:15:07 2009
@@ -29,7 +29,6 @@
 import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
@@ -144,11 +143,11 @@
     /**
      * {@inheritDoc}
      */
-    public void writeNodeTypeDef(NodeTypeDef ntd) throws JournalException {
+    public void writeNodeTypeDef(QNodeTypeDefinition ntd) throws JournalException {
         try {
             StringWriter sw = new StringWriter();
             CompactNodeTypeDefWriter writer = new CompactNodeTypeDefWriter(sw, nsResolver, resolver);
-            writer.write(ntd.getQNodeTypeDefinition());
+            writer.write(ntd);
             writer.close();
 
             writeString(sw.toString());
@@ -246,7 +245,7 @@
     /**
      * {@inheritDoc}
      */
-    public NodeTypeDef readNodeTypeDef() throws JournalException {
+    public QNodeTypeDefinition readNodeTypeDef() throws JournalException {
         try {
             StringReader sr = new StringReader(readString());
 
@@ -259,7 +258,7 @@
             if (ntds.size() != 1) {
                 throw new JournalException("Expected one node type definition: got " + ntds.size());
             }
-            return new NodeTypeDef(ntds.iterator().next());
+            return ntds.iterator().next();
         } catch (ParseException e) {
             String msg = "Parse error while reading node type definition.";
             throw new JournalException(msg, e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java Fri Sep 18 09:15:07 2009
@@ -18,9 +18,9 @@
 
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * Record interface.
@@ -150,7 +150,7 @@
      * @return node type definition
      * @throws JournalException if an error occurs
      */
-    NodeTypeDef readNodeTypeDef() throws JournalException;
+    QNodeTypeDefinition readNodeTypeDef() throws JournalException;
 
     /**
      * Write a byte to the underlying stream.
@@ -254,7 +254,7 @@
      * @param ntd node type definition
      * @throws JournalException if an error occurs
      */
-    void writeNodeTypeDef(NodeTypeDef ntd) throws JournalException;
+    void writeNodeTypeDef(QNodeTypeDefinition ntd) throws JournalException;
 
     /**
      * Update the changes made to an appended record. This will also update

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Fri Sep 18 09:15:07 2009
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -94,9 +95,9 @@
      * @throws NoSuchNodeTypeException if a node type reference (e.g. a supertype)
      *                                 could not be resolved.
      */
-    static EffectiveNodeType create(NodeTypeDef ntd,
+    static EffectiveNodeType create(QNodeTypeDefinition ntd,
                                     EffectiveNodeTypeCache entCache,
-                                    Map<Name, NodeTypeDef> ntdCache)
+                                    Map<Name, QNodeTypeDefinition> ntdCache)
             throws NodeTypeConflictException, NoSuchNodeTypeException {
         // create empty effective node type instance
         EffectiveNodeType ent = new EffectiveNodeType();
@@ -220,7 +221,7 @@
         } else {
             Name[] nta = ent.getInheritedNodeTypes();
             for (Name aNta : nta) {
-                NodeTypeDef def = ntdCache.get(aNta);
+                QNodeTypeDefinition def = ntdCache.get(aNta);
                 if (def.hasOrderableChildNodes()) {
                     ent.orderableChildNodes = true;
                     break;
@@ -234,7 +235,7 @@
         } else {
             Name[] nta = ent.getInheritedNodeTypes();
             for (Name aNta : nta) {
-                NodeTypeDef def = ntdCache.get(aNta);
+                QNodeTypeDefinition def = ntdCache.get(aNta);
                 if (def.getPrimaryItemName() != null) {
                     ent.primaryItemName = def.getPrimaryItemName();
                     break;
@@ -658,7 +659,7 @@
                                         NodeTypeRegistry ntReg)
             throws ConstraintViolationException, NoSuchNodeTypeException {
         if (nodeTypeName != null) {
-            NodeTypeDef ntDef = ntReg.getNodeTypeDef(nodeTypeName);
+            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(nodeTypeName);
             if (ntDef.isAbstract()) {
                 throw new ConstraintViolationException(nodeTypeName + " is abstract.");
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java Fri Sep 18 09:15:07 2009
@@ -30,6 +30,7 @@
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * A <code>NodeTypeDefDiff</code> represents the result of the comparison of
@@ -96,8 +97,8 @@
      */
     public static final int MAJOR = 3;
 
-    private final NodeTypeDef oldDef;
-    private final NodeTypeDef newDef;
+    private final QNodeTypeDefinition oldDef;
+    private final QNodeTypeDefinition newDef;
     private int type;
 
     private List<PropDefDiff> propDefDiffs = new ArrayList<PropDefDiff>();
@@ -106,7 +107,7 @@
     /**
      * Constructor
      */
-    private NodeTypeDefDiff(NodeTypeDef oldDef, NodeTypeDef newDef) {
+    private NodeTypeDefDiff(QNodeTypeDefinition oldDef, QNodeTypeDefinition newDef) {
         this.oldDef = oldDef;
         this.newDef = newDef;
         init();
@@ -165,7 +166,7 @@
      * @param newDef
      * @return
      */
-    public static NodeTypeDefDiff create(NodeTypeDef oldDef, NodeTypeDef newDef) {
+    public static NodeTypeDefDiff create(QNodeTypeDefinition oldDef, QNodeTypeDefinition newDef) {
         if (oldDef == null || newDef == null) {
             throw new IllegalArgumentException("arguments can not be null");
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java Fri Sep 18 09:15:07 2009
@@ -43,13 +43,13 @@
 public class NodeTypeDefStore {
 
     /** Map of node type names to node type definitions. */
-    private final Map<Name, NodeTypeDef> ntDefs;
+    private final Map<Name, QNodeTypeDefinition> ntDefs;
 
     /**
      * Empty default constructor.
      */
     public NodeTypeDefStore() throws RepositoryException {
-        ntDefs = new HashMap<Name, NodeTypeDef>();
+        ntDefs = new HashMap<Name, QNodeTypeDefinition>();
     }
 
     /**
@@ -60,8 +60,8 @@
     public void load(InputStream in)
             throws IOException, InvalidNodeTypeDefException,
             RepositoryException {
-        NodeTypeDef[] types = NodeTypeReader.read(in);
-        for (NodeTypeDef type : types) {
+        QNodeTypeDefinition[] types = NodeTypeReader.read(in);
+        for (QNodeTypeDefinition type : types) {
             add(type);
         }
     }
@@ -83,7 +83,7 @@
                     in, systemId, new QDefinitionBuilderFactory());
 
             for (QNodeTypeDefinition qdef: r.getNodeTypeDefinitions()) {
-                add(new NodeTypeDef(qdef));
+                add(qdef);
             }
         } catch (ParseException e) {
             throw new InvalidNodeTypeDefException("Unable to parse CND stream.", e);
@@ -98,14 +98,14 @@
      */
     public void store(OutputStream out, NamespaceRegistry registry)
             throws IOException, RepositoryException {
-        NodeTypeDef[] types = ntDefs.values().toArray(new NodeTypeDef[ntDefs.size()]);
+        QNodeTypeDefinition[] types = ntDefs.values().toArray(new QNodeTypeDefinition[ntDefs.size()]);
         NodeTypeWriter.write(out, types, registry);
     }
 
     /**
      * @param ntd
      */
-    public void add(NodeTypeDef ntd) {
+    public void add(QNodeTypeDefinition ntd) {
         ntDefs.put(ntd.getName(), ntd);
     }
 
@@ -136,14 +136,14 @@
      * @param name
      * @return
      */
-    public NodeTypeDef get(Name name) {
+    public QNodeTypeDefinition get(Name name) {
         return ntDefs.get(name);
     }
 
     /**
      * @return
      */
-    public Collection<NodeTypeDef> all() {
+    public Collection<QNodeTypeDefinition> all() {
         return Collections.unmodifiableCollection(ntDefs.values());
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java Fri Sep 18 09:15:07 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
@@ -33,7 +34,7 @@
 
 /**
  * This class implements the <code>NodeTypeDefinition</code> interface.
- * All method calls are delegated to the wrapped {@link NodeTypeDef},
+ * All method calls are delegated to the wrapped {@link QNodeTypeDefinition},
  * performing the translation from <code>Name</code>s to JCR names
  * (and vice versa) where necessary.
  */
@@ -41,12 +42,12 @@
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeDefinitionImpl.class);
 
-    private final NodeTypeDef ntd;
+    private final QNodeTypeDefinition ntd;
     // resolver used to translate <code>Name</code>s to JCR name strings.
     private final NamePathResolver resolver;
     private final ValueFactory valueFactory;
 
-    public NodeTypeDefinitionImpl(NodeTypeDef ntd, NamePathResolver resolver, ValueFactory valueFactory) {
+    public NodeTypeDefinitionImpl(QNodeTypeDefinition ntd, NamePathResolver resolver, ValueFactory valueFactory) {
         this.ntd = ntd;
         this.resolver = resolver;
         this.valueFactory = valueFactory;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java Fri Sep 18 09:15:07 2009
@@ -18,6 +18,8 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Set;
+import java.util.List;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
@@ -36,6 +38,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeType;
@@ -50,7 +53,7 @@
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeImpl.class);
 
-    private final NodeTypeDef ntd;
+    private final QNodeTypeDefinition ntd;
     private final EffectiveNodeType ent;
     private final NodeTypeManagerImpl ntMgr;
     // resolver used to translate translate <code>Name</code>s to JCR name strings.
@@ -62,18 +65,25 @@
     /**
      * Package private constructor
      * <p/>
-     * Creates a valid node type instance.
-     * We assume that the node type definition is valid and all referenced
-     * node types (supertypes, required node types etc.) do exist and are valid.
-     *
-     * @param ent        the effective (i.e. merged and resolved) node type representation
-     * @param ntd        the definition of this node type
-     * @param ntMgr      the node type manager associated with this node type
-     * @param resolver
-     */
-    NodeTypeImpl(EffectiveNodeType ent, NodeTypeDef ntd,
-                 NodeTypeManagerImpl ntMgr, NamePathResolver resolver,
-                 ValueFactory valueFactory, DataStore store) {
+     * Creates a valid node type instance. We assume that the node type
+     * definition is valid and all referenced node types (supertypes, required
+     * node types etc.) do exist and are valid.
+     *
+     * @param ent          the effective (i.e. merged and resolved) node type
+     *                     representation
+     * @param ntd          the definition of this node type
+     * @param ntMgr        the node type manager associated with this node type
+     * @param resolver     the name path resolver of the session.
+     * @param valueFactory the value factory of the session.
+     * @param store        the data store or <code>null</code> if none is
+     *                     configured.
+     */
+    NodeTypeImpl(EffectiveNodeType ent,
+                 QNodeTypeDefinition ntd,
+                 NodeTypeManagerImpl ntMgr,
+                 NamePathResolver resolver,
+                 ValueFactory valueFactory,
+                 DataStore store) {
         super(ntMgr);
         this.ent = ent;
         this.ntMgr = ntMgr;
@@ -86,7 +96,7 @@
     /**
      * Checks if the effective node type includes the given <code>nodeTypeName</code>.
      *
-     * @param nodeTypeName
+     * @param nodeTypeName the name of a node type.
      * @return true if the effective node type includes the given <code>nodeTypeName</code>.
      */
     public boolean isNodeType(Name nodeTypeName) {
@@ -97,7 +107,7 @@
      * Checks if this node type is directly or indirectly derived from the
      * specified node type.
      *
-     * @param nodeTypeName
+     * @param nodeTypeName the name of a node type.
      * @return true if this node type is directly or indirectly derived from the
      *         specified node type, otherwise false.
      */
@@ -110,9 +120,8 @@
      *
      * @return the definition of this node type
      */
-    public NodeTypeDef getDefinition() {
-        // return clone to make sure nobody messes around with the 'live' definition
-        return (NodeTypeDef) ntd.clone();
+    public QNodeTypeDefinition getDefinition() {
+        return ntd;
     }
 
     /**
@@ -206,19 +215,19 @@
     public NodeType[] getInheritedSupertypes() {
         // declared supertypes
         Name[] ntNames = ntd.getSupertypes();
-        HashSet declared = new HashSet();
-        for (int i = 0; i < ntNames.length; i++) {
-            declared.add(ntNames[i]);
+        Set<Name> declared = new HashSet<Name>();
+        for (Name ntName : ntNames) {
+            declared.add(ntName);
         }
         // all supertypes
         ntNames = ent.getInheritedNodeTypes();
 
         // filter from all supertypes those that are not declared
-        ArrayList inherited = new ArrayList();
-        for (int i = 0; i < ntNames.length; i++) {
-            if (!declared.contains(ntNames[i])) {
+        List<NodeType> inherited = new ArrayList<NodeType>();
+        for (Name ntName : ntNames) {
+            if (!declared.contains(ntName)) {
                 try {
-                    inherited.add(ntMgr.getNodeType(ntNames[i]));
+                    inherited.add(ntMgr.getNodeType(ntName));
                 } catch (NoSuchNodeTypeException e) {
                     // should never get here
                     log.error("undefined supertype", e);
@@ -227,7 +236,7 @@
             }
         }
 
-        return (NodeType[]) inherited.toArray(new NodeType[inherited.size()]);
+        return inherited.toArray(new NodeType[inherited.size()]);
     }
 
 
@@ -488,14 +497,14 @@
             Name name = resolver.getQName(propertyName);
             // determine type of values
             int type = PropertyType.UNDEFINED;
-            for (int i = 0; i < values.length; i++) {
-                if (values[i] == null) {
+            for (Value value : values) {
+                if (value == null) {
                     // skip null values as those would be purged
                     continue;
                 }
                 if (type == PropertyType.UNDEFINED) {
-                    type = values[i].getType();
-                } else if (type != values[i].getType()) {
+                    type = value.getType();
+                } else if (type != value.getType()) {
                     // inhomogeneous types
                     return false;
                 }
@@ -526,27 +535,25 @@
                 targetType = type;
             }
 
-            ArrayList list = new ArrayList();
+            List<InternalValue> list = new ArrayList<InternalValue>();
             // convert values and compact array (purge null entries)
-            for (int i = 0; i < values.length; i++) {
-                if (values[i] != null) {
+            for (Value value : values) {
+                if (value != null) {
                     // perform type conversion as necessary and create InternalValue
                     // from (converted) Value
                     InternalValue internalValue;
                     if (targetType != type) {
                         // type conversion required
-                        Value targetVal = ValueHelper.convert(
-                                values[i], targetType, valueFactory);
+                        Value targetVal = ValueHelper.convert(value, targetType, valueFactory);
                         internalValue = InternalValue.create(targetVal, resolver, store);
                     } else {
                         // no type conversion required
-                        internalValue = InternalValue.create(values[i], resolver, store);
+                        internalValue = InternalValue.create(value, resolver, store);
                     }
                     list.add(internalValue);
                 }
             }
-            InternalValue[] internalValues =
-                    (InternalValue[]) list.toArray(new InternalValue[list.size()]);
+            InternalValue[] internalValues = list.toArray(new InternalValue[list.size()]);
             EffectiveNodeType.checkSetPropertyValueConstraints(def, internalValues);
             return true;
         } catch (NameException be) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Fri Sep 18 09:15:07 2009
@@ -35,17 +35,13 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Value;
 import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
 import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.nodetype.NodeTypeIterator;
-import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
@@ -57,10 +53,8 @@
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
 import org.apache.jackrabbit.core.util.Dumpable;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
@@ -70,8 +64,8 @@
 import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
-import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -198,7 +192,7 @@
             NodeTypeImpl nt = ntCache.get(name);
             if (nt == null) {
                 EffectiveNodeType ent = ntReg.getEffectiveNodeType(name);
-                NodeTypeDef def = ntReg.getNodeTypeDef(name);
+                QNodeTypeDefinition def = ntReg.getNodeTypeDef(name);
                 nt = new NodeTypeImpl(ent, def, this, session, valueFactory, store);
                 ntCache.put(name, nt);
             }
@@ -241,7 +235,7 @@
 
         try {
             Map<String, String> namespaceMap = new HashMap<String, String>();
-            List<NodeTypeDef> nodeTypeDefs = new ArrayList<NodeTypeDef>();
+            List<QNodeTypeDefinition> nodeTypeDefs = new ArrayList<QNodeTypeDefinition>();
 
             if (contentType.equalsIgnoreCase(TEXT_XML)
                     || contentType.equalsIgnoreCase(APPLICATION_XML)) {
@@ -258,7 +252,7 @@
                         }
                     }
 
-                    NodeTypeDef[] defs = ntr.getNodeTypeDefs();
+                    QNodeTypeDefinition[] defs = ntr.getNodeTypeDefs();
                     nodeTypeDefs.addAll(Arrays.asList(defs));
                 } catch (NameException e) {
                     throw new RepositoryException("Illegal JCR name", e);
@@ -274,7 +268,7 @@
 
                     namespaceMap.putAll(mapping.getPrefixToURIMapping());
                     for (QNodeTypeDefinition ntDef: reader.getNodeTypeDefinitions()) {
-                        nodeTypeDefs.add(new NodeTypeDef(ntDef));
+                        nodeTypeDefs.add(ntDef);
                     }
                 } catch (ParseException e) {
                     IOException e2 = new IOException(e.getMessage());
@@ -292,9 +286,9 @@
                 // split the node types into new and already registered node types.
                 // this way we can register new node types together with already
                 // registered node types which make circular dependencies possible
-                List<NodeTypeDef> newNodeTypeDefs = new ArrayList<NodeTypeDef>();
-                List<NodeTypeDef> registeredNodeTypeDefs = new ArrayList<NodeTypeDef>();
-                for (NodeTypeDef nodeTypeDef: nodeTypeDefs) {
+                List<QNodeTypeDefinition> newNodeTypeDefs = new ArrayList<QNodeTypeDefinition>();
+                List<QNodeTypeDefinition> registeredNodeTypeDefs = new ArrayList<QNodeTypeDefinition>();
+                for (QNodeTypeDefinition nodeTypeDef: nodeTypeDefs) {
                     if (ntReg.isRegistered(nodeTypeDef.getName())) {
                         registeredNodeTypeDefs.add(nodeTypeDef);
                     } else {
@@ -308,7 +302,7 @@
                 nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs));
 
                 // re-register already existing node types
-                for (NodeTypeDef nodeTypeDef: registeredNodeTypeDefs) {
+                for (QNodeTypeDefinition nodeTypeDef: registeredNodeTypeDefs) {
                     ntReg.reregisterNodeType(nodeTypeDef);
                     nodeTypes.add(getNodeType(nodeTypeDef.getName()));
                 }
@@ -449,17 +443,17 @@
      * Internal helper method for registering a list of node type definitions.
      * Returns a collection containing the registered node types.
      *
-     * @param defs a collection of <code>NodeTypeDef<code> objects
+     * @param defs a collection of <code>QNodeTypeDefinition<code> objects
      * @return registered node types
      * @throws InvalidNodeTypeDefException if a nodetype is invalid
      * @throws RepositoryException if an error occurs
      */
-    private Collection<NodeType> registerNodeTypes(List<NodeTypeDef> defs)
+    private Collection<NodeType> registerNodeTypes(List<QNodeTypeDefinition> defs)
             throws InvalidNodeTypeDefException, RepositoryException {
         ntReg.registerNodeTypes(defs);
 
         Set<NodeType> types = new HashSet<NodeType>();
-        for (NodeTypeDef def : defs) {
+        for (QNodeTypeDefinition def : defs) {
             try {
                 types.add(getNodeType(def.getName()));
             } catch (NoSuchNodeTypeException e) {
@@ -568,11 +562,11 @@
         // split the node types into new and already registered node types.
         // this way we can register new node types together with already
         // registered node types which make circular dependencies possible
-        List<NodeTypeDef> addedDefs = new ArrayList<NodeTypeDef>();
-        List<NodeTypeDef> modifiedDefs = new ArrayList<NodeTypeDef>();
+        List<QNodeTypeDefinition> addedDefs = new ArrayList<QNodeTypeDefinition>();
+        List<QNodeTypeDefinition> modifiedDefs = new ArrayList<QNodeTypeDefinition>();
         for (NodeTypeDefinition definition : definitions) {
-            // convert to NodeTypeDef
-            NodeTypeDef def = toNodeTypeDef(definition);
+            // convert to QNodeTypeDefinition
+            QNodeTypeDefinition def = toNodeTypeDef(definition);
             if (ntReg.isRegistered(def.getName())) {
               if (allowUpdate) {
                   modifiedDefs.add(def);
@@ -591,7 +585,7 @@
             result.addAll(registerNodeTypes(addedDefs));
 
             // re-register already existing node types
-            for (NodeTypeDef nodeTypeDef: modifiedDefs) {
+            for (QNodeTypeDefinition nodeTypeDef: modifiedDefs) {
                 ntReg.reregisterNodeType(nodeTypeDef);
                 result.add(getNodeType(nodeTypeDef.getName()));
             }
@@ -642,180 +636,9 @@
      * @throws InvalidNodeTypeDefinitionException if the definiton is invalid
      * @throws RepositoryException if a repository error occurs
      */
-    private NodeTypeDef toNodeTypeDef(NodeTypeDefinition definition)
+    private QNodeTypeDefinition toNodeTypeDef(NodeTypeDefinition definition)
             throws InvalidNodeTypeDefinitionException, RepositoryException {
-        NodeTypeDef def = new NodeTypeDef();
-
-        // name
-        String name = definition.getName();
-        if (name == null) {
-            throw new InvalidNodeTypeDefinitionException("No node type name specified");
-        }
-        try {
-            def.setName(session.getQName(name));
-        } catch (NamespaceException e) {
-            throw new InvalidNodeTypeDefinitionException("Invalid name: " + name, e);
-        } catch (NameException e) {
-            throw new InvalidNodeTypeDefinitionException("Invalid name: " + name, e);
-        }
-
-        // supertypes
-        String[] names = definition.getDeclaredSupertypeNames();
-        Name[] qnames = new Name[names.length];
-        for (int i = 0; i < names.length; i++) {
-            try {
-                qnames[i] = session.getQName(names[i]);
-            } catch (NamespaceException e) {
-                throw new InvalidNodeTypeDefinitionException("Invalid supertype name: " + names[i], e);
-            } catch (NameException e) {
-                throw new InvalidNodeTypeDefinitionException("Invalid supertype name: " + names[i], e);
-            }
-        }
-        def.setSupertypes(qnames);
-
-        // primary item
-        name = definition.getPrimaryItemName();
-        if (name != null) {
-            try {
-                def.setPrimaryItemName(session.getQName(name));
-            } catch (NamespaceException e) {
-                throw new InvalidNodeTypeDefinitionException("Invalid primary item name: " + name, e);
-            } catch (NameException e) {
-                throw new InvalidNodeTypeDefinitionException("Invalid primary item name: " + name, e);
-            }
-        }
-
-        // misc. flags
-        def.setMixin(definition.isMixin());
-        def.setAbstract(definition.isAbstract());
-        def.setOrderableChildNodes(definition.hasOrderableChildNodes());
-
-        // child nodes
-        NodeDefinition[] ndefs = definition.getDeclaredChildNodeDefinitions();
-        if (ndefs != null) {
-            QNodeDefinition[] qndefs = new QNodeDefinition[ndefs.length];
-            for (int i = 0; i < ndefs.length; i++) {
-                QNodeDefinitionBuilder qndef = new QNodeDefinitionBuilder();
-                // declaring node type
-                qndef.setDeclaringNodeType(def.getName());
-                // name
-                name = ndefs[i].getName();
-                if (name != null) {
-                    if (name.equals("*")) {
-                        qndef.setName(NameConstants.ANY_NAME);
-                    } else {
-                        try {
-                            qndef.setName(session.getQName(name));
-                        } catch (NamespaceException e) {
-                            throw new InvalidNodeTypeDefinitionException("Invalid node name: " + name, e);
-                        } catch (NameException e) {
-                            throw new InvalidNodeTypeDefinitionException("Invalid node name: " + name, e);
-                        }
-                    }
-                }
-                // default primary type
-                name = ndefs[i].getDefaultPrimaryTypeName();
-                if (name != null) {
-                    try {
-                        qndef.setDefaultPrimaryType(session.getQName(name));
-                    } catch (NamespaceException e) {
-                        throw new InvalidNodeTypeDefinitionException("Invalid default primary type: " + name, e);
-                    } catch (NameException e) {
-                        throw new InvalidNodeTypeDefinitionException("Invalid default primary type: " + name, e);
-                    }
-                }
-                // required primary types
-                names = ndefs[i].getRequiredPrimaryTypeNames();
-                qnames = new Name[names.length];
-                for (int j = 0; j < names.length; j++) {
-                    try {
-                        qnames[j] = session.getQName(names[j]);
-                    } catch (NamespaceException e) {
-                        throw new InvalidNodeTypeDefinitionException("Invalid required primary type: " + names[j], e);
-                    } catch (NameException e) {
-                        throw new InvalidNodeTypeDefinitionException("Invalid required primary type: " + names[j], e);
-                    }
-                }
-                qndef.setRequiredPrimaryTypes(qnames);
-
-                // misc. flags/attributes
-                qndef.setAutoCreated(ndefs[i].isAutoCreated());
-                qndef.setMandatory(ndefs[i].isMandatory());
-                qndef.setProtected(ndefs[i].isProtected());
-                qndef.setOnParentVersion(ndefs[i].getOnParentVersion());
-                qndef.setAllowsSameNameSiblings(ndefs[i].allowsSameNameSiblings());
-
-                qndefs[i] = qndef.build();
-            }
-            def.setChildNodeDefs(qndefs);
-        }
-
-        // properties
-        PropertyDefinition[] pdefs = definition.getDeclaredPropertyDefinitions();
-        if (pdefs != null) {
-            QPropertyDefinition[] qpdefs = new QPropertyDefinition[pdefs.length];
-            for (int i = 0; i < pdefs.length; i++) {
-                QPropertyDefinitionBuilder qpdef = new QPropertyDefinitionBuilder();
-                // declaring node type
-                qpdef.setDeclaringNodeType(def.getName());
-                // name
-                name = pdefs[i].getName();
-                if (name != null) {
-                    if (name.equals("*")) {
-                        qpdef.setName(NameConstants.ANY_NAME);
-                    } else {
-                        try {
-                            qpdef.setName(session.getQName(name));
-                        } catch (NamespaceException e) {
-                            throw new InvalidNodeTypeDefinitionException("Invalid property name: " + name, e);
-                        } catch (NameException e) {
-                            throw new InvalidNodeTypeDefinitionException("Invalid property name: " + name, e);
-                        }
-                    }
-                }
-                // misc. flags/attributes
-                int type = pdefs[i].getRequiredType();
-                qpdef.setRequiredType(type);
-                qpdef.setAutoCreated(pdefs[i].isAutoCreated());
-                qpdef.setMandatory(pdefs[i].isMandatory());
-                qpdef.setProtected(pdefs[i].isProtected());
-                qpdef.setOnParentVersion(pdefs[i].getOnParentVersion());
-                qpdef.setMultiple(pdefs[i].isMultiple());
-                // value constraints
-                String[] constraints = pdefs[i].getValueConstraints();
-                if (constraints != null) {
-                    QValueConstraint[] qconstraints = new QValueConstraint[constraints.length];
-                    for (int j = 0; j < constraints.length; j++) {
-                        try {
-                            qconstraints[j] = ValueConstraint.create(type, constraints[j], session);
-                        } catch (InvalidConstraintException e) {
-                            throw new InvalidNodeTypeDefinitionException(
-                                    "Invalid value constraint: " + constraints[j], e);
-                        }
-                    }
-                    qpdef.setValueConstraints(qconstraints);
-                }
-                // default values
-                Value[] values = pdefs[i].getDefaultValues();
-                if (values != null) {
-                    InternalValue[] qvalues = new InternalValue[values.length];
-                    for (int j = 0; j < values.length; j++) {
-                        try {
-                            qvalues[j] = InternalValue.create(values[j], session);
-                        } catch (ValueFormatException e) {
-                            throw new InvalidNodeTypeDefinitionException(
-                                    "Invalid default value format: " + values[j], e);
-                        }
-                    }
-                    qpdef.setDefaultValues(qvalues);
-                }
-
-                qpdefs[i] = qpdef.build();
-            }
-            def.setPropertyDefs(qpdefs);
-        }
-
-        return def;
+        return new QNodeTypeDefinitionImpl(definition, session, QValueFactoryImpl.getInstance());
     }
 
     //-------------------------------------------------------------< Dumpable >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java Fri Sep 18 09:15:07 2009
@@ -31,6 +31,8 @@
 import java.util.Set;
 import java.util.Stack;
 import java.util.TreeSet;
+import java.util.List;
+import java.util.ArrayList;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PropertyType;
@@ -52,9 +54,11 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,7 +91,7 @@
     private EffectiveNodeTypeCache entCache;
 
     // map of node type names and node type definitions
-    private final Map<Name, NodeTypeDef> registeredNTDefs;
+    private final Map<Name, QNodeTypeDefinition> registeredNTDefs;
 
     // definition of the root node
     private final QNodeDefinition rootNodeDef;
@@ -119,8 +123,7 @@
      */
     public static NodeTypeRegistry create(NamespaceRegistry nsReg, FileSystem ntStore)
             throws RepositoryException {
-        NodeTypeRegistry ntMgr = new NodeTypeRegistry(nsReg, ntStore);
-        return ntMgr;
+        return new NodeTypeRegistry(nsReg, ntStore);
     }
 
     //----------------------------------------< public NodeTypeRegistry 'api' >
@@ -171,7 +174,7 @@
      * @throws InvalidNodeTypeDefException if the given node type definition is invalid.
      * @throws RepositoryException if a repository error occurs.
      */
-    public synchronized EffectiveNodeType registerNodeType(NodeTypeDef ntd)
+    public synchronized EffectiveNodeType registerNodeType(QNodeTypeDefinition ntd)
             throws InvalidNodeTypeDefException, RepositoryException {
         // validate and register new node type definition
         EffectiveNodeType ent = internalRegister(ntd);
@@ -181,7 +184,7 @@
         persistCustomNodeTypeDefs(customNTDefs);
 
         if (eventChannel != null) {
-            Set<NodeTypeDef> ntDefs = new HashSet<NodeTypeDef>();
+            Set<QNodeTypeDefinition> ntDefs = new HashSet<QNodeTypeDefinition>();
             ntDefs.add(ntd);
             eventChannel.registered(ntDefs);
         }
@@ -193,18 +196,18 @@
     }
 
     /**
-     * Same as <code>{@link #registerNodeType(NodeTypeDef)}</code> except
+     * Same as <code>{@link #registerNodeType(QNodeTypeDefinition)}</code> except
      * that a collection of <code>NodeTypeDef</code>s is registered instead of
      * just one.
      * <p/>
      * This method can be used to register a set of node types that have
      * dependencies on each other.
      *
-     * @param ntDefs a collection of <code>NodeTypeDef<code> objects
+     * @param ntDefs a collection of <code>QNodeTypeDefinition<code> objects
      * @throws InvalidNodeTypeDefException if the given node type definition is invalid.
      * @throws RepositoryException if a repository error occurs.
      */
-    public void registerNodeTypes(Collection<NodeTypeDef> ntDefs)
+    public void registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs)
             throws InvalidNodeTypeDefException, RepositoryException {
 
         registerNodeTypes(ntDefs, false);
@@ -213,19 +216,19 @@
     /**
      * Internal implementation of {@link #registerNodeTypes(Collection)}
      *
-     * @param ntDefs a collection of <code>NodeTypeDef<code> objects
+     * @param ntDefs a collection of <code>QNodeTypeDefinition<code> objects
      * @param external whether this invocation should be considered external
      * @throws InvalidNodeTypeDefException if the given node type definition is invalid.
      * @throws RepositoryException if a repository error occurs.
      */
-    private synchronized void registerNodeTypes(Collection<NodeTypeDef> ntDefs,
+    private synchronized void registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs,
                                                 boolean external)
             throws InvalidNodeTypeDefException, RepositoryException {
 
         // validate and register new node type definitions
         internalRegister(ntDefs);
         // persist new node type definitions
-        for (NodeTypeDef ntDef: ntDefs) {
+        for (QNodeTypeDefinition ntDef: ntDefs) {
             customNTDefs.add(ntDef);
         }
         persistCustomNodeTypeDefs(customNTDefs);
@@ -236,7 +239,7 @@
         }
 
         // notify listeners
-        for (NodeTypeDef ntDef : ntDefs) {
+        for (QNodeTypeDefinition ntDef : ntDefs) {
             notifyRegistered(ntDef.getName());
         }
     }
@@ -353,7 +356,7 @@
      *                                     is invalid
      * @throws RepositoryException if another error occurs
      */
-    public EffectiveNodeType reregisterNodeType(NodeTypeDef ntd)
+    public EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd)
             throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
             RepositoryException {
 
@@ -361,7 +364,7 @@
     }
 
     /**
-     * Internal implementation of {@link #reregisterNodeType(NodeTypeDef)}.
+     * Internal implementation of {@link #reregisterNodeType(QNodeTypeDefinition)}.
      *
      * @param ntd node type definition
      * @param external whether this invocation should be considered external
@@ -372,7 +375,7 @@
      *                                     is invalid
      * @throws RepositoryException if another error occurs
      */
-    private synchronized EffectiveNodeType reregisterNodeType(NodeTypeDef ntd,
+    private synchronized EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd,
                                                               boolean external)
             throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
             RepositoryException {
@@ -389,13 +392,13 @@
         /**
          * validate new node type definition
          */
-        checkNtBaseSubtyping(ntd, registeredNTDefs);
+        ntd = checkNtBaseSubtyping(ntd, registeredNTDefs);
         validateNodeTypeDef(ntd, entCache, registeredNTDefs, nsReg, false);
 
         /**
          * build diff of current and new definition and determine type of change
          */
-        NodeTypeDef ntdOld = registeredNTDefs.get(name);
+        QNodeTypeDefinition ntdOld = registeredNTDefs.get(name);
         NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntdOld, ntd);
         if (!diff.isModified()) {
             // the definition has not been modified, there's nothing to do here...
@@ -509,7 +512,7 @@
          * node type
          */
         HashSet<Name> names = new HashSet<Name>();
-        for (NodeTypeDef ntd : registeredNTDefs.values()) {
+        for (QNodeTypeDefinition ntd : registeredNTDefs.values()) {
             if (ntd.getDependencies().contains(nodeTypeName)) {
                 names.add(ntd.getName());
             }
@@ -525,14 +528,13 @@
      * @throws NoSuchNodeTypeException if a node type with the given name
      *                                 does not exist
      */
-    public NodeTypeDef getNodeTypeDef(Name nodeTypeName)
+    public QNodeTypeDefinition getNodeTypeDef(Name nodeTypeName)
             throws NoSuchNodeTypeException {
-        NodeTypeDef def = registeredNTDefs.get(nodeTypeName);
+        QNodeTypeDefinition def = registeredNTDefs.get(nodeTypeName);
         if (def == null) {
             throw new NoSuchNodeTypeException(nodeTypeName.toString());
         }
-        // return clone to make sure nobody messes around with the 'live' definition
-        return (NodeTypeDef) def.clone();
+        return def;
     }
 
     /**
@@ -583,7 +585,7 @@
         ps.println();
         ps.println("Registered NodeTypes:");
         ps.println();
-        for (NodeTypeDef ntd : registeredNTDefs.values()) {
+        for (QNodeTypeDefinition ntd : registeredNTDefs.values()) {
             ps.println(ntd.getName());
             Name[] supertypes = ntd.getSupertypes();
             ps.println("\tSupertypes");
@@ -664,7 +666,7 @@
     /**
      * {@inheritDoc}
      */
-    public void externalRegistered(Collection ntDefs)
+    public void externalRegistered(Collection<QNodeTypeDefinition> ntDefs)
             throws RepositoryException, InvalidNodeTypeDefException {
 
         registerNodeTypes(ntDefs, true);
@@ -673,7 +675,7 @@
     /**
      * {@inheritDoc}
      */
-    public void externalReregistered(NodeTypeDef ntDef)
+    public void externalReregistered(QNodeTypeDefinition ntDef)
             throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
             RepositoryException {
 
@@ -683,7 +685,7 @@
     /**
      * {@inheritDoc}
      */
-    public void externalUnregistered(Collection ntNames)
+    public void externalUnregistered(Collection<Name> ntNames)
             throws RepositoryException, NoSuchNodeTypeException {
 
         unregisterNodeTypes(ntNames, true);
@@ -910,7 +912,7 @@
      * @throws RepositoryException If there is conflicting content or if the
      *                             check failed for some other reason.
      */
-    protected void checkForConflictingContent(NodeTypeDef ntd)
+    protected void checkForConflictingContent(QNodeTypeDefinition ntd)
             throws RepositoryException {
         /**
          * collect names of node types that have dependencies on the given
@@ -979,7 +981,7 @@
      */
     static EffectiveNodeType getEffectiveNodeType(Name ntName,
                                                   EffectiveNodeTypeCache entCache,
-                                                  Map<Name, NodeTypeDef> ntdCache)
+                                                  Map<Name, QNodeTypeDefinition> ntdCache)
             throws NoSuchNodeTypeException {
         // 1. check if effective node type has already been built
         EffectiveNodeTypeCache.Key key = entCache.getKey(new Name[]{ntName});
@@ -989,7 +991,7 @@
         }
 
         // 2. make sure we've got the definition of the specified node type
-        NodeTypeDef ntd = ntdCache.get(ntName);
+        QNodeTypeDefinition ntd = ntdCache.get(ntName);
         if (ntd == null) {
             throw new NoSuchNodeTypeException(ntName.toString());
         }
@@ -1025,7 +1027,7 @@
      */
     static EffectiveNodeType getEffectiveNodeType(Name[] ntNames,
                                                   EffectiveNodeTypeCache entCache,
-                                                  Map<Name, NodeTypeDef> ntdCache)
+                                                  Map<Name, QNodeTypeDefinition> ntdCache)
             throws NodeTypeConflictException, NoSuchNodeTypeException {
 
         EffectiveNodeTypeCache.Key key = entCache.getKey(ntNames);
@@ -1068,7 +1070,7 @@
                      */
                     Name[] remainder = key.getNames();
                     for (Name aRemainder : remainder) {
-                        NodeTypeDef ntd = ntdCache.get(aRemainder);
+                        QNodeTypeDefinition ntd = ntdCache.get(aRemainder);
                         EffectiveNodeType ent =
                                 EffectiveNodeType.create(ntd, entCache, ntdCache);
                         // store new effective node type
@@ -1096,7 +1098,7 @@
 
     static void checkForCircularInheritance(Name[] supertypes,
                                             Stack<Name> inheritanceChain,
-                                            Map<Name, NodeTypeDef> ntDefCache)
+                                            Map<Name, QNodeTypeDefinition> ntDefCache)
             throws InvalidNodeTypeDefException, RepositoryException {
         for (Name nt : supertypes) {
             int pos = inheritanceChain.lastIndexOf(nt);
@@ -1115,7 +1117,7 @@
             }
 
             try {
-                NodeTypeDef ntd = ntDefCache.get(nt);
+                QNodeTypeDefinition ntd = ntDefCache.get(nt);
                 Name[] sta = ntd.getSupertypes();
                 if (sta.length > 0) {
                     // check recursively
@@ -1134,7 +1136,7 @@
     static void checkForCircularNodeAutoCreation(EffectiveNodeType childNodeENT,
                                                  Stack<Name> definingParentNTs,
                                                  EffectiveNodeTypeCache anEntCache,
-                                                 Map<Name, NodeTypeDef> ntDefCache)
+                                                 Map<Name, QNodeTypeDefinition> ntDefCache)
             throws InvalidNodeTypeDefException {
         // check for circularity through default node types of auto-created child nodes
         // (node type 'a' defines auto-created child node with default node type 'a')
@@ -1180,7 +1182,7 @@
         }
     }
 
-    private EffectiveNodeType internalRegister(NodeTypeDef ntd)
+    private EffectiveNodeType internalRegister(QNodeTypeDefinition ntd)
             throws InvalidNodeTypeDefException, RepositoryException {
         Name name = ntd.getName();
         if (name != null && registeredNTDefs.containsKey(name)) {
@@ -1189,15 +1191,13 @@
             throw new InvalidNodeTypeDefException(msg);
         }
 
-        checkNtBaseSubtyping(ntd, registeredNTDefs);
+        ntd = checkNtBaseSubtyping(ntd, registeredNTDefs);
         EffectiveNodeType ent =
                 validateNodeTypeDef(ntd, entCache, registeredNTDefs, nsReg, false);
 
         // store new effective node type instance
         entCache.put(ent);
 
-        // register clone of node type definition
-        ntd = (NodeTypeDef) ntd.clone();
         registeredNTDefs.put(name, ntd);
 
         return ent;
@@ -1216,7 +1216,7 @@
      * @throws RepositoryException if an error occurs
      * @see #registerNodeType
      */
-    private void internalRegister(Collection<NodeTypeDef> ntDefs)
+    private void internalRegister(Collection<QNodeTypeDefinition> ntDefs)
             throws InvalidNodeTypeDefException, RepositoryException {
         internalRegister(ntDefs, false);
     }
@@ -1231,15 +1231,18 @@
      * that can be exposed in a property definition because it is
      * system-generated (such as jcr:primaryType in nt:base).
      */
-    private void internalRegister(Collection<NodeTypeDef> ntDefs, boolean lenient)
+    private void internalRegister(Collection<QNodeTypeDefinition> ntDefs, boolean lenient)
             throws InvalidNodeTypeDefException, RepositoryException {
 
+        // need a list/collection that can be modified
+        List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>(ntDefs);
+
         // map of node type names and node type definitions
-        Map<Name, NodeTypeDef> tmpNTDefCache = new HashMap<Name, NodeTypeDef>(registeredNTDefs);
+        Map<Name, QNodeTypeDefinition> tmpNTDefCache = new HashMap<Name, QNodeTypeDefinition>(registeredNTDefs);
 
         // temporarily register the node type definition
         // and do some preliminary checks
-        for (NodeTypeDef ntd : ntDefs) {
+        for (QNodeTypeDefinition ntd : defs) {
             Name name = ntd.getName();
             if (name != null && tmpNTDefCache.containsKey(name)) {
                 String msg = name + " already exists";
@@ -1254,14 +1257,21 @@
         }
 
         // check if all node type defs have proper nt:base subtyping
-        for (NodeTypeDef ntd : ntDefs) {
-            checkNtBaseSubtyping(ntd, tmpNTDefCache);
+        for (int i = 0; i < defs.size(); i++) {
+            QNodeTypeDefinition ntd = defs.get(i);
+            QNodeTypeDefinition mod = checkNtBaseSubtyping(ntd, tmpNTDefCache);
+            if (mod != ntd) {
+                // check fixed subtyping
+                // -> update cache and list of defs
+                tmpNTDefCache.put(mod.getName(), mod);
+                defs.set(i, mod);
+            }
         }
 
         // create working copies of current ent & ntd caches:
         // cache of pre-built aggregations of node types
         EffectiveNodeTypeCache tmpENTCache = (EffectiveNodeTypeCache) entCache.clone();
-        for (NodeTypeDef ntd : ntDefs) {
+        for (QNodeTypeDefinition ntd : defs) {
             EffectiveNodeType ent = validateNodeTypeDef(ntd, tmpENTCache,
                     tmpNTDefCache, nsReg, lenient);
 
@@ -1271,9 +1281,7 @@
 
         // since no exception was thrown so far the definitions are assumed to
         // be valid
-        for (NodeTypeDef ntd : ntDefs) {
-            // register clone of node type definition
-            ntd = (NodeTypeDef) ntd.clone();
+        for (QNodeTypeDefinition ntd : defs) {
             registeredNTDefs.put(ntd.getName(), ntd);
         }
 
@@ -1282,7 +1290,7 @@
     }
 
     private void internalUnregister(Name name) throws NoSuchNodeTypeException {
-        NodeTypeDef ntd = registeredNTDefs.get(name);
+        QNodeTypeDefinition ntd = registeredNTDefs.get(name);
         if (ntd == null) {
             throw new NoSuchNodeTypeException(name.toString());
         }
@@ -1321,15 +1329,16 @@
      *
      * @param ntd the node type def to check
      * @param ntdCache cache for lookup
-     * @return <code>true</code> if the ntd was modified
+     * @return the node type definition that was given to check or a new
+     *          instance if it had to be fixed up.
      */
-    private static boolean checkNtBaseSubtyping(NodeTypeDef ntd, Map<Name, NodeTypeDef> ntdCache) {
+    private static QNodeTypeDefinition checkNtBaseSubtyping(QNodeTypeDefinition ntd, Map<Name, QNodeTypeDefinition> ntdCache) {
         if (NameConstants.NT_BASE.equals(ntd.getName())) {
-            return false;
+            return ntd;
         }
         Set<Name> supertypes = new TreeSet<Name>(Arrays.asList(ntd.getSupertypes()));
         if (supertypes.isEmpty()) {
-            return false;
+            return ntd;
         }
         boolean modified;
         if (ntd.isMixin()) {
@@ -1340,7 +1349,7 @@
             boolean allMixins = true;
             for (Name name: supertypes) {
                 if (!name.equals(NameConstants.NT_BASE)) {
-                    NodeTypeDef def = ntdCache.get(name);
+                    QNodeTypeDefinition def = ntdCache.get(name);
                     if (def != null && !def.isMixin()) {
                         allMixins = false;
                         break;
@@ -1355,14 +1364,19 @@
                 // ntd is a primary node type and at least one of the supertypes
                 // is too, so ensure that no nt:base is added. note that the
                 // trivial case, where there would be no supertype left is handled
-                // in the NodeTypeDef directly
+                // in the QNodeTypeDefinition directly
                 modified = supertypes.remove(NameConstants.NT_BASE);
             }
         }
         if (modified) {
-            ntd.setSupertypes(supertypes.toArray(new Name[supertypes.size()]));
+            ntd = new QNodeTypeDefinitionImpl(ntd.getName(),
+                    supertypes.toArray(new Name[supertypes.size()]),
+                    ntd.getSupportedMixinTypes(), ntd.isMixin(),
+                    ntd.isAbstract(), ntd.isQueryable(),
+                    ntd.hasOrderableChildNodes(), ntd.getPrimaryItemName(),
+                    ntd.getPropertyDefs(), ntd.getChildNodeDefs());
         }
-        return modified;
+        return ntd;
     }
 
     /**
@@ -1374,13 +1388,13 @@
      * @param ntdCache cache of 'known' node type definitions, used to resolve dependencies
      * @param nsReg    namespace registry used for validatingatch names
      * @param lenient flag governing whether validation can be lenient or has to be strict
-     * @return an effective node type representation of the specified <code>NodeTypeDef</code>
+     * @return an effective node type representation of the specified <code>QNodeTypeDefinition</code>
      * @throws InvalidNodeTypeDefException if the node type is not valid
      * @throws RepositoryException         if another error occurs
      */
-    private static EffectiveNodeType validateNodeTypeDef(NodeTypeDef ntd,
+    private static EffectiveNodeType validateNodeTypeDef(QNodeTypeDefinition ntd,
                                                          EffectiveNodeTypeCache entCache,
-                                                         Map<Name, NodeTypeDef> ntdCache,
+                                                         Map<Name, QNodeTypeDefinition> ntdCache,
                                                          NamespaceRegistry nsReg,
                                                          boolean lenient)
             throws InvalidNodeTypeDefException, RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Fri Sep 18 09:15:07 2009
@@ -25,7 +25,6 @@
 import javax.jcr.version.OnParentVersionAction;
 
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -37,6 +36,7 @@
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 /**
@@ -75,7 +75,7 @@
         VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null);
         Name[] ntNames = ntReg.getRegisteredNodeTypes();
         for (int i = 0; i < ntNames.length; i++) {
-            NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntNames[i]);
+            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntNames[i]);
             VirtualNodeState ntState = createNodeTypeState(root, ntDef);
             root.addChildNodeEntry(ntNames[i], ntState.getNodeId());
             // add as hard reference
@@ -104,7 +104,7 @@
     public void onNodeTypeAdded(Name ntName) throws RepositoryException {
         try {
             VirtualNodeState root = (VirtualNodeState) getRootState();
-            NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntName);
+            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntName);
             VirtualNodeState ntState = createNodeTypeState(root, ntDef);
             root.addChildNodeEntry(ntName, ntState.getNodeId());
 
@@ -149,7 +149,7 @@
      * @throws RepositoryException
      */
     private VirtualNodeState createNodeTypeState(VirtualNodeState parent,
-                                                 NodeTypeDef ntDef)
+                                                 QNodeTypeDefinition ntDef)
             throws RepositoryException {
         NodeId id = calculateStableId(ntDef.getName().toString());
         VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE);
@@ -194,7 +194,7 @@
      */
     private VirtualNodeState createPropertyDefState(VirtualNodeState parent,
                                                     QPropertyDefinition propDef,
-                                                    NodeTypeDef ntDef, int n)
+                                                    QNodeTypeDefinition ntDef, int n)
             throws RepositoryException {
         NodeId id = calculateStableId(
                 ntDef.getName().toString() + "/" + NameConstants.JCR_PROPERTYDEFINITION.toString() + "/" + n);
@@ -245,7 +245,7 @@
      */
     private VirtualNodeState createChildNodeDefState(VirtualNodeState parent,
                                                      QNodeDefinition cnDef,
-                                                     NodeTypeDef ntDef, int n)
+                                                     QNodeTypeDefinition ntDef, int n)
             throws RepositoryException {
         NodeId id = calculateStableId(
                 ntDef.getName().toString() + "/" + NameConstants.JCR_CHILDNODEDEFINITION.toString() + "/" + n);

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=816551&r1=816550&r2=816551&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 Fri Sep 18 09:15:07 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.nodetype.xml;
 
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.util.DOMWalker;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.value.InternalValueFactory;
@@ -31,12 +30,14 @@
 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.nodetype.QNodeTypeDefinitionBuilder;
 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.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.value.ValueHelper;
 
 import javax.jcr.PropertyType;
@@ -70,7 +71,7 @@
      * @throws InvalidNodeTypeDefException if the node type definition
      *                                     format is invalid
      */
-    public static NodeTypeDef[] read(InputStream xml)
+    public static QNodeTypeDefinition[] read(InputStream xml)
             throws IOException, InvalidNodeTypeDefException {
         try {
             NodeTypeReader reader = new NodeTypeReader(xml);
@@ -130,13 +131,13 @@
      *                                     illegal name
      * @throws NamespaceException if a namespace is not defined
      */
-    public NodeTypeDef[] getNodeTypeDefs()
+    public QNodeTypeDefinition[] getNodeTypeDefs()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
-        List<NodeTypeDef> defs = new ArrayList<NodeTypeDef>();
+        List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>();
         while (walker.iterateElements(Constants.NODETYPE_ELEMENT)) {
             defs.add(getNodeTypeDef());
         }
-        return defs.toArray(new NodeTypeDef[defs.size()]);
+        return defs.toArray(new QNodeTypeDefinition[defs.size()]);
     }
 
     /**
@@ -148,9 +149,9 @@
      *                                     illegal name
      * @throws NamespaceException if a namespace is not defined
      */
-    private NodeTypeDef getNodeTypeDef()
+    private QNodeTypeDefinition getNodeTypeDef()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
-        NodeTypeDef type = new NodeTypeDef();
+        QNodeTypeDefinitionBuilder type = new QNodeTypeDefinitionBuilder();
 
         type.setName(resolver.getQName(
                 walker.getAttribute(Constants.NAME_ATTRIBUTE)));
@@ -200,7 +201,7 @@
         }
         type.setChildNodeDefs(nodes.toArray(new QNodeDefinition[nodes.size()]));
 
-        return type;
+        return type.build();
     }
 
     /**

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=816551&r1=816550&r2=816551&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 Fri Sep 18 09:15:07 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.util.DOMBuilder;
 import org.apache.jackrabbit.core.value.InternalValueFactory;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
@@ -30,6 +29,7 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PropertyType;
@@ -63,11 +63,11 @@
      * @throws RepositoryException on repository errors
      */
     public static void write(
-            OutputStream xml, NodeTypeDef[] types, NamespaceRegistry registry)
+            OutputStream xml, QNodeTypeDefinition[] types, NamespaceRegistry registry)
             throws IOException, RepositoryException {
         try {
             NodeTypeWriter writer = new NodeTypeWriter(registry);
-            for (NodeTypeDef type : types) {
+            for (QNodeTypeDefinition type : types) {
                 writer.addNodeTypeDef(type);
             }
             writer.write(xml);
@@ -125,7 +125,7 @@
      * @throws NamespaceException if the node type definition contains
      *                                   invalid namespace references
      */
-    private void addNodeTypeDef(NodeTypeDef def)
+    private void addNodeTypeDef(QNodeTypeDefinition def)
             throws NamespaceException, RepositoryException {
         builder.startElement(Constants.NODETYPE_ELEMENT);
 

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=816551&r1=816550&r2=816551&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 Fri Sep 18 09:15:07 2009
@@ -16,11 +16,11 @@
  */
 package org.apache.jackrabbit.core.query;
 
-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.spi.Name;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,7 +86,7 @@
 
     public void nodeTypeRegistered(Name ntName) {
         try {
-            NodeTypeDef def = registry.getNodeTypeDef(ntName);
+            QNodeTypeDefinition def = registry.getNodeTypeDef(ntName);
             QPropertyDefinition[] propDefs = def.getPropertyDefs();
             synchronized (typeMapping) {
                 for (QPropertyDefinition propDef : propDefs) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java Fri Sep 18 09:15:07 2009
@@ -31,11 +31,12 @@
 import org.apache.jackrabbit.core.journal.JournalFactory;
 import org.apache.jackrabbit.core.journal.MemoryJournal;
 import org.apache.jackrabbit.core.journal.MemoryJournal.MemoryRecord;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder;
 import org.apache.jackrabbit.test.JUnitTest;
 
 /**
@@ -178,12 +179,12 @@
      * @throws Exception
      */
     public void testNodeTypeRegistration() throws Exception {
-        NodeTypeDef ntd = new NodeTypeDef();
+        QNodeTypeDefinitionBuilder ntd = new QNodeTypeDefinitionBuilder();
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList<NodeTypeDef> list = new ArrayList<NodeTypeDef>();
-        list.add(ntd);
+        ArrayList<QNodeTypeDefinition> list = new ArrayList<QNodeTypeDefinition>();
+        list.add(ntd.build());
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REGISTER, list);
         master.registered(event.getCollection());
@@ -201,15 +202,15 @@
      * @throws Exception
      */
     public void testNodeTypeReregistration() throws Exception {
-        NodeTypeDef ntd = new NodeTypeDef();
+        QNodeTypeDefinitionBuilder ntd = new QNodeTypeDefinitionBuilder();
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList<NodeTypeDef> list = new ArrayList<NodeTypeDef>();
-        list.add(ntd);
+        ArrayList<QNodeTypeDefinition> list = new ArrayList<QNodeTypeDefinition>();
+        list.add(ntd.build());
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REREGISTER, list);
-        master.reregistered(ntd);
+        master.reregistered(ntd.build());
 
         SimpleEventListener listener = new SimpleEventListener();
         slave.setListener((NodeTypeEventListener) listener);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java?rev=816551&r1=816550&r2=816551&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java Fri Sep 18 09:15:07 2009
@@ -29,9 +29,9 @@
 
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * Simple event listener that can be registered for all cluster event listener
@@ -206,7 +206,7 @@
     /**
      * {@inheritDoc}
      */
-    public void externalReregistered(NodeTypeDef ntDef)
+    public void externalReregistered(QNodeTypeDefinition ntDef)
             throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
             RepositoryException {
 



Mime
View raw message