jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r628282 - in /jackrabbit/branches/1.4/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/NodeImpl.java main/java/org/apache/jackrabbit/core/version/NodeStateEx.java test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
Date Sat, 16 Feb 2008 12:31:49 GMT
Author: jukka
Date: Sat Feb 16 04:31:48 2008
New Revision: 628282

URL: http://svn.apache.org/viewvc?rev=628282&view=rev
Log:
1.4: Merged revision 628281 (JCR-1227)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
    jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=628282&r1=628281&r2=628282&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Sat Feb 16 04:31:48 2008
@@ -3892,7 +3892,8 @@
             PropertyState prop = props[i];
             propNames.add(prop.getName());
             if (prop.isMultiValued()) {
-                internalSetProperty(props[i].getName(), prop.getValues());
+                internalSetProperty(
+                        props[i].getName(), prop.getValues(), prop.getType());
             } else {
                 internalSetProperty(props[i].getName(), prop.getValues()[0]);
             }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=628282&r1=628281&r2=628282&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
Sat Feb 16 04:31:48 2008
@@ -592,17 +592,11 @@
     public void copyFrom(PropertyImpl prop) throws RepositoryException {
         if (prop.getDefinition().isMultiple()) {
             InternalValue[] values = prop.internalGetValues();
-            int type;
-            if (values.length > 0) {
-                type = values[0].getType();
-            } else {
-                type = prop.getDefinition().getRequiredType();
-            }
             InternalValue[] copiedValues = new InternalValue[values.length];
             for (int i = 0; i < values.length; i++) {
                 copiedValues[i] = values[i].createCopy();
             }
-            setPropertyValues(prop.getQName(), type, copiedValues);
+            setPropertyValues(prop.getQName(), prop.getType(), copiedValues);
         } else {
             setPropertyValue(prop.getQName(), prop.internalGetValue().createCopy());
         }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java?rev=628282&r1=628281&r2=628282&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
Sat Feb 16 04:31:48 2008
@@ -21,6 +21,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.version.Version;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
@@ -54,6 +55,38 @@
                 "JCR-1389: setProperty(name, new Value[0], PropertyType.LONG)"
                 + " loses property type",
                 PropertyType.LONG, property.getType());
+    }
+
+    /**
+     * Test case for JCR-1227.
+     * 
+     * @see https://issues.apache.org/jira/browse/JCR-1227
+     */
+    public void testRestoreEmptyMultiValueProperty() throws Exception {
+        node.addMixin("mix:versionable");
+        node.setProperty("test", new Value[0], PropertyType.LONG);
+        node.save();
+        assertEquals(PropertyType.LONG, node.getProperty("test").getType());
+
+        Version version = node.checkin();
+        assertEquals(PropertyType.LONG, node.getProperty("test").getType());
+
+        node.restore(version, false);
+        assertEquals(
+                "JCR-1227: Restore of empty multivalue property always"
+                + " changes property type to String",
+                PropertyType.LONG, node.getProperty("test").getType());
+
+        node.checkout();
+        node.setProperty("test", new Value[0], PropertyType.BOOLEAN);
+        node.save();
+        assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType());
+
+        node.restore(version, false);
+        assertEquals(
+                "JCR-1227: Restore of empty multivalue property always"
+                + " changes property type to String",
+                PropertyType.LONG, node.getProperty("test").getType());
     }
 
 }



Mime
View raw message