chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1511617 [3/5] - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/query/ main/java/org/apache/c...
Date Thu, 08 Aug 2013 08:40:27 GMT
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.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/DefaultTypeSystemCreator.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java Thu Aug  8 08:40:26 2013
@@ -20,16 +20,21 @@ package org.apache.chemistry.opencmis.in
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.definitions.Choice;
-import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
@@ -39,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
 import org.apache.chemistry.opencmis.inmemory.TypeCreator;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 
 public class DefaultTypeSystemCreator implements TypeCreator {
     public static final List<TypeDefinition> singletonTypes = buildTypesList();
@@ -79,273 +85,323 @@ public class DefaultTypeSystemCreator im
      */
     private static List<TypeDefinition> buildTypesList() {
         // always add CMIS default types
+        TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
+
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
 
-        InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
-                "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-        typesList.add(cmisType1);
-
-        InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
-                "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-        typesList.add(cmisType2);
-
-        InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
-                "My Type 3 Level 2", cmisType1);
-        typesList.add(cmisType11);
-
-        InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
-                "My Type 4 Level 3", cmisType11);
-        typesList.add(cmisType111);
-
-        InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
-                "My Type 5 Level 3", cmisType11);
-        typesList.add(cmisType112);
-
-        InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
-                "My Type 6 Level 2", cmisType1);
-        typesList.add(cmisType12);
-
-        InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
-                "My Type 7 Level 2", cmisType2);
-        typesList.add(cmisType21);
-
-        InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
-                "My Type 8 Level 2", cmisType2);
-        typesList.add(cmisType22);
-        InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
-                "My Type 9 Level 2", cmisType2);
-        typesList.add(cmisType23);
-        DocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4", "My Type 10 Level 2",
-                cmisType2);
-        typesList.add(cmisType24);
-        InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
-                "My Type 11 Level 2", cmisType2);
-        typesList.add(cmisType25);
-
-        InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
-                "My Type 12 Level 2", cmisType2);
-        typesList.add(cmisType26);
-        InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
-                "My Type 13 Level 2", cmisType2);
-        typesList.add(cmisType27);
-        InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
-                "My Type 14 Level 2", cmisType2);
-        typesList.add(cmisType28);
-        InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
-                "My Type 15 Level 2", cmisType2);
-        typesList.add(cmisType29);
-
-        // create a complex type with properties
-        InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
-                "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a boolean property definition
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
-                "Sample Boolean Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
-                "Sample Boolean multi-value Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
-                "Sample DateTime Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
-                "Sample DateTime multi-value Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
-                "Sample Decimal Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        prop3 = PropertyCreationHelper.createDecimalMultiDefinition("DecimalPropMV",
-                "Sample Decimal multi-value Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
-                "Sample Html Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        prop4 = PropertyCreationHelper.createHtmlMultiDefinition("HtmlPropMV", "Sample Html multi-value Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        prop5 = PropertyCreationHelper.createIdMultiDefinition("IdPropMV", "Sample Id Html multi-value Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
-                "Sample Int Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        prop6 = PropertyCreationHelper.createIntegerMultiDefinition("IntPropMV", "Sample Int multi-value Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
-                "Sample String Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop7.getId(), prop7);
-
-        PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        prop8 = PropertyCreationHelper.createUriMultiDefinition("UriPropMV", "Sample Uri multi-value Property",
-                Updatability.READWRITE);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
-                "Sample Pick List Property", Updatability.READWRITE);
-        List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-        ChoiceImpl<String> elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("red"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("green"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("blue"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("black"));
-        choiceList.add(elem);
-        prop9.setChoices(choiceList);
-        prop9.setDefaultValue(Collections.singletonList("blue"));
-        propertyDefinitions.put(prop9.getId(), prop9);
-
-        /*
-         * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
-         * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
-         * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
-         * PropertyCreationHelper.addElemToPicklist(prop9, "black");
-         * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
-         */
-
-        cmisComplexType.setPropertyDefinitions(propertyDefinitions);
-
-        // add type to types collection
-        typesList.add(cmisComplexType);
-
-        // create a type hierarchy with inherited properties
-        InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
-                "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
-                "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-
-        InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
-                "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
-                "Sample String Property", Updatability.READWRITE);
-        propertyDefinitions.put(propTop.getId(), propTop);
-        cmisDocTypeTopLevel.setPropertyDefinitions(propertyDefinitions);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
-                "String Property Level 1", Updatability.READWRITE);
-        propertyDefinitions.put(propLevel1.getId(), propLevel1);
-        cmisDocTypeLevel1.setPropertyDefinitions(propertyDefinitions);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
-                "String Property Level 2", Updatability.READWRITE);
-        propertyDefinitions.put(propLevel2.getId(), propLevel2);
-        cmisDocTypeLevel2.setPropertyDefinitions(propertyDefinitions);
-
-        // add type to types collection
-        typesList.add(cmisDocTypeTopLevel);
-        typesList.add(cmisDocTypeLevel1);
-        typesList.add(cmisDocTypeLevel2);
-
-        // Create a type that is versionable
-        InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
-                "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a single String property definition
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
-                "Sample String Property", Updatability.WHENCHECKEDOUT);
-        propertyDefinitions.put(prop1.getId(), prop1);
-
-        cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
-        cmisVersionedType.setIsVersionable(true); // make it a versionable type;
-
-        // add type to types collection
-        typesList.add(cmisVersionedType);
-        
-        //CMIS 1.1 create an item item type
-
-        InMemoryItemTypeDefinition cmisItemType = new InMemoryItemTypeDefinition(ITEM_TYPE, "MyItemType");
-
-        // create a single String property definition
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        prop1 = PropertyCreationHelper.createStringDefinition("ItemStringProp",
-                "Item String Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop1.getId(), prop1);
-        cmisItemType.addCustomPropertyDefinitions(propertyDefinitions);
-        // add type to types collection
-        typesList.add(cmisItemType);
-        
-
-        InMemorySecondaryTypeDefinition cmisSecondaryType = new InMemorySecondaryTypeDefinition(SECONDARY_TYPE_ID, 
-                "MySecondaryType");
-        // create a single String property definition
-        Map<String, PropertyDefinition<?>> secondaryPropertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propS1 = PropertyCreationHelper.createStringDefinition("SecondaryStringProp",
-                "Secondary String Property", Updatability.READWRITE);
-        secondaryPropertyDefinitions.put(propS1.getId(), propS1);
-        PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition("SecondaryIntegerProp",
-                "Secondary Integer Property", Updatability.READWRITE);
-        propS2.setIsRequired(true);
-        secondaryPropertyDefinitions.put(propS2.getId(), propS2);
-        cmisSecondaryType.addCustomPropertyDefinitions(secondaryPropertyDefinitions);
-        // add type to types collection
-        typesList.add(cmisSecondaryType);
-
-        // add relationship type
-        InMemoryRelationshipTypeDefinition cmisRelType = new InMemoryRelationshipTypeDefinition(
-                "CrossReferenceType", "CrossReferenceRelationshipType");
-        // create a single String property definition
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        prop1 = PropertyCreationHelper.createStringDefinition("CrossReferenceKind",
-                "CrossReferenceType", Updatability.READWRITE);
-        propertyDefinitions.put(prop1.getId(), prop1);
-        cmisRelType.addCustomPropertyDefinitions(propertyDefinitions);
-        typesList.add(cmisRelType);            
-
-        // add a policy type
-        InMemoryPolicyTypeDefinition polType = new InMemoryPolicyTypeDefinition(
-                "AuditPolicy", "Audit Policy", InMemoryPolicyTypeDefinition.getRootPolicyType());
-
-        // create a String property definition
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        prop1 = PropertyCreationHelper.createStringDefinition("AuditSettings",
-                "Audit Kind Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop1.getId(), prop1);
-
-        polType.addCustomPropertyDefinitions(propertyDefinitions);
-        typesList.add(polType);            
-        
-        return typesList;
+        MutableDocumentTypeDefinition cmisType1;        
+        try {
+            cmisType1 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisType1.setId("MyDocType1");
+            cmisType1.setDisplayName("My Type 1 Level 1");
+            cmisType1.setDescription("Builtin InMemory type definition MyDocType1");
+            typesList.add(cmisType1);
+
+            MutableDocumentTypeDefinition cmisType2;        
+            cmisType2 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisType2.setId("MyDocType2");
+            cmisType2.setDisplayName("My Type 2 Level 1");
+            cmisType2.setDescription("Builtin InMemory type definition MyDocType2");
+            typesList.add(cmisType2);
+
+            MutableTypeDefinition cmisType11;        
+            cmisType11 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.1");
+            cmisType11.setDisplayName("My Type 3 Level 2");
+            cmisType11.setDescription("Builtin InMemory type definition MyDocType1.1");
+            typesList.add(cmisType11);
+
+            MutableTypeDefinition cmisType111;        
+            cmisType111 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.1");
+            cmisType111.setDisplayName("My Type 4 Level 3");
+            cmisType111.setDescription("Builtin InMemory type definition MyDocType1.1.1");
+            typesList.add(cmisType111);
+
+            MutableTypeDefinition cmisType112;        
+            cmisType112 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.2");
+            cmisType112.setId("MyDocType1.1.2");
+            cmisType112.setDisplayName("My Type 5 Level 3");
+            cmisType112.setDescription("Builtin InMemory type definition MyDocType1.1.2");
+            typesList.add(cmisType112);
+
+            MutableTypeDefinition cmisType12;        
+            cmisType12 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.2");
+            cmisType12.setDisplayName("My Type 6 Level 2");
+            cmisType12.setDescription("Builtin InMemory type definition MyDocType1.2");
+            typesList.add(cmisType12);
+
+            MutableTypeDefinition cmisType21;        
+            cmisType21 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.1");
+            cmisType21.setDisplayName("My Type 7 Level 2");
+            cmisType21.setDescription("Builtin InMemory type definition MyDocType2.1");
+            typesList.add(cmisType21);
+
+            MutableTypeDefinition cmisType22;        
+            cmisType22 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.2");
+            cmisType22.setDisplayName("My Type 8 Level 2");
+            cmisType22.setDescription("Builtin InMemory type definition MyDocType2.2");
+            typesList.add(cmisType22);
+
+            MutableTypeDefinition cmisType23;        
+            cmisType23 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.3");
+            cmisType23.setDisplayName("My Type 9 Level 2");
+            cmisType23.setDescription("Builtin InMemory type definition MyDocType2.3");
+            typesList.add(cmisType23);
+
+            MutableTypeDefinition cmisType24;        
+            cmisType24 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.4");
+            cmisType24.setDisplayName("My Type 10 Level 2");
+            cmisType24.setDescription("Builtin InMemory type definition MyDocType2.4");
+            typesList.add(cmisType24);
+
+            MutableTypeDefinition cmisType25;        
+            cmisType25 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.5");
+            cmisType25.setDisplayName("My Type 11 Level 2");
+            cmisType25.setDescription("Builtin InMemory type definition MyDocType2.5");
+            typesList.add(cmisType25);
+
+            MutableTypeDefinition cmisType26;        
+            cmisType26 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.6");
+            cmisType26.setDisplayName("My Type 12 Level 2");
+            cmisType26.setDescription("Builtin InMemory type definition MyDocType2.6");
+            typesList.add(cmisType26);
+
+            MutableTypeDefinition cmisType27;        
+            cmisType27 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.7");
+            cmisType27.setDisplayName("My Type 13 Level 2");
+            cmisType27.setDescription("Builtin InMemory type definition MyDocType2.7");
+            typesList.add(cmisType27);
+
+            MutableTypeDefinition cmisType28;        
+            cmisType28 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.8");
+            cmisType28.setDisplayName("My Type 14 Level 2");
+            cmisType28.setDescription("Builtin InMemory type definition MyDocType2.8");
+            typesList.add(cmisType28);
+
+            MutableTypeDefinition cmisType29;        
+            cmisType29 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.9");
+            cmisType29.setDisplayName("My Type 15 Level 2");
+            cmisType29.setDescription("Builtin InMemory type definition MyDocType2.9");
+            typesList.add(cmisType29);
+
+            // create a complex type with properties
+            MutableDocumentTypeDefinition cmisComplexType;        
+            cmisComplexType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisComplexType.setId(COMPLEX_TYPE);
+            cmisComplexType.setDisplayName("Complex type with properties, Level 1");
+            cmisComplexType.setDescription("Builtin InMemory type definition ComplexType");
+
+            PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
+                    "Sample Boolean Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop);
+
+            prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
+                    "Sample Boolean multi-value Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop);
+
+            PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
+                    "Sample DateTime Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop2);
+
+            prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
+                    "Sample DateTime multi-value Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop2);
+
+            PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
+                    "Sample Decimal Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop3);
+
+            prop3 = PropertyCreationHelper.createDecimalMultiDefinition("DecimalPropMV",
+                    "Sample Decimal multi-value Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop3);
+
+            PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
+                    "Sample Html Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop4);
+
+            prop4 = PropertyCreationHelper.createHtmlMultiDefinition("HtmlPropMV", "Sample Html multi-value Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop4);
+
+            PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop5);
+
+            prop5 = PropertyCreationHelper.createIdMultiDefinition("IdPropMV", "Sample Id Html multi-value Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop5);
+
+            PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
+                    "Sample Int Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop6);
+
+            prop6 = PropertyCreationHelper.createIntegerMultiDefinition("IntPropMV", "Sample Int multi-value Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop6);
+
+            PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
+                    "Sample String Property", Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop7);
+
+            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop8);
+
+            prop8 = PropertyCreationHelper.createUriMultiDefinition("UriPropMV", "Sample Uri multi-value Property",
+                    Updatability.READWRITE);
+            cmisComplexType.addPropertyDefinition(prop8);
+
+            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+                    "Sample Pick List Property", Updatability.READWRITE);
+            List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+            ChoiceImpl<String> elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("red"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("green"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("blue"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("black"));
+            choiceList.add(elem);
+            prop9.setChoices(choiceList);
+            prop9.setDefaultValue(Collections.singletonList("blue"));
+            cmisComplexType.addPropertyDefinition(prop9);
+
+            /*
+             * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
+             * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
+             * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
+             * PropertyCreationHelper.addElemToPicklist(prop9, "black");
+             * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
+             */
+
+            // add type to types collection
+            typesList.add(cmisComplexType);
+
+            // create a type hierarchy with inherited properties
+            MutableDocumentTypeDefinition cmisDocTypeTopLevel;        
+            cmisDocTypeTopLevel = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisDocTypeTopLevel.setId(TOPLEVEL_TYPE);
+            cmisDocTypeTopLevel.setDisplayName("Document type with properties, Level 1");
+            cmisDocTypeTopLevel.setDescription("Builtin InMemory type definition " + TOPLEVEL_TYPE);
+
+            MutableTypeDefinition cmisDocTypeLevel1;        
+            cmisDocTypeLevel1 = typeFactory.createChildTypeDefinition(cmisDocTypeTopLevel, LEVEL1_TYPE);
+            cmisDocTypeLevel1.setDisplayName("Document type with inherited properties, Level 2");
+            cmisDocTypeLevel1 .setDescription("Builtin InMemory type definition " + LEVEL1_TYPE);
+
+            MutableTypeDefinition cmisDocTypeLevel2;        
+            cmisDocTypeLevel2 = typeFactory.createChildTypeDefinition(cmisDocTypeLevel1, LEVEL2_TYPE);
+            cmisDocTypeLevel2.setDisplayName("Document type with inherited properties, Level 3");
+            cmisDocTypeLevel2.setDescription("Builtin InMemory type definition " + LEVEL2_TYPE);
+
+            PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
+                    "Sample String Property", Updatability.READWRITE);
+            cmisDocTypeTopLevel.addPropertyDefinition(propTop);
+
+            PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
+                    "String Property Level 1", Updatability.READWRITE);
+            cmisDocTypeLevel1.addPropertyDefinition(propLevel1);
+
+            PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
+                    "String Property Level 2", Updatability.READWRITE);
+            cmisDocTypeLevel2.addPropertyDefinition(propLevel2);
+
+            // add type to types collection
+            typesList.add(cmisDocTypeTopLevel);
+            typesList.add(cmisDocTypeLevel1);
+            typesList.add(cmisDocTypeLevel2);
+
+            // Create a type that is versionable
+            MutableDocumentTypeDefinition cmisVersionedType;        
+            cmisVersionedType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisVersionedType.setId(VERSIONED_TYPE);
+            cmisVersionedType.setDisplayName("Versioned Type");
+            cmisVersionedType.setDescription("Builtin InMemory type definition " + VERSIONED_TYPE);
+            cmisVersionedType.setIsVersionable(true); // make it a versionable type;
+
+            // create a single String property definition
+            PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
+                    "Sample String Property", Updatability.WHENCHECKEDOUT);
+            cmisVersionedType.addPropertyDefinition(prop1);
+
+            // add type to types collection
+            typesList.add(cmisVersionedType);
+
+            // CMIS 1.1 create an item item type
+
+            MutableItemTypeDefinition itemType;        
+            itemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisItemType().getId());
+            itemType.setId(ITEM_TYPE);
+            itemType.setDisplayName("MyItemType");
+            itemType.setDescription("Builtin InMemory type definition " + ITEM_TYPE);
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(itemType);
+
+            // create a single String property definition
+
+            prop1 = PropertyCreationHelper.createStringDefinition("ItemStringProp",
+                    "Item String Property", Updatability.READWRITE);
+            itemType.addPropertyDefinition(prop1);
+            // add type to types collection
+            typesList.add(itemType);
+
+
+            MutableSecondaryTypeDefinition cmisSecondaryType;        
+            cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+            cmisSecondaryType.setId(SECONDARY_TYPE_ID);
+            cmisSecondaryType.setDisplayName("MySecondaryType");
+            cmisSecondaryType.setDescription("Builtin InMemory type definition " + SECONDARY_TYPE_ID);
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType);
+            cmisSecondaryType.setIsFileable(false);
+            
+            // create a single String property definition
+            PropertyStringDefinitionImpl propS1 = PropertyCreationHelper.createStringDefinition("SecondaryStringProp",
+                    "Secondary String Property", Updatability.READWRITE);
+            cmisSecondaryType.addPropertyDefinition(propS1);
+            PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition("SecondaryIntegerProp",
+                    "Secondary Integer Property", Updatability.READWRITE);
+            propS2.setIsRequired(true);
+            cmisSecondaryType.addPropertyDefinition(propS2);
+            // add type to types collection
+            typesList.add(cmisSecondaryType);
+
+            // add relationship type
+            MutableRelationshipTypeDefinition relType;        
+            relType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+            relType.setId("CrossReferenceType");
+            relType.setDisplayName("CrossReferenceType");
+            relType.setDescription("Builtin InMemory type definition CrossReferenceType");
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(relType);
+            relType.setIsFileable(false);
+
+            // create a single String property definition
+
+            prop1 = PropertyCreationHelper.createStringDefinition("CrossReferenceKind",
+                    "CrossReferenceType", Updatability.READWRITE);
+            relType.addPropertyDefinition(prop1);
+            typesList.add(relType);            
+
+            // add a policy type
+            MutablePolicyTypeDefinition polType;        
+            polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisPolicyType().getId());
+            polType.setId("AuditPolicy");
+            polType.setDisplayName("Audit Policy");
+            polType.setDescription("Builtin InMemory type definition AuditPolicy");
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(polType);
+            polType.setIsFileable(false);
+
+            // create a String property definition
+            prop1 = PropertyCreationHelper.createStringDefinition("AuditSettings",
+                    "Audit Kind Property", Updatability.READWRITE);
+            polType.addPropertyDefinition(prop1);
+            typesList.add(polType);            
+
+            return typesList;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.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/DocumentTypeCreationHelper.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java Thu Aug  8 08:40:26 2013
@@ -24,20 +24,216 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.ItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.SecondaryTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ItemTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyTypeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.SecondaryTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 
 public class DocumentTypeCreationHelper {
+    
+    public static class InMemoryDocumentType extends DocumentTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(DocumentTypeCreationHelper.getQueryName(id));
+        }
+    }
+
+    public static class InMemoryFolderType extends FolderTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(DocumentTypeCreationHelper.getQueryName(id));
+        }
+    }
+
+    public static class InMemoryRelationshipType extends RelationshipTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(DocumentTypeCreationHelper.getQueryName(id));
+        }
+    }
+    
+    public static class InMemoryPolicyType extends PolicyTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(DocumentTypeCreationHelper.getQueryName(id));
+        }
+    }
+
+    public static class InMemoryItemType extends ItemTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(id);
+        }
+    }
+
+    public static class InMemorySecondaryType extends SecondaryTypeDefinitionImpl {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
+            DocumentTypeCreationHelper.addPropertyDefinition(propertyDefinition);
+            super.addPropertyDefinition(propertyDefinition);
+        }        
+
+        @Override
+        public void setId(String id) {
+            super.setId(id);
+            super.setLocalName(id);
+            super.setQueryName(id);
+        }
+    }
 
     private static final List<TypeDefinition> defaultTypes = createCmisDefaultTypes();
+    private static TypeDefinitionFactory typeFactory;
+    private static MutableDocumentTypeDefinition cmisTypeDoc;
+    private static MutableFolderTypeDefinition cmisTypeFolder;
+    private static MutableRelationshipTypeDefinition cmisTypeRel;
+    private static MutablePolicyTypeDefinition cmisTypePolicy;
+    private static MutableItemTypeDefinition cmisTypeItem;
+    private static MutableSecondaryTypeDefinition cmisTypeSecondary;
+    
+    public static DocumentTypeDefinition getCmisDocumentType() {
+        return cmisTypeDoc;
+    }
+    
+    public static FolderTypeDefinition getCmisFolderType() {
+        return cmisTypeFolder;
+    }
+    
+    public static RelationshipTypeDefinition getCmisRelationshipType() {
+        return cmisTypeRel;
+    }
+
+    public static PolicyTypeDefinition getCmisPolicyType() {
+        return cmisTypePolicy;
+    }
+    
+    public static ItemTypeDefinition getCmisItemType() {
+        return cmisTypeItem;
+    }
+    
+    public static SecondaryTypeDefinition getCmisSecondaryType() {
+        return cmisTypeSecondary;
+    }
+    
+    private static void initType(MutableTypeDefinition type, TypeDefinition parentTypeDefinition) {
+        type.setBaseTypeId(parentTypeDefinition.getBaseTypeId());
+        type.setParentTypeId(parentTypeDefinition.getId());
+        type.setIsControllableAcl(parentTypeDefinition.isControllableAcl());
+        type.setIsControllablePolicy(parentTypeDefinition.isControllablePolicy());
+        type.setIsCreatable(parentTypeDefinition.isCreatable());
+        type.setDescription(null);
+        type.setDisplayName(null);
+        type.setIsFileable(parentTypeDefinition.isFileable());
+        type.setIsFulltextIndexed(parentTypeDefinition.isFulltextIndexed());
+        type.setIsIncludedInSupertypeQuery(parentTypeDefinition.isIncludedInSupertypeQuery());
+        type.setLocalName(null);
+        type.setLocalNamespace(parentTypeDefinition.getLocalNamespace());
+        type.setIsQueryable(parentTypeDefinition.isQueryable());
+        type.setQueryName(null);
+        type.setId(null);
+        type.setTypeMutability(parentTypeDefinition.getTypeMutability());
+    }
+
+    /**
+     * Creates a new mutable document type definition, which is a child of the
+     * provided type definition. Property definitions are not added which is useful
+     * for creating additional types at runtime
+     */
+    public static MutableDocumentTypeDefinition createDocumentTypeDefinitionWithoutBaseProperties(DocumentTypeDefinition parentTypeDefinition)
+            throws InstantiationException, IllegalAccessException {
+        MutableDocumentTypeDefinition documentType = new InMemoryDocumentType();
+        initType(documentType, parentTypeDefinition);
+
+        documentType.setIsVersionable(parentTypeDefinition.isVersionable());
+        documentType.setContentStreamAllowed(parentTypeDefinition.getContentStreamAllowed());
+        return documentType;
+    }
 
     private DocumentTypeCreationHelper() {
     }
@@ -51,33 +247,114 @@ public class DocumentTypeCreationHelper 
     public static final List<TypeDefinition> getDefaultTypes() {
         return defaultTypes;
     }
+    
+    private static void addPropertyDefinition(PropertyDefinition<?> propertyDefinition)  {
+        if (propertyDefinition.getId().equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS)) {
+            MutablePropertyDefinition<?> propDef = (MutablePropertyDefinition<?>) propertyDefinition;
+            propDef.setUpdatability(Updatability.READWRITE);
+        }        
+    }
 
+    private static String getQueryName(String id) {
+        if (null == id)
+            return null;
+        
+        StringBuffer sb = new StringBuffer(id);
+        for (int i=0; i<sb.length(); i++) {
+            char c = sb.charAt(i);
+            if (c == '.' || c == ' ') {
+                sb.setCharAt(i, '_');
+            }
+        }
+        return sb.toString();
+    }
+    
+    public static void setDefaultTypeCapabilities(MutableTypeDefinition cmisType) {
+        cmisType.setIsCreatable(true);
+        cmisType.setIsFileable(true);
+        cmisType.setIsFulltextIndexed(false);
+    }
+    
+    static TypeMutabilityImpl getBaseTypeMutability() {
+        TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+        typeMutability.setCanCreate(true);
+        typeMutability.setCanUpdate(false);
+        typeMutability.setCanDelete(false);
+        return typeMutability;
+    }
+    
     private static List<TypeDefinition> createCmisDefaultTypes() {
+        TypeDefinitionFactory typeFactory = getTypeDefinitionFactory();
+        
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
 
         // create root types:
-        TypeDefinition cmisType = InMemoryDocumentTypeDefinition.getRootDocumentType();
-        typesList.add(cmisType);
-
-        cmisType = InMemoryFolderTypeDefinition.getRootFolderType();
-        typesList.add(cmisType);
-
-        cmisType = InMemoryRelationshipTypeDefinition.getRootRelationshipType();
-        typesList.add(cmisType);
-        
-        cmisType = InMemoryPolicyTypeDefinition.getRootPolicyType();
-        typesList.add(cmisType);
-
-        // CMIS 1.1
-        cmisType = InMemoryItemTypeDefinition.getRootItemType();
-        typesList.add(cmisType);
-        
-        cmisType = InMemorySecondaryTypeDefinition.getRootSecondaryType();
-        typesList.add(cmisType);
+        try {
+            cmisTypeDoc = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypeDoc);
+            cmisTypeDoc.setTypeMutability(getBaseTypeMutability());
+            cmisTypeDoc.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+            cmisTypeDoc.setIsVersionable(false);
+            typesList.add(cmisTypeDoc);
+
+            cmisTypeFolder = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypeFolder);
+            cmisTypeFolder.setTypeMutability(getBaseTypeMutability());
+            typesList.add(cmisTypeFolder);
+            
+            cmisTypeRel = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypeRel);
+            cmisTypeRel.setTypeMutability(getBaseTypeMutability());
+            cmisTypeRel.setIsFileable(false);
+            typesList.add(cmisTypeRel);
+
+            cmisTypePolicy = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypePolicy);
+            cmisTypePolicy.setTypeMutability(getBaseTypeMutability());
+            cmisTypePolicy.setIsFileable(false);
+            typesList.add(cmisTypePolicy);
+            
+            cmisTypeItem = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypeItem);
+            cmisTypeItem.setTypeMutability(getBaseTypeMutability());
+            cmisTypeItem.setIsFileable(true);
+            typesList.add(cmisTypeItem);
+            
+            cmisTypeSecondary = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, null);
+            setDefaultTypeCapabilities(cmisTypeSecondary);
+            cmisTypeSecondary.setTypeMutability(getBaseTypeMutability());
+            cmisTypeSecondary.setIsFileable(false);
+            typesList.add(cmisTypeSecondary);            
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating base types. ", e);
+        }
 
         return typesList;
     }
 
+    public static TypeDefinitionFactory getTypeDefinitionFactory() {
+        if (null == typeFactory) {
+            typeFactory = TypeDefinitionFactory.newInstance();
+            typeFactory.setDefaultControllableAcl(true);
+            typeFactory.setDefaultControllablePolicy(true);
+            typeFactory.setDefaultNamespace("http://apache.org");
+            //        typeFactory.setDefaultIsFulltextIndexed(false);
+            typeFactory.setDefaultQueryable(true);
+            TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+            typeMutability.setCanCreate(true);
+            typeMutability.setCanUpdate(true);
+            typeMutability.setCanDelete(true);
+            typeFactory.setDefaultTypeMutability(typeMutability);
+            typeFactory.setDocumentTypeDefinitionClass(InMemoryDocumentType.class);
+            typeFactory.setFolderTypeDefinitionClass(InMemoryFolderType.class);
+            typeFactory.setRelationshipTypeDefinitionClass(InMemoryRelationshipType.class);
+            typeFactory.setPolicyTypeDefinitionClass(InMemoryPolicyType.class);
+            typeFactory.setItemTypeDefinitionClass(InMemoryItemType.class);
+            typeFactory.setSecondaryTypeDefinitionClass(InMemorySecondaryType.class);
+        }
+        return typeFactory;
+    }
+
     /**
      * create root types and a collection of sample types
      *

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.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/PropertyCreationHelper.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Thu Aug  8 08:40:26 2013
@@ -73,6 +73,8 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
 import org.apache.chemistry.opencmis.inmemory.NameValidator;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 import org.slf4j.Logger;
@@ -207,7 +209,7 @@ public final class PropertyCreationHelpe
         prop.setDefaultValue(Collections.singletonList(defVal));
     }
 
-    public static Properties getPropertiesFromObject(StoredObject so, TypeManager typeManager,
+    public static Properties getPropertiesFromObject(StoredObject so, ObjectStore objectStore, TypeManager typeManager,
             List<String> requestedIds, boolean fillOptionalPropertyData) {
         // build properties collection
 
@@ -217,6 +219,10 @@ public final class PropertyCreationHelpe
         TypeDefinition td = typeManager.getTypeById(so.getTypeId()).getTypeDefinition();
 
         String typeId = so.getTypeId();
+        if (so instanceof Folder && FilterParser.isContainedInFilter(PropertyIds.PATH, requestedIds)) {
+            String path = objectStore.getFolderPath(so.getId());
+            properties.put(PropertyIds.PATH, objectFactory.createPropertyStringData(PropertyIds.PATH, path));
+        }
         if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, requestedIds)) {
             if (td == null) {
                 log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
@@ -260,7 +266,7 @@ public final class PropertyCreationHelpe
         return props;
     }
 
-    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition primaryType, List<TypeDefinition> secondaryTypes,
+    public static Properties getPropertiesFromObject(StoredObject so, ObjectStore objectStore, TypeDefinition primaryType, List<TypeDefinition> secondaryTypes,
             Map<String, String> requestedIds, Map<String, String> requestedFuncs) {
         // build properties collection
 
@@ -268,6 +274,11 @@ public final class PropertyCreationHelpe
         BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
         Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
         so.fillProperties(properties, objectFactory, idList);
+        // special handling for path
+        if (so instanceof Folder && FilterParser.isContainedInFilter(PropertyIds.PATH, idList)) {
+            String path = objectStore.getFolderPath(so.getId());
+            properties.put(PropertyIds.PATH, objectFactory.createPropertyStringData(PropertyIds.PATH, path));
+        }
 
         if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, idList)) {
             String baseTypeId = primaryType.getBaseTypeId().value();
@@ -391,9 +402,9 @@ public final class PropertyCreationHelpe
         }
     }
 
-    public static ObjectData getObjectData(TypeManager tm, StoredObject so, String filter, String user,
-            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
-            Boolean includePolicyIds, Boolean includeACL, ExtensionsData extension) {
+    public static ObjectData getObjectData(TypeManager tm, ObjectStore objectStore, StoredObject so, String filter,
+            String user, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+            String renditionFilter, Boolean includePolicyIds, Boolean includeACL, ExtensionsData extension) {
 
         ObjectDataImpl od = new ObjectDataImpl();
 
@@ -403,7 +414,7 @@ public final class PropertyCreationHelpe
 
         // build properties collection
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-        Properties props = getPropertiesFromObject(so, tm, requestedIds, true);
+        Properties props = getPropertiesFromObject(so, objectStore, tm, requestedIds, true);
 
         // fill output object
         if (null != includeAllowableActions && includeAllowableActions) {
@@ -416,7 +427,8 @@ public final class PropertyCreationHelpe
             od.setRenditions(renditions);
 
         if (null != includeACL && includeACL) {
-            Acl acl = so instanceof DocumentVersion ? ((DocumentVersion) so).getParentDocument().getAcl() : so.getAcl();
+            int aclId = so instanceof DocumentVersion ? ((DocumentVersion) so).getParentDocument().getAclId() : so.getAclId();
+            Acl acl = objectStore.getAcl(aclId);
             od.setAcl(acl);
         }
         od.setIsExactAcl(true);
@@ -426,7 +438,7 @@ public final class PropertyCreationHelpe
         }
 
         if (null != includeRelationships && includeRelationships != IncludeRelationships.NONE) {
-            od.setRelationships(DataObjectCreator.fillRelationships(tm, includeRelationships, so, user));
+            od.setRelationships(DataObjectCreator.fillRelationships(tm, objectStore, includeRelationships, so, user));
         }
 
         if (null != includePolicyIds && includePolicyIds) {
@@ -443,15 +455,15 @@ public final class PropertyCreationHelpe
         return od;
     }
 
-    public static ObjectData getObjectDataQueryResult(TypeManager tm, TypeDefinition primaryType, StoredObject so,
-            String user, Map<String, String> requestedProperties, Map<String, String> requestedFuncs,
-            List<TypeDefinition> secondaryTypes, Boolean includeAllowableActions,
+    public static ObjectData getObjectDataQueryResult(TypeManager tm, ObjectStore objectStore,
+            TypeDefinition primaryType, StoredObject so, String user, Map<String, String> requestedProperties,
+            Map<String, String> requestedFuncs, List<TypeDefinition> secondaryTypes, Boolean includeAllowableActions,
             IncludeRelationships includeRelationships, String renditionFilter) {
 
         ObjectDataImpl od = new ObjectDataImpl();
 
         // build properties collection
-        Properties props = getPropertiesFromObject(so, primaryType, secondaryTypes, requestedProperties, requestedFuncs);
+        Properties props = getPropertiesFromObject(so, objectStore, primaryType, secondaryTypes, requestedProperties, requestedFuncs);
 
         // fill output object
         if (null != includeAllowableActions && includeAllowableActions) {
@@ -461,11 +473,14 @@ public final class PropertyCreationHelpe
             od.setAllowableActions(allowableActions);
         }
 
-        od.setAcl(so.getAcl());
+        int aclId = so.getAclId();
+        Acl acl = objectStore.getAcl(aclId);
+        od.setAcl(acl);
+
         od.setIsExactAcl(true);
 
         if (null != includeRelationships && includeRelationships != IncludeRelationships.NONE) {
-            od.setRelationships(DataObjectCreator.fillRelationships(tm, includeRelationships, so, user));
+            od.setRelationships(DataObjectCreator.fillRelationships(tm, objectStore, includeRelationships, so, user));
         }
 
         List<RenditionData> renditions = so.getRenditions(renditionFilter, 0, 0);
@@ -534,7 +549,7 @@ public final class PropertyCreationHelpe
         else if (propDef.getPropertyType().equals(PropertyType.DECIMAL))
         	emptyValue =  new PropertyDecimalImpl(propDef.getId(), (BigDecimal) null);
         else if (propDef.getPropertyType().equals(PropertyType.HTML))
-        	emptyValue =  new PropertyHtmlImpl(propDef.getId(), (String) null);
+            emptyValue =  new PropertyHtmlImpl(propDef.getId(), (String) null);
         else if (propDef.getPropertyType().equals(PropertyType.ID))
         	emptyValue =  new PropertyIdImpl(propDef.getId(), (String) null);
         else if (propDef.getPropertyType().equals(PropertyType.INTEGER))

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties Thu Aug  8 08:40:26 2013
@@ -25,6 +25,8 @@ InMemoryServer.User=dummyuser
 InMemoryServer.Password=dummysecret
 InMemoryServer.TypesCreatorClass=org.apache.chemistry.opencmis.inmemory.types.DefaultTypeSystemCreator
 InMemoryServer.TypeDefinitionsFile=types.xml
+InMemoryServer.Class=org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerImpl
+# InMemoryServer.Class=org.apache.chemistry.opencmis.inmemory.storedobj.dbimpl.StoreManagerImpl
 
 # InMemoryServer.MemoryThreshold=10485760
 # InMemoryServer.TempDir=/path/to/your/tmp
@@ -33,6 +35,7 @@ InMemoryServer.EncryptTempFiles=true
 
 # settings for init repository with data
   # enable or disable
+# RepositoryFiller.Enable=false
 RepositoryFiller.Enable=true
   # Type id of documents that are created
 RepositoryFiller.DocumentTypeId=ComplexType

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AclServiceTest.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/AclServiceTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AclServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AclServiceTest.java Thu Aug  8 08:40:26 2013
@@ -21,7 +21,6 @@ package org.apache.chemistry.opencmis.in
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
@@ -38,13 +37,12 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumBasicPermissions;
 import org.apache.chemistry.opencmis.inmemory.ObjectServiceTest.ObjectTestTypeSystemCreator;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.InMemoryAce;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AclServiceTest extends AbstractServiceTest {
 
@@ -52,8 +50,8 @@ public class AclServiceTest extends Abst
     private ObjectCreator fCreator;
     private static final String DOCUMENT_NAME = "DocumentWithAcl";
     private static final String FOLDER_NAME = "FolderWithAcl";
-    private static final String DOCUMENT_TYPE_ID = InMemoryDocumentTypeDefinition.getRootDocumentType().getId();
-    private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
+    private static final String DOCUMENT_TYPE_ID = DocumentTypeCreationHelper.getCmisDocumentType().getId();
+    private static final String FOLDER_TYPE_ID = DocumentTypeCreationHelper.getCmisFolderType().getId();
     private static final String USER = "user";
     private static final String ALICE = "alice";
     private static final String BOB = "bob";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.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/FolderTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java Thu Aug  8 08:40:26 2013
@@ -70,9 +70,9 @@ public class FolderTest extends TestCase
         assertNull(fRoot.getParentId());
         assertEquals(fRoot.getId(), f1.getParentId());
         assertEquals(f1.getId(), f11.getParentId());
-        assertEquals(Filing.PATH_SEPARATOR, fRoot.getPath());
-        assertEquals("/Folder 1", f1.getPath());
-        assertEquals("/Folder 1/Folder 1.1", f11.getPath());
+        assertEquals(Filing.PATH_SEPARATOR, getPath(fRoot));
+        assertEquals("/Folder 1", getPath(f1));
+        assertEquals("/Folder 1/Folder 1.1", getPath(f11));
         StoredObject fTest = fStore.getObjectByPath("/", USER);
         assertEquals(fRoot, fTest);
         fTest = fStore.getObjectByPath("/Folder 1", USER);
@@ -91,10 +91,10 @@ public class FolderTest extends TestCase
     public void testRenameFolder() {
         // rename top level folder
         String newName = "Folder B";
-        String oldPath = f2.getPath();
+        String oldPath = getPath(f2);
         fStore.rename(f2, newName);
         assertEquals(f2.getName(), newName);
-        assertEquals(f2.getPath(), Filing.PATH_SEPARATOR + newName);
+        assertEquals(getPath(f2), Filing.PATH_SEPARATOR + newName);
         assertNull(fStore.getObjectByPath(oldPath, USER));
         assertEquals(f2, fStore.getObjectByPath(Filing.PATH_SEPARATOR + newName, USER));
         try {
@@ -104,10 +104,10 @@ public class FolderTest extends TestCase
         }
 
         // rename sub folder
-        oldPath = f11.getPath();
+        oldPath = getPath(f11);
         fStore.rename(f11, newName);
         assertEquals(f11.getName(), newName);
-        assertEquals(f11.getPath(), "/Folder 1/Folder B");
+        assertEquals(getPath(f11), "/Folder 1/Folder B");
         assertNull(fStore.getObjectByPath(oldPath, USER));
         assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B", USER));
         try {
@@ -126,11 +126,11 @@ public class FolderTest extends TestCase
 
     @Test
     public void testMoveFolder() {
-        String oldPath = f1.getPath();
+        String oldPath = getPath(f1);
         Folder f1Parent = fRoot;
         fStore.move(f1, f1Parent, f3);
         assertNull(fStore.getObjectByPath(oldPath, USER));
-        assertEquals(f1.getPath(), "/Folder 3/Folder 1");
+        assertEquals(getPath(f1), "/Folder 3/Folder 1");
         assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1", USER));
 
         fStore.rename(f2, "Folder 1");
@@ -144,7 +144,7 @@ public class FolderTest extends TestCase
 
     @Test
     public void testDeleteFolder() {
-        String oldPath = f2.getPath();
+        String oldPath = getPath(f2);
         fStore.deleteObject(f2.getId(), true, "TestUser");
         assertNull(fStore.getObjectByPath(oldPath, USER));
 
@@ -158,22 +158,21 @@ public class FolderTest extends TestCase
     private void createFolders() {
         fRoot = (FolderImpl) fStore.getRootFolder();
         f1 = (FolderImpl) createFolder("Folder 1", fRoot);
-        f1.persist();
 
         f2 = (FolderImpl) createFolder("Folder 2", fRoot);
-        f2.persist();
 
         f3 = (FolderImpl) createFolder("Folder 3", fRoot);
-        f3.persist();
 
         f4 = (FolderImpl) createFolder("Folder 4", fRoot);
-        f4.persist();
 
         f11 = (FolderImpl) createFolder("Folder 1.1", f1);
-        f11.persist();
     }
     
     private Folder createFolder(String name, Folder parent) {
     	return fStore.createFolder(name, null, "user", parent, null, null, null);    	
     }
+    
+    private String getPath(Folder folder) {
+        return fStore.getFolderPath(folder.getId());
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.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/MultiFilingTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java Thu Aug  8 08:40:26 2013
@@ -40,18 +40,18 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MultiFilingTest extends AbstractServiceTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(MultiFilingTest.class);
     private static final String DOCUMENT_TYPE_ID = UnitTestTypeSystemCreator.COMPLEX_TYPE;
-    private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
+    private static final String FOLDER_TYPE_ID = DocumentTypeCreationHelper.getCmisFolderType().getId();
     private static final String UNFILED_DOC_NAME = "Unfiled document";
     private static final String RENAMED_DOC_NAME = "My Renamed Document";
 
@@ -178,6 +178,16 @@ public class MultiFilingTest extends Abs
         LOG.debug("End testRenameMultiFiledDocument()");
     }
 
+        
+    @Test
+    public void testRemoveDocumentFromAllFolders() {
+        LOG.debug("Begin testRemoveDocumentFromAllFolders()");
+
+        String docId = createUnfiledDocument();
+        removeDocumentFromAllFolders(docId);
+        LOG.debug("End testRemoveDocumentFromAllFolders()");
+    }
+    
     @Test
     public void testAddVersionedDocumentToFolder() {
         LOG.debug("Begin testAddVersionedDocumentToFolder()");
@@ -195,6 +205,15 @@ public class MultiFilingTest extends Abs
         LOG.debug("End testRemoveVersionedDocumentFromFolder()");
     }
 
+    @Test
+    public void testRemoveVersionedDocumentFromAllFolders() {
+        LOG.debug("Begin testRemoveVersionedDocumentFromAllFolders()");
+
+        String docId = createVersionedDocument();
+        removeDocumentFromAllFolders(docId);
+        LOG.debug("End testRemoveVersionedDocumentFromAllFolders()");
+    }
+    
     private void createFolders() {
         fId1 = createFolder("folder1", fRootFolderId, FOLDER_TYPE_ID);
         fId2 = createFolder("folder2", fRootFolderId, FOLDER_TYPE_ID);
@@ -249,6 +268,15 @@ public class MultiFilingTest extends Abs
         assertEquals(0, parents.size());
     }
 
+    private void removeDocumentFromAllFolders(String docId) {
+        prepareMultiFiledDocument(docId);
+
+        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, null, null);
+        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+        assertEquals(0, parents.size());
+    }
+    
     private String createUnfiledDocument() {
         return createDocument(UNFILED_DOC_NAME, null, DOCUMENT_TYPE_ID, true);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.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/NavigationServiceTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java Thu Aug  8 08:40:26 2013
@@ -36,13 +36,13 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Jens
@@ -205,8 +205,8 @@ public class NavigationServiceTest exten
     public void testGetPaging() {
         log.info("starting testGetPaging() ...");
         // create a folder
-        String folderId = super.createFolder("PagingFolder", fRootFolderId, InMemoryFolderTypeDefinition
-                .getRootFolderType().getId());
+        String folderId = super.createFolder("PagingFolder", fRootFolderId, DocumentTypeCreationHelper
+                .getCmisFolderType().getId());
         
         // create some documents
         for (int i=0; i<10; i++) {
@@ -275,8 +275,8 @@ public class NavigationServiceTest exten
         for (int i = 0; i < NUM_ROOT_FOLDERS; i++) {
             List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
             properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, "Folder " + i));
-            properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, InMemoryFolderTypeDefinition
-                    .getRootFolderType().getId()));
+            properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, DocumentTypeCreationHelper
+                    .getCmisFolderType().getId()));
             Properties props = fFactory.createPropertiesData(properties);
             String id = fObjSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
             if (i == 3) {



Mime
View raw message