jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r801232 - in /jackrabbit/branches/1.x: ./ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/test/resources/ jackrabbit-jcr2spi/src/te...
Date Wed, 05 Aug 2009 13:58:31 GMT
Author: jukka
Date: Wed Aug  5 13:58:31 2009
New Revision: 801232

URL: http://svn.apache.org/viewvc?rev=801232&view=rev
Log:
1.x: Merged revisions 794012, 794100 and 794102 from the 1.5 branch (JCR-1797)

Added:
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
      - copied, changed from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java
      - copied, changed from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
      - copied, changed from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/
      - copied from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/org/
      - copied from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/org/
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/org/apache/
      - copied from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/org/apache/
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/
      - copied from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/jcr2spi/
      - copied from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/jcr2spi/
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/jcr2spi/default-nodetypes.cnd
      - copied unchanged from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/resources/org/apache/jackrabbit/jcr2spi/default-nodetypes.cnd
Modified:
    jackrabbit/branches/1.x/   (props changed)
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
    jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
    jackrabbit/branches/1.x/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java

Propchange: jackrabbit/branches/1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug  5 13:58:31 2009
@@ -1,2 +1,3 @@
 /incubator/jackrabbit/trunk:78926
+/jackrabbit/branches/1.5:794012,794100,794102
 /jackrabbit/trunk:770143-773197,773483,773525-773555,773584,773588,773828,773835-775756,775833,775836,775840,775868,775981,775986,776036,776256,776310,776313,776321-776322,776332,776356-776357,776362,776373,776650-776693,776737,776757,776776-776777,777024,777029,777034,777478,777509,777541,777548,777936,778445,778613,778616,778621,778645,778720,778802,779032,779040,779068-779071,779074,779076,779081,779084,779086-779088,779090-779092,779094-779096,779101,779223,779225,779227-779228,779230,779233-779234,779460,779475-779476,779504,779550,779552,779555,779561,779563,779583,779590,779618,779621-779622,779624,779642,779654,779657-779659,779661,779936,780006,780010,780025,780085,780985,780989,780993,781017,781051,781054,781294-781300,781305-781311,781318,781328,781338,781344,781347,781369,781372,781377,781416-781417,781423,782621-782622,782644,782646,782652,782669,782675,782677,782683,782694,782921,782925,782930,782936,783002,783004-783005,783042-783043,783239,783278,783304,78331
 9-783321,783324,783326-783327,783330-783333,783337-783338,783340-783341,783343,783345-783346,783356,783359,783383,783386,783412,783435,783444,783447,783523,783688,783703,783708,783710,783719,783757,783759,783761,783786,783809,784011,784013,784039,784058,784060-784061,784090-784091,784106,784108-784109,784111,784117-784120,784124,784163,784261,784680,784691,784696,784760,784824,785112,785116,785157,785169,785209,785492,785517,785519,785529,785533,785535,785539-785540,785545,785580,785589-785590,785594,785597,785602,785627,785629,785631,785635,785668,785711,785725,785777,785863,785981,786003,786019,786028,786062,786075,786089-786090,786093-786094,786144,786146-786147,786149,786167,786280,786295,786319,786329-786330,786336,786409,786419,786423,786480,786485,786492,786513,786562,786565,786680,786685,787183,787219,787241,787942,787952,787964,787996,788002,788012-788013,788350-788351,788443,788446,788450,789245,789257,789269-789270,789279,789307,789312,789324,789338,789347,789485,
 789629,789809,789986,790054,790056,790065-790066,790068,790070-790071,790118,790127,790153,790235-790236,790528,790537,790541,790557-790558,790568,790590,790600,790603,790629,790814,790826,790834,790887,790892,790901,790930,790939,791180,791253,791255,791438-791439,791441,791452,791457,791475,791505,791520,791527,791737,791832,791884,791906,792102,792118,792138,792152,792155-792156,792160,792167-792168,792175,792180-792181,792211,792214,792218,792437,792453,792464,792467,792469,792485,792488,792496,792498,792509,792547-792548,792588-792589,793012-793013,793015-793016,793018,793046-793047,793072,793180,793238,793243,793283,793484-793485,793507,793559,793571,793830,793836,793840,794162,794190,794193,794253,794278,794293-794294,794304,794323,794329,794600,794617,794633,794641,794644,794652,794674,794702,794718,794743,794783,794994,795046,795049,795082,795096,795136,795138,795841-795842,795854,796586,796757,796845,796855,796876,796899,796955,796957,797094,797139,797158,797386,79
 7399,797410,797414,797416-797417,797424,797470,797484,797488-797489,797539,797549,797634,797662,797836,798141,798183,798196,798209,798306,798834,798844,798847-798848,798889-798890,798940,798958,799188,799284,799550,799595,799599,799610,800269,800464,800466,800478,800483,800715,800807,800829,800854,800862-800863,801104

Modified: jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=801232&r1=801231&r2=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Wed Aug  5 13:58:31 2009
@@ -218,13 +218,16 @@
         }
 
         // deal with all additional ItemInfos that may be present.
-        NodeEntry parentEntry = nodeState.getNodeEntry();
+        // Assuming locality of the itemInfos, we keep an estimate of a parent entry.
+        // This reduces the part of the hierarchy to traverse. For large batches this
+        // optimization results in about 25% speed up.
+        NodeEntry approxParentEntry = nodeState.getNodeEntry();
         while (infos.hasNext()) {
             ItemInfo info = (ItemInfo) infos.next();
             if (info.denotesNode()) {
-                createDeepNodeState((NodeInfo) info, parentEntry, infos);
+                approxParentEntry = createDeepNodeState((NodeInfo) info, approxParentEntry,
infos).getNodeEntry();
             } else {
-                createDeepPropertyState((PropertyInfo) info, parentEntry, infos);
+                createDeepPropertyState((PropertyInfo) info, approxParentEntry, infos);
             }
         }
         return nodeState;
@@ -360,9 +363,18 @@
 
             NodeEntry entry = anyParent;
             for (int i = 0; i < missingElems.length; i++) {
-                Name name = missingElems[i].getName();
-                int index = missingElems[i].getNormalizedIndex();
-                entry = createIntermediateNodeEntry(entry, name, index, infos);
+                if (missingElems[i].denotesParent()) {
+                    // Walk up the hierarchy for 'negative' paths
+                    // until the smallest common root is found
+                    entry = entry.getParent();
+                }
+                else if (missingElems[i].denotesName()) {
+                    // Add missing elements starting from the smallest common root
+                    Name name = missingElems[i].getName();
+                    int index = missingElems[i].getNormalizedIndex();
+                    entry = createIntermediateNodeEntry(entry, name, index, infos);
+                }
+                // else denotesCurrent -> ignore
             }
             if (entry == anyParent) {
                 throw new RepositoryException("Internal error while getting deep itemState");
@@ -401,9 +413,18 @@
             int i = 0;
             // NodeEntries except for the very last 'missingElem'
             while (i < missingElems.length - 1) {
-                Name name = missingElems[i].getName();
-                int index = missingElems[i].getNormalizedIndex();
-                entry = createIntermediateNodeEntry(entry, name, index, infos);
+                if (missingElems[i].denotesParent()) {
+                    // Walk up the hierarchy for 'negative' paths
+                    // until the smallest common root is found
+                    entry = entry.getParent();
+                }
+                else if (missingElems[i].denotesName()) {
+                    // Add missing elements starting from the smallest common root
+                    Name name = missingElems[i].getName();
+                    int index = missingElems[i].getNormalizedIndex();
+                    entry = createIntermediateNodeEntry(entry, name, index, infos);
+                }
+                // else denotesCurrent -> ignore
                 i++;
             }
             // create PropertyEntry for the last element if not existing yet
@@ -474,8 +495,8 @@
     }
 
     /**
-     * Returns true if the given <code>missingElems</code> start with a parent
(..),
-     * a current (.) or the root element, in which case the info is not within
+     * Returns true if the given <code>missingElems</code> start with
+     * the root element, in which case the info is not within
      * the tree as it is expected.
      * See also #JCR-1797 for the corresponding enhancement request.
      *
@@ -484,7 +505,7 @@
      */
     private static boolean startsWithIllegalElement(Path.Element[] missingElems) {
         if (missingElems.length > 0) {
-            return !missingElems[0].denotesName();
+            return missingElems[0].denotesRoot();
         }
         return false;
     }

Copied: jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
(from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java?p2=jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java&p1=jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java&r1=794012&r2=801232&rev=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
Wed Aug  5 13:58:31 2009
@@ -241,6 +241,15 @@
         return repositoryService.lock(sessionInfo, nodeId, deep, sessionScoped);
     }
 
+    public LockInfo lock(
+            SessionInfo sessionInfo, NodeId nodeId,
+            boolean deep, boolean sessionScoped,
+            long timeoutHint, String ownerHint)
+            throws RepositoryException {
+        return repositoryService.lock(
+            sessionInfo, nodeId, deep, sessionScoped, timeoutHint, ownerHint);
+    }
+
     public void refreshLock(SessionInfo sessionInfo, NodeId nodeId)
             throws RepositoryException {
 

Copied: jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java
(from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java?p2=jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java&p1=jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java&r1=794012&r2=801232&rev=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractRepositoryService.java
Wed Aug  5 13:58:31 2009
@@ -310,6 +310,14 @@
         throw new UnsupportedRepositoryOperationException("Locking not supported");
     }
 
+    public LockInfo lock(
+            SessionInfo sessionInfo, NodeId nodeId,
+            boolean deep, boolean sessionScoped,
+            long timeoutHint, String ownerHint)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("Locking not supported");
+    }
+
     public void refreshLock(SessionInfo sessionInfo, NodeId nodeId)
             throws RepositoryException {
 

Copied: jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
(from r794012, jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java?p2=jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java&p1=jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java&r1=794012&r2=801232&rev=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetItemsTest.java
Wed Aug  5 13:58:31 2009
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jackrabbit.jcr2spi;
 
 import java.util.ArrayList;
@@ -83,39 +99,23 @@
     private Iterable itemInfosProvider;
 
     /**
-     * Check whether we can traverse the hierarchy when the item infos are returned in their
-     * canonical order.
-     * @throws RepositoryException
-     */
-    public void testGetItemInfos() throws RepositoryException {
-        itemInfosProvider = new Iterable() {
-            public Iterator iterator() {
-                return itemInfos.iterator();
-            }
-        };
-
-        checkHierarchy();
-    }
-
-    /**
      * Check whether we can traverse the hierarchy when the item info for root is
-     * returned first.
+     * retrieved first.
      * @throws RepositoryException
      */
     public void testGetItemInfosRootFirst() throws RepositoryException {
         itemInfosProvider = new Iterable() {
+            Predicate isRoot = new Predicate() {
+                public boolean evaluate(Object object) {
+                    ItemInfo itemInfo = (ItemInfo) object;
+                    return itemInfo.getPath().denotesRoot();
+                }
+            };
 
             public Iterator iterator() {
-                Predicate isRoot = new Predicate() {
-                    public boolean evaluate(Object object) {
-                        ItemInfo itemInfo = (ItemInfo) object;
-                        return itemInfo.getPath().denotesRoot();
-                    }
-                };
-
                 return new IteratorChain(
-                    new FilterIterator(itemInfos.iterator(), isRoot),
-                    new FilterIterator(itemInfos.iterator(), NotPredicate.getInstance(isRoot)));
+                        new FilterIterator(itemInfos.iterator(), isRoot),
+                        new FilterIterator(itemInfos.iterator(), NotPredicate.getInstance(isRoot)));
             }
         };
 
@@ -124,28 +124,29 @@
     }
 
     /**
-     * Check whether we can traverse the hierarchy when the item info for root is
-     * returned last.
+     * Check whether we can traverse the hierarchy when the item info for a deep item
+     * is retrieved first.
      * @throws RepositoryException
      */
-    public void testGetItemInfosRootLast() throws RepositoryException {
+    public void testGetItemInfosDeepFirst() throws RepositoryException {
+        final String targetPath = "/node2/node21/node211/node2111/node21111/node211111/node2111111";
+
         itemInfosProvider = new Iterable() {
+            Predicate isTarget = new Predicate() {
+                public boolean evaluate(Object object) {
+                    ItemInfo itemInfo = (ItemInfo) object;
+                    return targetPath.equals(toJCRPath(itemInfo.getPath()));
+                }
+            };
 
             public Iterator iterator() {
-                Predicate isRoot = new Predicate() {
-                    public boolean evaluate(Object object) {
-                        ItemInfo itemInfo = (ItemInfo) object;
-                        return itemInfo.getPath().denotesRoot();
-                    }
-                };
-
                 return new IteratorChain(
-                    new FilterIterator(itemInfos.iterator(), NotPredicate.getInstance(isRoot)),
-                    new FilterIterator(itemInfos.iterator(), isRoot));
+                        new FilterIterator(itemInfos.iterator(), isTarget),
+                        new FilterIterator(itemInfos.iterator(), NotPredicate.getInstance(isTarget)));
             }
         };
 
-        assertTrue(session.getRootNode().getDepth() == 0);
+        assertEquals(targetPath, session.getItem(targetPath).getPath());
         checkHierarchy();
     }
 

Modified: jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=801232&r1=801231&r2=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Wed Aug  5 13:58:31 2009
@@ -19,6 +19,7 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,6 +35,7 @@
         TestSuite suite = new TestSuite("jcr2spi tests");
 
         suite.addTestSuite(AccessByRelativePathTest.class);
+        suite.addTestSuite(GetItemsTest.class);
 
         // get node(s)
         suite.addTestSuite(SNSIndexTest.class);
@@ -85,7 +87,7 @@
         suite.addTestSuite(ReorderNewAndSavedTest.class);
         suite.addTestSuite(ReorderMixedTest.class);
         suite.addTestSuite(ReorderMoveTest.class);
-        
+
         // update
         suite.addTestSuite(UpdateTest.class);
 
@@ -98,7 +100,7 @@
 
         // repository
         suite.addTestSuite(LoginTest.class);
-        
+
         return suite;
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.x/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=801232&r1=801231&r2=801232&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Wed Aug  5 13:58:31 2009
@@ -264,8 +264,7 @@
      * Method used to 'batch-read' from the persistent storage. It returns the
      * <code>NodeInfo</code> for the given <code>NodeId</code> as
the first
      * element in the <code>Iterator</code>. In addition the iterator may contain
-     * child <code>ItemInfo</code>s down to a certain depth. The configuration
-     * process however is left to the implementation.
+     * arbitrary <code>ItemInfo</code>s.
      *
      * @param sessionInfo
      * @param nodeId
@@ -273,8 +272,7 @@
      * 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> and all subsequent elements
-     * must represent children of that <code>Node</code>.
+     * identified by the given <code>NodeId</code>.
      * @throws javax.jcr.ItemNotFoundException
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.Session#getItem(String)



Mime
View raw message