jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r898267 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src: main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
Date Tue, 12 Jan 2010 09:45:13 GMT
Author: mduerig
Date: Tue Jan 12 09:45:11 2010
New Revision: 898267

URL: http://svn.apache.org/viewvc?rev=898267&view=rev
Log:
JCR-2462: IllegalStateException on session#save()

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java?rev=898267&r1=898266&r2=898267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
Tue Jan 12 09:45:11 2010
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi.hierarchy;
 
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.RepositoryException;
-
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.SetPropertyValue;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
@@ -29,6 +25,10 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PropertyId;
 
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.RepositoryException;
+
 /**
  * <code>PropertyEntryImpl</code> implements a reference to a property state.
  */
@@ -122,12 +122,15 @@
         }
         switch (operation.getStatus()) {
             case Operation.STATUS_PERSISTED:
-                /*
-                NOTE: Property can only be the changelog target, if it was
-                      existing and has been modified. removal, add and implicit modification
-                      of protected properties must be persisted by save on parent.
-                */
-                op.getPropertyState().setStatus(Status.EXISTING);
+                // Property can only be the change log target if it was existing and has
+                // been modified. This includes the case where a property was changed and
+                // then removed by removing its parent. See JCR-2462. 
+                // Removal, add and implicit modification of protected
+                // properties must be persisted by save on parent.
+                PropertyState state = op.getPropertyState();
+                if (state.getStatus() != Status.REMOVED) {
+                    state.setStatus(Status.EXISTING);
+                }
                 break;
             case Operation.STATUS_UNDO:
                 revert();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java?rev=898267&r1=898266&r2=898267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
Tue Jan 12 09:45:11 2010
@@ -16,10 +16,8 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.test.NotExecutableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+import java.util.List;
 
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.ItemNotFoundException;
@@ -29,8 +27,11 @@
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import java.util.Arrays;
-import java.util.List;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>UpdateTest</code>...
@@ -208,6 +209,18 @@
         }
     }
 
+    /**
+     * See JCR-2462
+     */
+    public void testSetSamePropertyTwice() throws RepositoryException {
+        Node node = this.testRootNode.addNode( "test" );
+        Session session = node.getSession();
+        node.setProperty( "prop", "value1");
+        node.setProperty( "prop", "value2");
+        node.remove();
+        session.save();
+    }
+
     private String getAnotherWorkspace() throws NotExecutableException, RepositoryException
{
         String srcWorkspace = getHelper().getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");;
         if (srcWorkspace == null || srcWorkspace.equals(currentWorkspace)) {



Mime
View raw message