Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 25894 invoked from network); 10 Mar 2006 16:59:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Mar 2006 16:59:32 -0000 Received: (qmail 1582 invoked by uid 500); 10 Mar 2006 16:59:03 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 1571 invoked by uid 500); 10 Mar 2006 16:59:03 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 1568 invoked by uid 99); 10 Mar 2006 16:59:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Mar 2006 08:59:03 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 10 Mar 2006 08:59:02 -0800 Received: (qmail 25292 invoked by uid 65534); 10 Mar 2006 16:58:23 -0000 Message-ID: <20060310165823.25287.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: jackrabbit-cvs@incubator.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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} *

- * 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());