Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5E7F3200CCC for ; Fri, 21 Jul 2017 14:03:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5D04316D16C; Fri, 21 Jul 2017 12:03:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7BB6B16D16B for ; Fri, 21 Jul 2017 14:03:39 +0200 (CEST) Received: (qmail 26078 invoked by uid 500); 21 Jul 2017 12:03:38 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 26067 invoked by uid 99); 21 Jul 2017 12:03:38 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jul 2017 12:03:38 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id A697A3A01AD for ; Fri, 21 Jul 2017 12:03:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170721120337.A697A3A01AD@svn01-us-west.apache.org> archived-at: Fri, 21 Jul 2017 12:03:40 -0000 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> properties) { + private void addProperties(Collection> 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 propertyOne = new PropertyStringImpl("my:test", "testOne"); + PropertyData 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> properties = new ArrayList>(); 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)));