jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r654826 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2sp...
Date Fri, 09 May 2008 14:37:22 GMT
Author: angela
Date: Fri May  9 07:37:21 2008
New Revision: 654826

URL: http://svn.apache.org/viewvc?rev=654826&view=rev
Log:
JCR-1576  Remove RepositoryService exists()  
JCR-1577  Remove RepositoryService.getRootId()  
JCR-1405  SPI: Introduce NodeInfo.getChildInfos()  

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/NodeInfo.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
Fri May  9 07:37:21 2008
@@ -62,7 +62,9 @@
     private final EntryFactory factory;
 
     /**
-     * Create a new <code>ChildNodeEntries</code> collection
+     * Create a new <code>ChildNodeEntries</code> collection and retrieve
+     * the entries from the persistent layer if the parent is neither
+     * NEW nor in a terminal status.
      */
     ChildNodeEntriesImpl(NodeEntry parent, EntryFactory factory) throws ItemNotFoundException,
RepositoryException {
         entriesByName = new NameMap();
@@ -71,15 +73,38 @@
         this.parent = parent;
         this.factory = factory;
 
-        if (parent.getStatus() == Status.NEW || Status.isTerminal(parent.getStatus())) {
-            return; // cannot retrieve child-entries from persistent layer
-        }
+        if (parent.getStatus() != Status.NEW && !Status.isTerminal(parent.getStatus()))
{
+            NodeId id = parent.getWorkspaceId();
+            Iterator childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id);
+            // simply add all child entries to the empty collection
+            while (childNodeInfos.hasNext()) {
+                ChildInfo ci = (ChildInfo) childNodeInfos.next();
+                NodeEntry entry = factory.createNodeEntry(parent, ci.getName(), ci.getUniqueID());
+                add(entry, ci.getIndex());
+            }
+        } /* else: cannot retrieve child-entries from persistent layer. the parent
+           * is NEW (transient only) or already removed from the persistent layer.
+           */
+    }
 
-        NodeId id = parent.getWorkspaceId();
-        Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
-        // simply add all child entries to the empty collection
-        while (it.hasNext()) {
-            ChildInfo ci = (ChildInfo) it.next();
+    /**
+     * Create a new <code>ChildNodeEntries</code> collection from the given
+     * <code>childNodeInfos</code> instead of retrieving them from the
+     * persistent layer.
+     *
+     * @param parent
+     * @param factory
+     * @param childNodeInfos
+     */
+    ChildNodeEntriesImpl(NodeEntry parent, EntryFactory factory, Iterator childNodeInfos)
{
+        entriesByName = new NameMap();
+        entries = new LinkedEntries();
+
+        this.parent = parent;
+        this.factory = factory;
+
+        while (childNodeInfos.hasNext()) {
+            ChildInfo ci = (ChildInfo) childNodeInfos.next();
             NodeEntry entry = factory.createNodeEntry(parent, ci.getName(), ci.getUniqueID());
             add(entry, ci.getIndex());
         }
@@ -117,15 +142,20 @@
         }
 
         NodeId id = parent.getWorkspaceId();
-        Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
+        Iterator childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id);
+        reload(childNodeInfos);
+    }
+
+    void reload(Iterator childNodeInfos) {
+        // TODO: should existing (not-new) entries that are not present in the childInfos
be removed?
         // create list from all ChildInfos (for multiple loop)
         List cInfos = new ArrayList();
-        while (it.hasNext()) {
-            cInfos.add(it.next());
+        while (childNodeInfos.hasNext()) {
+            cInfos.add(childNodeInfos.next());
         }
         // first make sure the ordering of all existing entries is ok
         NodeEntry entry = null;
-        for (it = cInfos.iterator(); it.hasNext();) {
+        for (Iterator it = cInfos.iterator(); it.hasNext();) {
             ChildInfo ci = (ChildInfo) it.next();
             NodeEntry nextEntry = get(ci);
             if (nextEntry != null) {
@@ -137,7 +167,7 @@
         }
         // then insert the 'new' entries
         List newEntries = new ArrayList();
-        for (it = cInfos.iterator(); it.hasNext();) {
+        for (Iterator it = cInfos.iterator(); it.hasNext();) {
             ChildInfo ci = (ChildInfo) it.next();
             NodeEntry beforeEntry = get(ci);
             if (beforeEntry == null) {
@@ -325,8 +355,8 @@
      * <code>null</code> <code>insertNode</code> is moved to the
end of the
      * child node entries.
      *
-     * @param insertNode the NodeEntry to move.
-     * @param beforeNode the NodeEntry where <code>insertNode</code> is
+     * @param insertEntry the NodeEntry to move.
+     * @param beforeEntry the NodeEntry where <code>insertNode</code> is
      * reordered to.
      * @return the NodeEntry that followed the 'insertNode' before the reordering.
      * @throws NoSuchElementException if <code>insertNode</code> or
@@ -355,11 +385,12 @@
 
     /**
      *
-     * @param insertObj
+     * @param insertName
      * @param insertLN
      * @param beforeLN
      */
-    private void reorder(Name insertName, LinkedEntries.LinkNode insertLN, LinkedEntries.LinkNode
beforeLN) {
+    private void reorder(Name insertName, LinkedEntries.LinkNode insertLN,
+                         LinkedEntries.LinkNode beforeLN) {
         // reorder named map
         if (entriesByName.containsSiblings(insertName)) {
             int position;
@@ -731,7 +762,6 @@
          *
          * @param siblings
          * @param index
-         * @param checkValidity
          * @return
          */
         private static NodeEntry findMatchingEntry(List siblings, int index) {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Fri May  9 07:37:21 2008
@@ -177,6 +177,14 @@
     public List getNodeEntries(Name nodeName) throws RepositoryException;
 
     /**
+     * Creates or updates the <code>ChildNodeEntries</code> of this node.
+     *
+     * @param childInfos
+     * @throws RepositoryException
+     */
+    public void setNodeEntries(Iterator childInfos) throws RepositoryException;
+
+    /**
      * Adds a new child NodeEntry to this entry.
      *
      * @param nodeName

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
Fri May  9 07:37:21 2008
@@ -590,6 +590,19 @@
     }
 
     /**
+     *
+     * @param childInfos
+     * @throws RepositoryException
+     */
+    public void setNodeEntries(Iterator childInfos) throws RepositoryException {
+        if (childNodeEntries == null) {
+            childNodeEntries = new ChildNodeEntriesImpl(this, factory, childInfos);
+        } else {
+            ((ChildNodeEntriesImpl) childNodeEntries).reload(childInfos);
+        }
+    }
+
+    /**
      * @inheritDoc
      * @see NodeEntry#addNodeEntry(Name, String, int)
      */

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
Fri May  9 07:37:21 2008
@@ -16,21 +16,23 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.QItemDefinition;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.PropertyId;
-import org.apache.jackrabbit.spi.NodeId;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.PropertyType;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.ConstraintViolationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>ItemDefinitionManagerImpl</code>...
@@ -57,8 +59,11 @@
      */
     public QNodeDefinition getRootNodeDefinition() throws RepositoryException {
         if (rootNodeDefinition == null) {
+            IdFactory idFactory = service.getIdFactory();
+            PathFactory pf = service.getPathFactory();
+
             rootNodeDefinition = service.getNodeDefinition(
-                    sessionInfo, service.getRootId(sessionInfo));
+                    sessionInfo, idFactory.createNodeId((String) null, pf.getRootPath()));
         }
         return rootNodeDefinition;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Fri May  9 07:37:21 2008
@@ -16,31 +16,34 @@
  */
 package org.apache.jackrabbit.jcr2spi.state;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.ItemInfo;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.PropertyInfo;
-import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.RepositoryService;
-import org.apache.jackrabbit.spi.ItemInfo;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>WorkspaceItemStateFactory</code>...
@@ -65,7 +68,10 @@
      * @see ItemStateFactory#createRootState(NodeEntry)
      */
     public NodeState createRootState(NodeEntry entry) throws ItemNotFoundException, RepositoryException
{
-        return createNodeState(service.getRootId(sessionInfo), entry);
+        IdFactory idFactory = service.getIdFactory();
+        PathFactory pf = service.getPathFactory();
+
+        return createNodeState(idFactory.createNodeId((String) null, pf.getRootPath()), entry);
     }
 
     /**
@@ -270,6 +276,13 @@
             log.warn("Internal error", e);
         }
 
+        // unless the child-info are omitted by the SPI impl -> make sure
+        // the childentries the nodeentry are initialized or updated.
+        Iterator childInfos = info.getChildInfos();
+        if (childInfos != null) {
+            entry.setNodeEntries(childInfos);
+        }
+
         notifyCreated(state);
         return state;
     }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
Fri May  9 07:37:21 2008
@@ -16,17 +16,18 @@
  */
 package org.apache.jackrabbit.spi.commons;
 
-import org.apache.jackrabbit.spi.NodeInfo;
-import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.ChildInfo;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.NodeInfo;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PropertyId;
 
-import java.util.List;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.io.Serializable;
+import java.util.List;
 
 /**
  * <code>NodeInfoImpl</code> implements a serializable <code>NodeInfo</code>
@@ -65,6 +66,11 @@
     private final List propertyIds;
 
     /**
+     * The list of {@link ChildInfo}s of this node info.
+     */
+    private final List childInfos;
+
+    /**
      * Creates a new serializable <code>NodeInfo</code> for the given
      * <code>NodeInfo</code>.
      *
@@ -86,6 +92,7 @@
             NodeId nodeId = nodeInfo.getId();
             nodeId = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath());
             final Iterator propIds = nodeInfo.getPropertyIds();
+            final Iterator childInfos = nodeInfo.getChildInfos();
             return new NodeInfoImpl(nodeInfo.getPath(), nodeId,
                     nodeInfo.getIndex(), nodeInfo.getNodetype(),
                     nodeInfo.getMixins(), serRefs.iterator(),
@@ -104,7 +111,25 @@
                         public void remove() {
                             throw new UnsupportedOperationException();
                         }
-                    });
+                    },
+                    ((childInfos == null) ? null :
+                    new Iterator() {
+                        public boolean hasNext() {
+                            return childInfos.hasNext();
+                        }
+                        public Object next() {
+                            ChildInfo cInfo = (ChildInfo) childInfos.next();
+                            if (cInfo instanceof Serializable) {
+                                return cInfo;
+                            } else {
+                                return new ChildInfoImpl(cInfo.getName(), cInfo.getUniqueID(),
cInfo.getIndex());
+                            }
+                        }
+                        public void remove() {
+                            throw new UnsupportedOperationException();
+                        }
+                    })
+            );
         }
     }
 
@@ -120,13 +145,15 @@
      * @param mixinNames      the names of the assigned mixins.
      * @param references      the references to this node.
      * @param propertyIds     the properties of this node.
+     * @param childInfos      the child infos of this node or <code>null</code>.
      * @deprecated Use {@link #NodeInfoImpl(Name, Path, NodeId, int, Name, Name[], Iterator,
Iterator)}
      * instead. The parentId is not used any more.
      */
     public NodeInfoImpl(NodeId parentId, Name name, Path path, NodeId id,
                         int index, Name primaryTypeName, Name[] mixinNames,
-                        Iterator references, Iterator propertyIds) {
-         this(path, id, index, primaryTypeName, mixinNames, references, propertyIds);
+                        Iterator references, Iterator propertyIds,
+                        Iterator childInfos) {
+         this(path, id, index, primaryTypeName, mixinNames, references, propertyIds, childInfos);
     }
 
     /**
@@ -141,7 +168,8 @@
      * @param propertyIds     the properties of this node.
      */
     public NodeInfoImpl(Path path, NodeId id, int index, Name primaryTypeName,
-                        Name[] mixinNames, Iterator references, Iterator propertyIds) {
+                        Name[] mixinNames, Iterator references, Iterator propertyIds,
+                        Iterator childInfos) {
         super(path, true);
         this.id = id;
         this.index = index;
@@ -155,6 +183,14 @@
         while (propertyIds.hasNext()) {
             this.propertyIds.add(propertyIds.next());
         }
+        if (childInfos == null) {
+            this.childInfos = null;
+        } else {
+            this.childInfos = new ArrayList();
+            while (childInfos.hasNext()) {
+                this.childInfos.add(childInfos.next());
+            }
+        }
     }
 
     //-------------------------------< NodeInfo >-------------------------------
@@ -202,4 +238,11 @@
     public Iterator getPropertyIds() {
         return propertyIds.iterator();
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator getChildInfos() {
+        return (childInfos == null) ? null : childInfos.iterator();
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/NodeInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/NodeInfo.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/NodeInfo.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/NodeInfo.java
Fri May  9 07:37:21 2008
@@ -73,4 +73,22 @@
      * @see PropertyInfo#getId()
      */
     public Iterator getPropertyIds();
+
+    /**
+     * Return the all <code>ChildInfo</code>s of the node represent by
+     * this info, an empty iterator if that node doesn't have any child nodes
+     * or <code>null</code> if the implementation is not able or for some
+     * internal reasons not willing to compute the <code>ChildInfo</code>
+     * iterator. In the latter case the user of this API must call
+     * {@link RepositoryService#getChildInfos(SessionInfo, NodeId)} in order
+     * to determine the existence and identity of the child nodes.
+     *
+     * @return An iterator of <code>ChildInfo</code>s or <code>null</code>
if
+     * the implementation is not able or willing to compute the set of
+     * <code>ChildInfo</code>s (e.g. an implementation may choose to return
+     * <code>null</code> if there is a huge amount of child nodes). In this
+     * case {@link RepositoryService#getChildInfos(SessionInfo, NodeId)} will
+     * be used to load the <code>ChildInfo</code>s.
+     */
+    public Iterator getChildInfos();
 }

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Fri May  9 07:37:21 2008
@@ -16,30 +16,31 @@
  */
 package org.apache.jackrabbit.spi;
 
-import javax.jcr.lock.LockException;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.Version;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Credentials;
-import javax.jcr.UnsupportedRepositoryOperationException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+
 import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.ItemExistsException;
-import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
 import javax.jcr.MergeException;
 import javax.jcr.NamespaceException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.ValueFormatException;
+import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
-import javax.jcr.LoginException;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.query.InvalidQueryException;
-import java.util.Map;
-import java.util.Iterator;
-import java.io.InputStream;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
 
 /**
  * The <code>RepositoryService</code> interface defines methods used to
@@ -206,20 +207,6 @@
 
     //------------------------------------------------------< Reading items >---
     /**
-     * The <code>NodeId</code> of the root node may basically have two
-     * characteristics. If the root node can be identified with a unique ID the
-     * returned <code>NodeId</code> simply has a uniqueID part and the path
-     * part is <code>null</code>. If the root node cannot be identified with
a
-     * unique ID the uniqueID part is <code>null</code> and the path part will
be set
-     * to "/".
-     *
-     * @param sessionInfo
-     * @return The <code>NodeId</code> of the root <code>Node</code>.
-     * @throws javax.jcr.RepositoryException
-     */
-    public NodeId getRootId(SessionInfo sessionInfo) throws RepositoryException;
-
-    /**
      * Returns the <code>QNodeDefinition</code> for the <code>Node</code>
      * identified by the given id. This method should only be used if the
      * caller is not able to unambiguously determine the applicable definition
@@ -249,20 +236,6 @@
     public QPropertyDefinition getPropertyDefinition(SessionInfo sessionInfo, PropertyId
propertyId) throws RepositoryException;
 
     /**
-     * Returns <code>true</code> if an <code>Item</code> with the
given
-     * <code>ItemId</code> exists. Note, that the implementation must be able
to
-     * deal with the various formats of an <code>ItemId</code>. The caller might
-     * not be aware of the uniqueID part the ItemId may have.
-     *
-     * @param sessionInfo
-     * @param itemId
-     * @return true if the item with the given id exists.
-     * @throws javax.jcr.RepositoryException
-     * @see javax.jcr.Session#itemExists(String)
-     */
-    public boolean exists(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException;
-
-    /**
      * Retrieve the <code>NodeInfo</code> for the node identified by the given
      * <code>NodeId</code>. See {@link #getItemInfos(SessionInfo, NodeId)} for
      * a similar method that in addition may return <code>ItemInfo</code>s of

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
Fri May  9 07:37:21 2008
@@ -16,18 +16,19 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
-import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
 import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.PropertyIterator;
-import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * <code>NodeInfoImpl</code> implements a <code>NodeInfo</code> on
top of a JCR
@@ -53,7 +54,8 @@
                 resolver.getQName(node.getPrimaryNodeType().getName()),
                 getNodeTypeNames(node.getMixinNodeTypes(), resolver),
                 getPropertyIds(node.getReferences(), resolver, idFactory),
-                getPropertyIds(node.getProperties(), resolver, idFactory));
+                getPropertyIds(node.getProperties(), resolver, idFactory),
+                getChildInfos(node.getNodes(), resolver));
     }
 
     /**
@@ -98,4 +100,13 @@
         }
         return references.iterator();
     }
+
+    private static Iterator getChildInfos(NodeIterator childNodes,
+                                          NamePathResolver resolver) throws RepositoryException
{
+        List childInfos = new ArrayList();
+        while (childNodes.hasNext()) {
+            childInfos.add(new ChildInfoImpl(childNodes.nextNode(), resolver));
+        }
+        return childInfos.iterator();
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=654826&r1=654825&r2=654826&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Fri May  9 07:37:21 2008
@@ -272,17 +272,6 @@
     /**
      * {@inheritDoc}
      */
-    public NodeId getRootId(SessionInfo sessionInfo)
-            throws RepositoryException {
-
-        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        return idFactory.createNodeId(sInfo.getSession().getRootNode(),
-                sInfo.getNamePathResolver());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public QNodeDefinition getNodeDefinition(SessionInfo sessionInfo,
                                              NodeId nodeId)
             throws RepositoryException {
@@ -315,26 +304,6 @@
     /**
      * {@inheritDoc}
      */
-    public boolean exists(SessionInfo sessionInfo, ItemId itemId)
-            throws RepositoryException {
-        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        try {
-            if (itemId.denotesNode()) {
-                getNode((NodeId) itemId, sInfo);
-            } else {
-                getProperty((PropertyId) itemId, sInfo);
-            }
-        } catch (ItemNotFoundException e) {
-            return false;
-        } catch (PathNotFoundException e) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId)
             throws ItemNotFoundException, RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
@@ -684,7 +653,7 @@
         executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
                 Version v = (Version) getNode(versionId, sInfo);
-                if (exists(sessionInfo, nodeId)) {
+                if (hasNode(sessionInfo, nodeId)) {
                     Node n = getNode(nodeId, sInfo);
                     n.restore(v, removeExisting);
                 } else {
@@ -700,7 +669,7 @@
                         while (degree < path.getLength()) {
                             Path ancestorPath = path.getAncestor(degree);
                             NodeId parentId = idFactory.createNodeId(nodeId.getUniqueID(),
ancestorPath);
-                            if (exists(sessionInfo, parentId)) {
+                            if (hasNode(sessionInfo, parentId)) {
                                 n = getNode(parentId, sInfo);
                                 relPath = ancestorPath.computeRelativePath(path);
                             }
@@ -718,6 +687,18 @@
         }, sInfo);
     }
 
+    private boolean hasNode(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException
{
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        try {
+            getNode(nodeId, sInfo);
+        } catch (ItemNotFoundException e) {
+            return false;
+        } catch (PathNotFoundException e) {
+            return false;
+        }
+        return true;
+    }
+
     /**
      * {@inheritDoc}
      */



Mime
View raw message