You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2012/12/09 18:55:51 UTC

svn commit: r1419046 - in /chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmem...

Author: jens
Date: Sun Dec  9 17:55:48 2012
New Revision: 1419046

URL: http://svn.apache.org/viewvc?rev=1419046&view=rev
Log:
InMemory: more CMIS 1.1 support, support cmis:item, start supporting secondary types (work in progress)

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryItemTypeDefinition.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.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/DocumentImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.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/DefaultTypeSystemCreator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.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
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.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/TypeManagerImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java Sun Dec  9 17:55:48 2012
@@ -28,18 +28,23 @@ import java.util.Map.Entry;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.impl.Converter;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDefinitionType;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceContext;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.TypeManagerCreatable;
 import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.InMemoryItemTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryPolicyTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryRelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,10 +88,17 @@ public class TypeManagerImpl implements 
     public synchronized Collection<TypeDefinitionContainer> getTypeDefinitionList() {
 
         List<TypeDefinitionContainer> typeRoots = new ArrayList<TypeDefinitionContainer>();
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
+
         // iterate types map and return a list collecting the root types:
         for (TypeDefinitionContainer typeDef : fTypesMap.values()) {
             if (typeDef.getTypeDefinition().getParentTypeId() == null) {
-                typeRoots.add(typeDef);
+                if (cmis11) {
+                    typeRoots.add(typeDef);
+                } else if (!typeDef.getTypeDefinition().getId().equals(BaseTypeId.CMIS_ITEM.value()) && 
+                            ! typeDef.getTypeDefinition().getId().equals(BaseTypeId.CMIS_SECONDARY.value())) {
+                    typeRoots.add(typeDef);                        
+                }
             }
         }
 
@@ -237,7 +249,10 @@ public class TypeManagerImpl implements 
         if (c.getTypeDefinition().equals(InMemoryFolderTypeDefinition.getRootFolderType())
                 || c.getTypeDefinition().equals(InMemoryDocumentTypeDefinition.getRootDocumentType())
                 || c.getTypeDefinition().equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType())
-                || c.getTypeDefinition().equals(InMemoryPolicyTypeDefinition.getRootPolicyType())) {
+                || c.getTypeDefinition().equals(InMemoryPolicyTypeDefinition.getRootPolicyType())
+                || c.getTypeDefinition().equals(InMemoryItemTypeDefinition.getRootItemType()) // CMIS 1.1
+                || c.getTypeDefinition().equals(InMemorySecondaryTypeDefinition.getRootSecondaryType()) // CMIS 1.1
+                ) {
             return true;
         } else {
             return false;
@@ -251,18 +266,4 @@ public class TypeManagerImpl implements 
         return clone;
     }
 
-    // private static PropertyDefinition<?>
-    // clonePropertyDefinition2(PropertyDefinition<?> src)
-    // throws IOException, ClassNotFoundException {
-    // ByteArrayOutputStream bout = new ByteArrayOutputStream();
-    // ObjectOutputStream oout = new ObjectOutputStream(bout);
-    // oout.writeObject(src);
-    // byte[] bytes = bout.toByteArray();
-    //
-    // ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
-    // ObjectInputStream oin = new ObjectInputStream(bin);
-    // PropertyDefinition<?> clone = (PropertyDefinition<?>) oin.readObject();
-    // return clone;
-    // }
-
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.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/BaseServiceValidatorImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java Sun Dec  9 17:55:48 2012
@@ -18,8 +18,11 @@
  */
 package org.apache.chemistry.opencmis.inmemory.server;
 
+import java.util.List;
+
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -253,6 +256,12 @@ public class BaseServiceValidatorImpl im
     	 return checkStandardParameters(repositoryId, folderId);
     }
 
+    // CMIS 1.1
+    public StoredObject createItem(CallContext context, String repositoryId, Properties properties, String folderId,
+            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
+        return checkStandardParametersAllowNull(repositoryId, folderId);
+   }
+
     public StoredObject getAllowableActions(CallContext context, String repositoryId, String objectId,
             ExtensionsData extension) {
         //

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.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/InMemoryAbstractServiceImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java Sun Dec  9 17:55:48 2012
@@ -68,7 +68,7 @@ public class InMemoryAbstractServiceImpl
     protected TypeDefinition getTypeDefinition(String repositoryId, StoredObject obj) {
 
         TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, obj.getTypeId());
-        return typeDefC.getTypeDefinition();
+        return typeDefC == null ? null : typeDefC.getTypeDefinition();
     }
 
     /**

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -44,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
@@ -77,6 +78,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.InMemoryItemTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryPolicyTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryRelationshipTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -177,6 +179,13 @@ public class InMemoryObjectServiceImpl e
         return so == null ? null : so.getId();
     }
 
+    // CMIS 1.1
+    public String createItem(CallContext context, String repositoryId, Properties properties, String folderId, List<String> policies,
+            Acl addAces, Acl removeAces, ExtensionsData extension) {
+        StoredObject so = createItemIntern(context, repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+        return so.getId();
+    }
+
     @SuppressWarnings("unchecked")
     public String create(CallContext context, String repositoryId, Properties properties, String folderId,
             ContentStream contentStream, VersioningState versioningState, List<String> policies,
@@ -211,6 +220,8 @@ public class InMemoryObjectServiceImpl e
             so = createPolicyIntern(context, repositoryId, properties, folderId, null, null, null, null);
         } else if (typeBaseId.equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType().getBaseTypeId())) {
             so = createRelationshipIntern(context, repositoryId, properties, null, null, null, null);
+        } else if (typeBaseId.equals(InMemoryItemTypeDefinition.getRootItemType().getBaseTypeId())) {
+            so = createItemIntern(context, repositoryId, properties, folderId, null, null, null, null);
         } else {
             LOG.error("The type contains an unknown base object id, object can't be created");
         }
@@ -600,7 +611,8 @@ public class InMemoryObjectServiceImpl e
         Map<String, PropertyData<?>> oldProperties = so.getProperties();
 
         // check properties for validity
-        TypeValidator.validateProperties(typeDef, properties, false);
+        boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
+        validateProperties(repositoryId, so, properties, false, cmis11);
 
         if (changeToken != null && changeToken.getValue() != null
                 && Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue())) {
@@ -612,13 +624,15 @@ public class InMemoryObjectServiceImpl e
 
         if(properties != null) {
         	for (String key : properties.getProperties().keySet()) {
-        		if (key.equals(PropertyIds.NAME))
-        		{
+        		if (key.equals(PropertyIds.NAME)) {
         			continue; // ignore here
         		}
 
         		PropertyData<?> value = properties.getProperties().get(key);
         		PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(key);
+        		if (null == propDef) {
+        		    throw new CmisInvalidArgumentException("Cannot update property " + key + ": not contained in type");
+        		}
         		if (value.getValues() == null || value.getFirstValue() == null) {
         			// delete property
         			// check if a required a property
@@ -832,7 +846,8 @@ public class InMemoryObjectServiceImpl e
             propMap = propMapNew;
         }
 
-        TypeValidator.validateProperties(typeDef, properties, true);
+        boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
+        validateProperties(repositoryId, null, properties, false, cmis11);
 
         // set user, creation date, etc.
         if (user == null) {
@@ -888,7 +903,6 @@ public class InMemoryObjectServiceImpl e
         String user = context.getUsername();
 
         ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
-        StoredObject so = null;
         Folder parent = null;
 
         // get required properties
@@ -917,11 +931,13 @@ public class InMemoryObjectServiceImpl e
             properties = new PropertiesImpl(propMapNew.values());
         }
 
-        TypeValidator.validateProperties(typeDef, properties, true);
+        boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
+        validateProperties(repositoryId, null, properties, false, cmis11);
 
         // validate ACL
         TypeValidator.validateAcl(typeDef, addACEs, removeACEs);
 
+        StoredObject so = null;
         // create folder
         try {
             LOG.debug("get folder for id: " + folderId);
@@ -996,7 +1012,8 @@ public class InMemoryObjectServiceImpl e
            properties = new PropertiesImpl(propMapNew.values());
        }
 
-       TypeValidator.validateProperties(typeDef, properties, true);
+       boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
+       validateProperties(repositoryId, null, properties, false, cmis11);
 
        // validate ACL
        TypeValidator.validateAcl(typeDef, addACEs, removeACEs);
@@ -1013,6 +1030,84 @@ public class InMemoryObjectServiceImpl e
         return storedObject;
     }
 
+    private StoredObject createItemIntern(CallContext context, String repositoryId, Properties properties, String folderId,
+            List<String> policies, Acl addACEs, Acl removeACEs,  ExtensionsData extension) {
+
+        validator.createItem(context, repositoryId, properties, folderId, policies, addACEs, removeACEs, extension);
+        
+        addACEs  = org.apache.chemistry.opencmis.inmemory.TypeValidator.expandAclMakros(context.getUsername(), addACEs);
+        removeACEs  = org.apache.chemistry.opencmis.inmemory.TypeValidator.expandAclMakros(context.getUsername(), removeACEs);
+
+        validator.createDocument(context, repositoryId, folderId, extension);
+
+        // Validation stuff
+        TypeValidator.validateRequiredSystemProperties(properties);
+
+        String user = context.getUsername();
+        TypeDefinition typeDef = getTypeDefinition(repositoryId, properties);
+
+        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+        Map<String, PropertyData<?>> propMap = properties.getProperties();
+        // get name from properties
+        PropertyData<?> pd = propMap.get(PropertyIds.NAME);
+        String name = (String) pd.getFirstValue();
+
+
+        // validate ACL
+        TypeValidator.validateAcl(typeDef, addACEs, removeACEs);
+        
+        Folder folder = null;
+        if (null != folderId) {
+            StoredObject so = objectStore.getObjectById(folderId);
+
+            if (null == so) {
+                throw new CmisInvalidArgumentException(" Cannot create item, folderId: " + folderId + " is invalid");
+            }
+
+            if (so instanceof Folder) {
+                folder = (Folder) so;
+            } else {
+                throw new CmisInvalidArgumentException("Can't create item, folderId does not refer to a folder: "
+                        + folderId);
+            }
+
+            TypeValidator.validateAllowedChildObjectTypes(typeDef, folder.getAllowedChildObjectTypeIds());
+        }
+
+        // check if the given type is an item type
+        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_ITEM)) {
+            throw new CmisInvalidArgumentException("Cannot create an item, with a non-item type: " + typeDef.getId());
+        }
+
+        // check name syntax
+        if (!NameValidator.isValidName(name)) {
+            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME + " Name is: " + name);
+        }
+
+        // set properties that are not set but have a default:
+        Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
+        if (propMapNew != propMap) {
+            properties = new PropertiesImpl(propMapNew.values());
+            propMap = propMapNew;
+        }
+
+        boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
+        validateProperties(repositoryId, null, properties, false, cmis11);
+
+        // set user, creation date, etc.
+        if (user == null) {
+            user = "unknown";
+        }
+
+        StoredObject so = null;
+
+        // Now we are sure to have document type definition:
+        so = objectStore.createItem(name, propMap, user, folder, addACEs, removeACEs);
+        so.persist();
+        
+        return so;
+
+    }
 
     private static boolean hasDescendant(Folder sourceFolder, Folder targetFolder) {
         String sourceId = sourceFolder.getId();
@@ -1112,4 +1207,40 @@ public class InMemoryObjectServiceImpl e
         }
         return properties;
     }
+    
+    private void validateProperties(String repositoryId, StoredObject so, Properties properties, boolean checkMandatory, boolean cmis11) {
+        TypeDefinition typeDef;
+        
+        if (null != so)
+            typeDef = getTypeDefinition(repositoryId, so);
+        else
+            typeDef = getTypeDefinition(repositoryId, properties);
+            
+        // check properties for validity
+        TypeValidator.validateProperties(typeDef, properties, cmis11, checkMandatory, cmis11);
+        
+        if (!cmis11)
+            return;
+        
+        // CMIS 1.1 secondary types
+        PropertyData<?> pd = properties.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+        
+        @SuppressWarnings("unchecked")
+        List<String> secondaryTypeIds = (List<String>) (pd == null ? null : pd.getValues());
+        if (null != so && (null == secondaryTypeIds || secondaryTypeIds.size() == 0)) {
+            secondaryTypeIds = so.getSecondaryTypeIds();
+        }
+        
+        if (null != secondaryTypeIds && secondaryTypeIds.size() != 0) {
+            // check if they are all valid
+            for (String typeId : secondaryTypeIds) {
+                TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
+                typeDef =  typeDefC == null ? null : typeDefC.getTypeDefinition();
+                if (null == typeDef) {
+                    throw new CmisInvalidArgumentException("Cannot set secondary type, a type with id " + typeId + " is unknown");                    
+                }
+                TypeValidator.validateProperties(typeDef, properties, true, checkMandatory, true);
+            }
+        }
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.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/InMemoryRepositoryServiceImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java Sun Dec  9 17:55:48 2012
@@ -72,8 +72,7 @@ public class InMemoryRepositoryServiceIm
 
         boolean inclPropDefs = includePropertyDefinitions == null ? false : includePropertyDefinitions;
         getRepositoryInfoFromStoreManager(repositoryId); // just to check if
-        // repository
-        // exists
+        // repository exists
 
         int skip = skipCount == null ? 0 : skipCount.intValue();
         int max = maxItems == null ? -1 : maxItems.intValue();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.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/InMemoryService.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java Sun Dec  9 17:55:48 2012
@@ -237,6 +237,12 @@ public class InMemoryService extends Abs
     }
 
     @Override
+    public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies,
+            Acl addAces, Acl removeAces, ExtensionsData extension) {
+        return fObjSvc.createItem(getCallContext(), repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+    }
+
+    @Override
     public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
             ExtensionsData extension) {
         fObjSvc.deleteContentStream(getCallContext(), repositoryId, objectId, changeToken, extension);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.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/CmisServiceValidator.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java Sun Dec  9 17:55:48 2012
@@ -18,8 +18,11 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.api;
 
+import java.util.List;
+
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -107,6 +110,7 @@ public interface CmisServiceValidator {
     StoredObject setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
             Boolean overwriteFlag, ExtensionsData extension);
     
+    // CMIS 1.1
     StoredObject appendContentStream(CallContext context, String repositoryId, Holder<String> objectId,
             ExtensionsData extension);
 
@@ -162,9 +166,11 @@ public interface CmisServiceValidator {
     StoredObject create(CallContext context, String repositoryId, String folderId,
             ExtensionsData extension);
 
-//    StoredObject deleteObjectOrCancelCheckOut(CallContext context, String repositoryId,
-//            String objectId, ExtensionsData extension);
-
     StoredObject applyAcl(CallContext context, String repositoryId, String objectId);
 
+    // CMIS 1.1
+    StoredObject createItem(CallContext context, String repositoryId, Properties properties, String folderId,
+            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension);
+
+
  }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.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/ObjectStore.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java Sun Dec  9 17:55:48 2012
@@ -101,7 +101,7 @@ public interface ObjectStore {
 
     /**
      * Create a folder as initial step. The folder is created but still
-     * temporary It is not yet persisted and does not have an id yet. After this
+     * temporary. It is not yet persisted and does not have an id yet. After this
      * call additional actions can take place (like assigning properties and a
      * type) before it is persisted.
      * 
@@ -147,6 +147,29 @@ public interface ObjectStore {
 			Acl addACEs, Acl removeACEs, ContentStream contentStream, VersioningState versioningState);
 
     /**
+     * Create an item as initial step. The item is created but still
+     * temporary. It is not yet persisted and does not have an id yet. After this
+     * call additional actions can take place (like assigning properties and a
+     * type) before it is persisted.
+     * 
+     * @param name
+     *            name of the document
+     * @param propMap
+     *            map of properties   
+     * @param user
+     *            the user who creates the document
+     * @param folder
+     *            the parent folder 
+     * @param addACEs
+     *            aces that are added 
+     * @param removeACEs 
+     *            aces that are removed
+     * @return document object
+     */
+    StoredObject createItem(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
+            Acl addACEs, Acl removeACEs);
+
+    /**
      * Clear repository and remove all data.
      */
     void clear();

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -92,6 +92,29 @@ public interface StoredObject {
      *            id of the type this object gets assigned.
      */
     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
+     */
+    List<String> getSecondaryTypeIds();
 
     /**
      * CMIS 1.1: set description of an object

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.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/DocumentImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java Sun Dec  9 17:55:48 2012
@@ -28,6 +28,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.data.RenditionData;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
@@ -35,6 +36,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
 import org.apache.chemistry.opencmis.inmemory.ConfigurationSettings;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceContext;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -182,6 +184,14 @@ public class DocumentImpl extends Abstra
                     (String) null));
         }
         
+        // CMIS 1.1
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
+
+        if (cmis11 && FilterParser.isContainedInFilter(PropertyIds.IS_PRIVATE_WORKING_COPY, requestedIds)) {
+            properties.put(PropertyIds.IS_PRIVATE_WORKING_COPY,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_PRIVATE_WORKING_COPY, (Boolean) null));
+        }
+        
     }
 
     public boolean hasContent() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.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/DocumentVersionImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Sun Dec  9 17:55:48 2012
@@ -27,12 +27,14 @@ import java.util.Map.Entry;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
 import org.apache.chemistry.opencmis.inmemory.ConfigurationSettings;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceContext;
 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.VersionedDocument;
@@ -267,6 +269,16 @@ public class DocumentVersionImpl extends
                         PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
             }
         }
+
+        // CMIS 1.1
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
+
+        if (cmis11 && FilterParser.isContainedInFilter(PropertyIds.IS_PRIVATE_WORKING_COPY, requestedIds)) {
+            properties.put(PropertyIds.IS_PRIVATE_WORKING_COPY,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_PRIVATE_WORKING_COPY, isPwc()));
+        }
+        
+        
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.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/FolderImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java Sun Dec  9 17:55:48 2012
@@ -93,6 +93,10 @@ public class FolderImpl extends Abstract
         addChildObject(doc);
     }
 
+    public void addChildItem(StoredObject item) {
+        addChildObject(item);
+    }
+
     private void addChildObject(StoredObject so) {
         try {
             fObjStore.lock();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.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/InMemoryServiceValidatorImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java Sun Dec  9 17:55:48 2012
@@ -18,8 +18,11 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
+import java.util.List;
+
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -263,6 +266,15 @@ public class InMemoryServiceValidatorImp
         return so;
     }
 
+    @Override
+    public StoredObject createItem(CallContext context, String repositoryId, Properties properties, String folderId,
+            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
+        StoredObject folder = super.createFolder(context, repositoryId, folderId, extension);
+        if (null != folder) // not if unfiled
+            checkWriteAccess(repositoryId, context.getUsername(), folder);
+        return folder;        
+    }
+
     /* (non-Javadoc)
      * @see org.apache.chemistry.opencmis.inmemory.server.BaseServiceValidatorImpl#getAllowableActions(org.apache.chemistry.opencmis.commons.server.CallContext, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
      */

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.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/ItemImpl.java?rev=1419046&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java Sun Dec  9 17:55:48 2012
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
+
+/**
+ * itemImpl is used for CMIS:item objects. Items are fileable  but do not have content
+ *
+ */
+public class ItemImpl extends AbstractMultiFilingImpl {
+
+    ItemImpl(ObjectStoreImpl objStore) {
+        super(objStore);
+    }
+
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.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/ObjectStoreImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java Sun Dec  9 17:55:48 2012
@@ -267,6 +267,21 @@ public class ObjectStoreImpl implements 
         return doc;
     }
 
+    public StoredObject createItem(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
+            Acl addACEs, Acl removeACEs) {
+        StoredObjectImpl item = new ItemImpl(this);
+        item.createSystemBasePropertiesWhenCreated(propMap, user);
+        item.setCustomProperties(propMap);
+        item.setRepositoryId(fRepositoryId);
+        item.setName(name);
+        if (null != folder) {
+            ((FolderImpl)folder).addChildItem(item); // add document to folder and
+        }
+        int aclId = getAclId(((FolderImpl)folder), addACEs, removeACEs);
+        item.setAclId(aclId);
+        return item;
+    }
+    
     public DocumentVersion createVersionedDocument(String name,
     		Map<String, PropertyData<?>> propMap, String user, Folder folder,
 			Acl addACEs, Acl removeACEs, ContentStream contentStream, VersioningState versioningState) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.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/StoreManagerImpl.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Sun Dec  9 17:55:48 2012
@@ -225,7 +225,24 @@ public class StoreManagerImpl implements
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
         }
         List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
-
+        
+        // remove cmis:item and cmis:secondary for CMIS 1.0
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
+        if (!cmis11) {
+            rootTypes = new ArrayList<TypeDefinitionContainer>(rootTypes);
+            TypeDefinitionContainer tcItem = null, tcSecondary = null;
+            for(TypeDefinitionContainer tc : rootTypes) {
+                if (tc.getTypeDefinition().getId().equals(BaseTypeId.CMIS_ITEM.value()))
+                    tcItem = tc;
+                if (tc.getTypeDefinition().getId().equals(BaseTypeId.CMIS_SECONDARY.value()))
+                    tcSecondary = tc;
+            }
+            if (tcItem != null)
+                rootTypes.remove(tcItem);
+            if (tcSecondary != null)
+                rootTypes.remove(tcSecondary);
+        }
+        
         return rootTypes;
     }
 

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -23,6 +23,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
@@ -72,6 +74,7 @@ public class StoredObjectImpl implements
     protected final ObjectStoreImpl fObjStore;
     protected int fAclId;
     protected String description; // CMIS 1.1
+    protected List<String> secondaryTypeIds; // CMIS 1.1
 
     StoredObjectImpl(ObjectStoreImpl objStore) { // visibility should be package
         GregorianCalendar now = getNow();
@@ -79,6 +82,7 @@ public class StoredObjectImpl implements
         fCreatedAt = now;
         fModifiedAt = now;
         fObjStore = objStore;
+        secondaryTypeIds = new ArrayList<String>();
     }
 
     public String getId() {
@@ -151,6 +155,18 @@ 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);
+    }
+
     public void setProperties(Map<String, PropertyData<?>> props) {
         fProperties = props;
     }
@@ -268,6 +284,9 @@ 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 (isCreated) {
             setCreatedBy(user);
             setName((String) properties.get(PropertyIds.NAME).getFirstValue());

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -45,6 +45,7 @@ public class DefaultTypeSystemCreator im
     public static final String COMPLEX_TYPE = "ComplexType";
     public static final String TOPLEVEL_TYPE = "DocumentTopLevel";
     public static final String VERSIONED_TYPE = "VersionableType";
+    public static final String ITEM_TYPE = "MyItemType";
     public static final String LEVEL1_TYPE = "DocumentLevel1";
     public static final String LEVEL2_TYPE = "DocumentLevel2";
 
@@ -282,6 +283,21 @@ public class DefaultTypeSystemCreator im
 
         // 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);
 
         return typesList;
     }

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -67,6 +67,13 @@ public class DocumentTypeCreationHelper 
         // cmisType = PolicyTypeDefinition.getRootPolicyType();
         // typesList.add(cmisType);
 
+        // CMIS 1.1
+        cmisType = InMemoryItemTypeDefinition.getRootItemType();
+        typesList.add(cmisType);
+        
+        cmisType = InMemorySecondaryTypeDefinition.getRootSecondaryType();
+        typesList.add(cmisType);
+
         return typesList;
     }
 
@@ -121,6 +128,9 @@ public class DocumentTypeCreationHelper 
         propS = PropertyCreationHelper.createStringDefinition(PropertyIds.DESCRIPTION, "Description", Updatability.READWRITE);
         propertyDefinitions.put(propS.getId(), propS);
 
+        propId = PropertyCreationHelper.createIdDefinition(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, "Secondary Type Ids",
+                Updatability.READONLY);
+        propertyDefinitions.put(propId.getId(), propId);
     }
 
     public static void setBasicDocumentPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
@@ -184,6 +194,12 @@ public class DocumentTypeCreationHelper 
         propId = PropertyCreationHelper.createIdDefinition(PropertyIds.CONTENT_STREAM_ID, "Stream Id", Updatability.READONLY);
         propertyDefinitions.put(propId.getId(), propId);
 
+        // CMIS 1.1:
+        propB = PropertyCreationHelper.createBooleanDefinition(PropertyIds.IS_PRIVATE_WORKING_COPY, "Private Working Copy", 
+                Updatability.READONLY);
+        propertyDefinitions.put(propB.getId(), propB);
+
+        propertyDefinitions.put(propS.getId(), propS);
     }
 
     public static void setBasicFolderPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
@@ -201,7 +217,6 @@ public class DocumentTypeCreationHelper 
         PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(PropertyIds.PATH,
                 "Path", Updatability.READONLY);
         propertyDefinitions.put(propS.getId(), propS);
-
     }
 
     public static void setBasicPolicyPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryItemTypeDefinition.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/InMemoryItemTypeDefinition.java?rev=1419046&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryItemTypeDefinition.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemoryItemTypeDefinition.java Sun Dec  9 17:55:48 2012
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ItemTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
+import org.apache.chemistry.opencmis.inmemory.NameValidator;
+
+public class InMemoryItemTypeDefinition extends ItemTypeDefinitionImpl {
+
+    private static final long serialVersionUID = 1L;
+    private static final InMemoryItemTypeDefinition ITEM_TYPE = new InMemoryItemTypeDefinition();
+
+    public static InMemoryItemTypeDefinition getRootItemType() {
+        return ITEM_TYPE;
+    }
+
+    /* This constructor is just for creating the root document */
+    public InMemoryItemTypeDefinition() {
+        init(BaseTypeId.CMIS_ITEM.value(), "CMIS Item");
+        setParentTypeId(null);
+        // set base properties
+        Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+        DocumentTypeCreationHelper.setBasicPropertyDefinitions(props);
+    }
+
+    public InMemoryItemTypeDefinition(String id, String displayName) {
+        init(id, displayName);
+        setParentTypeId(ITEM_TYPE.getId());
+    }
+
+    public InMemoryItemTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
+        // get root type
+        init(id, displayName);
+        if (parentType != null) {
+            setBaseTypeId(parentType.getBaseTypeId());
+        } else {
+            throw new IllegalArgumentException("Must provide a parent type when creating a document type definition");
+        }
+        setParentTypeId(parentType.getId());
+    }
+
+    /**
+     * Set the property definitions for this type. The parameter
+     * propertyDefinitions should only contain the custom property definitions
+     * for this type. The standard property definitions are added automatically.
+     *
+     * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+     * setPropertyDefinitions(java.util.Map)
+     */
+    public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+        DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+    }
+
+    private void init(String id, String displayName) {
+        if (!NameValidator.isValidId(id)) {
+            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_ID);
+        }
+
+        setBaseTypeId(BaseTypeId.CMIS_ITEM);
+        setId(id);
+        if (displayName == null) {
+            displayName = id;
+        }
+        setDisplayName(displayName);
+        // create some suitable defaults for convenience
+        setDescription("Description of " + getDisplayName() + " Type");
+        setLocalName(id);
+        setLocalNamespace("local");
+        setQueryName(id);
+        setIsControllableAcl(true);
+        setIsControllablePolicy(false);
+        setIsCreatable(false);
+        setIsFileable(true);
+        setIsFulltextIndexed(false);
+        setIsIncludedInSupertypeQuery(true);
+        setIsQueryable(true);
+
+        TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+        typeMutability.setCanCreate(true);
+        typeMutability.setCanDelete(false);
+        typeMutability.setCanCreate(false);
+        setTypeMutability (typeMutability);
+
+        Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+        setPropertyDefinitions(props); // set initial empty set of properties
+    }
+}

Added: 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=1419046&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/InMemorySecondaryTypeDefinition.java Sun Dec  9 17:55:48 2012
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.SecondaryTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
+import org.apache.chemistry.opencmis.inmemory.NameValidator;
+
+public class InMemorySecondaryTypeDefinition extends SecondaryTypeDefinitionImpl {
+
+    private static final long serialVersionUID = 1L;
+    private static final InMemorySecondaryTypeDefinition SECONDARY_TYPE = new InMemorySecondaryTypeDefinition();
+
+    public static InMemorySecondaryTypeDefinition getRootSecondaryType() {
+        return SECONDARY_TYPE;
+    }
+
+    /* This constructor is just for creating the root document */
+    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) {
+        init(id, displayName);
+        setParentTypeId(SECONDARY_TYPE.getId());
+    }
+
+    public InMemorySecondaryTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
+        // get root type
+        init(id, displayName);
+        if (parentType != null) {
+            setBaseTypeId(parentType.getBaseTypeId());
+        } else {
+            throw new IllegalArgumentException("Must provide a parent type when creating a document type definition");
+        }
+        setParentTypeId(parentType.getId());
+    }
+
+    /**
+     * Set the property definitions for this type. The parameter
+     * propertyDefinitions should only contain the custom property definitions
+     * for this type. The standard property definitions are added automatically.
+     *
+     * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#
+     * setPropertyDefinitions(java.util.Map)
+     */
+    public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+        DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+    }
+
+    private void init(String id, String displayName) {
+        if (!NameValidator.isValidId(id)) {
+            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_ID);
+        }
+
+        setBaseTypeId(BaseTypeId.CMIS_SECONDARY);
+        setId(id);
+        if (displayName == null) {
+            displayName = id;
+        }
+        setDisplayName(displayName);
+        // create some suitable defaults for convenience
+        setDescription("Description of " + getDisplayName() + " Type");
+        setLocalName(id);
+        setLocalNamespace("local");
+        setQueryName(id);
+        setIsControllableAcl(true);
+        setIsControllablePolicy(false);
+        setIsCreatable(false);
+        setIsFileable(false);
+        setIsFulltextIndexed(false);
+        setIsIncludedInSupertypeQuery(true);
+        setIsQueryable(false);
+
+        TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+        typeMutability.setCanCreate(true);
+        typeMutability.setCanDelete(false);
+        typeMutability.setCanCreate(false);
+        setTypeMutability (typeMutability);
+
+        Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+        setPropertyDefinitions(props); // set initial empty set of properties
+
+    }
+}

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -72,6 +72,8 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.DocumentImpl;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.InMemoryItemTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
 import org.junit.After;
@@ -106,6 +108,8 @@ public class ObjectServiceTest extends A
     private static final String TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT = "MyCustomDocumentIntPropMandatoryDefault";
     private static final String TEST_DOCUMENT_MY_SUB_STRING_PROP_ID = "MyInheritedStringProp";
     private static final String TEST_DOCUMENT_MY_SUB_INT_PROP_ID = "MyInheritedIntProp";
+    private static final String TEST_ITEM_TYPE_ID = "MyItemType";
+    private static final String ITEM_STRING_PROP = "ItemStringProp";
     private static final String DOCUMENT_TYPE_ID = InMemoryDocumentTypeDefinition.getRootDocumentType().getId();
     private static final String DOCUMENT_ID = "Document_1";
     private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
@@ -116,6 +120,9 @@ public class ObjectServiceTest extends A
     private static final String JPEG = "image/jpeg";
     private static final String NEW_STRING_PROP_VAL = "My ugly string 1";
     private static final BigInteger NEW_INT_PROP_VAL = BigInteger.valueOf(815);
+    public static final String TEST_SECONDARY_TYPE_ID = "MySecondaryType";
+    public static final String SECONDARY_STRING_PROP = "SecondaryStringProp";
+    public static final String SECONDARY_INTEGER_PROP = "SecondaryIntegerProp";
 
     ObjectCreator fCreator;
 
@@ -1147,6 +1154,89 @@ public class ObjectServiceTest extends A
         log.info("... testBulkUpdateProperties() finished.");
     }
 
+    // CMIS 1.1: test item typpe
+    @Test
+    public void testItemCreation() {
+ 
+        log.info("starting testItemCreation() ...");
+        String propVal = "abc123";
+        String name = "CoolItem";
+        String id = createItem(name, fRootFolderId, propVal);
+        if (id != null) {
+            log.info("testItemCreation succeeded with created id: " + id);
+        }
+        log.info("... testCreateObject() finished.");
+        
+        // read document again and check properties
+        ObjectData res = getDocumentObjectData(id);
+        String returnedId = res.getId();
+        Map<String, PropertyData<?>> props = res.getProperties().getProperties();
+        testReturnedProperties(returnedId, name, TEST_ITEM_TYPE_ID, props);
+        PropertyData<?> pd = props.get(ITEM_STRING_PROP);
+        assertEquals(propVal, pd.getFirstValue());
+        assertEquals(12, props.size()); // should not contain all the document properties
+        log.info("... finished testItemCreation()");
+    }
+    
+    @Test
+    public void testSecondaryTypes() {
+        log.info("starting testItemCreation() ...");
+        final String strPropVal = "Secondary";
+        final BigInteger intPropVal = BigInteger.valueOf(100);
+        final String primaryPropVal = "Sample Doc String Property";
+        
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(fFactory.createPropertyIdData(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);
+        
+        Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
+        assertNotNull(res.getProperties());
+        Map<String, PropertyData<?>> returnedProps = res.getProperties();
+        assertNotNull(returnedProps);
+        String returnedValueStr = (String) returnedProps.get(SECONDARY_STRING_PROP).getFirstValue();
+        BigInteger returnedValueInt = (BigInteger) returnedProps.get(SECONDARY_INTEGER_PROP).getFirstValue();
+        assertEquals(strPropVal, returnedValueStr);
+        assertEquals(intPropVal, returnedValueInt);
+        String returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
+        assertEquals(primaryPropVal, returnedPrimaryPropVal);
+        
+        // test updating properties
+        final String strPropVal2 = "Secondary updated";
+        final String primaryPropVal2 = "Sample Doc String Property updated";
+        properties = new ArrayList<PropertyData<?>>();
+        properties.add(fFactory.createPropertyStringData(SECONDARY_STRING_PROP, strPropVal2));
+        properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID, primaryPropVal));
+        props = fFactory.createPropertiesData(properties);
+//        fObjSvc.updateProperties(fRepositoryId, new Holder<String>(id), new Holder<String>(), props, null);
+//        
+//        res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
+//        assertNotNull(res.getProperties());
+//        returnedProps = res.getProperties();
+//        assertNotNull(returnedProps);
+//        returnedValueStr = (String) returnedProps.get(SECONDARY_STRING_PROP).getFirstValue();
+//        returnedValueInt = (BigInteger) returnedProps.get(SECONDARY_INTEGER_PROP).getFirstValue();
+//        assertEquals(strPropVal2, returnedValueStr);
+//        assertEquals(intPropVal, returnedValueInt);
+//        returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
+//        assertEquals(primaryPropVal2, returnedPrimaryPropVal);
+      
+        log.info("... finished testSecondaryTypes()");        
+    }
+    
+    // TODO: test add secondary type
+    // TODO: remove secondary type
+    // TODO: test constraints on secondary types
+    
+    
     private void verifyUpdatedProperties(String id, String name) {
         
         ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
@@ -1333,6 +1423,18 @@ public class ObjectServiceTest extends A
         return createDocument(name, folderId, DOCUMENT_TYPE_ID, withContent);
     }
 
+    private String createItem(String name, String folderId, String itemPropVal) {
+        
+        // create the properties:
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, name));
+        properties.add(fFactory.createPropertyStringData(ITEM_STRING_PROP, itemPropVal));
+        properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, TEST_ITEM_TYPE_ID));
+        Properties props = fFactory.createPropertiesData(properties);
+
+        return fObjSvc.createItem(fRepositoryId, props, folderId, null, null, null, null);
+    }
+
     private Properties createDocumentPropertiesForDocumentFromSource(String name) {
         // We only provide a name but not a type id, as spec says to copy
         // missing attributes
@@ -1467,6 +1569,7 @@ public class ObjectServiceTest extends A
             InMemoryDocumentTypeDefinition noContentType = createCustomTypeNoContent();
             InMemoryDocumentTypeDefinition mustHaveContentType = createCustomTypeMustHaveContent();
 
+            
             // add type to types collection
             typesList.add(cmisDocumentType);
             typesList.add(cmisFolderType);
@@ -1476,6 +1579,9 @@ public class ObjectServiceTest extends A
             typesList.add(createCustomInheritedType(customDocType));
             typesList.add(createDocumentTypeWithDefault());
             typesList.add(createFolderTypeWithDefault());
+            typesList.add(createItemType());
+            typesList.add(createSecondaryType());
+            
             return typesList;
         }
 
@@ -1596,6 +1702,43 @@ public class ObjectServiceTest extends A
 
             return cmisFolderType;
         }
+        
+        private static InMemoryItemTypeDefinition createItemType() {
+            //CMIS 1.1 create an item item type
+
+            InMemoryItemTypeDefinition cmisItemType = new InMemoryItemTypeDefinition(TEST_ITEM_TYPE_ID, "MyItemType");
+            // create a single String property definition
+
+            Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+            propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+            PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(ITEM_STRING_PROP,
+                    "Item String Property", Updatability.READWRITE);
+            propertyDefinitions.put(prop1.getId(), prop1);
+            cmisItemType.addCustomPropertyDefinitions(propertyDefinitions);
+            // add type to types collection
+            return cmisItemType;            
+        }
+        
+        private static InMemorySecondaryTypeDefinition createSecondaryType() {
+            //CMIS 1.1 create an item item type
+
+            InMemorySecondaryTypeDefinition cmisSecondaryType = new InMemorySecondaryTypeDefinition(TEST_SECONDARY_TYPE_ID, 
+                    "MySecondaryType");
+            // create a single String property definition
+
+            Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+            propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+            PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
+                    "Secondary String Property", Updatability.READWRITE);
+            propertyDefinitions.put(prop1.getId(), prop1);
+            PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
+                    "Secondary Integer Property", Updatability.READWRITE);
+            prop2.setIsRequired(true);
+            propertyDefinitions.put(prop2.getId(), prop2);
+            cmisSecondaryType.addCustomPropertyDefinitions(propertyDefinitions);
+
+            return cmisSecondaryType;            
+        }
     }
 
 }

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=1419046&r1=1419045&r2=1419046&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 Sun Dec  9 17:55:48 2012
@@ -127,7 +127,7 @@ public class RepositoryServiceTest exten
         int totalSize = getRecursiveSize(types);
 
         assertEquals(expectedSize, totalSize);
-        assertEquals(2, types.size());
+        assertEquals(4, types.size());
 
         for (TypeDefinitionContainer type : types) {
             assertNotNull(type);
@@ -502,6 +502,8 @@ public class RepositoryServiceTest exten
         } else if (baseTypeId.equals(BaseTypeId.CMIS_RELATIONSHIP.value())) {
             assertTrue(propDefs.containsKey(PropertyIds.SOURCE_ID));
             assertTrue(propDefs.containsKey(PropertyIds.TARGET_ID));
+        } else if (baseTypeId.equals(BaseTypeId.CMIS_ITEM.value())) {
+        } else if (baseTypeId.equals(BaseTypeId.CMIS_SECONDARY.value())) {
         } else {
             fail("Unknown base type id in type definition");
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java?rev=1419046&r1=1419045&r2=1419046&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java Sun Dec  9 17:55:48 2012
@@ -244,44 +244,52 @@ public class TypeValidator {
         }
     }
 
-    @SuppressWarnings("unchecked")
     public static <T> void validateProperties(TypeDefinition typeDef, Properties properties, boolean checkMandatory) {
+        validateProperties(typeDef, properties, false, checkMandatory, false);
+    }
+
+    public static <T> void validateProperties(TypeDefinition typeDef, Properties properties, boolean checkMandatory, boolean cmis11) {
+
+        validateProperties(typeDef, properties, false, checkMandatory, cmis11);
+    }
 
+    public static <T> void validateProperties(TypeDefinition typeDef, Properties properties, boolean allowUnknowns, boolean checkMandatory, boolean cmis11) {
         List<String> propDefsRequired = getMandatoryPropDefs(typeDef.getPropertyDefinitions());
 
         if(properties != null) {
-			for (PropertyData<?> prop : properties.getProperties().values()) {
-				String propertyId = prop.getId();
-				BaseTypeId baseTypeId = typeDef.getBaseTypeId();
-
-				// check that all mandatory attributes are present
-				if (checkMandatory && propDefsRequired.contains(propertyId)) {
-					propDefsRequired.remove(propertyId);
-				}
-
-				if (isSystemProperty(baseTypeId, propertyId)) {
-					continue; // ignore system properties for validation
-				}
-
-				// Check if all properties are known in the type
-				if (!typeContainsProperty(typeDef, propertyId)) {
-					throw new CmisConstraintException("Unknown property "
-							+ propertyId + " in type " + typeDef.getId());
-				}
-
-				// check all type specific constraints:
-				PropertyDefinition<T> propDef = getPropertyDefinition(typeDef,
-						propertyId);
-				PropertyValidator<T> validator = createPropertyValidator(propDef);
-				validator.validate(propDef, (PropertyData<T>) prop);
-			}
+            for (PropertyData<?> prop : properties.getProperties().values()) {
+                String propertyId = prop.getId();
+                BaseTypeId baseTypeId = typeDef.getBaseTypeId();
+
+                // check that all mandatory attributes are present
+                if (checkMandatory && propDefsRequired.contains(propertyId)) {
+                    propDefsRequired.remove(propertyId);
+                }
+
+                if (isSystemProperty(baseTypeId, propertyId, cmis11)) {
+                    continue; // ignore system properties for validation
+                }
+
+                // Check if all properties are known in the type
+                if (typeContainsProperty(typeDef, propertyId)) {
+                    // check all type specific constraints:
+                    PropertyDefinition<T> propDef = getPropertyDefinition(typeDef,
+                            propertyId);
+                    PropertyValidator<T> validator = createPropertyValidator(propDef);
+                    validator.validate(propDef, (PropertyData<T>) prop);
+                }
+                else if (!allowUnknowns) {
+                    throw new CmisConstraintException("Unknown property "
+                            + propertyId + " in type " + typeDef.getId());
+                }
+            }
         }
 
         if (checkMandatory && !propDefsRequired.isEmpty()) {
             throw new CmisConstraintException("The following mandatory properties are missing: " + propDefsRequired);
-        }
+        }    
     }
-
+    
     public static void validateVersionStateForCreate(DocumentTypeDefinition typeDef, VersioningState verState) {
         if (null == verState) {
             return;
@@ -397,7 +405,7 @@ public class TypeValidator {
         }
     }
 
-    private static boolean isSystemProperty(BaseTypeId baseTypeId, String propertyId) {
+    private static boolean isSystemProperty(BaseTypeId baseTypeId, String propertyId, boolean cmis11) {
 
         if (propertyId.equals(PropertyIds.NAME)) {
             return true;
@@ -417,6 +425,10 @@ public class TypeValidator {
             return true;
         } else if (propertyId.equals(PropertyIds.CHANGE_TOKEN)) {
             return true;
+        } else if (cmis11 && propertyId.equals(PropertyIds.DESCRIPTION)) {
+            return true;
+        } else if (cmis11 && propertyId.equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS)) {
+            return true;
         }
 
         if (baseTypeId.equals(BaseTypeId.CMIS_DOCUMENT)) {