jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r555209 - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ spi-logger/src/main/ja...
Date Wed, 11 Jul 2007 08:41:32 GMT
Author: angela
Date: Wed Jul 11 01:41:30 2007
New Revision: 555209

URL: http://svn.apache.org/viewvc?view=rev&rev=555209
Log:
minor improvement: remove unused instance fields
minor improvement: let TransientISFactory listen to states created by the WorkspaceItemStateFactory
JCR-1004 SPI: Add RepositoryService.getQNodeTypeDefinition 
         >> modify to RepositoryService.getQNodeTypeDefinitions(QName)
         >> adjust SPI implementations
         >> change NodeTypeRegistry to load definitions upon demand.


Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java Wed Jul 11 01:41:30 2007
@@ -138,7 +138,7 @@
         nsMappings = new LocalNamespaceMappings(workspace.getNamespaceRegistryImpl());
 
         // build nodetype manager
-        ntManager = new NodeTypeManagerImpl(workspace.getNodeTypeRegistry(), this, getJcrValueFactory(), getQValueFactory());
+        ntManager = new NodeTypeManagerImpl(workspace.getNodeTypeRegistry(), this, getJcrValueFactory());
         validator = new ItemStateValidator(this);
 
         itemStateManager = createSessionItemStateManager(workspace.getUpdatableItemStateManager(), workspace.getItemStateFactory());

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Wed Jul 11 01:41:30 2007
@@ -160,7 +160,7 @@
         Map repositoryDescriptors = service.getRepositoryDescriptors();
         nsRegistry = createNamespaceRegistry(repositoryDescriptors);
         QNodeDefinition rootNodeDef = service.getNodeDefinition(sessionInfo, service.getRootId(sessionInfo));
-        ntRegistry = createNodeTypeRegistry(rootNodeDef, nsRegistry, repositoryDescriptors);
+        ntRegistry = createNodeTypeRegistry(rootNodeDef, nsRegistry);
         changeFeed = createChangeFeed(pollTimeout);
         definitionProvider = createDefinitionProvider(rootNodeDef, getEffectiveNodeTypeProvider());
 
@@ -346,7 +346,7 @@
      * @return
      */
     private TransientItemStateFactory createItemStateFactory() {
-        ItemStateFactory isf = new WorkspaceItemStateFactory(service, sessionInfo, getItemDefinitionProvider());
+        WorkspaceItemStateFactory isf = new WorkspaceItemStateFactory(service, sessionInfo, getItemDefinitionProvider());
         TransientItemStateFactory tisf = new TransientISFactory(isf, getItemDefinitionProvider());
         return tisf;
     }
@@ -385,13 +385,14 @@
      * @return
      * @throws RepositoryException
      */
-    private NodeTypeRegistry createNodeTypeRegistry(QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry, Map descriptors) throws RepositoryException {
-        Iterator it = service.getQNodeTypeDefinitions(sessionInfo);
-        List ntDefs = new ArrayList();
-        while (it.hasNext()) {
-            ntDefs.add(it.next());
-        }
+    private NodeTypeRegistry createNodeTypeRegistry(QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry) {
         NodeTypeStorage ntst = new NodeTypeStorage() {
+            public Iterator getAllDefinitions() throws RepositoryException {
+                return service.getQNodeTypeDefinitions(sessionInfo);
+            }
+            public Iterator getDefinitions(QName[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException {
+                return service.getQNodeTypeDefinitions(sessionInfo, nodeTypeNames);
+            }
             public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException {
                 throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
             }
@@ -402,7 +403,7 @@
                 throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
             }
         };
-        return NodeTypeRegistryImpl.create(ntDefs, ntst, rootNodeDef, nsRegistry);
+        return NodeTypeRegistryImpl.create(ntst, rootNodeDef, nsRegistry);
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java Wed Jul 11 01:41:30 2007
@@ -29,7 +29,6 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.spi.QValueFactory;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -77,11 +76,6 @@
     private final ValueFactory valueFactory;
 
     /**
-     * The QValueFactory used to convert JCR values to qualified ones.
-     */
-    private final QValueFactory qValueFactory;
-
-    /**
      * A cache for <code>NodeType</code> instances created by this
      * <code>NodeTypeManager</code>
      */
@@ -106,12 +100,11 @@
      * @param nsResolver namespace resolver
      */
     public NodeTypeManagerImpl(NodeTypeRegistry ntReg, ManagerProvider mgrProvider,
-                               ValueFactory valueFactory, QValueFactory qValueFactory) {
+                               ValueFactory valueFactory) {
         this.mgrProvider = mgrProvider;
         this.ntReg = ntReg;
         this.ntReg.addListener(this);
         this.valueFactory = valueFactory;
-        this.qValueFactory = qValueFactory;
 
         // setup caches with soft references to node type
         ntCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java Wed Jul 11 01:41:30 2007
@@ -67,7 +67,7 @@
      *
      * @return the names of all registered node types.
      */
-    public QName[] getRegisteredNodeTypes();
+    public QName[] getRegisteredNodeTypes() throws RepositoryException;
 
     /**
      * Validates the <code>NodeTypeDef</code> and returns

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java Wed Jul 11 01:41:30 2007
@@ -38,7 +38,6 @@
 import java.io.PrintStream;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -57,10 +56,8 @@
     private final EffectiveNodeTypeCache entCache;
 
     // map of node type names and node type definitions
-    private final ConcurrentReaderHashMap registeredNTDefs;
-
-    // definition of the root node
-    private final QNodeDefinition rootNodeDef;
+    //private final ConcurrentReaderHashMap registeredNTDefs;
+    private final NodeTypeDefinitionMap registeredNTDefs;
 
     // set of property definitions
     private final Set propDefs;
@@ -90,9 +87,8 @@
      * @return <code>NodeTypeRegistry</codes> object
      * @throws RepositoryException
      */
-    public static NodeTypeRegistryImpl create(Collection nodeTypeDefs, NodeTypeStorage storage, QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry)
-            throws RepositoryException {
-        NodeTypeRegistryImpl ntRegistry = new NodeTypeRegistryImpl(nodeTypeDefs, storage, rootNodeDef, nsRegistry);
+    public static NodeTypeRegistryImpl create(NodeTypeStorage storage, QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry) {
+        NodeTypeRegistryImpl ntRegistry = new NodeTypeRegistryImpl(storage, rootNodeDef, nsRegistry);
         return ntRegistry;
     }
 
@@ -103,35 +99,21 @@
      * @param nsRegistry
      * @throws RepositoryException
      */
-    private NodeTypeRegistryImpl(Collection nodeTypeDefs, NodeTypeStorage storage, QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry)
-            throws RepositoryException {
+    private NodeTypeRegistryImpl(NodeTypeStorage storage, QNodeDefinition rootNodeDef, NamespaceRegistry nsRegistry) {
         this.storage = storage;
         this.validator = new DefinitionValidator(this, nsRegistry);
 
         entCache = new BitsetENTCacheImpl();
-        registeredNTDefs = new ConcurrentReaderHashMap();
+        //registeredNTDefs = new ConcurrentReaderHashMap();
+        registeredNTDefs = new NodeTypeDefinitionMap();
 
         propDefs = new HashSet();
         nodeDefs = new HashSet();
 
         // setup definition of root node
-        this.rootNodeDef = rootNodeDef;
         synchronized (nodeDefs) {
             nodeDefs.add(rootNodeDef);
         }
-
-        try {
-            // validate & register the definitions
-            /* Note: since the client reads all nodetypes from the server, it is
-             * not able to distinguish between built-in and custom-defined
-             * nodetypes (compared to Jackrabbit-core) */
-            Map defMap = validator.validateNodeTypeDefs(nodeTypeDefs, new HashMap(registeredNTDefs));
-            internalRegister(defMap);
-        } catch (InvalidNodeTypeDefException intde) {
-            String error = "Unexpected error: Found invalid node type definition.";
-            log.debug(error);
-            throw new RepositoryException(error, intde);
-        }
     }
 
     //---------------------------------------------------< NodeTypeRegistry >---
@@ -154,8 +136,9 @@
     /**
      * @see NodeTypeRegistry#getRegisteredNodeTypes()
      */
-    public QName[] getRegisteredNodeTypes() {
-        return (QName[]) registeredNTDefs.keySet().toArray(new QName[registeredNTDefs.size()]);
+    public QName[] getRegisteredNodeTypes() throws RepositoryException {
+        Set qNames = registeredNTDefs.keySet();
+        return (QName[]) qNames.toArray(new QName[registeredNTDefs.size()]);
     }
 
 
@@ -222,18 +205,14 @@
         // do some preliminary checks
         for (Iterator iter = nodeTypeNames.iterator(); iter.hasNext();) {
             QName ntName = (QName) iter.next();
-            if (!registeredNTDefs.containsKey(ntName)) {
-                throw new NoSuchNodeTypeException(ntName.toString());
-            }
-
-            // check for node types other than those to be unregistered
-            // that depend on the given node types
-            Set dependents = getDependentNodeTypes(ntName);
+            
+            // Best effort check for node types other than those to be
+            // unregistered that depend on the given node types
+            Set dependents = registeredNTDefs.getDependentNodeTypes(ntName);
             dependents.removeAll(nodeTypeNames);
             if (dependents.size() > 0) {
                 StringBuffer msg = new StringBuffer();
-                msg.append(ntName
-                        + " can not be removed because the following node types depend on it: ");
+                msg.append(ntName).append(" can not be removed because the following node types depend on it: ");
                 for (Iterator depIter = dependents.iterator(); depIter.hasNext();) {
                     msg.append(depIter.next());
                     msg.append(" ");
@@ -290,7 +269,7 @@
         throws NoSuchNodeTypeException {
         QNodeTypeDefinition def = (QNodeTypeDefinition) registeredNTDefs.get(nodeTypeName);
         if (def == null) {
-            throw new NoSuchNodeTypeException(nodeTypeName.toString());
+            throw new NoSuchNodeTypeException("Nodetype " + nodeTypeName + " doesn't exist");
         }
         return def;
     }
@@ -539,9 +518,13 @@
     }
 
     private void internalRegister(QNodeTypeDefinition ntd, EffectiveNodeTypeImpl ent) {
-
-        // store new effective node type instance
-        entCache.put(ent);
+        // store new effective node type instance if present. otherwise it
+        // will be created on demand.
+        if (ent != null) {
+            entCache.put(ent);
+        } else {
+            log.debug("Effective node type for " + ntd + " not yet built.");
+        }
         // register nt-definition
         registeredNTDefs.put(ntd.getQName(), ntd);
 
@@ -561,21 +544,22 @@
     }
 
     private void internalUnregister(QName name) {
-        QNodeTypeDefinition ntd = (QNodeTypeDefinition) registeredNTDefs.get(name);
-        registeredNTDefs.remove(name);
+        QNodeTypeDefinition ntd = (QNodeTypeDefinition) registeredNTDefs.remove(name);
         entCache.invalidate(name);
 
-        // remove property & child node definitions
-        QPropertyDefinition[] pda = ntd.getPropertyDefs();
-        synchronized (propDefs) {
-            for (int i = 0; i < pda.length; i++) {
-                propDefs.remove(pda[i]);
+        if (ntd != null) {
+            // remove property & child node definitions
+            QPropertyDefinition[] pda = ntd.getPropertyDefs();
+            synchronized (propDefs) {
+                for (int i = 0; i < pda.length; i++) {
+                    propDefs.remove(pda[i]);
+                }
             }
-        }
-        synchronized (nodeDefs) {
-            QNodeDefinition[] nda = ntd.getChildNodeDefs();
-            for (int i = 0; i < nda.length; i++) {
-                nodeDefs.remove(nda[i]);
+            synchronized (nodeDefs) {
+                QNodeDefinition[] nda = ntd.getChildNodeDefs();
+                for (int i = 0; i < nda.length; i++) {
+                    nodeDefs.remove(nda[i]);
+                }
             }
         }
     }
@@ -587,32 +571,6 @@
         }
     }
 
-   /**
-     * Returns the names of those registered node types that have
-     * dependencies on the given node type.
-     *
-     * @param nodeTypeName node type name
-     * @return a set of node type <code>QName</code>s
-     * @throws NoSuchNodeTypeException
-     */
-    private Set getDependentNodeTypes(QName nodeTypeName)
-            throws NoSuchNodeTypeException {
-        if (!registeredNTDefs.containsKey(nodeTypeName)) {
-            throw new NoSuchNodeTypeException(nodeTypeName.toString());
-        }
-
-        // get names of those node types that have dependencies on the given nt
-        HashSet names = new HashSet();
-        Iterator iter = registeredNTDefs.values().iterator();
-        while (iter.hasNext()) {
-            QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
-            if (ntd.getDependencies().contains(nodeTypeName)) {
-                names.add(ntd.getQName());
-            }
-        }
-        return names;
-    }
-
     //-----------------------------------------------------------< Dumpable >---
     /**
      * {@inheritDoc}
@@ -620,87 +578,223 @@
     public void dump(PrintStream ps) {
         ps.println("NodeTypeRegistry (" + this + ")");
         ps.println();
-        ps.println("Registered NodeTypes:");
+        ps.println("Known NodeTypes:");
         ps.println();
-        Iterator iter = registeredNTDefs.values().iterator();
-        while (iter.hasNext()) {
-            QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
-            ps.println(ntd.getQName());
-            QName[] supertypes = ntd.getSupertypes();
-            ps.println("\tSupertypes");
-            for (int i = 0; i < supertypes.length; i++) {
-                ps.println("\t\t" + supertypes[i]);
-            }
-            ps.println("\tMixin\t" + ntd.isMixin());
-            ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
-            ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>" : ntd.getPrimaryItemName().toString()));
-            QPropertyDefinition[] pd = ntd.getPropertyDefs();
-            for (int i = 0; i < pd.length; i++) {
-                ps.print("\tPropertyDefinition");
-                ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") ");
-                ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getQName().toString()));
-                String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
-                ps.println("\t\tRequiredType\t" + type);
-                String[] vca = pd[i].getValueConstraints();
-                StringBuffer constraints = new StringBuffer();
-                if (vca == null) {
-                    constraints.append("<null>");
-                } else {
-                    for (int n = 0; n < vca.length; n++) {
-                        if (constraints.length() > 0) {
-                            constraints.append(", ");
-                        }
-                        constraints.append(vca[n]);
-                    }
+        registeredNTDefs.dump(ps);
+        ps.println();
+
+        entCache.dump(ps);
+    }
+
+    //--------------------------------------------------------< inner class >---
+    /**
+     * Inner class representing the map of <code>QNodeTypeDefinition</code>s
+     * that have been loaded yet.
+     */
+    private class NodeTypeDefinitionMap implements Map, Dumpable {
+
+        // map of node type names and node type definitions
+        private final ConcurrentReaderHashMap nodetypeDefinitions = new ConcurrentReaderHashMap();
+
+        /**
+         * Returns the names of those registered node types that have
+         * dependencies on the given node type.<p/>
+         * Note, that the returned Set may not be complete with respect
+         * to all node types registered within the repository. Instead it
+         * will only contain those node type definitions that are known so far.
+         *
+         * @param nodeTypeName node type name
+         * @return a set of node type <code>QName</code>s
+         * @throws NoSuchNodeTypeException
+         */
+        private Set getDependentNodeTypes(QName nodeTypeName) throws NoSuchNodeTypeException {
+            if (!nodetypeDefinitions.containsKey(nodeTypeName)) {
+                throw new NoSuchNodeTypeException(nodeTypeName.toString());
+            }
+            // get names of those node types that have dependencies on the
+            // node type with the given nodeTypeName.
+            HashSet names = new HashSet();
+            Iterator iter = nodetypeDefinitions.values().iterator();
+            while (iter.hasNext()) {
+                QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
+                if (ntd.getDependencies().contains(nodeTypeName)) {
+                    names.add(ntd.getQName());
                 }
-                ps.println("\t\tValueConstraints\t" + constraints.toString());
-                QValue[] defVals = pd[i].getDefaultValues();
-                StringBuffer defaultValues = new StringBuffer();
-                if (defVals == null) {
-                    defaultValues.append("<null>");
-                } else {
-                    for (int n = 0; n < defVals.length; n++) {
-                        if (defaultValues.length() > 0) {
-                            defaultValues.append(", ");
+            }
+            return names;
+        }
+
+        private void updateInternalMap(Iterator definitions) {
+            // since definition were retrieved from the storage, valiation
+            // can be omitted -> register without building effective-nodetype.
+            // TODO: check if correct
+            while (definitions.hasNext()) {
+                internalRegister((QNodeTypeDefinition) definitions.next(), null);
+            }
+        }
+
+        //------------------------------------------------------------< Map >---
+        public int size() {
+            return nodetypeDefinitions.size();
+        }
+
+        public void clear() {
+            throw new UnsupportedOperationException("Implementation missing");
+        }
+
+        public boolean isEmpty() {
+            return nodetypeDefinitions.isEmpty();
+        }
+
+        public boolean containsKey(Object key) {
+            if (!(key instanceof QName)) {
+                return false;
+            }
+            return get(key) != null;
+        }
+
+        public boolean containsValue(Object value) {
+            if (!(value instanceof QNodeTypeDefinition)) {
+                return false;
+            }
+            return get(((QNodeTypeDefinition)value).getQName()) != null;
+        }
+
+        public Set keySet() {
+            // to be aware of all (recently) registered nodetypes retrieve
+            // complete set from the storage again and add missing / replace
+            // existing definitions.
+            try {
+                Iterator it = storage.getAllDefinitions();
+                updateInternalMap(it);
+            } catch (RepositoryException e) {
+                log.error(e.getMessage());
+            }
+            return nodetypeDefinitions.keySet();
+        }
+
+        public Collection values() {
+            // make sure all node type definitions have been loaded.
+            keySet();
+            // and retrieve the collection containing all definitions.
+            return nodetypeDefinitions.values();
+        }
+
+        public Object put(Object key, Object value) {
+            return nodetypeDefinitions.put(key, value);
+        }
+
+        public void putAll(Map t) {
+            throw new UnsupportedOperationException("Implementation missing");
+        }
+
+        public Set entrySet() {
+            // make sure all node type definitions have been loaded.
+            keySet();
+            return nodetypeDefinitions.entrySet();
+        }
+
+        public Object get(Object key) {
+            if (!(key instanceof QName)) {
+                throw new IllegalArgumentException();
+            }
+            QNodeTypeDefinition def = (QNodeTypeDefinition) nodetypeDefinitions.get(key);
+            if (def == null) {
+                try {
+                    // node type does either not exist or hasn't been loaded yet
+                    Iterator it = storage.getDefinitions(new QName[] {(QName) key});
+                    updateInternalMap(it);
+                } catch (RepositoryException e) {
+                    log.debug(e.getMessage());
+                }
+            }
+            def = (QNodeTypeDefinition) nodetypeDefinitions.get(key);
+            return def;
+        }
+
+        public Object remove(Object key) {
+            return (QNodeTypeDefinition) nodetypeDefinitions.remove(key);
+        }
+
+        //-------------------------------------------------------< Dumpable >---
+        public void dump(PrintStream ps) {
+            Iterator iter = nodetypeDefinitions.values().iterator();
+            while (iter.hasNext()) {
+                QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
+                ps.println(ntd.getQName());
+                QName[] supertypes = ntd.getSupertypes();
+                ps.println("\tSupertypes");
+                for (int i = 0; i < supertypes.length; i++) {
+                    ps.println("\t\t" + supertypes[i]);
+                }
+                ps.println("\tMixin\t" + ntd.isMixin());
+                ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
+                ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>" : ntd.getPrimaryItemName().toString()));
+                QPropertyDefinition[] pd = ntd.getPropertyDefs();
+                for (int i = 0; i < pd.length; i++) {
+                    ps.print("\tPropertyDefinition");
+                    ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") ");
+                    ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getQName().toString()));
+                    String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
+                    ps.println("\t\tRequiredType\t" + type);                  
+                    String[] vca = pd[i].getValueConstraints();
+                    StringBuffer constraints = new StringBuffer();
+                    if (vca == null) {
+                        constraints.append("<null>");
+                    } else {
+                        for (int n = 0; n < vca.length; n++) {
+                            if (constraints.length() > 0) {
+                                constraints.append(", ");
+                            }
+                            constraints.append(vca[n]);
                         }
-                        try {
-                            defaultValues.append(defVals[n].getString());
-                        } catch (RepositoryException e) {
-                            defaultValues.append(defVals[n].toString());
+                    }
+                    ps.println("\t\tValueConstraints\t" + constraints.toString());
+                    QValue[] defVals = pd[i].getDefaultValues();
+                    StringBuffer defaultValues = new StringBuffer();
+                    if (defVals == null) {
+                        defaultValues.append("<null>");
+                    } else {
+                        for (int n = 0; n < defVals.length; n++) {
+                            if (defaultValues.length() > 0) {
+                                defaultValues.append(", ");
+                            }
+                            try {
+                                defaultValues.append(defVals[n].getString());
+                            } catch (RepositoryException e) {
+                                defaultValues.append(defVals[n].toString());
+                            }
                         }
                     }
+                    ps.println("\t\tDefaultValue\t" + defaultValues.toString());
+                    ps.println("\t\tAutoCreated\t" + pd[i].isAutoCreated());
+                    ps.println("\t\tMandatory\t" + pd[i].isMandatory());
+                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd[i].getOnParentVersion()));
+                    ps.println("\t\tProtected\t" + pd[i].isProtected());
+                    ps.println("\t\tMultiple\t" + pd[i].isMultiple());
                 }
-                ps.println("\t\tDefaultValue\t" + defaultValues.toString());
-                ps.println("\t\tAutoCreated\t" + pd[i].isAutoCreated());
-                ps.println("\t\tMandatory\t" + pd[i].isMandatory());
-                ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd[i].getOnParentVersion()));
-                ps.println("\t\tProtected\t" + pd[i].isProtected());
-                ps.println("\t\tMultiple\t" + pd[i].isMultiple());
-            }
-            QNodeDefinition[] nd = ntd.getChildNodeDefs();
-            for (int i = 0; i < nd.length; i++) {
-                ps.print("\tNodeDefinition");
-                ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") ");
-                ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getQName().toString()));
-                QName[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
-                if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
-                    for (int n = 0; n < reqPrimaryTypes.length; n++) {
-                        ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n]);
+                QNodeDefinition[] nd = ntd.getChildNodeDefs();
+                for (int i = 0; i < nd.length; i++) {
+                    ps.print("\tNodeDefinition");
+                    ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") ");
+                    ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getQName().toString()));
+                    QName[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
+                    if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
+                        for (int n = 0; n < reqPrimaryTypes.length; n++) {
+                            ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n]);
+                        }
                     }
+                    QName defPrimaryType = nd[i].getDefaultPrimaryType();
+                    if (defPrimaryType != null) {
+                        ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
+                    }
+                    ps.println("\n\t\tAutoCreated\t" + nd[i].isAutoCreated());
+                    ps.println("\t\tMandatory\t" + nd[i].isMandatory());
+                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(nd[i].getOnParentVersion()));
+                    ps.println("\t\tProtected\t" + nd[i].isProtected());
+                    ps.println("\t\tAllowsSameNameSiblings\t" + nd[i].allowsSameNameSiblings());
                 }
-                QName defPrimaryType = nd[i].getDefaultPrimaryType();
-                if (defPrimaryType != null) {
-                    ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
-                }
-                ps.println("\n\t\tAutoCreated\t" + nd[i].isAutoCreated());
-                ps.println("\t\tMandatory\t" + nd[i].isMandatory());
-                ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(nd[i].getOnParentVersion()));
-                ps.println("\t\tProtected\t" + nd[i].isProtected());
-                ps.println("\t\tAllowsSameNameSiblings\t" + nd[i].allowsSameNameSiblings());
             }
         }
-        ps.println();
-
-        entCache.dump(ps);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java Wed Jul 11 01:41:30 2007
@@ -21,11 +21,32 @@
 
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.RepositoryException;
+import java.util.Iterator;
 
 /**
  * <code>NodeTypeStorage</code>...
  */
 public interface NodeTypeStorage {
+
+    /**
+     * Returns an Iterator over all node type definitions registered.
+     *
+     * @return
+     * @throws RepositoryException
+     */
+    public Iterator getAllDefinitions() throws RepositoryException;
+
+    /**
+     * Returns the <code>QNodeTypeDefinition</code>s for the given node type
+     * names. The implementation is free to return additional definitions e.g.
+     * dependencies.
+     *
+     * @param nodeTypeNames
+     * @return
+     * @throws NoSuchNodeTypeException
+     * @throws RepositoryException
+     */
+    public Iterator getDefinitions(QName[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException;
 
     public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException;
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java Wed Jul 11 01:41:30 2007
@@ -34,16 +34,20 @@
 /**
  * <code>TransientISFactory</code>...
  */
-public final class TransientISFactory extends AbstractItemStateFactory implements TransientItemStateFactory  {
+public final class TransientISFactory extends AbstractItemStateFactory implements TransientItemStateFactory, ItemStateCreationListener  {
 
     private static Logger log = LoggerFactory.getLogger(TransientISFactory.class);
 
     private final ItemStateFactory workspaceStateFactory;
     private final ItemDefinitionProvider defProvider;
 
-    public TransientISFactory(ItemStateFactory workspaceStateFactory, ItemDefinitionProvider defProvider) {
+    public TransientISFactory(AbstractItemStateFactory workspaceStateFactory, ItemDefinitionProvider defProvider) {
         this.workspaceStateFactory = workspaceStateFactory;
         this.defProvider = defProvider;
+        // start listening to 'creations' on the workspaceStateFactory (and
+        // consequently skip an extra notification if the has been built by the
+        // workspaceStateFactory.
+        workspaceStateFactory.addCreationListener(this);
     }
 
     //------------------------------------------< TransientItemStateFactory >---
@@ -82,8 +86,6 @@
      */
     public NodeState createRootState(NodeEntry entry) throws ItemNotFoundException, RepositoryException {
         NodeState state = workspaceStateFactory.createRootState(entry);
-        notifyCreated(state);
-
         return state;
     }
 
@@ -94,8 +96,6 @@
     public NodeState createNodeState(NodeId nodeId, NodeEntry entry)
             throws ItemNotFoundException, RepositoryException {
         NodeState state = workspaceStateFactory.createNodeState(nodeId, entry);
-        notifyCreated(state);
-
         return state;
     }
 
@@ -106,8 +106,6 @@
     public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent)
             throws ItemNotFoundException, RepositoryException {
         NodeState state = workspaceStateFactory.createDeepNodeState(nodeId, anyParent);
-        notifyCreated(state);
-
         return state;
     }
 
@@ -118,10 +116,7 @@
     public PropertyState createPropertyState(PropertyId propertyId,
                                              PropertyEntry entry)
             throws ItemNotFoundException, RepositoryException {
-
         PropertyState state = workspaceStateFactory.createPropertyState(propertyId, entry);
-        notifyCreated(state);
-
         return state;
 
     }
@@ -131,8 +126,6 @@
      */
     public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent) throws ItemNotFoundException, RepositoryException {
         PropertyState state = workspaceStateFactory.createDeepPropertyState(propertyId, anyParent);
-        notifyCreated(state);
-
         return state;
     }
 
@@ -153,5 +146,21 @@
             return EmptyNodeReferences.getInstance();
         }
         return workspaceStateFactory.getNodeReferences(nodeState);
+    }
+
+    //------------------------------------------< ItemStateCreationListener >---
+    /**
+     * @see ItemStateCreationListener#created(ItemState)
+     */
+    public void created(ItemState state) {
+        log.debug("ItemState created by WorkspaceItemStateFactory");
+        notifyCreated(state);
+    }
+
+    /**
+     * @see ItemStateCreationListener#statusChanged(ItemState, int)
+     */
+    public void statusChanged(ItemState state, int previousStatus) {
+        // ignore
     }
 }

Modified: jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java (original)
+++ jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java Wed Jul 11 01:41:30 2007
@@ -32,7 +32,6 @@
 import org.apache.jackrabbit.spi.QueryInfo;
 import org.apache.jackrabbit.spi.EventFilter;
 import org.apache.jackrabbit.spi.EventBundle;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 
@@ -613,14 +612,14 @@
         }, "getQNodeTypeDefinitions(SessionInfo)", new Object[]{});
     }
 
-    public QNodeTypeDefinition getQNodeTypeDefinition(
-            final SessionInfo sessionInfo,final QName name)
+    public Iterator getQNodeTypeDefinitions(
+            final SessionInfo sessionInfo,final QName[] ntNames)
             throws RepositoryException {
-        return (QNodeTypeDefinition) execute(new Callable() {
+        return (Iterator) execute(new Callable() {
             public Object call() throws RepositoryException {
-                return service.getQNodeTypeDefinition(sessionInfo, name);
+                return service.getQNodeTypeDefinitions(sessionInfo, ntNames);
             }
-        }, "getQNodeTypeDefinition(SessionInfo,QName)", new Object[]{name});
+        }, "getQNodeTypeDefinition(SessionInfo,QName)", new Object[]{ntNames});
     }
 
     private Object execute(Callable callable, String methodName, Object[] args)

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java (original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java Wed Jul 11 01:41:30 2007
@@ -742,12 +742,10 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getQNodeTypeDefinitions(
-            SessionInfo sessionInfo) throws RepositoryException {
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo) throws RepositoryException {
         try {
-            QNodeTypeDefinition[] ntDefs = remoteService.getQNodeTypeDefinitions(
-                    getRemoteSessionInfo(sessionInfo));
-            return Arrays.asList(ntDefs).iterator();
+            RemoteIterator it = remoteService.getQNodeTypeDefinitions(getRemoteSessionInfo(sessionInfo));
+            return new ClientIterator(it);
         } catch (RemoteException e) {
             throw new RemoteRepositoryException(e);
         }
@@ -756,16 +754,22 @@
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName) throws RepositoryException {
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, QName[] nodetypeNames) throws RepositoryException {
         try {
-            return remoteService.getQNodeTypeDefinition(getRemoteSessionInfo(sessionInfo), nodetypeName);
+            RemoteIterator it = remoteService.getQNodeTypeDefinitions(getRemoteSessionInfo(sessionInfo), nodetypeNames);
+            return new ClientIterator(it);
         } catch (RemoteException e) {
             throw new RemoteRepositoryException(e);
         }
     }
 
     //------------------------------< internal >--------------------------------
-
+    /**
+     *
+     * @param sessionInfo
+     * @return
+     * @throws RepositoryException
+     */
     private RemoteSessionInfo getRemoteSessionInfo(SessionInfo sessionInfo)
             throws RepositoryException {
         if (sessionInfo instanceof ClientSessionInfo) {

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java (original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java Wed Jul 11 01:41:30 2007
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.spi.LockInfo;
 import org.apache.jackrabbit.spi.EventFilter;
 import org.apache.jackrabbit.spi.EventBundle;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.NodeInfo;
 import org.apache.jackrabbit.spi.commons.SerializableBatch;
@@ -671,11 +670,11 @@
      * @throws RemoteException if an error occurs.
      * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinitions(org.apache.jackrabbit.spi.SessionInfo)
      */
-    public QNodeTypeDefinition[] getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+    public RemoteIterator getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
             throws RepositoryException, RemoteException;
 
     /**
-     * Retrieve the <code>QNodeTypeDefinition</code> for the given node type name.
+     * Retrieve the <code>QNodeTypeDefinition</code>s for the given node type names.
      *
      * @param sessionInfo
      * @return
@@ -683,5 +682,5 @@
      * @throws RemoteException if an error occurs.
      * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinition(org.apache.jackrabbit.spi.SessionInfo, QName)
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(RemoteSessionInfo sessionInfo, QName ntName) throws RepositoryException, RemoteException;
+    public RemoteIterator getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo, QName[] ntNames) throws RepositoryException, RemoteException;
 }

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java (original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java Wed Jul 11 01:41:30 2007
@@ -820,35 +820,23 @@
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition[] getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+    public RemoteIterator getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
             throws RepositoryException, RemoteException {
         Iterator it = service.getQNodeTypeDefinitions(getSessionInfo(sessionInfo));
-        List nts = new ArrayList();
-        while (it.hasNext()) {
-            QNodeTypeDefinition nt = (QNodeTypeDefinition) it.next();
-            if (nt instanceof Serializable) {
-                nts.add(nt);
-            } else {
-                nts.add(new QNodeTypeDefinitionImpl(nt));
-            }
-        }
-        return (QNodeTypeDefinition[]) nts.toArray(new QNodeTypeDefinition[nts.size()]);
+        return getQNodeTypeDefinitionIterator(it);
     }
 
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(RemoteSessionInfo sessionInfo, QName ntName)
+    public RemoteIterator getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo,
+                                                 QName[] ntNames)
             throws RepositoryException, RemoteException {
-        QNodeTypeDefinition ntDef = service.getQNodeTypeDefinition(getSessionInfo(sessionInfo), ntName);
-        if (ntDef instanceof Serializable) {
-            return ntDef;
-        } else {
-            return new QNodeTypeDefinitionImpl(ntDef);
-        }
+        Iterator it = service.getQNodeTypeDefinitions(getSessionInfo(sessionInfo), ntNames);
+        return getQNodeTypeDefinitionIterator(it);
     }
-    //---------------------------< internal >-----------------------------------
 
+    //---------------------------< internal >-----------------------------------
     /**
      * Creates a server session info for the given <code>sessionInfo</code>.
      *
@@ -920,5 +908,24 @@
             }
         }
         return filters;
+    }
+
+    /**
+     *
+     * @param it
+     * @return
+     * @throws RemoteException
+     */
+    private RemoteIterator getQNodeTypeDefinitionIterator(Iterator it) throws RemoteException {
+        List nts = new ArrayList();
+        while (it.hasNext()) {
+            QNodeTypeDefinition nt = (QNodeTypeDefinition) it.next();
+            if (nt instanceof Serializable) {
+                nts.add(nt);
+            } else {
+                nts.add(new QNodeTypeDefinitionImpl(nt));
+            }
+        }
+        return new ServerIterator(nts.iterator(), DEFAULT_BUFFER_SIZE);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java (original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java Wed Jul 11 01:41:30 2007
@@ -769,10 +769,15 @@
     public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo) throws RepositoryException;
 
     /**
-     * Retrieve a specific <code>QNodeTypeDefinition</code>.
+     * Retrieve <code>QNodeTypeDefinition</code>s for the given names. The
+     * implementation is free to return additional definitions which will (probably)
+     * be needed by the caller due to node type inheritance. The caller must be
+     * able to deal with any kind of additional <code>QNodeTypeDefinition</code>s
+     * present in the <code>Iterator</code> irrespective whether they have been
+     * loaded before or not.
      *
      * @param sessionInfo
-     * @param nodetypeName name of node type to retrieve
+     * @param nodetypeNames names of node types to retrieve
      * @return {@link QNodeTypeDefinition}
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.Workspace#getNodeTypeManager()
@@ -781,5 +786,5 @@
      * @see javax.jcr.nodetype.NodeTypeManager#getPrimaryNodeTypes()
      * @see javax.jcr.nodetype.NodeTypeManager#getNodeType(String)
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName) throws RepositoryException;
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, QName[] nodetypeNames) throws RepositoryException;
 }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java Wed Jul 11 01:41:30 2007
@@ -1822,21 +1822,7 @@
             method.checkSuccess();
 
             Document reportDoc = method.getResponseBodyAsDocument();
-            ElementIterator it = DomUtil.getChildren(reportDoc.getDocumentElement(), NodeTypeConstants.NODETYPE_ELEMENT, null);
-            List ntDefs = new ArrayList();
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
-            while (it.hasNext()) {
-                ntDefs.add(new QNodeTypeDefinitionImpl(it.nextElement(), resolver, getQValueFactory()));
-            }
-            // refresh node type definitions map
-            synchronized (nodeTypeDefinitions) {
-                nodeTypeDefinitions.clear();
-                for (Iterator defIt = ntDefs.iterator(); defIt.hasNext(); ) {
-                    QNodeTypeDefinition def = (QNodeTypeDefinition) defIt.next();
-                    nodeTypeDefinitions.put(def.getQName(), def);
-                }
-            }
-            return ntDefs.iterator();
+            return retrieveQNodeTypeDefinitions(sessionInfo, reportDoc);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
@@ -1851,16 +1837,18 @@
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName) throws RepositoryException {
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, QName[] nodetypeNames) throws RepositoryException {
         ReportMethod method = null;
         try {
             NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
 
             ReportInfo info = new ReportInfo(NodeTypesReport.NODETYPES_REPORT, DEPTH_0);
-            Element el = DomUtil.createElement(domFactory, NodeTypeConstants.XML_NODETYPE, NodeTypeConstants.NAMESPACE);
-            String jcrName = NameFormat.format(nodetypeName, resolver);
-            DomUtil.addChildElement(el, NodeTypeConstants.XML_NODETYPENAME, NodeTypeConstants.NAMESPACE, jcrName);
-            info.setContentElement(el);
+            for (int i = 0; i < nodetypeNames.length; i++) {
+                Element el = DomUtil.createElement(domFactory, NodeTypeConstants.XML_NODETYPE, NodeTypeConstants.NAMESPACE);
+                String jcrName = NameFormat.format(nodetypeNames[i], resolver);
+                DomUtil.addChildElement(el, NodeTypeConstants.XML_NODETYPENAME, NodeTypeConstants.NAMESPACE, jcrName);
+                info.setContentElement(el);
+            }
 
             String workspaceUri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
             method = new ReportMethod(workspaceUri, info);
@@ -1868,13 +1856,7 @@
             method.checkSuccess();
 
             Document reportDoc = method.getResponseBodyAsDocument();
-            Element ntDefEl = DomUtil.getChildElement(reportDoc.getDocumentElement(), NodeTypeConstants.NODETYPE_ELEMENT, null);
-            QNodeTypeDefinition def = new QNodeTypeDefinitionImpl(ntDefEl, resolver, getQValueFactory());
-            // refresh node type definitions map
-            synchronized (nodeTypeDefinitions) {
-                nodeTypeDefinitions.put(def.getQName(), def);
-            }
-            return def;
+            return retrieveQNodeTypeDefinitions(sessionInfo, reportDoc);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
@@ -1886,6 +1868,31 @@
                 method.releaseConnection();
             }
         }
+    }
+
+    /**
+     * 
+     * @param sessionInfo
+     * @param reportDoc
+     * @return
+     * @throws RepositoryException
+     */
+    private Iterator retrieveQNodeTypeDefinitions(SessionInfo sessionInfo, Document reportDoc) throws RepositoryException {
+        ElementIterator it = DomUtil.getChildren(reportDoc.getDocumentElement(), NodeTypeConstants.NODETYPE_ELEMENT, null);
+            List ntDefs = new ArrayList();
+            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            while (it.hasNext()) {
+                ntDefs.add(new QNodeTypeDefinitionImpl(it.nextElement(), resolver, getQValueFactory()));
+            }
+            // refresh node type definitions map
+            synchronized (nodeTypeDefinitions) {
+                nodeTypeDefinitions.clear();
+                for (Iterator defIt = ntDefs.iterator(); defIt.hasNext(); ) {
+                    QNodeTypeDefinition def = (QNodeTypeDefinition) defIt.next();
+                    nodeTypeDefinitions.put(def.getQName(), def);
+                }
+            }
+            return ntDefs.iterator();
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=555209&r1=555208&r2=555209
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java Wed Jul 11 01:41:30 2007
@@ -23,7 +23,6 @@
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.NodeInfo;
@@ -1000,16 +999,26 @@
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName) throws RepositoryException {
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, QName[] nodetypeNames) throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
-        try {
-            String ntName = NameFormat.format(nodetypeName, sInfo.getNamespaceResolver());
-            NodeType nt = ntMgr.getNodeType(ntName);
-            return new QNodeTypeDefinitionImpl(nt, sInfo.getNamespaceResolver(), getQValueFactory());
-        } catch (NameException e) {
-            throw new RepositoryException(e);
+        List defs = new ArrayList();
+        for (int i = 0; i < nodetypeNames.length; i++) {
+            try {
+                String ntName = NameFormat.format(nodetypeNames[i], sInfo.getNamespaceResolver());
+                NodeType nt = ntMgr.getNodeType(ntName);
+                defs.add(new QNodeTypeDefinitionImpl(nt, sInfo.getNamespaceResolver(), getQValueFactory()));
+
+                // in addition pack all supertypes into the return value
+                NodeType[] supertypes = nt.getSupertypes();
+                for (int st = 0; st < supertypes.length; st++) {
+                    defs.add(new QNodeTypeDefinitionImpl(supertypes[i], sInfo.getNamespaceResolver(), getQValueFactory()));
+                }
+            } catch (NameException e) {
+                throw new RepositoryException(e);
+            }
         }
+        return defs.iterator();
     }
 
     //----------------------------< internal >----------------------------------



Mime
View raw message