jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r397936 - /jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
Date Fri, 28 Apr 2006 15:55:37 GMT
Author: angela
Date: Fri Apr 28 08:55:35 2006
New Revision: 397936

URL: http://svn.apache.org/viewcvs?rev=397936&view=rev
Log:
ValuesProperty:
- bug while deserializing from xml (retrieve txt of prop-value instead of individual value-elements)
- add assertion for non-null values
- add ValueHelper.serialize in order to be consistent with parsing
  from xml.

Modified:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=397936&r1=397935&r2=397936&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
Fri Apr 28 08:55:35 2006
@@ -102,7 +102,7 @@
                     * comment etc.) is ignored. NO bad-request/conflict error is
                     * thrown.
                     */
-                    if (isValueElement(propValue)) {
+                    if (isValueElement(el)) {
                         valueElements.add(el);
                     }
                 }
@@ -111,10 +111,7 @@
             Element[] elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
             jcrValues = new Value[elems.length];
             for (int i = 0; i < elems.length; i++) {
-                String value = DomUtil.getText(elems[i]);
-                String typeStr = DomUtil.getAttribute(elems[i], ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
-                int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
-                jcrValues[i] = ValueHelper.deserialize(value, type, false);
+                jcrValues[i] = getJcrValue(elems[i], defaultType);
             }
         }
     }
@@ -130,6 +127,26 @@
     }
 
     /**
+     *
+     * @param valueElement
+     * @param defaultType
+     * @return
+     * @throws ValueFormatException
+     * @throws RepositoryException
+     */
+    private static Value getJcrValue(Element valueElement, int defaultType) throws ValueFormatException,
RepositoryException {
+        if (valueElement == null) {
+            return null;
+        }
+        // make sure the value is never 'null'
+        String value = DomUtil.getText(valueElement, "");
+        String typeStr = DomUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
+        int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
+        // deserialize value ->> see #toXml where values are serialized
+        return ValueHelper.deserialize(value, type, true);
+    }
+
+    /**
      * Converts the value of this property to a {@link javax.jcr.Value value array}.
      *
      * @return Array of Value objects
@@ -209,7 +226,8 @@
             for (int i = 0; i < jcrValues.length; i++) {
                 Value v = jcrValues[i];
                 String type = PropertyType.nameFromValue(v.getType());
-                Element xmlValue = DomUtil.createElement(document, XML_VALUE, ItemResourceConstants.NAMESPACE,
v.getString());
+                String serializedValue = ValueHelper.serialize(v, true);
+                Element xmlValue = DomUtil.createElement(document, XML_VALUE, ItemResourceConstants.NAMESPACE,
serializedValue);
                 DomUtil.setAttribute(xmlValue, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE,
type);
                 elem.appendChild(xmlValue);
             }



Mime
View raw message