chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1802577 - in /chemistry/opencmis/trunk: chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache...
Date Fri, 21 Jul 2017 12:03:36 GMT
Author: fmui
Date: Fri Jul 21 12:03:35 2017
New Revision: 1802577

URL: http://svn.apache.org/viewvc?rev=1802577&view=rev
Log:
CMIS-1041: fixed inconstancy in PropertiesImpl.addProperty()

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/PropertiesTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/MutableProperties.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/MutableProperties.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/MutableProperties.java?rev=1802577&r1=1802576&r2=1802577&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/MutableProperties.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/MutableProperties.java
Fri Jul 21 12:03:35 2017
@@ -24,7 +24,7 @@ package org.apache.chemistry.opencmis.co
 public interface MutableProperties extends Properties {
 
     /**
-     * Adds a property to the end of the property list.
+     * Adds a new property to the end of the property list.
      * 
      * @param property
      *            the property, {@code null} values are ignored

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.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/PropertiesImpl.java?rev=1802577&r1=1802576&r2=1802577&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java
Fri Jul 21 12:03:35 2017
@@ -81,7 +81,7 @@ public class PropertiesImpl extends Abst
         return Collections.unmodifiableList(propertyList);
     }
 
-    protected void addProperties(Collection<PropertyData<?>> properties) {
+    private void addProperties(Collection<PropertyData<?>> properties) {
         if (properties != null) {
             for (PropertyData<?> prop : properties) {
                 addProperty(prop);
@@ -95,6 +95,10 @@ public class PropertiesImpl extends Abst
             return;
         }
 
+        if (properties.containsKey(property.getId())) {
+            throw new IllegalArgumentException("Property '" + property.getId() + "' already
added.");
+        }
+
         propertyList.add(property);
         properties.put(property.getId(), property);
     }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/PropertiesTest.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/misc/PropertiesTest.java?rev=1802577&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/PropertiesTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/PropertiesTest.java
Fri Jul 21 12:03:35 2017
@@ -0,0 +1,52 @@
+/*
+ * 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.misc;
+
+import org.apache.chemistry.opencmis.commons.data.MutableProperties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class PropertiesTest {
+
+    @Test
+    /* see CMIS-1041 */
+    public void testProperties() throws Exception {
+        MutableProperties properties = new PropertiesImpl();
+        PropertyData<String> propertyOne = new PropertyStringImpl("my:test", "testOne");
+        PropertyData<String> propertyTwo = new PropertyStringImpl("my:test", "testTwo");
+
+        properties.addProperty(propertyOne);
+        assertEquals(1, properties.getProperties().size());
+        assertEquals(1, properties.getPropertyList().size());
+
+        properties.replaceProperty(propertyTwo);
+        assertEquals(1, properties.getProperties().size());
+        assertEquals(1, properties.getPropertyList().size());
+
+        try {
+            properties.addProperty(propertyOne);
+            fail("adding an existing property must fail");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/PropertiesTest.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1802577&r1=1802576&r2=1802577&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
Fri Jul 21 12:03:35 2017
@@ -141,7 +141,7 @@ public class InMemoryObjectServiceImpl e
         if (null != properties) {
             // overwrite all new properties
             for (PropertyData<?> prop : properties.getProperties().values()) {
-                newPD.addProperty(prop);
+                newPD.replaceProperty(prop);
             }
         }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java?rev=1802577&r1=1802576&r2=1802577&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java
Fri Jul 21 12:03:35 2017
@@ -452,7 +452,7 @@ public class TypeValidationTest extends
         List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
         properties.add(FACTORY.createPropertyIdData(PropertyIds.NAME, "Document_1"));
         properties.add(FACTORY.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeIdPrimary));
-        properties.add(FACTORY.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, secondaryTypeIds));
+        properties.add(FACTORY.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS,
secondaryTypeIds));
         properties.add(FACTORY.createPropertyBooleanData("BooleanProp", true));
         properties.add(FACTORY.createPropertyIntegerData(INT_PROP_TYPE, BigInteger.valueOf(0)));
         properties.add(FACTORY.createPropertyDecimalData(DECIMAL_PROP_TYPE, BigDecimal.valueOf(0.5)));



Mime
View raw message