jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r161904 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: NodeImpl.java util/ValueHelper.java
Date Tue, 19 Apr 2005 15:32:14 GMT
Author: stefan
Date: Tue Apr 19 08:32:13 2005
New Revision: 161904

URL: http://svn.apache.org/viewcvs?view=rev&rev=161904
Log:
fixed bug in Node.setProperty(String, String, int) and setProperty(String, String[], int):
type argument was ignored in certain situations

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ValueHelper.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=161903&r2=161904
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Tue Apr 19
08:32:13 2005
@@ -35,6 +35,7 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.util.ChildrenCollectorFilter;
 import org.apache.jackrabbit.core.util.IteratorHelper;
+import org.apache.jackrabbit.core.util.ValueHelper;
 import org.apache.jackrabbit.core.util.uuid.UUID;
 import org.apache.jackrabbit.core.version.GenericVersionSelector;
 import org.apache.jackrabbit.core.version.InternalFreeze;
@@ -1889,7 +1890,7 @@
         BitSet status = new BitSet();
         PropertyImpl prop = getOrCreateProperty(name, type, true, status);
         try {
-            prop.setValue(values);
+            prop.setValue(ValueHelper.convert(values, type));
         } catch (RepositoryException re) {
             if (status.get(CREATED)) {
                 // setting value failed, get rid of newly created property
@@ -1933,14 +1934,10 @@
         // check lock status
         checkLock();
 
-        /**
-         * if the target property is not of type STRING then a
-         * best-effort conversion is tried
-         */
         BitSet status = new BitSet();
         PropertyImpl prop = getOrCreateProperty(name, type, false, status);
         try {
-            prop.setValue(value);
+            prop.setValue(ValueHelper.convert(value, type));
         } catch (RepositoryException re) {
             if (status.get(CREATED)) {
                 // setting value failed, get rid of newly created property

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ValueHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ValueHelper.java?view=diff&r1=161903&r2=161904
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ValueHelper.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ValueHelper.java Tue
Apr 19 08:32:13 2005
@@ -66,6 +66,25 @@
     }
 
     /**
+     * @param srcValues
+     * @param targetType
+     * @return
+     * @throws ValueFormatException
+     * @throws IllegalArgumentException
+     */
+    public static Value[] convert(String[] srcValues, int targetType)
+            throws ValueFormatException, IllegalArgumentException {
+        if (srcValues == null) {
+            return null;
+        }
+        Value[] newValues = new Value[srcValues.length];
+        for (int i = 0; i < srcValues.length; i++) {
+            newValues[i] = convert(srcValues[i], targetType);
+        }
+        return newValues;
+    }
+
+    /**
      * @param srcValue
      * @param targetType
      * @return
@@ -339,19 +358,19 @@
     }
 
     /**
-     * @param srcVal
+     * @param srcValues
      * @return
      * @throws IllegalStateException
      */
-    public static Value[] copy(Value[] srcVal) throws IllegalStateException {
-        if (srcVal == null) {
+    public static Value[] copy(Value[] srcValues) throws IllegalStateException {
+        if (srcValues == null) {
             return null;
         }
-        Value[] newVal = new Value[srcVal.length];
-        for (int i = 0; i < srcVal.length; i++) {
-            newVal[i] = copy(srcVal[i]);
+        Value[] newValues = new Value[srcValues.length];
+        for (int i = 0; i < srcValues.length; i++) {
+            newValues[i] = copy(srcValues[i]);
         }
-        return newVal;
+        return newValues;
     }
 
     /**



Mime
View raw message