jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r791827 - in /jackrabbit/branches/1.x: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/
Date Tue, 07 Jul 2009 13:24:48 GMT
Author: jukka
Date: Tue Jul  7 13:24:48 2009
New Revision: 791827

URL: http://svn.apache.org/viewvc?rev=791827&view=rev
Log:
1.x: Merged revision 789245 (JCR-2138)

Added:
    jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java
      - copied, changed from r789245, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java
Modified:
    jackrabbit/branches/1.x/   (props changed)
    jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java

Propchange: jackrabbit/branches/1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul  7 13:24:48 2009
@@ -1 +1 @@
-/jackrabbit/trunk:770143-773197,773483,773525-773554,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,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,783319-78332
 1,783324,783326,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,783786,783809,784011,784013,784039,784058,784060-784061,784090-784091,784106,784108-784109,784111,784117-784120,784124,784163,784261,784680,784691,784696,784760,784824,785981
+/jackrabbit/trunk:770143-773197,773483,773525-773554,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,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,783319-78332
 1,783324,783326,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,783786,783809,784011,784013,784039,784058,784060-784061,784090-784091,784106,784108-784109,784111,784117-784120,784124,784163,784261,784680,784691,784696,784760,784824,785981,786003,786319,786680,787183,787219,787241,787942,787952,787964,787996,788002,788012-788013,788350-788351,788443,788446,788450,789245

Modified: jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=791827&r1=791826&r2=791827&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Tue Jul  7 13:24:48 2009
@@ -873,7 +873,15 @@
         private void updateReferences() throws ItemStateException {
             // process added REFERENCE properties
             for (Iterator i = local.addedStates(); i.hasNext();) {
-                addReferences((ItemState) i.next());
+                ItemState state = (ItemState) i.next();
+                if (!state.isNode()) {
+                    // remove refs from the target which have been added externally (JCR-2138)
+                    if (hasItemState(state.getId())) {
+                        removeReferences(getItemState(state.getId()));
+                    }
+                    // add new references to the target
+                    addReferences((PropertyState) state);
+                }
             }
 
             // process modified REFERENCE properties
@@ -883,7 +891,7 @@
                     // remove old references from the target
                     removeReferences(getItemState(state.getId()));
                     // add new references to the target
-                    addReferences(state);
+                    addReferences((PropertyState) state);
                 }
             }
 
@@ -893,16 +901,12 @@
             }
         }
 
-        private void addReferences(ItemState state)
-                throws NoSuchItemStateException, ItemStateException {
-            if (!state.isNode()) {
-                PropertyState property = (PropertyState) state;
-                if (property.getType() == PropertyType.REFERENCE) {
-                    InternalValue[] values = property.getValues();
-                    for (int i = 0; values != null && i < values.length; i++)
{
-                        addReference(
-                                property.getPropertyId(), values[i].getUUID());
-                    }
+        private void addReferences(PropertyState property) throws NoSuchItemStateException,
+                ItemStateException {
+            if (property.getType() == PropertyType.REFERENCE) {
+                InternalValue[] values = property.getValues();
+                for (int i = 0; values != null && i < values.length; i++) {
+                    addReference(property.getPropertyId(), values[i].getUUID());
                 }
             }
         }

Copied: jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java
(from r789245, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java?p2=jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java&r1=789245&r2=791827&rev=791827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ReferencesTest.java
Tue Jul  7 13:24:48 2009
@@ -45,7 +45,7 @@
         a.addMixin("mix:referenceable");
         b.addMixin("mix:referenceable");
         getTestRootNode(session).addNode("C");
-        saveAndlogout(session);
+        saveAndLogout(session);
     }
 
     /**
@@ -62,7 +62,7 @@
         Node bses2 = getTestRootNode(session2).getNode("A").getNode("B");
         getTestRootNode(session2).getNode("C").setProperty("ref to B", bses2);
 
-        saveAndlogout(session1, session2);
+        saveAndLogout(session1, session2);
         assertRemoveTestNodes();
     }
 
@@ -79,7 +79,7 @@
         Session session3 = createSession();
         getTestRootNode(session3).getNode("C").setProperty("ref to B", new Value[]{});
 
-        saveAndlogout(session2, session3);
+        saveAndLogout(session2, session3);
         assertRemoveTestNodes();
     }
 
@@ -98,7 +98,7 @@
         Node ases3 = getTestRootNode(session3).getNode("A");
         getTestRootNode(session3).getNode("C").setProperty("ref", ases3);
 
-        saveAndlogout(session2, session3);
+        saveAndLogout(session2, session3);
         assertRemoveTestNodes();
     }
 
@@ -120,7 +120,7 @@
         getTestRootNode(session3).getNode("C").setProperty("ref to B",
             new Value[]{valFac3.createValue(bses3), valFac3.createValue(bses3)});
 
-        saveAndlogout(session2, session3);
+        saveAndLogout(session2, session3);
         assertRemoveTestNodes();
     }
 
@@ -141,7 +141,7 @@
         Node bses3 = getTestRootNode(session3).getNode("A").getNode("B");
         getTestRootNode(session3).getNode("C").setProperty("ref", new Value[]{valFac3.createValue(bses3)});
 
-        saveAndlogout(session2, session3);
+        saveAndLogout(session2, session3);
         assertRemoveTestNodes();
     }
 
@@ -162,7 +162,7 @@
             new Value[]{valFac2.createValue(bses2), valFac2.createValue(bses2)});
         getTestRootNode(session2).getNode("C").setProperty("another ref to B", bses2);
 
-        saveAndlogout(session1, session2);
+        saveAndLogout(session1, session2);
         assertRemoveTestNodes();
     }
 
@@ -192,15 +192,18 @@
         return helper.getSuperuserSession();
     }
 
-    private void saveAndlogout(Session... sessions) throws RepositoryException {
-        if (sessions != null) {
-            for (Session session : sessions) {
-                session.save();
-                session.logout();
-            }
+    private void saveAndLogout(Session session) throws RepositoryException {
+        if (session != null) {
+            session.save();
+            session.logout();
         }
     }
 
+    private void saveAndLogout(Session a, Session b) throws RepositoryException {
+        saveAndLogout(a);
+        saveAndLogout(b);
+    }
+
     /**
      * @param session the session to use
      * @return a node which is more or less unique per testcase

Modified: jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=791827&r1=791826&r2=791827&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
Tue Jul  7 13:24:48 2009
@@ -41,6 +41,7 @@
         suite.addTestSuite(RetentionRegistryImplTest.class);
         suite.addTestSuite(InvalidDateTest.class);
         suite.addTestSuite(SessionGarbageCollectedTest.class);
+        suite.addTestSuite(ReferencesTest.class);
 
         return suite;
     }



Mime
View raw message