jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1159182 - in /jackrabbit/trunk: jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ jackrab...
Date Thu, 18 Aug 2011 11:58:38 GMT
Author: mduerig
Date: Thu Aug 18 11:58:38 2011
New Revision: 1159182

URL: http://svn.apache.org/viewvc?rev=1159182&view=rev
Log:
JCR-3054: Deprecate RepositoryService.getPropertyInfo method

Modified:
    jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/benchmark/ReadPerformanceTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
Thu Aug 18 11:58:38 2011
@@ -301,7 +301,7 @@ public class RepositoryFactoryImplTest e
             return null;
         }
 
-        public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId) throws ItemNotFoundException, RepositoryException {
+        public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId) throws ItemNotFoundException, RepositoryException {
             return null;
         }
 
@@ -514,4 +514,4 @@ public class RepositoryFactoryImplTest e
         }
     }
 
-}
\ No newline at end of file
+}

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=1159182&r1=1159181&r2=1159182&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
Thu Aug 18 11:58:38 2011
@@ -85,20 +85,20 @@ public class WorkspaceItemStateFactory e
 
         try {
             Entry<NodeInfo> cached = cache.getNodeInfo(nodeId);
-            NodeInfo info;
+            ItemInfo info;
             if (isUpToDate(cached, entry)) {
                 info = cached.info;
             } else {
                 // otherwise retreive item info from service and cache the whole batch
                 Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo,
nodeId);
                 info = first(infos, cache, entry.getGeneration());
-                if (info == null) {
+                if (info == null || !info.denotesNode()) {
                     throw new ItemNotFoundException("NodeId: " + nodeId);
                 }
             }
 
             assertMatchingPath(info, entry);
-            return createNodeState(info, entry);
+            return createNodeState((NodeInfo) info, entry);
         }
         catch (PathNotFoundException e) {
             throw new ItemNotFoundException(e);
@@ -116,12 +116,12 @@ public class WorkspaceItemStateFactory e
             // Get item info from cache
             Iterator<? extends ItemInfo> infos = null;
             Entry<NodeInfo> cached = cache.getNodeInfo(nodeId);
-            NodeInfo info;
+            ItemInfo info;
             if (cached == null) {
                 // or from service if not in cache
                 infos = service.getItemInfos(sessionInfo, nodeId);
                 info = first(infos, null, 0);
-                if (info == null) {
+                if (info == null || !info.denotesNode()) {
                     throw new ItemNotFoundException("NodeId: " + nodeId);
                 }
             } else {
@@ -147,7 +147,7 @@ public class WorkspaceItemStateFactory e
                 }
 
                 assertMatchingPath(info, entry);
-                return createNodeState(info, (NodeEntry) entry);
+                return createNodeState((NodeInfo) info, (NodeEntry) entry);
             }
         }
         catch (PathNotFoundException e) {
@@ -164,17 +164,20 @@ public class WorkspaceItemStateFactory e
         try {
             // Get item info from cache and use it if up to date
             Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
-            PropertyInfo info;
+            ItemInfo info;
             if (isUpToDate(cached, entry)) {
                 info = cached.info;
             } else {
                 // otherwise retreive item info from service and cache the whole batch
-                info = service.getPropertyInfo(sessionInfo, propertyId);
-                cache.put(info, entry.getGeneration());
+                Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo,
propertyId);
+                info = first(infos, cache, entry.getGeneration());
+                if (info == null || info.denotesNode()) {
+                    throw new ItemNotFoundException("PropertyId: " + propertyId);
+                }
             }
 
             assertMatchingPath(info, entry);
-            return createPropertyState(info, entry);
+            return createPropertyState((PropertyInfo) info, entry);
         }
         catch (PathNotFoundException e) {
             throw new ItemNotFoundException(e);
@@ -190,30 +193,39 @@ public class WorkspaceItemStateFactory e
 
         try {
             // Get item info from cache
+            Iterator<? extends ItemInfo> infos = null;
             Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
-            PropertyInfo info;
+            ItemInfo info;
             if (cached == null) {
                 // or from service if not in cache
-                info = service.getPropertyInfo(sessionInfo, propertyId);
+                infos = service.getItemInfos(sessionInfo, propertyId);
+                info = first(infos, null, 0);
+                if (info == null || info.denotesNode()) {
+                    throw new ItemNotFoundException("PropertyId: " + propertyId);
+                }
             } else {
                 info = cached.info;
             }
 
             // Build the hierarchy entry for the item info
             HierarchyEntry entry = createHierarchyEntries(info, anyParent);
-
             if (entry == null || entry.denotesNode()) {
                 throw new ItemNotFoundException(
                         "HierarchyEntry does not belong to any existing ItemInfo. No ItemState
was created.");
             } else {
+                long generation = entry.getGeneration();
                 if (isOutdated(cached, entry)) {
                     // if not, retreive the item info from the service and put the whole
batch into the cache
-                    info = service.getPropertyInfo(sessionInfo, propertyId);
-                    cache.put(info, entry.getGeneration());
+                    infos = service.getItemInfos(sessionInfo, propertyId);
+                    info = first(infos, cache, generation);
+                } else if (infos != null) {
+                    // Otherwise put the whole batch retrieved from the service earlier into
the cache
+                    cache.put(info, generation);
+                    first(infos, cache, generation);
                 }
 
                 assertMatchingPath(info, entry);
-                return createPropertyState(info, (PropertyEntry) entry);
+                return createPropertyState((PropertyInfo) info, (PropertyEntry) entry);
             }
 
         } catch (PathNotFoundException e) {
@@ -250,22 +262,17 @@ public class WorkspaceItemStateFactory e
     //------------------------------------------------------------< private >---
 
     /**
-     * Returns the first item in the iterator if it exists and denotes a node.
-     * Otherwise returns <code>null</code>. If <code>cache</code>
is not
-     * <code>null</code>, caches all items by the given <code>generation</code>.
-     * @param generation
+     * Returns the first item in the iterator if it exists. Otherwise returns <code>null</code>.
+     * If <code>cache</code> is not <code>null</code>, caches all
items by the given
+     * <code>generation</code>.
      */
-    private static NodeInfo first(Iterator<? extends ItemInfo> infos, ItemInfoCache
cache, long generation) {
+    private static ItemInfo first(Iterator<? extends ItemInfo> infos, ItemInfoCache
cache, long generation) {
         ItemInfo first = null;
         if (infos.hasNext()) {
             first = infos.next();
             if (cache != null) {
                 cache.put(first, generation);
             }
-
-            if (!first.denotesNode()) {
-                first = null;
-            }
         }
 
         if (cache != null) {
@@ -274,7 +281,7 @@ public class WorkspaceItemStateFactory e
             }
         }
 
-        return (NodeInfo) first;
+        return first;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
Thu Aug 18 11:58:38 2011
@@ -154,10 +154,10 @@ public abstract class AbstractJCR2SPITes
                 return AbstractJCR2SPITest.this.createRootNodeDefinition();
             }
 
-            public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo,
NodeId nodeId)
+            public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo,
ItemId itemId)
                     throws ItemNotFoundException, RepositoryException {
 
-                return AbstractJCR2SPITest.this.getItemInfos(sessionInfo, nodeId);
+                return AbstractJCR2SPITest.this.getItemInfos(sessionInfo, itemId);
             }
 
             public Iterator<ChildInfo> getChildInfos(SessionInfo sessionInfo, NodeId
parentId)
@@ -316,7 +316,7 @@ public abstract class AbstractJCR2SPITes
 
     public abstract NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException;
 
-    public abstract Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo,
NodeId nodeId) throws ItemNotFoundException, RepositoryException;
+    public abstract Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo,
ItemId itemId) throws ItemNotFoundException, RepositoryException;
 
     public abstract Iterator<ChildInfo> getChildInfos(SessionInfo sessionInfo, NodeId
parentId) throws ItemNotFoundException, RepositoryException;
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
Thu Aug 18 11:58:38 2011
@@ -16,11 +16,8 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.filterIterator;
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.iteratorChain;
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.singleton;
-
 import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.ItemInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.NodeInfo;
@@ -39,9 +36,12 @@ import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-
 import java.util.Iterator;
 
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.filterIterator;
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.iteratorChain;
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.singleton;
+
 /**
  * Test cases for {@link RepositoryService#getItemInfos(SessionInfo, NodeId)}. Specifically
  * for JCR-1797.
@@ -150,14 +150,14 @@ public class GetItemsTest extends Abstra
     }
 
     @Override
-    public Iterator<ItemInfo> getItemInfos(SessionInfo sessionInfo, final NodeId nodeId)
+    public Iterator<ItemInfo> getItemInfos(SessionInfo sessionInfo, final ItemId itemId)
             throws RepositoryException {
-
+        
         return iteratorChain(
-                singleton(itemInfoStore.getNodeInfo(nodeId)),
+                singleton(itemInfoStore.getItemInfo(itemId)),
                 filterIterator(itemInfoStore.getItemInfos(), new Predicate<ItemInfo>()
{
                     public boolean evaluate(ItemInfo info) {
-                        return !nodeId.equals(info.getId());
+                        return !itemId.equals(info.getId());
                     }
                 }));
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/benchmark/ReadPerformanceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/benchmark/ReadPerformanceTest.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/benchmark/ReadPerformanceTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/benchmark/ReadPerformanceTest.java
Thu Aug 18 11:58:38 2011
@@ -16,12 +16,9 @@
  */
 package org.apache.jackrabbit.jcr2spi.benchmark;
 
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.filterIterator;
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.iteratorChain;
-import static org.apache.jackrabbit.spi.commons.iterator.Iterators.singleton;
-
 import org.apache.jackrabbit.jcr2spi.AbstractJCR2SPITest;
 import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.ItemInfo;
 import org.apache.jackrabbit.spi.ItemInfoCache;
 import org.apache.jackrabbit.spi.NodeId;
@@ -42,7 +39,6 @@ import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -51,6 +47,10 @@ import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.Callable;
 
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.filterIterator;
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.iteratorChain;
+import static org.apache.jackrabbit.spi.commons.iterator.Iterators.singleton;
+
 /**
  * Utility for testing jcr2spi read performance
  */
@@ -320,12 +320,12 @@ public class ReadPerformanceTest extends
     }
 
     @Override
-    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId)
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId)
             throws ItemNotFoundException, RepositoryException {
 
         roundTripCount++;
-        NodeInfo nodeInfo = itemInfoStore.getNodeInfo(nodeId);
-        return iteratorChain(singleton(nodeInfo), getBatch());
+        ItemInfo itemInfo = itemInfoStore.getItemInfo(itemId);
+        return iteratorChain(singleton(itemInfo), getBatch());
     }
 
     @Override

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
Thu Aug 18 11:58:38 2011
@@ -213,14 +213,14 @@ public class RepositoryServiceLogger ext
         }, "getNodeInfo(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
     }
 
-    public Iterator<? extends ItemInfo> getItemInfos(final SessionInfo sessionInfo,
final NodeId nodeId)
+    public Iterator<? extends ItemInfo> getItemInfos(final SessionInfo sessionInfo,
final ItemId itemId)
             throws RepositoryException {
 
         return (Iterator<? extends ItemInfo>) execute(new Callable() {
             public Object call() throws RepositoryException {
-                return service.getItemInfos(unwrap(sessionInfo), nodeId);
+                return service.getItemInfos(unwrap(sessionInfo), itemId);
             }
-        }, "getItemInfos(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+        }, "getItemInfos(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), itemId});
     }
 
     public Iterator<ChildInfo> getChildInfos(final SessionInfo sessionInfo, final NodeId
parentId)

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=1159182&r1=1159181&r2=1159182&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
Thu Aug 18 11:58:38 2011
@@ -274,17 +274,17 @@ public interface RepositoryService {
 
     /**
      * Method used to 'batch-read' from the persistent storage. It returns the
-     * <code>NodeInfo</code> for the given <code>NodeId</code> as
the first
+     * <code>ItemInfo</code> for the given <code>ItemId</code> as
the first
      * element in the <code>Iterator</code>. In addition the iterator may contain
      * arbitrary <code>ItemInfo</code>s.
      *
      * @param sessionInfo
-     * @param nodeId
+     * @param itemId
      * @return An <code>Iterator</code> of <code>ItemInfo</code>s
containing
-     * at least a single element: the <code>NodeInfo</code> that represents
-     * the Node identified by the given <code>NodeId</code>. If the Iterator
-     * contains multiple elements, the first is expected to represent the Node
-     * identified by the given <code>NodeId</code>.
+     * at least a single element: the <code>ItemInfo</code> that represents
+     * the Item identified by the given <code>ItemId</code>. If the Iterator
+     * contains multiple elements, the first is expected to represent the Item
+     * identified by the given <code>ItemId</code>.
      * @throws javax.jcr.ItemNotFoundException
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.Session#getItem(String)
@@ -297,7 +297,7 @@ public interface RepositoryService {
      * @see javax.jcr.Node#getVersionHistory()
      * @see javax.jcr.version.Version#getContainingHistory()
      */
-    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId) throws ItemNotFoundException, RepositoryException;
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId) throws ItemNotFoundException, RepositoryException;
 
     /**
      * Returns an Iterator of <code>ChildInfo</code>s present on the
@@ -348,6 +348,7 @@ public interface RepositoryService {
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.Session#getItem(String)
      * @see javax.jcr.Node#getProperty(String)
+     * @deprecated Use {@link #getItemInfos(SessionInfo, NodeId)}
      */
     public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId) throws
ItemNotFoundException, RepositoryException;
 

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Thu Aug 18 11:58:38 2011
@@ -121,6 +121,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.conversion.ParsingNameResolver;
 import org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
@@ -988,17 +989,23 @@ public class RepositoryServiceImpl imple
     /**
      * @see RepositoryService#getItemInfos(SessionInfo, NodeId)
      */
-    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId) throws RepositoryException {
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId) throws RepositoryException {
         // TODO: implement batch read properly:
         // currently: missing 'value/values' property PropertyInfo cannot be built
         // currently: missing prop-names with child-NodeInfo
-        List<ItemInfo> l = new ArrayList<ItemInfo>();
-        NodeInfo nInfo = getNodeInfo(sessionInfo, nodeId);
-        l.add(nInfo);
-        // at least add propertyInfos for the meta-props already known from the
-        // nodeInfo.
-        l.addAll(buildPropertyInfos(nInfo));
-        return l.iterator();
+        if (itemId.denotesNode()) {
+            List<ItemInfo> l = new ArrayList<ItemInfo>();
+            NodeInfo nInfo = getNodeInfo(sessionInfo, (NodeId) itemId);
+            l.add(nInfo);
+            // at least add propertyInfos for the meta-props already known from the
+            // nodeInfo.
+            l.addAll(buildPropertyInfos(nInfo));
+            return l.iterator();
+        }
+        else {
+            PropertyInfo pInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
+            return Iterators.singleton(pInfo);
+        }
     }
 
     private NodeInfoImpl buildNodeInfo(MultiStatusResponse nodeResponse,

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java?rev=1159182&r1=1159181&r2=1159182&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
Thu Aug 18 11:58:38 2011
@@ -48,6 +48,7 @@ import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
@@ -55,6 +56,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
 import org.apache.jackrabbit.spi.commons.identifier.IdFactoryImpl;
+import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.PathBuilder;
@@ -300,42 +302,49 @@ public class RepositoryServiceImpl exten
      * @see RepositoryService#getItemInfos(SessionInfo, NodeId)
      */
     @Override
-    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId) throws ItemNotFoundException, RepositoryException {
-        Path path = getPath(nodeId, sessionInfo);
-        String uri = getURI(path, sessionInfo);
-        int depth = batchReadConfig.getDepth(path, this.getNamePathResolver(sessionInfo));
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId) throws ItemNotFoundException, RepositoryException {
+        if (!itemId.denotesNode()) {
+            PropertyInfo propertyInfo = super.getPropertyInfo(sessionInfo, (PropertyId) itemId);
+            return Iterators.singleton(propertyInfo);
+        }
+        else {
+            NodeId nodeId = (NodeId) itemId;
+            Path path = getPath(itemId, sessionInfo);
+            String uri = getURI(path, sessionInfo);
+            int depth = batchReadConfig.getDepth(path, this.getNamePathResolver(sessionInfo));
 
-        GetMethod method = new GetMethod(uri + "." + depth + ".json");
-        try {
-            int statusCode = getClient(sessionInfo).executeMethod(method);
-            if (statusCode == DavServletResponse.SC_OK) {
-                if (method.getResponseContentLength() == 0) {
-                    // no JSON response -> no such node on the server
-                    throw new ItemNotFoundException("No such node " + nodeId);
-                }
-
-                NamePathResolver resolver = getNamePathResolver(sessionInfo);
-                NodeInfoImpl nInfo = new NodeInfoImpl(nodeId, path);
+            GetMethod method = new GetMethod(uri + "." + depth + ".json");
+            try {
+                int statusCode = getClient(sessionInfo).executeMethod(method);
+                if (statusCode == DavServletResponse.SC_OK) {
+                    if (method.getResponseContentLength() == 0) {
+                        // no JSON response -> no such node on the server
+                        throw new ItemNotFoundException("No such item " + nodeId);
+                    }
 
-                ItemInfoJsonHandler handler = new ItemInfoJsonHandler(resolver, nInfo, getRootURI(sessionInfo),
getQValueFactory(sessionInfo), getPathFactory(), getIdFactory());
-                JsonParser ps = new JsonParser(handler);
-                ps.parse(method.getResponseBodyAsStream(), method.getResponseCharSet());
+                    NamePathResolver resolver = getNamePathResolver(sessionInfo);
+                    NodeInfoImpl nInfo = new NodeInfoImpl(nodeId, path);
 
-                Iterator<? extends ItemInfo> it = handler.getItemInfos();
-                if (!it.hasNext()) {
-                    throw new ItemNotFoundException("No such node " + uri);
+                    ItemInfoJsonHandler handler = new ItemInfoJsonHandler(resolver, nInfo,
getRootURI(sessionInfo), getQValueFactory(sessionInfo), getPathFactory(), getIdFactory());
+                    JsonParser ps = new JsonParser(handler);
+                    ps.parse(method.getResponseBodyAsStream(), method.getResponseCharSet());
+
+                    Iterator<? extends ItemInfo> it = handler.getItemInfos();
+                    if (!it.hasNext()) {
+                        throw new ItemNotFoundException("No such node " + uri);
+                    }
+                    return handler.getItemInfos();
+                } else {
+                    throw ExceptionConverter.generate(new DavException(statusCode, "Unable
to retrieve NodeInfo for " + uri), method);
                 }
-                return handler.getItemInfos();
-            } else {
-                throw ExceptionConverter.generate(new DavException(statusCode, "Unable to
retrieve NodeInfo for " + uri), method);
+            } catch (HttpException e) {
+                throw ExceptionConverter.generate(new DavException(method.getStatusCode(),
"Unable to retrieve NodeInfo for " + uri));
+            } catch (IOException e) {
+                log.error("Internal error while retrieving NodeInfo.",e);
+                throw new RepositoryException(e.getMessage());
+            } finally {
+                method.releaseConnection();
             }
-        } catch (HttpException e) {
-            throw ExceptionConverter.generate(new DavException(method.getStatusCode(), "Unable
to retrieve NodeInfo for " + uri));
-        } catch (IOException e) {
-            log.error("Internal error while retrieving NodeInfo.",e);
-            throw new RepositoryException(e.getMessage());
-        } finally {
-            method.releaseConnection();
         }
     }
 

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=1159182&r1=1159181&r2=1159182&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
Thu Aug 18 11:58:38 2011
@@ -49,6 +49,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
@@ -383,55 +384,64 @@ public class RepositoryServiceImpl imple
     /**
      * {@inheritDoc}
      */
-    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId
nodeId)
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId
itemId)
             throws ItemNotFoundException, RepositoryException {
-        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        Node node = getNode(nodeId, sInfo);
-        Name ntName = null;
-        try {
-            ntName = sInfo.getNamePathResolver().getQName(node.getProperty(JcrConstants.JCR_PRIMARYTYPE).getString());
-        } catch (NameException e) {
-            // ignore. should never occur
+
+        if (!itemId.denotesNode()) {
+            PropertyId propertyId = (PropertyId) itemId;
+            PropertyInfo propertyInfo = getPropertyInfo(sessionInfo, propertyId);
+            return Iterators.singleton(propertyInfo);
         }
-        int depth = batchReadConfig.getDepth(ntName);
-        if (depth == BatchReadConfig.DEPTH_DEFAULT) {
-            NodeInfo info;
+        else {
+            NodeId nodeId = (NodeId) itemId;
+            final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+            Node node = getNode(nodeId, sInfo);
+            Name ntName = null;
             try {
-                info = new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver());
+                ntName = sInfo.getNamePathResolver().getQName(node.getProperty(JcrConstants.JCR_PRIMARYTYPE).getString());
             } catch (NameException e) {
-                throw new RepositoryException(e);
+                // ignore. should never occur
             }
-            return Collections.singletonList(info).iterator();
-        } else {
-            final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
-            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
-                @Override
-                protected void entering(Property property, int i) throws RepositoryException
{
-                    try {
-                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(),
getQValueFactory()));
-                    } catch (NameException e) {
-                        throw new RepositoryException(e);
-                    }
+            int depth = batchReadConfig.getDepth(ntName);
+            if (depth == BatchReadConfig.DEPTH_DEFAULT) {
+                NodeInfo info;
+                try {
+                    info = new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver());
+                } catch (NameException e) {
+                    throw new RepositoryException(e);
                 }
-                @Override
-                protected void entering(Node node, int i) throws RepositoryException {
-                    try {
-                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
-                    } catch (NameException e) {
-                        throw new RepositoryException(e);
+                return Collections.singletonList(info).iterator();
+            } else {
+                final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
+                ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
+                    @Override
+                    protected void entering(Property property, int i) throws RepositoryException
{
+                        try {
+                            itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(),
getQValueFactory()));
+                        } catch (NameException e) {
+                            throw new RepositoryException(e);
+                        }
                     }
-                }
-                @Override
-                protected void leaving(Property property, int i) {
-                    // nothing to do
-                }
-                @Override
-                protected void leaving(Node node, int i) {
-                    // nothing to do
-                }
-            };
-            visitor.visit(node);
-            return itemInfos.iterator();
+                    @Override
+                    protected void entering(Node node, int i) throws RepositoryException
{
+                        try {
+                            itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
+                        } catch (NameException e) {
+                            throw new RepositoryException(e);
+                        }
+                    }
+                    @Override
+                    protected void leaving(Property property, int i) {
+                        // nothing to do
+                    }
+                    @Override
+                    protected void leaving(Node node, int i) {
+                        // nothing to do
+                    }
+                };
+                visitor.visit(node);
+                return itemInfos.iterator();
+            }
         }
     }
 



Mime
View raw message