Author: jens
Date: Wed Dec 12 06:58:40 2012
New Revision: 1420542
URL: http://svn.apache.org/viewvc?rev=1420542&view=rev
Log:
InMemory: more secondary types support
Modified:
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/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
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=1420542&r1=1420541&r2=1420542&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
Wed Dec 12 06:58:40 2012
@@ -635,9 +635,8 @@ public class InMemoryObjectServiceImpl e
if (null != newSecondaryTypeIds)
secondaryTypeIds.addAll(newSecondaryTypeIds);
- // Find secondary type definitions to delete
- // TODO: implement this
- if (null != newSecondaryTypeIds && newSecondaryTypeIds.size() > 0) {
+ // Find secondary type definitions to delete (null means not set -->
do not change, empty --> remove all secondary types)
+ if (null != newSecondaryTypeIds) {
List<String> propertiesIdToDelete =
getListOfPropertiesToDeleteFromRemovedSecondaryTypes(repositoryId, so,
newSecondaryTypeIds);
for (String propIdToRemove : propertiesIdToDelete) {
so.getProperties().remove(propIdToRemove);
@@ -1301,7 +1300,7 @@ public class InMemoryObjectServiceImpl e
propertiesToDelete.addAll(typeDef.getPropertyDefinitions().keySet());
}
- // Note the list may contain too many properties, if the same property
is also in a type not to be removed
+ // TODO: the list may contain too many properties, if the same
property is also in a type not to be removed
return propertiesToDelete;
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.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/storedobj/api/StoredObject.java?rev=1420542&r1=1420541&r2=1420542&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
Wed Dec 12 06:58:40 2012
@@ -94,22 +94,6 @@ public interface StoredObject {
void setTypeId(String type);
/**
- * CMIS 1.1 add a secondary type
- *
- * @param typeId
- * id of secondary type to add
- */
- void addSecondaryType (String typeId);
-
- /**
- * CMIS 1.1 add a list of secondary types
- *
- * @param typeId
- * id of secondary type to add
- */
- void addSecondaryTypes(List<String> typeIds);
-
- /**
* CMIS 1.1 get ids of all secondary types
* @return
* list of type ids
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.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/storedobj/impl/StoredObjectImpl.java?rev=1420542&r1=1420541&r2=1420542&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
Wed Dec 12 06:58:40 2012
@@ -155,14 +155,6 @@ public class StoredObjectImpl implements
return description;
}
- public void addSecondaryType (String typeId) {
- secondaryTypeIds.add(typeId);
- }
-
- public void addSecondaryTypes(List<String> typeIds) {
- secondaryTypeIds.addAll(typeIds);
- }
-
public List<String> getSecondaryTypeIds() {
return Collections.unmodifiableList(secondaryTypeIds);
}
@@ -285,8 +277,10 @@ public class StoredObjectImpl implements
if (null != properties.get(PropertyIds.DESCRIPTION))
setDescription((String)properties.get(PropertyIds.DESCRIPTION).getFirstValue());
- if (null != properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS))
-
addSecondaryTypes((List<String>)properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues());
+ if (null != properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS)) {
+ secondaryTypeIds.clear();
+
secondaryTypeIds.addAll((List<String>)properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues());
+ }
if (isCreated) {
setCreatedBy(user);
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.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/types/InMemorySecondaryTypeDefinition.java?rev=1420542&r1=1420541&r2=1420542&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java
Wed Dec 12 06:58:40 2012
@@ -41,9 +41,6 @@ public class InMemorySecondaryTypeDefini
public InMemorySecondaryTypeDefinition() {
init(BaseTypeId.CMIS_SECONDARY.value(), "Secondary Type");
setParentTypeId(null);
- // set base properties
- Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
- DocumentTypeCreationHelper.setBasicDocumentPropertyDefinitions(props);
}
public InMemorySecondaryTypeDefinition(String id, String displayName) {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.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/ObjectServiceTest.java?rev=1420542&r1=1420541&r2=1420542&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Wed Dec 12 06:58:40 2012
@@ -1232,7 +1232,6 @@ public class ObjectServiceTest extends A
log.info("... finished testSecondaryTypes()");
}
- // TODO: test add secondary type
@Test
public void testUpdatePropertiesWithTypeCreation () {
final String strPropVal = "Secondary";
@@ -1277,7 +1276,59 @@ public class ObjectServiceTest extends A
log.info("... finished testUpdatePropertiesWithTypeCreation()");
}
- // TODO: remove secondary type
+ @Test
+ public void testDeleteSecondaryType () {
+ final String primaryPropVal = "Sample Doc String Property";
+ final String primaryPropVal2 = "Sample Doc String Property updated";
+ final String strPropVal = "Secondary";
+ final BigInteger intPropVal = BigInteger.valueOf(100);
+
+ log.info("starting testDeleteSecondaryType() ...");
+
+ // create a document with a secondary type
+ List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+ properties.add(fFactory.createPropertyStringData(PropertyIds.NAME,
"ObjectWithSecondaryType"));
+
properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID,
TEST_DOCUMENT_TYPE_ID));
+
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID,
primaryPropVal));
+
properties.add(fFactory.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS,
TEST_SECONDARY_TYPE_ID));
+
properties.add(fFactory.createPropertyStringData(SECONDARY_STRING_PROP,
strPropVal));
+
properties.add(fFactory.createPropertyIntegerData(SECONDARY_INTEGER_PROP,
intPropVal));
+ Properties props = fFactory.createPropertiesData(properties);
+
+ String id = fObjSvc.createDocument(fRepositoryId, props,
fRootFolderId, null, VersioningState.NONE, null,
+ null, null, null);
+ assertNotNull(id);
+
+ // delete the secondary type
+ properties = new ArrayList<PropertyData<?>>();
+
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID,
primaryPropVal2));
+
properties.add(fFactory.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS,
(String)null)); // set list to empty
+ props = fFactory.createPropertiesData(properties);
+ fObjSvc.updateProperties(fRepositoryId, new Holder<String>(id), new
Holder<String>(), props, null);
+
+ // test that properties are gone
+ Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
+ assertNotNull(res.getProperties());
+ Map<String, PropertyData<?>> returnedProps = res.getProperties();
+ assertNotNull(returnedProps);
+ assertEquals(0,
returnedProps.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues().size());
+ PropertyData<?> pd = returnedProps.get(SECONDARY_STRING_PROP);
+ assertNull(pd); // property must not exist any longer
+ pd = returnedProps.get(SECONDARY_INTEGER_PROP);
+ assertNull(pd); // property must not exist any longer
+ String returnedPrimaryPropVal = (String)
returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
+ assertEquals(primaryPropVal2, returnedPrimaryPropVal); // other
properties should be updated
+ // test that system properties are there
+ pd = returnedProps.get(PropertyIds.NAME);
+ assertNotNull(pd);
+ pd = returnedProps.get(PropertyIds.OBJECT_ID);
+ assertNotNull(pd);
+ pd = returnedProps.get(PropertyIds.OBJECT_TYPE_ID);
+ assertNotNull(pd);
+
+ log.info("... finished testDeleteSecondaryType()");
+ }
+
// TODO: test constraints on secondary types
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.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/RepositoryServiceTest.java?rev=1420542&r1=1420541&r2=1420542&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
Wed Dec 12 06:58:40 2012
@@ -461,15 +461,17 @@ public class RepositoryServiceTest exten
Map<String, PropertyDefinition<?>> propDefs =
typeDef.getPropertyDefinitions();
String baseTypeId = typeDef.getBaseTypeId().value();
- assertTrue(propDefs.containsKey(PropertyIds.NAME));
- assertTrue(propDefs.containsKey(PropertyIds.OBJECT_ID));
- assertTrue(propDefs.containsKey(PropertyIds.OBJECT_TYPE_ID));
- assertTrue(propDefs.containsKey(PropertyIds.BASE_TYPE_ID));
- assertTrue(propDefs.containsKey(PropertyIds.CREATED_BY));
- assertTrue(propDefs.containsKey(PropertyIds.CREATION_DATE));
- assertTrue(propDefs.containsKey(PropertyIds.LAST_MODIFIED_BY));
- assertTrue(propDefs.containsKey(PropertyIds.LAST_MODIFICATION_DATE));
- assertTrue(propDefs.containsKey(PropertyIds.CHANGE_TOKEN));
+ if (!typeDef.getId().equals(BaseTypeId.CMIS_SECONDARY.value())) {
+ assertTrue(propDefs.containsKey(PropertyIds.NAME));
+ assertTrue(propDefs.containsKey(PropertyIds.OBJECT_ID));
+ assertTrue(propDefs.containsKey(PropertyIds.OBJECT_TYPE_ID));
+ assertTrue(propDefs.containsKey(PropertyIds.BASE_TYPE_ID));
+ assertTrue(propDefs.containsKey(PropertyIds.CREATED_BY));
+ assertTrue(propDefs.containsKey(PropertyIds.CREATION_DATE));
+ assertTrue(propDefs.containsKey(PropertyIds.LAST_MODIFIED_BY));
+
assertTrue(propDefs.containsKey(PropertyIds.LAST_MODIFICATION_DATE));
+ assertTrue(propDefs.containsKey(PropertyIds.CHANGE_TOKEN));
+ }
if (baseTypeId.equals(BaseTypeId.CMIS_DOCUMENT.value())) {
assertTrue(propDefs.containsKey(PropertyIds.IS_IMMUTABLE));