jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r628159 - in /jackrabbit/branches/1.4/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/NodeImpl.java main/java/org/apache/jackrabbit/core/PropertyImpl.java test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
Date Fri, 15 Feb 2008 20:16:02 GMT
Author: jukka
Date: Fri Feb 15 12:16:01 2008
New Revision: 628159

URL: http://svn.apache.org/viewvc?rev=628159&view=rev
Log:
1.4: Merged revision 628156 (JCR-1389)

Added:
    jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
      - copied unchanged from r628156, jackrabbit/trunk/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
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.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=628159&r1=628158&r2=628159&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
Fri Feb 15 12:16:01 2008
@@ -2085,12 +2085,7 @@
         BitSet status = new BitSet();
         PropertyImpl prop = getOrCreateProperty(name, type, true, true, status);
         try {
-            if (prop.getDefinition().getRequiredType() == PropertyType.UNDEFINED
-                    && type != PropertyType.UNDEFINED) {
-                prop.setValue(ValueHelper.convert(values, type, session.getValueFactory()));
-            } else {
-                prop.setValue(values);
-            }
+            prop.setValue(values, type);
         } catch (RepositoryException re) {
             if (status.get(CREATED)) {
                 // setting value failed, get rid of newly created property

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=628159&r1=628158&r2=628159&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Fri Feb 15 12:16:01 2008
@@ -615,6 +615,19 @@
             throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException,
             RepositoryException {
+        setValue(values, PropertyType.UNDEFINED);
+    }
+
+    /**
+     * Sets the values of this property.
+     *
+     * @param values property values (possibly <code>null</code>)
+     * @param valueType default value type if not set in the node type,
+     *                  may be {@link PropertyType#UNDEFINED}
+     * @throws RepositoryException if the property values could not be set
+     */
+    public void setValue(Value[] values, int valueType)
+            throws RepositoryException {
         // check state of this instance
         sanityCheck();
 
@@ -623,50 +636,46 @@
 
         if (values != null) {
             // check type of values
-            int valueType = PropertyType.UNDEFINED;
+            int firstValueType = PropertyType.UNDEFINED;
             for (int i = 0; i < values.length; i++) {
-                if (values[i] == null) {
-                    // skip null values as those will be purged later
-                    continue;
-                }
-                if (valueType == PropertyType.UNDEFINED) {
-                    valueType = values[i].getType();
-                } else if (valueType != values[i].getType()) {
-                    // inhomogeneous types
-                    String msg = "inhomogeneous type of values";
-                    log.debug(msg);
-                    throw new ValueFormatException(msg);
+                if (values[i] != null) {
+                    if (firstValueType == PropertyType.UNDEFINED) {
+                        firstValueType = values[i].getType();
+                    } else if (firstValueType != values[i].getType()) {
+                        throw new ValueFormatException(
+                                "inhomogeneous type of values");
+                    }
                 }
             }
         }
 
         int reqType = definition.getRequiredType();
+        if (reqType == PropertyType.UNDEFINED) {
+            reqType = valueType; // use the given type as property type
+        }
 
         InternalValue[] internalValues = null;
         // convert to internal values of correct type
         if (values != null) {
             internalValues = new InternalValue[values.length];
+
+            // check type of values
             for (int i = 0; i < values.length; i++) {
                 Value value = values[i];
-                InternalValue internalValue = null;
                 if (value != null) {
-                    // check type according to definition of this property
                     if (reqType == PropertyType.UNDEFINED) {
-                        // use the value's type as property type
+                        // Use the type of the fist value as the type
                         reqType = value.getType();
                     }
                     if (reqType != value.getType()) {
-                        // type conversion required
-                        Value targetVal = ValueHelper.convert(
-                                value, reqType,
-                                ValueFactoryImpl.getInstance());
-                        internalValue = InternalValue.create(targetVal, session.getNamePathResolver(),
rep.getDataStore());
-                    } else {
-                        // no type conversion required
-                        internalValue = InternalValue.create(value, session.getNamePathResolver(),
rep.getDataStore());
+                        value = ValueHelper.convert(
+                                value, reqType, session.getValueFactory());
                     }
+                    internalValues[i] = InternalValue.create(
+                            value, session, rep.getDataStore());
+                } else {
+                    internalValues[i] = null;
                 }
-                internalValues[i] = internalValue;
             }
         }
 



Mime
View raw message