jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1376134 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Date Wed, 22 Aug 2012 16:42:00 GMT
Author: reschke
Date: Wed Aug 22 16:42:00 2012
New Revision: 1376134

URL: http://svn.apache.org/viewvc?rev=1376134&view=rev
Log:
OAK-273: reject attempts to replace single-valued props by multi-valued props and vice versa

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1376134&r1=1376133&r2=1376134&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Aug 22 16:42:00 2012
@@ -53,10 +53,6 @@ org.apache.jackrabbit.test.api.NodeOrder
 org.apache.jackrabbit.test.api.NodeOrderableChildNodesTest#testOrderBeforePlaceAtEndSessionSave<!--OAK-169-->
 org.apache.jackrabbit.test.api.SetValueValueFormatExceptionTest
 org.apache.jackrabbit.test.api.SetValueFormatExceptionTest
-org.apache.jackrabbit.test.api.SetPropertyStringTest#testSetSingleStringArrayValueFormatException<!--OAK-273-->
-org.apache.jackrabbit.test.api.SetPropertyStringTest#testSetSingleStringArrayValueFormatExceptionWithPropertyType<!--OAK-273-->
-org.apache.jackrabbit.test.api.SetPropertyValueTest#testSetSingleValueArrayValueFormatException<!--OAK-273-->
-org.apache.jackrabbit.test.api.SetPropertyValueTest#testSetSingleValueArrayValueFormatExceptionWithPropertyType<!--OAK-273-->
 org.apache.jackrabbit.test.api.SetPropertyAssumeTypeTest
 org.apache.jackrabbit.test.api.NodeAddMixinTest#testAddInheritedMixin
 org.apache.jackrabbit.test.api.ValueFactoryTest#testValueFormatException<!--OAK-204-->

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1376134&r1=1376133&r2=1376134&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Wed Aug 22 16:42:00 2012
@@ -29,6 +29,7 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.ValueFormatException;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
@@ -278,7 +279,11 @@ public class NodeDelegate extends ItemDe
      * @return  the set property
      */
     @Nonnull
-    public PropertyDelegate setProperty(String name, CoreValue value) throws InvalidItemStateException
{
+    public PropertyDelegate setProperty(String name, CoreValue value) throws InvalidItemStateException,
ValueFormatException {
+        PropertyState old = getTree().getProperty(name);
+        if (old != null && old.isArray()) {
+            throw new ValueFormatException("Attempt to set a single value to multi-valued
property.");
+        }
         PropertyState propertyState = getTree().setProperty(name, value);
         return new PropertyDelegate(sessionDelegate, getTree(), propertyState);
     }
@@ -294,7 +299,11 @@ public class NodeDelegate extends ItemDe
      * @return  the set property
      */
     @Nonnull
-    public PropertyDelegate setProperty(String name, List<CoreValue> value) throws
InvalidItemStateException {
+    public PropertyDelegate setProperty(String name, List<CoreValue> value) throws
InvalidItemStateException, ValueFormatException {
+        PropertyState old = getTree().getProperty(name);
+        if (old != null && ! old.isArray()) {
+            throw new ValueFormatException("Attempt to set multiple values to single valued
property.");
+        }
         PropertyState propertyState = getTree().setProperty(name, value);
         return new PropertyDelegate(sessionDelegate, getTree(), propertyState);
     }



Mime
View raw message