jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r384850 - in /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml: DocViewImportHandler.java DocViewSAXEventGenerator.java
Date Fri, 10 Mar 2006 16:58:21 GMT
Author: stefan
Date: Fri Mar 10 08:58:17 2006
New Revision: 384850

URL: http://svn.apache.org/viewcvs?rev=384850&view=rev
Log:
JCR-325: multi-value serialization in document view export is not spec-compliant; for the
time being just skip multi-valued properties on document view export which is legal according
to "6.4.2.5 Multi-value Properties"

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java?rev=384850&r1=384849&r2=384850&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
Fri Mar 10 08:58:17 2006
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.util.ISO9075;
-import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
@@ -154,7 +153,7 @@
     /**
      * {@inheritDoc}
      * <p/>
-     * See also {@link DocViewSAXEventGenerator#leaving(javax.jcr.Node, int)}
+     * See also {@link DocViewSAXEventGenerator#leavingProperties(javax.jcr.Node, int)}
      * regarding special handling of multi-valued properties on export.
      */
     public void startElement(String namespaceURI, String localName,
@@ -183,25 +182,13 @@
                 String attrValue = atts.getValue(i);
                 Importer.TextValue[] propValues;
 
-                if (attrValue.startsWith("\n")) {
-                    // assume multi-valued property:
-                    // a leading line-feed (a valid whitespace NMTOKENS delimiter)
-                    // is interpreted as a hint that this attribute value is of
-                    // type NMTOKENS.
-                    // see DocViewSAXEventGenerator#leaving(Node, int)
-                    attrValue = attrValue.substring(1);
-                    String[] strings = Text.explode(attrValue, ' ', true);
-                    propValues = new Importer.TextValue[strings.length];
-                    for (int j = 0; j < strings.length; j++) {
-                        // decode encoded blanks in value
-                        strings[j] = Text.replace(strings[j], "_x0020_", " ");
-                        propValues[j] = new StringValue(strings[j]);
-                    }
-                } else {
-                    // assume single-valued property
-                    propValues = new Importer.TextValue[1];
-                    propValues[0] = new StringValue(attrValue);
-                }
+                // always assume single-valued property for the time being
+                // until a way of properly serializing/detecting multi-valued
+                // properties on re-import is found (see JCR-325);
+                // see also DocViewSAXEventGenerator#leavingProperties(Node, int)
+                // todo proper multi-value serialization support
+                propValues = new Importer.TextValue[1];
+                propValues[0] = new StringValue(attrValue);
 
                 if (propName.equals(QName.JCR_PRIMARYTYPE)) {
                     // jcr:primaryType

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java?rev=384850&r1=384849&r2=384850&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java
Fri Mar 10 08:58:17 2006
@@ -29,7 +29,6 @@
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
-import javax.jcr.Value;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -136,6 +135,20 @@
             while (iter.hasNext()) {
                 Property prop = (Property) iter.next();
                 String propName = prop.getName();
+
+                if (prop.getDefinition().isMultiple()) {
+                    // todo proper multi-value serialization support
+                    // skip multi-valued properties for the time being
+                    // until a way of properly handling/detecting multi-valued
+                    // properties on re-import is found (see JCR-325);
+                    // see also DocViewImportHandler#startElement()
+
+                    // skipping multi-valued properties entirely is legal
+                    // according to "6.4.2.5 Multi-value Properties" of the
+                    // jsr-170 specification
+                    continue;
+                }
+
                 // attribute name (encode property name to make sure it's a valid xml name)
                 String attrName = ISO9075.encode(propName);
                 QName qName = getQName(attrName);
@@ -147,47 +160,8 @@
                             qName.getLocalName(), attrName, CDATA_TYPE, "");
                 } else {
                     StringBuffer attrValue = new StringBuffer();
-                    // process property value(s)
-                    boolean multiValued = prop.getDefinition().isMultiple();
-
-                    if (multiValued) {
-                        // multi-valued property:
-                        // according to "6.4.2.5 Multi-value Properties" of the
-                        // jsr-170 specification a multi-valued property can be
-                        // either skipped or it must be exported as NMTOKENS
-                        // type where "a mechanism must be adopted whereby upon
-                        // re-import the distinction between multi- and single-
-                        // value properties is not lost"...
-
-                        // the following implementation is a pragmatic approach
-                        // in the interest of improved useability:
-                        // the attribute value is constructed by concatenating
-                        // the serialized and escaped values, separated by a
-                        // space character each, into a single string and
-                        // prepending a new-line to help distinguish multi-
-                        // from single-valued properties on re-import.
-
-                        // use a leading line-feed (a valid whitespace
-                        // delimiter) as a hint on re-import that this attribute
-                        // value is of type NMTOKENS; note that line-feed rather
-                        // than space has been chosen as leading line-feeds are 
-                        // not affected by attribute-value normalization
-                        // (http://www.w3.org/TR/REC-xml/#AVNormalize)
-                        attrValue.append("\n");
-                        Value[] vals = prop.getValues();
-                        for (int i = 0; i < vals.length; i++) {
-                            if (i > 0) {
-                                // use space as delimiter for separate values
-                                attrValue.append(" ");
-                            }
-                            // serialize value (with encoded embedded spaces)
-                            attrValue.append(ValueHelper.serialize(vals[i], true));
-                        }
-                    } else {
-                        // single-valued property:
-                        // serialize value without encoding embedded spaces
-                        attrValue.append(ValueHelper.serialize(prop.getValue(), false));
-                    }
+                    // serialize single-valued property
+                    attrValue.append(ValueHelper.serialize(prop.getValue(), false));
                     attrs.addAttribute(qName.getNamespaceURI(),
                             qName.getLocalName(), attrName, CDATA_TYPE,
                             attrValue.toString());



Mime
View raw message