Author: jens
Date: Thu Oct 16 05:29:09 2014
New Revision: 1632214

URL: http://svn.apache.org/r1632214
Log:
InMemory: do not pass TypeMutability info in type def for CMIS 1.0 endpoints

Modified:
    
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/storedobj/impl/StoreManagerImpl.java

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=1632214&r1=1632213&r2=1632214&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
 Thu Oct 16 05:29:09 2014
@@ -97,6 +97,7 @@ public class InMemoryRepositoryServiceIm
         }
 
         result.setList(childrenTypes);
+
         return result;
     }
 

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=1632214&r1=1632213&r2=1632214&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
 Thu Oct 16 05:29:09 2014
@@ -177,6 +177,11 @@ public class StoreManagerImpl implements
                     || td.getId().equals(BaseTypeId.CMIS_ITEM.value())
                     || td.getId().equals(BaseTypeId.CMIS_SECONDARY.value())) {
                 tdc = null; // filter new types for CMIS 1.0
+            } else {
+               // remove type mutability information:
+                MutableTypeDefinition tdm = typeFactory.copy(td, true);
+                tdm.setTypeMutability(null);
+                tdc = new TypeDefinitionContainerImpl(tdm);
             }
         }
         return tdc;
@@ -192,10 +197,11 @@ public class StoreManagerImpl implements
         }
 
         TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
+        boolean cmis11 = 
InMemoryServiceContext.getCallContext().getCmisVersion() != 
CmisVersion.CMIS_1_0;
 
         if (tc != null) {
             if (depth == -1) {
-                if (includePropertyDefinitions) {
+                if (cmis11 && includePropertyDefinitions) {
                     return tc;
                 } else {
                     depth = Integer.MAX_VALUE;
@@ -204,7 +210,7 @@ public class StoreManagerImpl implements
                 throw new CmisInvalidArgumentException("illegal depth value: " 
+ depth);
             }
 
-            return cloneTypeList(depth, includePropertyDefinitions, tc, null);
+            return cloneTypeList(depth, includePropertyDefinitions, tc, null, 
cmis11);
         } else {
             return null;
         }
@@ -251,21 +257,28 @@ public class StoreManagerImpl implements
             }
         }
 
-        if (includePropertyDefinitions) {
+        if (cmis11 && includePropertyDefinitions) {
             result = rootTypes;
         } else {
-            result = new ArrayList<TypeDefinitionContainer>(rootTypes.size());
-            // copy list and omit properties
-            for (TypeDefinitionContainer c : rootTypes) {
-                MutableTypeDefinition td = 
typeFactory.copy(c.getTypeDefinition(), includePropertyDefinitions);
-                TypeDefinitionContainerImpl tdc = new 
TypeDefinitionContainerImpl(td);
-                tdc.setChildren(c.getChildren());
-                result.add(tdc);
-            }
+            result = cloneTypeDefinitionTree(rootTypes, 
includePropertyDefinitions, cmis11);
         }
         return result;
     }
-
+    
+    private List<TypeDefinitionContainer> cloneTypeDefinitionTree 
(List<TypeDefinitionContainer> tdcList, boolean includePropertyDefinitions, 
boolean cmis11) {
+       List<TypeDefinitionContainer> result = new 
ArrayList<TypeDefinitionContainer>(tdcList.size());
+               for (TypeDefinitionContainer c : tdcList) {
+                       MutableTypeDefinition td = 
typeFactory.copy(c.getTypeDefinition(), includePropertyDefinitions);
+                       if (!cmis11) {
+                               td.setTypeMutability(null);
+                       }
+                       TypeDefinitionContainerImpl tdc = new 
TypeDefinitionContainerImpl(td);
+                       
tdc.setChildren(cloneTypeDefinitionTree(c.getChildren(), 
includePropertyDefinitions, cmis11));
+                       result.add(tdc);
+               }
+               return result;
+       }
+    
     @Override
     public RepositoryInfo getRepositoryInfo(String repositoryId) {
         ObjectStore sm = fMapRepositoryToObjectStore.get(repositoryId);
@@ -523,11 +536,13 @@ public class StoreManagerImpl implements
      * @return cloned type definition
      */
     public static TypeDefinitionContainer cloneTypeList(int depth, boolean 
includePropertyDefinitions,
-            TypeDefinitionContainer tdc, TypeDefinitionContainer parent) {
+            TypeDefinitionContainer tdc, TypeDefinitionContainer parent, 
boolean cmis11) {
 
         final TypeDefinitionFactory typeFactory = 
TypeDefinitionFactory.newInstance();
         MutableTypeDefinition tdClone = 
typeFactory.copy(tdc.getTypeDefinition(), includePropertyDefinitions);
-
+        if (!cmis11) {
+               tdClone.setTypeMutability(null);
+        }
         TypeDefinitionContainerImpl tdcClone = new 
TypeDefinitionContainerImpl(tdClone);
         if (null != parent) {
             parent.getChildren().add(tdcClone);
@@ -536,7 +551,7 @@ public class StoreManagerImpl implements
         if (depth > 0) {
             List<TypeDefinitionContainer> children = tdc.getChildren();
             for (TypeDefinitionContainer child : children) {
-                cloneTypeList(depth - 1, includePropertyDefinitions, child, 
tdcClone);
+                cloneTypeList(depth - 1, includePropertyDefinitions, child, 
tdcClone, cmis11);
             }
         }
         return tdcClone;


Reply via email to