chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1456526 - in /chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src: main/java/org/apache/chemistry/opencmis/commons/impl/ main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ test/java/org/ap...
Date Thu, 14 Mar 2013 16:48:16 GMT
Author: fmui
Date: Thu Mar 14 16:48:15 2013
New Revision: 1456526

URL: http://svn.apache.org/r1456526
Log:
CMIS 1.1 AtomPub: bulk update properties preparations

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java?rev=1456526&r1=1456525&r2=1456526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
Thu Mar 14 16:48:15 2013
@@ -241,4 +241,14 @@ public class XMLConstants {
     public static final String TAG_QUERY_RENDITIONFILTER = "renditionFilter";
     public static final String TAG_QUERY_MAXITEMS = "maxItems";
     public static final String TAG_QUERY_SKIPCOUNT = "skipCount";
+
+    public static final String TAG_BULK_UPDATE = "bulkUpdate";
+    public static final String TAG_BULK_UPDATE_ID_AND_TOKEN = "objectIdAndChangeToken";
+    public static final String TAG_BULK_UPDATE_PROPERTIES = "properties";
+    public static final String TAG_BULK_UPDATE_ADD_SECONDARY_TYPES = "addSecondaryTypeIds";
+    public static final String TAG_BULK_UPDATE_REMOVE_SECONDARY_TYPES = "removeSecondaryTypeIds";
+
+    public static final String TAG_IDANDTOKEN_ID = "id";
+    public static final String TAG_IDANDTOKEN_NEWID = "newId";
+    public static final String TAG_IDANDTOKEN_CHANGETOKEN = "changeToken";
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1456526&r1=1456525&r2=1456526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
Thu Mar 14 16:48:15 2013
@@ -39,6 +39,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
 import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes;
@@ -107,6 +108,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl;
@@ -931,6 +934,61 @@ public class XMLConverter {
         writer.writeEndElement();
     }
 
+    // -------------------
+    // --- bulk update ---
+    // -------------------
+
+    public static void writeBulkUpdate(XMLStreamWriter writer, CmisVersion cmisVersion, String
namespace,
+            List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken, Properties
properties,
+            List<String> addSecondaryTypeIds, List<String> removeSecondaryTypeIds)
throws XMLStreamException {
+        if (objectIdAndChangeToken == null) {
+            return;
+        }
+
+        writer.writeStartElement(namespace, TAG_BULK_UPDATE);
+
+        for (BulkUpdateObjectIdAndChangeToken idAndToken : objectIdAndChangeToken) {
+            if (idAndToken == null) {
+                continue;
+            }
+
+            writer.writeStartElement(PREFIX_CMIS, TAG_BULK_UPDATE_ID_AND_TOKEN, NAMESPACE_CMIS);
+
+            XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_IDANDTOKEN_ID, idAndToken.getId());
+            XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_IDANDTOKEN_CHANGETOKEN,
idAndToken.getChangeToken());
+
+            writeExtensions(writer, idAndToken);
+            writer.writeEndElement();
+        }
+
+        if (properties != null) {
+            writer.writeStartElement(PREFIX_CMIS, TAG_BULK_UPDATE_PROPERTIES, NAMESPACE_CMIS);
+
+            if (properties.getPropertyList() != null) {
+                for (PropertyData<?> property : properties.getPropertyList()) {
+                    writeProperty(writer, property, false);
+                }
+            }
+
+            writeExtensions(writer, properties);
+            writer.writeEndElement();
+        }
+
+        if (addSecondaryTypeIds != null) {
+            for (String id : addSecondaryTypeIds) {
+                XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_BULK_UPDATE_ADD_SECONDARY_TYPES,
id);
+            }
+        }
+
+        if (removeSecondaryTypeIds != null) {
+            for (String id : removeSecondaryTypeIds) {
+                XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_BULK_UPDATE_REMOVE_SECONDARY_TYPES,
id);
+            }
+        }
+
+        writer.writeEndElement();
+    }
+
     // -------------------------
     // --- extension writers ---
     // -------------------------
@@ -1035,6 +1093,10 @@ public class XMLConverter {
         return ACL_PARSER.walk(parser);
     }
 
+    public static BulkUpdateImpl convertBulkUpdate(XMLStreamReader parser) throws XMLStreamException
{
+        return BULK_UPDATE_PARSER.walk(parser);
+    }
+
     // ------------------------------
     // --- repository info parser ---
     // ------------------------------
@@ -2594,4 +2656,74 @@ public class XMLConverter {
             return false;
         }
     };
+
+    // --------------------------
+    // --- bulk update parser ---
+    // --------------------------
+
+    private static final XMLWalker<BulkUpdateImpl> BULK_UPDATE_PARSER = new XMLWalker<BulkUpdateImpl>()
{
+        @Override
+        protected BulkUpdateImpl prepareTarget(XMLStreamReader parser, QName name) throws
XMLStreamException {
+            return new BulkUpdateImpl();
+        }
+
+        @Override
+        protected boolean read(XMLStreamReader parser, QName name, BulkUpdateImpl target)
throws XMLStreamException {
+            if (isCmisNamespace(name)) {
+                if (isTag(name, TAG_BULK_UPDATE_ID_AND_TOKEN)) {
+                    target.setObjectIdAndChangeToken(addToList(target.getObjectIdAndChangeToken(),
+                            ID_AND_TOKEN_PARSER.walk(parser)));
+                    return true;
+                }
+
+                if (isTag(name, TAG_BULK_UPDATE_PROPERTIES)) {
+                    target.setProperties(PROPERTIES_PARSER.walk(parser));
+                    return true;
+                }
+
+                if (isTag(name, TAG_BULK_UPDATE_ADD_SECONDARY_TYPES)) {
+                    target.setAddSecondaryTypeIds(addToList(target.getAddSecondaryTypeIds(),
readText(parser)));
+                    return true;
+                }
+
+                if (isTag(name, TAG_BULK_UPDATE_REMOVE_SECONDARY_TYPES)) {
+                    target.setRemoveSecondaryTypeIds(addToList(target.getRemoveSecondaryTypeIds(),
readText(parser)));
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    };
+
+    private static final XMLWalker<BulkUpdateObjectIdAndChangeTokenImpl> ID_AND_TOKEN_PARSER
= new XMLWalker<BulkUpdateObjectIdAndChangeTokenImpl>() {
+        @Override
+        protected BulkUpdateObjectIdAndChangeTokenImpl prepareTarget(XMLStreamReader parser,
QName name)
+                throws XMLStreamException {
+            return new BulkUpdateObjectIdAndChangeTokenImpl();
+        }
+
+        @Override
+        protected boolean read(XMLStreamReader parser, QName name, BulkUpdateObjectIdAndChangeTokenImpl
target)
+                throws XMLStreamException {
+            if (isCmisNamespace(name)) {
+                if (isTag(name, TAG_IDANDTOKEN_ID)) {
+                    target.setId(readText(parser));
+                    return true;
+                }
+
+                if (isTag(name, TAG_IDANDTOKEN_NEWID)) {
+                    target.setNewId(readText(parser));
+                    return true;
+                }
+
+                if (isTag(name, TAG_IDANDTOKEN_CHANGETOKEN)) {
+                    target.setChangeToken(readText(parser));
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    };
 }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java?rev=1456526&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java
Thu Mar 14 16:48:15 2013
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.commons.impl.dataobjects;
+
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+
+public class BulkUpdateImpl extends AbstractExtensionData {
+
+    private static final long serialVersionUID = 1L;
+
+    private List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken;
+    private Properties properties;
+    private List<String> addSecondaryTypeIds;
+    private List<String> removeSecondaryTypeIds;
+
+    public List<BulkUpdateObjectIdAndChangeToken> getObjectIdAndChangeToken() {
+        return objectIdAndChangeToken;
+    }
+
+    public void setObjectIdAndChangeToken(List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken)
{
+        this.objectIdAndChangeToken = objectIdAndChangeToken;
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    public List<String> getAddSecondaryTypeIds() {
+        return addSecondaryTypeIds;
+    }
+
+    public void setAddSecondaryTypeIds(List<String> addSecondaryTypeIds) {
+        this.addSecondaryTypeIds = addSecondaryTypeIds;
+    }
+
+    public List<String> getRemoveSecondaryTypeIds() {
+        return removeSecondaryTypeIds;
+    }
+
+    public void setRemoveSecondaryTypeIds(List<String> removeSecondaryTypeIds) {
+        this.removeSecondaryTypeIds = removeSecondaryTypeIds;
+    }
+
+    @Override
+    public String toString() {
+        return "BulkUpdate [objectIdAndChangeToken=" + objectIdAndChangeToken + ", properties="
+ properties
+                + ", addSecondaryTypeIds=" + addSecondaryTypeIds + ", removeSecondaryTypeIds="
+ removeSecondaryTypeIds
+                + "]" + super.toString();
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java?rev=1456526&r1=1456525&r2=1456526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
Thu Mar 14 16:48:15 2013
@@ -27,10 +27,14 @@ public class BulkUpdateObjectIdAndChange
         BulkUpdateObjectIdAndChangeToken {
 
     private static final long serialVersionUID = 1L;
+
     private String id;
     private String newId;
     private String changeToken = null;
 
+    public BulkUpdateObjectIdAndChangeTokenImpl() {
+    }
+
     public BulkUpdateObjectIdAndChangeTokenImpl(String id, String changeToken) {
         this.id = id;
         this.newId = null;
@@ -63,6 +67,18 @@ public class BulkUpdateObjectIdAndChange
         return changeToken;
     }
 
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setNewId(String newId) {
+        this.newId = newId;
+    }
+
+    public void setChangeToken(String changeToken) {
+        this.changeToken = changeToken;
+    }
+
     @Override
     public String toString() {
         return "BulkUpdateObjectIdAndChangeToken [id=" + id + ", newId=" + newId + ", changeToken="
+ changeToken + "]"

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java?rev=1456526&r1=1456525&r2=1456526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
Thu Mar 14 16:48:15 2013
@@ -30,8 +30,10 @@ import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
@@ -52,9 +54,23 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.PropertyId;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
 import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyData;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
 import org.junit.Before;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -69,7 +85,7 @@ public abstract class AbstractXMLConvert
 
     private final static long SEED = 1234567890;
 
-    protected final static String TEST_SCHEMA = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+    protected final static String TEST_SCHEMA10 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
             + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\"
targetNamespace=\""
             + TEST_NAMESPACE
             + "\" xmlns:test=\""
@@ -91,6 +107,29 @@ public abstract class AbstractXMLConvert
             + "<xs:element name=\"test\" type=\"test:testType\"/>" //
             + "</xs:schema>";
 
+    protected final static String TEST_SCHEMA11 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\"
targetNamespace=\""
+            + TEST_NAMESPACE
+            + "\" xmlns:test=\""
+            + TEST_NAMESPACE
+            + "\" xmlns:cmis=\""
+            + XMLConstants.NAMESPACE_CMIS
+            + "\" version=\"1.0\">"
+            + "<xs:import namespace=\""
+            + XMLConstants.NAMESPACE_CMIS
+            + "\"/>"
+            + "<xs:complexType name=\"testType\">"
+            + "<xs:sequence>"
+            + "<xs:element name=\"repositoryInfo\" type=\"cmis:cmisRepositoryInfoType\"
minOccurs=\"0\" maxOccurs=\"1\" />"
+            + "<xs:element name=\"type\" type=\"cmis:cmisTypeDefinitionType\" minOccurs=\"0\"
maxOccurs=\"1\" />"
+            + "<xs:element name=\"object\" type=\"cmis:cmisObjectType\" minOccurs=\"0\"
maxOccurs=\"1\" />"
+            + "<xs:element name=\"query\" type=\"cmis:cmisQueryType\" minOccurs=\"0\"
maxOccurs=\"1\" />"
+            + "<xs:element name=\"bulkUpdate\" type=\"cmis:cmisBulkUpdateType\" minOccurs=\"0\"
maxOccurs=\"1\" />"
+            + "</xs:sequence>" //
+            + "</xs:complexType>" //
+            + "<xs:element name=\"test\" type=\"test:testType\"/>" //
+            + "</xs:schema>";
+
     protected Schema schema10;
     protected Schema schema11;
     protected Random rnd;
@@ -105,14 +144,14 @@ public abstract class AbstractXMLConvert
         InputStream schema10stream = AbstractXMLConverterTest.class.getResourceAsStream("/schema/cmis10/CMIS-core.xsd");
         if (schema10stream != null) {
             StreamSource core10 = new StreamSource(schema10stream);
-            StreamSource test10 = new StreamSource(new ByteArrayInputStream(TEST_SCHEMA.getBytes("UTF-8")));
+            StreamSource test10 = new StreamSource(new ByteArrayInputStream(TEST_SCHEMA10.getBytes("UTF-8")));
             schema10 = sf.newSchema(new Source[] { core10, test10 });
         }
 
         InputStream schema11stream = AbstractXMLConverterTest.class.getResourceAsStream("/schema/cmis11/CMIS-core.xsd");
         if (schema11stream != null) {
             StreamSource core11 = new StreamSource(schema11stream);
-            StreamSource test11 = new StreamSource(new ByteArrayInputStream(TEST_SCHEMA.getBytes("UTF-8")));
+            StreamSource test11 = new StreamSource(new ByteArrayInputStream(TEST_SCHEMA11.getBytes("UTF-8")));
             schema11 = sf.newSchema(new Source[] { core11, test11 });
         }
 
@@ -232,6 +271,140 @@ public abstract class AbstractXMLConvert
         return result.getWriter().toString();
     }
 
+    protected PropertyData<?> createPropertyData(PropertyType propertyType, int numValues)
{
+        AbstractPropertyData<?> result;
+
+        switch (propertyType) {
+        case BOOLEAN:
+            result = new PropertyBooleanImpl();
+            if (numValues > 0) {
+                List<Boolean> values = new ArrayList<Boolean>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomBoolean());
+                }
+                ((PropertyBooleanImpl) result).setValues(values);
+            }
+            break;
+        case DATETIME:
+            result = new PropertyDateTimeImpl();
+            if (numValues > 0) {
+                List<GregorianCalendar> values = new ArrayList<GregorianCalendar>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomDateTime());
+                }
+                ((PropertyDateTimeImpl) result).setValues(values);
+            }
+            break;
+        case DECIMAL:
+            result = new PropertyDecimalImpl();
+            if (numValues > 0) {
+                List<BigDecimal> values = new ArrayList<BigDecimal>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomDecimal());
+                }
+                ((PropertyDecimalImpl) result).setValues(values);
+            }
+            break;
+        case HTML:
+            result = new PropertyHtmlImpl();
+            if (numValues > 0) {
+                List<String> values = new ArrayList<String>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomString());
+                }
+                ((PropertyHtmlImpl) result).setValues(values);
+            }
+            break;
+        case ID:
+            result = new PropertyIdImpl();
+            if (numValues > 0) {
+                List<String> values = new ArrayList<String>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomString());
+                }
+                ((PropertyIdImpl) result).setValues(values);
+            }
+            break;
+        case INTEGER:
+            result = new PropertyIntegerImpl();
+            if (numValues > 0) {
+                List<BigInteger> values = new ArrayList<BigInteger>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomInteger());
+                }
+                ((PropertyIntegerImpl) result).setValues(values);
+            }
+            break;
+        case STRING:
+            result = new PropertyStringImpl();
+            if (numValues > 0) {
+                List<String> values = new ArrayList<String>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomString());
+                }
+                ((PropertyStringImpl) result).setValues(values);
+            }
+            break;
+        case URI:
+            result = new PropertyUriImpl();
+            if (numValues > 0) {
+                List<String> values = new ArrayList<String>();
+                for (int i = 0; i < numValues; i++) {
+                    values.add(randomUri());
+                }
+                ((PropertyUriImpl) result).setValues(values);
+            }
+            break;
+        default:
+            return null;
+        }
+
+        result.setId(randomString());
+        result.setDisplayName(randomString());
+        result.setLocalName(randomString());
+        result.setQueryName(randomString());
+
+        return result;
+    }
+
+    protected PropertyId createIdPropertyData(String id, String value) {
+        PropertyIdImpl result = new PropertyIdImpl();
+
+        result.setId(id);
+        result.setDisplayName(id);
+        result.setLocalName(id);
+        result.setQueryName(id);
+        result.setValue(value);
+
+        return result;
+    }
+
+    protected List<CmisExtensionElement> createExtensions(int depth) {
+        List<CmisExtensionElement> result = new ArrayList<CmisExtensionElement>();
+
+        String[] namespaces = new String[] { "http://ext1.com", "http://ext2.org", "http://ext3.net"
};
+
+        for (int i = 0; i < randomInt(4) + 1; i++) {
+            String ns = namespaces[randomInt(namespaces.length)];
+
+            Map<String, String> attr = new HashMap<String, String>();
+            for (int j = 0; j < randomInt(3); j++) {
+                attr.put(randomTag(), randomString());
+            }
+
+            CmisExtensionElementImpl element;
+            if (randomBoolean() || depth < 1) {
+                element = new CmisExtensionElementImpl(ns, randomTag(), attr, randomString());
+            } else {
+                element = new CmisExtensionElementImpl(ns, randomTag(), attr, createExtensions(depth
- 1));
+            }
+
+            result.add(element);
+        }
+
+        return result;
+    }
+
     protected String randomString() {
         StringBuilder sb = new StringBuilder();
 

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java?rev=1456526&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
Thu Mar 14 16:48:15 2013
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.commons.impl.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.junit.Test;
+
+public class BukUpdateConverterTest extends AbstractXMLConverterTest {
+
+    @Test
+    public void testBulkUpdate() throws Exception {
+        // run the test a few times with different values
+        for (int i = 0; i < 5; i++) {
+            BulkUpdateImpl bulkUpdate = new BulkUpdateImpl();
+
+            List<BulkUpdateObjectIdAndChangeToken> list = new ArrayList<BulkUpdateObjectIdAndChangeToken>();
+            for (int j = 0; j < randomInt(19) + 1; j++) {
+                BulkUpdateObjectIdAndChangeTokenImpl idAndToken = new BulkUpdateObjectIdAndChangeTokenImpl(
+                        randomString(), randomString());
+                list.add(idAndToken);
+            }
+            bulkUpdate.setObjectIdAndChangeToken(list);
+
+            PropertiesImpl properties = new PropertiesImpl();
+            for (int j = 0; j < randomInt(9) + 1; j++) {
+                properties.addProperty(createPropertyData(
+                        PropertyType.values()[randomInt(PropertyType.values().length)], randomInt(2)));
+            }
+            bulkUpdate.setProperties(properties);
+
+            List<String> addSecTypes = new ArrayList<String>();
+            for (int j = 0; j < randomInt(4) + 1; j++) {
+                addSecTypes.add(randomString());
+            }
+            bulkUpdate.setAddSecondaryTypeIds(addSecTypes);
+
+            List<String> removeSecTypes = new ArrayList<String>();
+            for (int j = 0; j < randomInt(4) + 1; j++) {
+                removeSecTypes.add(randomString());
+            }
+            bulkUpdate.setRemoveSecondaryTypeIds(removeSecTypes);
+
+            assertBulkUpdate11(bulkUpdate, true);
+        }
+    }
+
+    protected void assertBulkUpdate11(BulkUpdateImpl bulkUpdate, boolean validate) throws
Exception {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        XMLStreamWriter writer = createWriter(out);
+        XMLConverter.writeBulkUpdate(writer, CmisVersion.CMIS_1_1, TEST_NAMESPACE,
+                bulkUpdate.getObjectIdAndChangeToken(), bulkUpdate.getProperties(),
+                bulkUpdate.getAddSecondaryTypeIds(), bulkUpdate.getRemoveSecondaryTypeIds());
+        closeWriter(writer);
+
+        byte[] xml = out.toByteArray();
+
+        if (validate) {
+            validate(xml, CmisVersion.CMIS_1_1);
+        }
+
+        XMLStreamReader parser = createParser(xml);
+        BulkUpdateImpl result = XMLConverter.convertBulkUpdate(parser);
+        closeParser(parser);
+
+        assertNotNull(result);
+        assertDataObjectsEquals("BulkUpdate", bulkUpdate, result, null);
+        assertNull(result.getExtensions());
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java?rev=1456526&r1=1456525&r2=1456526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java
Thu Mar 14 16:48:15 2013
@@ -21,24 +21,16 @@ package org.apache.chemistry.opencmis.co
 import static org.junit.Assert.assertNotNull;
 
 import java.io.ByteArrayOutputStream;
-import java.math.BigDecimal;
-import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Ace;
-import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.PropertyId;
 import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
@@ -46,24 +38,14 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyData;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
 import org.junit.Test;
 
@@ -190,140 +172,6 @@ public class ObjectConvertTest extends A
         return result;
     }
 
-    protected PropertyData<?> createPropertyData(PropertyType propertyType, int numValues)
{
-        AbstractPropertyData<?> result;
-
-        switch (propertyType) {
-        case BOOLEAN:
-            result = new PropertyBooleanImpl();
-            if (numValues > 0) {
-                List<Boolean> values = new ArrayList<Boolean>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomBoolean());
-                }
-                ((PropertyBooleanImpl) result).setValues(values);
-            }
-            break;
-        case DATETIME:
-            result = new PropertyDateTimeImpl();
-            if (numValues > 0) {
-                List<GregorianCalendar> values = new ArrayList<GregorianCalendar>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomDateTime());
-                }
-                ((PropertyDateTimeImpl) result).setValues(values);
-            }
-            break;
-        case DECIMAL:
-            result = new PropertyDecimalImpl();
-            if (numValues > 0) {
-                List<BigDecimal> values = new ArrayList<BigDecimal>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomDecimal());
-                }
-                ((PropertyDecimalImpl) result).setValues(values);
-            }
-            break;
-        case HTML:
-            result = new PropertyHtmlImpl();
-            if (numValues > 0) {
-                List<String> values = new ArrayList<String>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomString());
-                }
-                ((PropertyHtmlImpl) result).setValues(values);
-            }
-            break;
-        case ID:
-            result = new PropertyIdImpl();
-            if (numValues > 0) {
-                List<String> values = new ArrayList<String>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomString());
-                }
-                ((PropertyIdImpl) result).setValues(values);
-            }
-            break;
-        case INTEGER:
-            result = new PropertyIntegerImpl();
-            if (numValues > 0) {
-                List<BigInteger> values = new ArrayList<BigInteger>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomInteger());
-                }
-                ((PropertyIntegerImpl) result).setValues(values);
-            }
-            break;
-        case STRING:
-            result = new PropertyStringImpl();
-            if (numValues > 0) {
-                List<String> values = new ArrayList<String>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomString());
-                }
-                ((PropertyStringImpl) result).setValues(values);
-            }
-            break;
-        case URI:
-            result = new PropertyUriImpl();
-            if (numValues > 0) {
-                List<String> values = new ArrayList<String>();
-                for (int i = 0; i < numValues; i++) {
-                    values.add(randomUri());
-                }
-                ((PropertyUriImpl) result).setValues(values);
-            }
-            break;
-        default:
-            return null;
-        }
-
-        result.setId(randomString());
-        result.setDisplayName(randomString());
-        result.setLocalName(randomString());
-        result.setQueryName(randomString());
-
-        return result;
-    }
-
-    protected PropertyId createIdPropertyData(String id, String value) {
-        PropertyIdImpl result = new PropertyIdImpl();
-
-        result.setId(id);
-        result.setDisplayName(id);
-        result.setLocalName(id);
-        result.setQueryName(id);
-        result.setValue(value);
-
-        return result;
-    }
-
-    protected List<CmisExtensionElement> createExtensions(int depth) {
-        List<CmisExtensionElement> result = new ArrayList<CmisExtensionElement>();
-
-        String[] namespaces = new String[] { "http://ext1.com", "http://ext2.org", "http://ext3.net"
};
-
-        for (int i = 0; i < randomInt(4) + 1; i++) {
-            String ns = namespaces[randomInt(namespaces.length)];
-
-            Map<String, String> attr = new HashMap<String, String>();
-            for (int j = 0; j < randomInt(3); j++) {
-                attr.put(randomTag(), randomString());
-            }
-
-            CmisExtensionElementImpl element;
-            if (randomBoolean() || depth < 1) {
-                element = new CmisExtensionElementImpl(ns, randomTag(), attr, randomString());
-            } else {
-                element = new CmisExtensionElementImpl(ns, randomTag(), attr, createExtensions(depth
- 1));
-            }
-
-            result.add(element);
-        }
-
-        return result;
-    }
-
     protected void assertObjectData10(ObjectData data, boolean validate) throws Exception
{
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 



Mime
View raw message