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 2010/04/16 16:00:25 UTC

svn commit: r934878 [7/13] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/clientprovider/ mai...

Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Fri Apr 16 14:00:23 2010
@@ -48,7 +48,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 
-
 /**
  * factory to create objects that are stored in the InMemory store
  * 
@@ -56,313 +55,298 @@ import org.apache.chemistry.opencmis.inm
  */
 public class StoreManagerImpl implements StoreManager {
 
-  protected BindingsObjectFactory fObjectFactory;
-  protected RepositoryInfo fRepositoryInfo;
-  
-  /**
-   * map from repository id to a type manager 
-   */
-  private Map<String,  TypeManager> fMapRepositoryToTypeManager
-    = new HashMap<String,  TypeManager>();
-
-  /**
-   * map from repository id to a object store
-   */
-  private Map<String, ObjectStore> fMapRepositoryToObjectStore
-    = new HashMap<String, ObjectStore>();
-
-  public ObjectStoreImpl getStore(String repositoryId) {
-    return (ObjectStoreImpl)fMapRepositoryToObjectStore.get(repositoryId);
-  }  
-  
-  public StoreManagerImpl() {
-    fObjectFactory = new BindingsObjectFactoryImpl();
-  }
-
-  public List<String> getAllRepositoryIds() {
-    Set<String> repIds = fMapRepositoryToObjectStore.keySet();
-    List<String> result = new ArrayList<String>();
-    result.addAll(repIds);
-    return result;
-  }
-
-  public void initRepository(String repositoryId) {
-    fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));  
-    fMapRepositoryToTypeManager.put(repositoryId, new TypeManager());      
-  }
-  
-  public void createAndInitRepository(String repositoryId, String typeCreatorClassName) {
-    if (fMapRepositoryToObjectStore.containsKey(repositoryId)
-        || fMapRepositoryToTypeManager.containsKey(repositoryId))
-      throw new RuntimeException("Cannot add repository, repository " + repositoryId
-          + " already exists.");
-    
-    fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));  
-    fMapRepositoryToTypeManager.put(repositoryId, new TypeManager());
-    
-    // initialize the type system:
-    initTypeSystem(repositoryId, typeCreatorClassName);
-  }
-
-  public ObjectStore getObjectStore(String repositoryId) {
-    return fMapRepositoryToObjectStore.get(repositoryId);
-  }
-
-  public BindingsObjectFactory getObjectFactory() {
-    return fObjectFactory;
-  }
-
-  public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-
-    return typeManager.getTypeById(typeId);    
-  }
-
-  public TypeDefinitionContainer getTypeById(String repositoryId, String typeId,
-      boolean includePropertyDefinitions, int depth) {
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-
-    TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
-    List<TypeDefinitionContainer> result = null;
-    
-    if (tc != null) {
-      if (depth == -1) {
-        result = tc.getChildren();
-        if (!includePropertyDefinitions)
-          cloneTypeList(depth - 1, false, result);
-      }
-      else if (depth == 0 || depth < -1)
-        throw new CmisInvalidArgumentException("illegal depth value: " + depth);
-      else {
-        result = tc.getChildren();
-        cloneTypeList(depth - 1, includePropertyDefinitions, result);
-      }
-    }    
-    return tc;
-  }
-  
-  public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId, boolean includePropertyDefinitions) {
-    Collection<TypeDefinitionContainer> result;
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-    Collection<TypeDefinitionContainer> typeColl = typeManager.getTypeDefinitionList();
-    if (includePropertyDefinitions) {
-      result = typeColl;
-    } else {
-      result = new ArrayList<TypeDefinitionContainer>(typeColl);
-      // copy list and omit properties
-      for (TypeDefinitionContainer c : result) {
-        AbstractTypeDefinition td = ((AbstractTypeDefinition) c.getTypeDefinition()).clone();
-        TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td);
-        tdc.setChildren(c.getChildren());
-        td.setPropertyDefinitions(null);
-      }
-    }
-    return result;
-  }
-  
-  public Map<String, TypeDefinitionContainer> getTypeDefinitionMap(String repositoryId) {
-    return null;
-  }
-
-  public List<TypeDefinitionContainer> getRootTypes(String repositoryId) {
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-    List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
-
-    return rootTypes;
-  }
-
-  public RepositoryInfo getRepositoryInfo(String repositoryId) {
-    ObjectStore sm = fMapRepositoryToObjectStore.get(repositoryId);
-    if (null == sm)
-      return null;
-    
-    RepositoryInfo repoInfo = createDefaultRepositoryInfo(repositoryId);
-
-    return repoInfo;
-  }
-
-  public void clearTypeSystem(String repositoryId) {
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-
-    
-    typeManager.clearTypeSystem();
-  }
-
-  public void initRepositoryInfo(String repositoryId, String repoInfoCreatorClassName) {
-    RepositoryInfoCreator repoCreator = null;
-
-    if (repoInfoCreatorClassName != null) {
-      Object obj = null;
-      try {
-        obj = Class.forName(repoInfoCreatorClassName).newInstance();
-      }
-      catch (InstantiationException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement RepositoryInfoCreator interface.",
-            e);
-      }
-      catch (IllegalAccessException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement RepositoryInfoCreator interface.",
-            e);
-      }
-      catch (ClassNotFoundException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement RepositoryInfoCreator interface.",
-            e);
-      }
-
-      if (obj instanceof RepositoryInfoCreator) {
-        repoCreator = (RepositoryInfoCreator) obj;
-        fRepositoryInfo = repoCreator.createRepositoryInfo();
-      }
-      else
-        throw new RuntimeException(
-            "Illegal class to create repository info, must implement RepositoryInfoCreator interface.");
-    }
-    else {
-      // create a default repository info
-      createDefaultRepositoryInfo(repositoryId);
-    }
-  }
-  
-  public List<TypeDefinition> initTypeSystem(String typeCreatorClassName) {
-    
-    List<TypeDefinition> typesList = null;
-
-    if (typeCreatorClassName != null) {
-      Object obj = null;
-      TypeCreator typeCreator = null;
-
-      try {
-        obj = Class.forName(typeCreatorClassName).newInstance();
-      }
-      catch (InstantiationException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement TypeCreator interface.", e);
-      }
-      catch (IllegalAccessException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement TypeCreator interface.", e);
-      }
-      catch (ClassNotFoundException e) {
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement TypeCreator interface.", e);
-      }
-
-      if (obj instanceof TypeCreator)
-        typeCreator = (TypeCreator) obj;
-      else
-        throw new RuntimeException(
-            "Illegal class to create type system, must implement TypeCreator interface.");
-
-      // retrieve the list of available types from the configured class.
-      // test
-      typesList = typeCreator.createTypesList();      
-    }
-    
-    return typesList;
-  }
-
-  private void initTypeSystem(String repositoryId, String typeCreatorClassName) {
-
-    List<TypeDefinition> typeDefs = null;
-    TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    if (null == typeManager)
-      throw new RuntimeException("Unknown repository " + repositoryId);
-
-    if (null != typeCreatorClassName)
-      typeDefs = initTypeSystem(typeCreatorClassName);
-
-    typeManager.initTypeSystem(typeDefs);
-  }
-
-  private RepositoryInfo createDefaultRepositoryInfo(String repositoryId) {
-    ObjectStore objStore = getObjectStore(repositoryId);
-    String rootFolderId = objStore.getRootFolder().getId();
-    // repository info
-    RepositoryInfoImpl repoInfo;
-    repoInfo = new RepositoryInfoImpl();
-    repoInfo.setRepositoryId(repositoryId==null ? "inMem" : repositoryId);
-    repoInfo.setRepositoryName("InMemory Repository");
-    repoInfo.setRepositoryDescription("InMemory Test Repository");
-    repoInfo.setCmisVersionSupported("1.0");
-    repoInfo.setRepositoryCapabilities(null);
-    repoInfo.setRootFolder(rootFolderId);
-    repoInfo.setPrincipalAnonymous("anonymous");
-    repoInfo.setPrincipalAnyone("anyone");
-    repoInfo.setThinClientUri(null);
-    repoInfo.setChangesIncomplete(Boolean.TRUE);
-    repoInfo.setChangesOnType(null);
-    repoInfo.setLatestChangeLogToken(null);
-    repoInfo.setVendorName("OpenCMIS");
-    repoInfo.setProductName("OpenCMIS InMemory-Server");
-    repoInfo.setProductVersion("0.1");
-    
-    // set capabilities
-    RepositoryCapabilitiesImpl caps = new RepositoryCapabilitiesImpl();
-    caps.setAllVersionsSearchable(false);
-    caps.setCapabilityAcl(CapabilityAcl.NONE);
-    caps.setCapabilityChanges(CapabilityChanges.PROPERTIES); // just for testing
-    caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.PWCONLY);
-    caps.setCapabilityJoin(CapabilityJoin.NONE);
-    caps.setCapabilityQuery(CapabilityQuery.METADATAONLY); // just for testing
-    caps.setCapabilityRendition(CapabilityRenditions.NONE);
-    caps.setIsPwcSearchable(false);
-    caps.setIsPwcUpdatable(true);
-    caps.setSupportsGetDescendants(true);
-    caps.setSupportsGetFolderTree(true);
-    caps.setSupportsMultifiling(true);
-    caps.setSupportsUnfiling(true);
-    caps.setSupportsVersionSpecificFiling(false);
-    repoInfo.setRepositoryCapabilities(caps);
-    
-//    AclCapabilitiesDataImpl aclCaps = new AclCapabilitiesDataImpl();
-//    aclCaps.setACLPropagation(AclPropagation.REPOSITORYDETERMINED);
-//    aclCaps.setPermissionDefinitionData(null);
-//    aclCaps.setPermissionMappingData(null);
-//    repoInfo.setACLCapabilities(aclCaps);
-    repoInfo.setAclCapabilities(null);
-    fRepositoryInfo = repoInfo;
-    return repoInfo;
-  }
-
-  /**
-   * traverse tree and replace each need node with a clone. remove properties on clone if requested,
-   * cut children of clone if depth is exceeded.
-   * 
-   * @param depth
-   * @param types
-   */
-  private void cloneTypeList(int depth, boolean includePropertyDefinitions,
-      List<TypeDefinitionContainer> types) {
-
-    ListIterator<TypeDefinitionContainer> it = types.listIterator();
-    while (it.hasNext()) {
-      TypeDefinitionContainer tdc = it.next();
-      AbstractTypeDefinition td = ((AbstractTypeDefinition) tdc.getTypeDefinition()).clone();
-      if (!includePropertyDefinitions)
-        td.setPropertyDefinitions(null);
-      TypeDefinitionContainerImpl tdcClone = new TypeDefinitionContainerImpl(td);
-      if (depth > 0) {
-        ArrayList<TypeDefinitionContainer> children = new ArrayList<TypeDefinitionContainer>(tdc
-            .getChildren().size());
-        children.addAll(tdc.getChildren());
-        tdcClone.setChildren(children);
-        cloneTypeList(depth - 1, includePropertyDefinitions, children);
-      }
-      it.set(tdcClone);
-    }
-  }
-  
+	protected BindingsObjectFactory fObjectFactory;
+	protected RepositoryInfo fRepositoryInfo;
+
+	/**
+	 * map from repository id to a type manager
+	 */
+	private Map<String, TypeManager> fMapRepositoryToTypeManager = new HashMap<String, TypeManager>();
+
+	/**
+	 * map from repository id to a object store
+	 */
+	private Map<String, ObjectStore> fMapRepositoryToObjectStore = new HashMap<String, ObjectStore>();
+
+	public ObjectStoreImpl getStore(String repositoryId) {
+		return (ObjectStoreImpl) fMapRepositoryToObjectStore.get(repositoryId);
+	}
+
+	public StoreManagerImpl() {
+		fObjectFactory = new BindingsObjectFactoryImpl();
+	}
+
+	public List<String> getAllRepositoryIds() {
+		Set<String> repIds = fMapRepositoryToObjectStore.keySet();
+		List<String> result = new ArrayList<String>();
+		result.addAll(repIds);
+		return result;
+	}
+
+	public void initRepository(String repositoryId) {
+		fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));
+		fMapRepositoryToTypeManager.put(repositoryId, new TypeManager());
+	}
+
+	public void createAndInitRepository(String repositoryId, String typeCreatorClassName) {
+		if (fMapRepositoryToObjectStore.containsKey(repositoryId)
+				|| fMapRepositoryToTypeManager.containsKey(repositoryId))
+			throw new RuntimeException("Cannot add repository, repository " + repositoryId + " already exists.");
+
+		fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));
+		fMapRepositoryToTypeManager.put(repositoryId, new TypeManager());
+
+		// initialize the type system:
+		initTypeSystem(repositoryId, typeCreatorClassName);
+	}
+
+	public ObjectStore getObjectStore(String repositoryId) {
+		return fMapRepositoryToObjectStore.get(repositoryId);
+	}
+
+	public BindingsObjectFactory getObjectFactory() {
+		return fObjectFactory;
+	}
+
+	public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+
+		return typeManager.getTypeById(typeId);
+	}
+
+	public TypeDefinitionContainer getTypeById(String repositoryId, String typeId, boolean includePropertyDefinitions,
+			int depth) {
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+
+		TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
+		List<TypeDefinitionContainer> result = null;
+
+		if (tc != null) {
+			if (depth == -1) {
+				result = tc.getChildren();
+				if (!includePropertyDefinitions)
+					cloneTypeList(depth - 1, false, result);
+			} else if (depth == 0 || depth < -1)
+				throw new CmisInvalidArgumentException("illegal depth value: " + depth);
+			else {
+				result = tc.getChildren();
+				cloneTypeList(depth - 1, includePropertyDefinitions, result);
+			}
+		}
+		return tc;
+	}
+
+	public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId,
+			boolean includePropertyDefinitions) {
+		Collection<TypeDefinitionContainer> result;
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+		Collection<TypeDefinitionContainer> typeColl = typeManager.getTypeDefinitionList();
+		if (includePropertyDefinitions) {
+			result = typeColl;
+		} else {
+			result = new ArrayList<TypeDefinitionContainer>(typeColl);
+			// copy list and omit properties
+			for (TypeDefinitionContainer c : result) {
+				AbstractTypeDefinition td = ((AbstractTypeDefinition) c.getTypeDefinition()).clone();
+				TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td);
+				tdc.setChildren(c.getChildren());
+				td.setPropertyDefinitions(null);
+			}
+		}
+		return result;
+	}
+
+	public Map<String, TypeDefinitionContainer> getTypeDefinitionMap(String repositoryId) {
+		return null;
+	}
+
+	public List<TypeDefinitionContainer> getRootTypes(String repositoryId) {
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+		List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
+
+		return rootTypes;
+	}
+
+	public RepositoryInfo getRepositoryInfo(String repositoryId) {
+		ObjectStore sm = fMapRepositoryToObjectStore.get(repositoryId);
+		if (null == sm)
+			return null;
+
+		RepositoryInfo repoInfo = createDefaultRepositoryInfo(repositoryId);
+
+		return repoInfo;
+	}
+
+	public void clearTypeSystem(String repositoryId) {
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+
+		typeManager.clearTypeSystem();
+	}
+
+	public void initRepositoryInfo(String repositoryId, String repoInfoCreatorClassName) {
+		RepositoryInfoCreator repoCreator = null;
+
+		if (repoInfoCreatorClassName != null) {
+			Object obj = null;
+			try {
+				obj = Class.forName(repoInfoCreatorClassName).newInstance();
+			} catch (InstantiationException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement RepositoryInfoCreator interface.", e);
+			} catch (IllegalAccessException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement RepositoryInfoCreator interface.", e);
+			} catch (ClassNotFoundException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement RepositoryInfoCreator interface.", e);
+			}
+
+			if (obj instanceof RepositoryInfoCreator) {
+				repoCreator = (RepositoryInfoCreator) obj;
+				fRepositoryInfo = repoCreator.createRepositoryInfo();
+			} else
+				throw new RuntimeException(
+						"Illegal class to create repository info, must implement RepositoryInfoCreator interface.");
+		} else {
+			// create a default repository info
+			createDefaultRepositoryInfo(repositoryId);
+		}
+	}
+
+	public List<TypeDefinition> initTypeSystem(String typeCreatorClassName) {
+
+		List<TypeDefinition> typesList = null;
+
+		if (typeCreatorClassName != null) {
+			Object obj = null;
+			TypeCreator typeCreator = null;
+
+			try {
+				obj = Class.forName(typeCreatorClassName).newInstance();
+			} catch (InstantiationException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement TypeCreator interface.", e);
+			} catch (IllegalAccessException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement TypeCreator interface.", e);
+			} catch (ClassNotFoundException e) {
+				throw new RuntimeException(
+						"Illegal class to create type system, must implement TypeCreator interface.", e);
+			}
+
+			if (obj instanceof TypeCreator)
+				typeCreator = (TypeCreator) obj;
+			else
+				throw new RuntimeException("Illegal class to create type system, must implement TypeCreator interface.");
+
+			// retrieve the list of available types from the configured class.
+			// test
+			typesList = typeCreator.createTypesList();
+		}
+
+		return typesList;
+	}
+
+	private void initTypeSystem(String repositoryId, String typeCreatorClassName) {
+
+		List<TypeDefinition> typeDefs = null;
+		TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+		if (null == typeManager)
+			throw new RuntimeException("Unknown repository " + repositoryId);
+
+		if (null != typeCreatorClassName)
+			typeDefs = initTypeSystem(typeCreatorClassName);
+
+		typeManager.initTypeSystem(typeDefs);
+	}
+
+	private RepositoryInfo createDefaultRepositoryInfo(String repositoryId) {
+		ObjectStore objStore = getObjectStore(repositoryId);
+		String rootFolderId = objStore.getRootFolder().getId();
+		// repository info
+		RepositoryInfoImpl repoInfo;
+		repoInfo = new RepositoryInfoImpl();
+		repoInfo.setRepositoryId(repositoryId == null ? "inMem" : repositoryId);
+		repoInfo.setRepositoryName("InMemory Repository");
+		repoInfo.setRepositoryDescription("InMemory Test Repository");
+		repoInfo.setCmisVersionSupported("1.0");
+		repoInfo.setRepositoryCapabilities(null);
+		repoInfo.setRootFolder(rootFolderId);
+		repoInfo.setPrincipalAnonymous("anonymous");
+		repoInfo.setPrincipalAnyone("anyone");
+		repoInfo.setThinClientUri(null);
+		repoInfo.setChangesIncomplete(Boolean.TRUE);
+		repoInfo.setChangesOnType(null);
+		repoInfo.setLatestChangeLogToken(null);
+		repoInfo.setVendorName("OpenCMIS");
+		repoInfo.setProductName("OpenCMIS InMemory-Server");
+		repoInfo.setProductVersion("0.1");
+
+		// set capabilities
+		RepositoryCapabilitiesImpl caps = new RepositoryCapabilitiesImpl();
+		caps.setAllVersionsSearchable(false);
+		caps.setCapabilityAcl(CapabilityAcl.NONE);
+		caps.setCapabilityChanges(CapabilityChanges.PROPERTIES); // just for
+																	// testing
+		caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.PWCONLY);
+		caps.setCapabilityJoin(CapabilityJoin.NONE);
+		caps.setCapabilityQuery(CapabilityQuery.METADATAONLY); // just for
+																// testing
+		caps.setCapabilityRendition(CapabilityRenditions.NONE);
+		caps.setIsPwcSearchable(false);
+		caps.setIsPwcUpdatable(true);
+		caps.setSupportsGetDescendants(true);
+		caps.setSupportsGetFolderTree(true);
+		caps.setSupportsMultifiling(true);
+		caps.setSupportsUnfiling(true);
+		caps.setSupportsVersionSpecificFiling(false);
+		repoInfo.setRepositoryCapabilities(caps);
+
+		// AclCapabilitiesDataImpl aclCaps = new AclCapabilitiesDataImpl();
+		// aclCaps.setACLPropagation(AclPropagation.REPOSITORYDETERMINED);
+		// aclCaps.setPermissionDefinitionData(null);
+		// aclCaps.setPermissionMappingData(null);
+		// repoInfo.setACLCapabilities(aclCaps);
+		repoInfo.setAclCapabilities(null);
+		fRepositoryInfo = repoInfo;
+		return repoInfo;
+	}
+
+	/**
+	 * traverse tree and replace each need node with a clone. remove properties
+	 * on clone if requested, cut children of clone if depth is exceeded.
+	 * 
+	 * @param depth
+	 * @param types
+	 */
+	private void cloneTypeList(int depth, boolean includePropertyDefinitions, List<TypeDefinitionContainer> types) {
+
+		ListIterator<TypeDefinitionContainer> it = types.listIterator();
+		while (it.hasNext()) {
+			TypeDefinitionContainer tdc = it.next();
+			AbstractTypeDefinition td = ((AbstractTypeDefinition) tdc.getTypeDefinition()).clone();
+			if (!includePropertyDefinitions)
+				td.setPropertyDefinitions(null);
+			TypeDefinitionContainerImpl tdcClone = new TypeDefinitionContainerImpl(td);
+			if (depth > 0) {
+				ArrayList<TypeDefinitionContainer> children = new ArrayList<TypeDefinitionContainer>(tdc.getChildren()
+						.size());
+				children.addAll(tdc.getChildren());
+				tdcClone.setChildren(children);
+				cloneTypeList(depth - 1, includePropertyDefinitions, children);
+			}
+			it.set(tdcClone);
+		}
+	}
+
 }

Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java Fri Apr 16 14:00:23 2010
@@ -40,378 +40,436 @@ import org.apache.chemistry.opencmis.inm
  */
 
 /**
- * StoredObject is the common superclass of all objects hold in the repository Documents, Folders,
- * Relationships and Policies
+ * StoredObject is the common superclass of all objects hold in the repository
+ * Documents, Folders, Relationships and Policies
  */
 
 public class StoredObjectImpl implements StoredObject {
-  protected String fId;
-  protected String fName;
-  protected String fTypeId;
-  protected String fCreatedBy;
-  protected String fModifiedBy;
-  protected GregorianCalendar fCreatedAt;
-  protected GregorianCalendar fModifiedAt;
-  protected String fRepositoryId;
-  protected Map<String, PropertyData<?>> fProperties;
-  protected ObjectStoreImpl fObjStore;
-  
-  StoredObjectImpl(ObjectStoreImpl objStore) {  // visibility should be package    
-    GregorianCalendar now = getNow();
-    now.setTime(new Date());
-    fCreatedAt = now;
-    fModifiedAt = now;
-    fObjStore = objStore;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
-   */
-  public String getId() {
-    return fId;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
-   */
-  public String getName() {
-    return fName;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.lang.String)
-   */
-  public void setName(String name) {
-    fName = name;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
-   */
-  public String getTypeId() {
-    return fTypeId;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java.lang.String)
-   */
-  public void setTypeId(String type) {
-    fTypeId = type;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
-   */
-  public String getCreatedBy() {
-    return fCreatedBy;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(java.lang.String)
-   */
-  public void setCreatedBy(String createdBy) {
-    this.fCreatedBy = createdBy;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
-   */
-  public String getModifiedBy() {
-    return fModifiedBy;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy(java.lang.String)
-   */
-  public void setModifiedBy(String modifiedBy) {
-    this.fModifiedBy = modifiedBy;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
-   */
-  public GregorianCalendar getCreatedAt() {
-    return fCreatedAt;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(java.util.GregorianCalendar)
-   */
-  public void setCreatedAt(GregorianCalendar createdAt) {
-    this.fCreatedAt = createdAt;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
-   */
-  public GregorianCalendar getModifiedAt() {
-    return fModifiedAt;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow()
-   */
-  public void setModifiedAtNow() {
-    this.fModifiedAt = getNow();
-  }
-  
-  public void setRepositoryId(String repositoryId) {
-	  fRepositoryId = repositoryId;
-  }
-  
-  public String getRepositoryId() {
-	  return fRepositoryId;
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties(java.util.Map)
-   */
-  public void setProperties(Map<String, PropertyData<?>> props) {
-    fProperties = props;
-  }
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
-   */
-  public Map<String, PropertyData<?>> getProperties() {
-    return fProperties;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#getChangeToken()
-   */
-  public String getChangeToken() {
-    GregorianCalendar lastModified = getModifiedAt();
-    String token = Long.valueOf(lastModified.getTimeInMillis()).toString();
-    return token;
-  }
-  
-  public void rename(String newName) {
-    setName(newName);
-    persist();
-  }
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
-   */
-  public void createSystemBasePropertiesWhenCreated(
-      Map<String, PropertyData<?>> properties,
-      String user) {
-    addSystemBaseProperties(properties, user, true);
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
-   */
-  public void updateSystemBasePropertiesWhenModified(
-      Map<String, PropertyData<?>> properties,
-      String user) {
-    addSystemBaseProperties(properties, user, false);
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties(java.util.List, org.opencmis.client.provider.ProviderObjectFactory, java.util.List)
-   */
-  public void fillProperties(Map<String, PropertyData<?>> properties,
-      BindingsObjectFactory objFactory, List<String> requestedIds) {
-    
-    if (FilterParser.isContainedInFilter(PropertyIds.NAME, requestedIds)) {
-      properties.put(PropertyIds.NAME, objFactory.createPropertyStringData(PropertyIds.NAME, getName()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_ID, requestedIds)) {
-      properties.put(PropertyIds.OBJECT_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_ID, getId()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_TYPE_ID, requestedIds)) {
-      properties.put(PropertyIds.OBJECT_TYPE_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, getTypeId()));
-    }
-    // set the base type id outside becaus it requires the type definition
-//    if (FilterParser.isContainedInFilter(PropertyIds.CMIS_BASE_TYPE_ID, requestedIds)) {
-//      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_BASE_TYPE_ID, getBaseTypeId()));
-//    }
-    if (FilterParser.isContainedInFilter(PropertyIds.CREATED_BY, requestedIds)) {
-      properties.put(PropertyIds.CREATED_BY, objFactory.createPropertyStringData(PropertyIds.CREATED_BY, getCreatedBy()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.CREATION_DATE, requestedIds)) {
-      properties.put(PropertyIds.CREATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CREATION_DATE, getCreatedAt()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFIED_BY, requestedIds)) {
-      properties.put(PropertyIds.LAST_MODIFIED_BY, objFactory.createPropertyStringData(PropertyIds.LAST_MODIFIED_BY, getModifiedBy()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFICATION_DATE, requestedIds)) {
-      properties.put(PropertyIds.LAST_MODIFICATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.LAST_MODIFICATION_DATE, getModifiedAt()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.CHANGE_TOKEN, requestedIds)) {
-      String token = getChangeToken();
-      properties.put(PropertyIds.CHANGE_TOKEN, objFactory.createPropertyStringData(PropertyIds.CHANGE_TOKEN, token));
-    }
-
-    // add custom properties of type definition to the collection
-    if (null != fProperties) {
-      for (Entry<String, PropertyData<?>> prop: fProperties.entrySet()) {
-        properties.put(prop.getKey(), prop.getValue());      
-      }
-    }
-  }
-
-
-  /////////////////////////////////////////////
-  // private helper methods
-  
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties(java.util.Map)
-   */
-  public void setCustomProperties(Map<String, PropertyData<?>> properties) {
-    properties = new HashMap<String, PropertyData<?>>(properties); // get a writable collection
-    removeAllSystemProperties(properties);    
-    setProperties(properties);        
-  }
-
-  private GregorianCalendar getNow() {
-    GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
-    return now; 
-  }
-  
-  /**
-   * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY, CMIS_LAST_MODIFICATION_DATE,
-   * CMIS_CHANGE_TOKEN system properties to the list of properties with current values
-   */
-  private void addSystemBaseProperties(Map<String, PropertyData<?>> properties, String user, boolean isCreated) {
-    if (user == null)
-      user = "unknown";
-
-    // Note that initial creation and modification date is set in constructor.
-    setModifiedBy(user);
-    if (isCreated) {
-      setCreatedBy(user);
-      setName((String) properties.get(PropertyIds.NAME).getFirstValue());
-      setTypeId((String) properties.get(PropertyIds.OBJECT_TYPE_ID).getFirstValue());
-    } else {
-      setModifiedAtNow();
-    }      
-  }
-  
-  /**
-   * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY, CMIS_LAST_MODIFICATION_DATE,
-   * CMIS_CHANGE_TOKEN system properties to the list of properties with current values
-   */
-  protected void setSystemBasePropertiesWhenCreatedDirect(String name, String typeId, String user) {
-    // Note that initial creation and modification date is set in constructor.
-    setModifiedBy(user);
-    setCreatedBy(user);
-    setName(name);
-    setTypeId(typeId);    
-  }
-  
-/*  
-  CMIS_NAME
-  CMIS_OBJECT_ID
-  CMIS_OBJECT_TYPE_ID
-  CMIS_BASE_TYPE_ID
-  CMIS_CREATED_BY
-  CMIS_CREATION_DATE
-  CMIS_LAST_MODIFIED_BY
-  CMIS_LAST_MODIFICATION_DATE
-  CMIS_CHANGE_TOKEN 
-
-  // ---- document ----
-  CMIS_IS_IMMUTABLE
-  CMIS_IS_LATEST_VERSION
-  CMIS_IS_MAJOR_VERSION
-  CMIS_IS_LATEST_MAJOR_VERSION
-  CMIS_VERSION_LABEL
-  CMIS_VERSION_SERIES_ID
-  CMIS_IS_VERSION_SERIES_CHECKED_OUT
-  CMIS_VERSION_SERIES_CHECKED_OUT_BY
-  CMIS_VERSION_SERIES_CHECKED_OUT_ID
-  CMIS_CHECKIN_COMMENT
-  CMIS_CONTENT_STREAM_LENGTH
-  CMIS_CONTENT_STREAM_MIME_TYPE
-  CMIS_CONTENT_STREAM_FILE_NAME
-  CMIS_CONTENT_STREAM_ID
-
-   // ---- folder ---- 
-  CMIS_PARENT_ID
-  CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS
-  CMIS_PATH
-
-    // ---- relationship ----
-  CMIS_SOURCE_ID
-  CMIS_TARGET_ID
-
-    // ---- policy ----
-  CMIS_POLICY_TEXT
-  */
-  private void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
-    // ---- base ----
-    if (properties.containsKey(PropertyIds.NAME))
-      properties.remove(PropertyIds.NAME);
-    if (properties.containsKey(PropertyIds.OBJECT_ID))
-      properties.remove(PropertyIds.OBJECT_ID);
-    if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID))
-      properties.remove(PropertyIds.OBJECT_TYPE_ID);
-    if (properties.containsKey(PropertyIds.BASE_TYPE_ID))
-      properties.remove(PropertyIds.BASE_TYPE_ID);
-    if (properties.containsKey(PropertyIds.CREATED_BY))
-      properties.remove(PropertyIds.CREATED_BY);
-    if (properties.containsKey(PropertyIds.CREATION_DATE))
-      properties.remove(PropertyIds.CREATION_DATE);
-    if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY))
-      properties.remove(PropertyIds.LAST_MODIFIED_BY);
-    if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE))
-      properties.remove(PropertyIds.LAST_MODIFICATION_DATE);
-    if (properties.containsKey(PropertyIds.CHANGE_TOKEN))
-      properties.remove(PropertyIds.CHANGE_TOKEN);
-    // ---- document ----
-    if (properties.containsKey(PropertyIds.IS_IMMUTABLE))
-      properties.remove(PropertyIds.IS_IMMUTABLE);
-    if (properties.containsKey(PropertyIds.IS_LATEST_VERSION))
-      properties.remove(PropertyIds.IS_LATEST_VERSION);
-    if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION))
-      properties.remove(PropertyIds.IS_MAJOR_VERSION);
-    if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION))
-      properties.remove(PropertyIds.IS_LATEST_MAJOR_VERSION);
-    if (properties.containsKey(PropertyIds.VERSION_LABEL))
-      properties.remove(PropertyIds.VERSION_LABEL);
-    if (properties.containsKey(PropertyIds.VERSION_SERIES_ID))
-      properties.remove(PropertyIds.VERSION_SERIES_ID);
-    if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT))
-      properties.remove(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
-    if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY))
-      properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
-    if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID))
-      properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
-    if (properties.containsKey(PropertyIds.CHECKIN_COMMENT))
-      properties.remove(PropertyIds.CHECKIN_COMMENT);
-    if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH))
-      properties.remove(PropertyIds.CONTENT_STREAM_LENGTH);
-    if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE))
-      properties.remove(PropertyIds.CONTENT_STREAM_MIME_TYPE);
-    if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME))
-      properties.remove(PropertyIds.CONTENT_STREAM_FILE_NAME);
-    if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID))
-      properties.remove(PropertyIds.CONTENT_STREAM_ID);
-    // ---- folder ----     
-    if (properties.containsKey(PropertyIds.PARENT_ID))
-      properties.remove(PropertyIds.PARENT_ID);
-    if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS))
-      properties.remove(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
-    if (properties.containsKey(PropertyIds.PATH))
-      properties.remove(PropertyIds.PATH);
-    // ---- relationship ----
-    if (properties.containsKey(PropertyIds.SOURCE_ID))
-      properties.remove(PropertyIds.SOURCE_ID);
-    if (properties.containsKey(PropertyIds.TARGET_ID))
-      properties.remove(PropertyIds.TARGET_ID);
-    // ---- policy ----
-    if (properties.containsKey(PropertyIds.POLICY_TEXT))
-      properties.remove(PropertyIds.POLICY_TEXT);
-  }
-
-public void persist() {
-  // in-memory implementation does not need to to anything to persist,
-  // but after this call the id should be set.
-  fId = fObjStore.storeObject(this);
-
-}
+	protected String fId;
+	protected String fName;
+	protected String fTypeId;
+	protected String fCreatedBy;
+	protected String fModifiedBy;
+	protected GregorianCalendar fCreatedAt;
+	protected GregorianCalendar fModifiedAt;
+	protected String fRepositoryId;
+	protected Map<String, PropertyData<?>> fProperties;
+	protected ObjectStoreImpl fObjStore;
+
+	StoredObjectImpl(ObjectStoreImpl objStore) { // visibility should be package
+		GregorianCalendar now = getNow();
+		now.setTime(new Date());
+		fCreatedAt = now;
+		fModifiedAt = now;
+		fObjStore = objStore;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
+	 */
+	public String getId() {
+		return fId;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
+	 */
+	public String getName() {
+		return fName;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.
+	 * lang.String)
+	 */
+	public void setName(String name) {
+		fName = name;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
+	 */
+	public String getTypeId() {
+		return fTypeId;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java
+	 * .lang.String)
+	 */
+	public void setTypeId(String type) {
+		fTypeId = type;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
+	 */
+	public String getCreatedBy() {
+		return fCreatedBy;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(
+	 * java.lang.String)
+	 */
+	public void setCreatedBy(String createdBy) {
+		this.fCreatedBy = createdBy;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
+	 */
+	public String getModifiedBy() {
+		return fModifiedBy;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy
+	 * (java.lang.String)
+	 */
+	public void setModifiedBy(String modifiedBy) {
+		this.fModifiedBy = modifiedBy;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
+	 */
+	public GregorianCalendar getCreatedAt() {
+		return fCreatedAt;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(
+	 * java.util.GregorianCalendar)
+	 */
+	public void setCreatedAt(GregorianCalendar createdAt) {
+		this.fCreatedAt = createdAt;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
+	 */
+	public GregorianCalendar getModifiedAt() {
+		return fModifiedAt;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow
+	 * ()
+	 */
+	public void setModifiedAtNow() {
+		this.fModifiedAt = getNow();
+	}
+
+	public void setRepositoryId(String repositoryId) {
+		fRepositoryId = repositoryId;
+	}
+
+	public String getRepositoryId() {
+		return fRepositoryId;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties
+	 * (java.util.Map)
+	 */
+	public void setProperties(Map<String, PropertyData<?>> props) {
+		fProperties = props;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
+	 */
+	public Map<String, PropertyData<?>> getProperties() {
+		return fProperties;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#
+	 * getChangeToken()
+	 */
+	public String getChangeToken() {
+		GregorianCalendar lastModified = getModifiedAt();
+		String token = Long.valueOf(lastModified.getTimeInMillis()).toString();
+		return token;
+	}
+
+	public void rename(String newName) {
+		setName(newName);
+		persist();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
+	 * createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
+	 */
+	public void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user) {
+		addSystemBaseProperties(properties, user, true);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
+	 * updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
+	 */
+	public void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user) {
+		addSystemBaseProperties(properties, user, false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties
+	 * (java.util.List, org.opencmis.client.provider.ProviderObjectFactory,
+	 * java.util.List)
+	 */
+	public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+			List<String> requestedIds) {
+
+		if (FilterParser.isContainedInFilter(PropertyIds.NAME, requestedIds)) {
+			properties.put(PropertyIds.NAME, objFactory.createPropertyStringData(PropertyIds.NAME, getName()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_ID, requestedIds)) {
+			properties.put(PropertyIds.OBJECT_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_ID, getId()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.OBJECT_TYPE_ID, requestedIds)) {
+			properties.put(PropertyIds.OBJECT_TYPE_ID, objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID,
+					getTypeId()));
+		}
+		// set the base type id outside becaus it requires the type definition
+		// if (FilterParser.isContainedInFilter(PropertyIds.CMIS_BASE_TYPE_ID,
+		// requestedIds)) {
+		// properties.add(objFactory.createPropertyIdData(PropertyIds.
+		// CMIS_BASE_TYPE_ID, getBaseTypeId()));
+		// }
+		if (FilterParser.isContainedInFilter(PropertyIds.CREATED_BY, requestedIds)) {
+			properties.put(PropertyIds.CREATED_BY, objFactory.createPropertyStringData(PropertyIds.CREATED_BY,
+					getCreatedBy()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.CREATION_DATE, requestedIds)) {
+			properties.put(PropertyIds.CREATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CREATION_DATE,
+					getCreatedAt()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFIED_BY, requestedIds)) {
+			properties.put(PropertyIds.LAST_MODIFIED_BY, objFactory.createPropertyStringData(
+					PropertyIds.LAST_MODIFIED_BY, getModifiedBy()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.LAST_MODIFICATION_DATE, requestedIds)) {
+			properties.put(PropertyIds.LAST_MODIFICATION_DATE, objFactory.createPropertyDateTimeData(
+					PropertyIds.LAST_MODIFICATION_DATE, getModifiedAt()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.CHANGE_TOKEN, requestedIds)) {
+			String token = getChangeToken();
+			properties.put(PropertyIds.CHANGE_TOKEN, objFactory.createPropertyStringData(PropertyIds.CHANGE_TOKEN,
+					token));
+		}
+
+		// add custom properties of type definition to the collection
+		if (null != fProperties) {
+			for (Entry<String, PropertyData<?>> prop : fProperties.entrySet()) {
+				properties.put(prop.getKey(), prop.getValue());
+			}
+		}
+	}
+
+	// ///////////////////////////////////////////
+	// private helper methods
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties
+	 * (java.util.Map)
+	 */
+	public void setCustomProperties(Map<String, PropertyData<?>> properties) {
+		properties = new HashMap<String, PropertyData<?>>(properties); // get a
+																		// writable
+																		// collection
+		removeAllSystemProperties(properties);
+		setProperties(properties);
+	}
+
+	private GregorianCalendar getNow() {
+		GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+		return now;
+	}
+
+	/**
+	 * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
+	 * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
+	 * list of properties with current values
+	 */
+	private void addSystemBaseProperties(Map<String, PropertyData<?>> properties, String user, boolean isCreated) {
+		if (user == null)
+			user = "unknown";
+
+		// Note that initial creation and modification date is set in
+		// constructor.
+		setModifiedBy(user);
+		if (isCreated) {
+			setCreatedBy(user);
+			setName((String) properties.get(PropertyIds.NAME).getFirstValue());
+			setTypeId((String) properties.get(PropertyIds.OBJECT_TYPE_ID).getFirstValue());
+		} else {
+			setModifiedAtNow();
+		}
+	}
+
+	/**
+	 * Add CMIS_CREATED_BY, CMIS_CREATION_DATE, CMIS_LAST_MODIFIED_BY,
+	 * CMIS_LAST_MODIFICATION_DATE, CMIS_CHANGE_TOKEN system properties to the
+	 * list of properties with current values
+	 */
+	protected void setSystemBasePropertiesWhenCreatedDirect(String name, String typeId, String user) {
+		// Note that initial creation and modification date is set in
+		// constructor.
+		setModifiedBy(user);
+		setCreatedBy(user);
+		setName(name);
+		setTypeId(typeId);
+	}
+
+	/*
+	 * CMIS_NAME CMIS_OBJECT_ID CMIS_OBJECT_TYPE_ID CMIS_BASE_TYPE_ID
+	 * CMIS_CREATED_BY CMIS_CREATION_DATE CMIS_LAST_MODIFIED_BY
+	 * CMIS_LAST_MODIFICATION_DATE CMIS_CHANGE_TOKEN
+	 * 
+	 * // ---- document ---- CMIS_IS_IMMUTABLE CMIS_IS_LATEST_VERSION
+	 * CMIS_IS_MAJOR_VERSION CMIS_IS_LATEST_MAJOR_VERSION CMIS_VERSION_LABEL
+	 * CMIS_VERSION_SERIES_ID CMIS_IS_VERSION_SERIES_CHECKED_OUT
+	 * CMIS_VERSION_SERIES_CHECKED_OUT_BY CMIS_VERSION_SERIES_CHECKED_OUT_ID
+	 * CMIS_CHECKIN_COMMENT CMIS_CONTENT_STREAM_LENGTH
+	 * CMIS_CONTENT_STREAM_MIME_TYPE CMIS_CONTENT_STREAM_FILE_NAME
+	 * CMIS_CONTENT_STREAM_ID
+	 * 
+	 * // ---- folder ---- CMIS_PARENT_ID CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS
+	 * CMIS_PATH
+	 * 
+	 * // ---- relationship ---- CMIS_SOURCE_ID CMIS_TARGET_ID
+	 * 
+	 * // ---- policy ---- CMIS_POLICY_TEXT
+	 */
+	private void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
+		// ---- base ----
+		if (properties.containsKey(PropertyIds.NAME))
+			properties.remove(PropertyIds.NAME);
+		if (properties.containsKey(PropertyIds.OBJECT_ID))
+			properties.remove(PropertyIds.OBJECT_ID);
+		if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID))
+			properties.remove(PropertyIds.OBJECT_TYPE_ID);
+		if (properties.containsKey(PropertyIds.BASE_TYPE_ID))
+			properties.remove(PropertyIds.BASE_TYPE_ID);
+		if (properties.containsKey(PropertyIds.CREATED_BY))
+			properties.remove(PropertyIds.CREATED_BY);
+		if (properties.containsKey(PropertyIds.CREATION_DATE))
+			properties.remove(PropertyIds.CREATION_DATE);
+		if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY))
+			properties.remove(PropertyIds.LAST_MODIFIED_BY);
+		if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE))
+			properties.remove(PropertyIds.LAST_MODIFICATION_DATE);
+		if (properties.containsKey(PropertyIds.CHANGE_TOKEN))
+			properties.remove(PropertyIds.CHANGE_TOKEN);
+		// ---- document ----
+		if (properties.containsKey(PropertyIds.IS_IMMUTABLE))
+			properties.remove(PropertyIds.IS_IMMUTABLE);
+		if (properties.containsKey(PropertyIds.IS_LATEST_VERSION))
+			properties.remove(PropertyIds.IS_LATEST_VERSION);
+		if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION))
+			properties.remove(PropertyIds.IS_MAJOR_VERSION);
+		if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION))
+			properties.remove(PropertyIds.IS_LATEST_MAJOR_VERSION);
+		if (properties.containsKey(PropertyIds.VERSION_LABEL))
+			properties.remove(PropertyIds.VERSION_LABEL);
+		if (properties.containsKey(PropertyIds.VERSION_SERIES_ID))
+			properties.remove(PropertyIds.VERSION_SERIES_ID);
+		if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT))
+			properties.remove(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+		if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY))
+			properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
+		if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID))
+			properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
+		if (properties.containsKey(PropertyIds.CHECKIN_COMMENT))
+			properties.remove(PropertyIds.CHECKIN_COMMENT);
+		if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH))
+			properties.remove(PropertyIds.CONTENT_STREAM_LENGTH);
+		if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE))
+			properties.remove(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+		if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME))
+			properties.remove(PropertyIds.CONTENT_STREAM_FILE_NAME);
+		if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID))
+			properties.remove(PropertyIds.CONTENT_STREAM_ID);
+		// ---- folder ----
+		if (properties.containsKey(PropertyIds.PARENT_ID))
+			properties.remove(PropertyIds.PARENT_ID);
+		if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS))
+			properties.remove(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
+		if (properties.containsKey(PropertyIds.PATH))
+			properties.remove(PropertyIds.PATH);
+		// ---- relationship ----
+		if (properties.containsKey(PropertyIds.SOURCE_ID))
+			properties.remove(PropertyIds.SOURCE_ID);
+		if (properties.containsKey(PropertyIds.TARGET_ID))
+			properties.remove(PropertyIds.TARGET_ID);
+		// ---- policy ----
+		if (properties.containsKey(PropertyIds.POLICY_TEXT))
+			properties.remove(PropertyIds.POLICY_TEXT);
+	}
+
+	public void persist() {
+		// in-memory implementation does not need to to anything to persist,
+		// but after this call the id should be set.
+		fId = fObjStore.storeObject(this);
 
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java Fri Apr 16 14:00:23 2010
@@ -33,138 +33,152 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
 
 public class VersionedDocumentImpl extends AbstractMultiFilingImpl implements VersionedDocument {
-  
-  private boolean fIsCheckedOut;
-  private String fCheckedOutUser;
-  private List<DocumentVersion> fVersions;
-  
-  
-  public VersionedDocumentImpl(ObjectStoreImpl objStore) {
-    super(objStore);
-    fVersions = new ArrayList<DocumentVersion>();
-    fIsCheckedOut = false;
-  }
-  
-  public DocumentVersion addVersion(ContentStream content,
-      VersioningState verState, String user) {
-    
-    if (isCheckedOut())
-        throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
-    
-    DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
-    ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy name and type id from version series.
-    ver.persist();
-    fVersions.add(ver);
-    if (verState == VersioningState.CHECKEDOUT) {
-      fCheckedOutUser = user;
-      fIsCheckedOut = true;
-    }
-    
-    return ver;
-  }
-
-  public boolean deleteVersion(DocumentVersion version) {
-    if (fIsCheckedOut)
-      throw new RuntimeException("version cannot be deleted if document is checked-out: " + version.getId());
-    boolean found = fVersions.remove(version);
-    if (!found)
-      throw new RuntimeException("Version is not contained in the document:" + version.getId());
-    
-    return !fVersions.isEmpty();
-  }
-  
-  
-  public void cancelCheckOut(String user) {
-    DocumentVersion pwc = getPwc();
-    fVersions.remove(pwc);
-    fObjStore.removeVersion(pwc);
-    fIsCheckedOut = false;
-    fCheckedOutUser = null;
-  }
-
-  public void checkIn(boolean isMajor, String checkinComment, String user) {
-    if (fIsCheckedOut) {
-      if (fCheckedOutUser.equals(user)) {        
-        fIsCheckedOut = false;
-        fCheckedOutUser = null;
-      } else {
-        throw new CmisConstraintException("Error: Can't checkin. Document " + getId()
-            + " user " + user + " has not checked out the document");
-      }
-    }
-    else
-      throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId() + " is not checked out.");
-    
-    DocumentVersion pwc = getPwc();
-    pwc.setCheckinComment(checkinComment);
-    pwc.commit(isMajor);
-  }
-
-  public DocumentVersion checkOut(ContentStream content, String user) {
-    if (fIsCheckedOut) {
-      throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
-    }
-    
-    // create PWC
-    DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will set check-out flag
-    return pwc;
-  }
-
-  public List<DocumentVersion> getAllVersions() {
-    return fVersions;
-  }
-
-  public DocumentVersion getLatestVersion(boolean major) {
-    
-    DocumentVersion latest = null;
-    if (major) {
-      for (DocumentVersion ver : fVersions) {
-        if (ver.isMajor())
-          latest = ver;
-      }
-    } else {
-      latest = fVersions.get(fVersions.size() - 1);
-    }
-    return latest;
-  }
-
-  public boolean isCheckedOut() {
-    return fIsCheckedOut;
-  }
-
-  public String getCheckedOutBy() {
-    return fCheckedOutUser;
-  }
-  
-  public DocumentVersion getPwc() {
-    for ( DocumentVersion ver : fVersions) {
-      if (ver.isPwc())
-        return ver;
-    }
-    return null;
-  }
-
-  public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
-      List<String> requestedIds) {
-    
-    DocumentVersion pwc = getPwc();
-    
-    super.fillProperties(properties, objFactory, requestedIds);
-    
-    // overwrite the version related properties 
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) { 
-      properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_ID, getId()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-      properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-      properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-      properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
-    }
-    
-  }
+
+	private boolean fIsCheckedOut;
+	private String fCheckedOutUser;
+	private List<DocumentVersion> fVersions;
+
+	public VersionedDocumentImpl(ObjectStoreImpl objStore) {
+		super(objStore);
+		fVersions = new ArrayList<DocumentVersion>();
+		fIsCheckedOut = false;
+	}
+
+	public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
+
+		if (isCheckedOut())
+			throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
+
+		DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
+		ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
+																					// name
+																					// and
+																					// type
+																					// id
+																					// from
+																					// version
+																					// series
+																					// .
+		ver.persist();
+		fVersions.add(ver);
+		if (verState == VersioningState.CHECKEDOUT) {
+			fCheckedOutUser = user;
+			fIsCheckedOut = true;
+		}
+
+		return ver;
+	}
+
+	public boolean deleteVersion(DocumentVersion version) {
+		if (fIsCheckedOut)
+			throw new RuntimeException("version cannot be deleted if document is checked-out: " + version.getId());
+		boolean found = fVersions.remove(version);
+		if (!found)
+			throw new RuntimeException("Version is not contained in the document:" + version.getId());
+
+		return !fVersions.isEmpty();
+	}
+
+	public void cancelCheckOut(String user) {
+		DocumentVersion pwc = getPwc();
+		fVersions.remove(pwc);
+		fObjStore.removeVersion(pwc);
+		fIsCheckedOut = false;
+		fCheckedOutUser = null;
+	}
+
+	public void checkIn(boolean isMajor, String checkinComment, String user) {
+		if (fIsCheckedOut) {
+			if (fCheckedOutUser.equals(user)) {
+				fIsCheckedOut = false;
+				fCheckedOutUser = null;
+			} else {
+				throw new CmisConstraintException("Error: Can't checkin. Document " + getId() + " user " + user
+						+ " has not checked out the document");
+			}
+		} else
+			throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId()
+					+ " is not checked out.");
+
+		DocumentVersion pwc = getPwc();
+		pwc.setCheckinComment(checkinComment);
+		pwc.commit(isMajor);
+	}
+
+	public DocumentVersion checkOut(ContentStream content, String user) {
+		if (fIsCheckedOut) {
+			throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
+		}
+
+		// create PWC
+		DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will
+																						// set
+																						// check
+																						// -
+																						// out
+																						// flag
+		return pwc;
+	}
+
+	public List<DocumentVersion> getAllVersions() {
+		return fVersions;
+	}
+
+	public DocumentVersion getLatestVersion(boolean major) {
+
+		DocumentVersion latest = null;
+		if (major) {
+			for (DocumentVersion ver : fVersions) {
+				if (ver.isMajor())
+					latest = ver;
+			}
+		} else {
+			latest = fVersions.get(fVersions.size() - 1);
+		}
+		return latest;
+	}
+
+	public boolean isCheckedOut() {
+		return fIsCheckedOut;
+	}
+
+	public String getCheckedOutBy() {
+		return fCheckedOutUser;
+	}
+
+	public DocumentVersion getPwc() {
+		for (DocumentVersion ver : fVersions) {
+			if (ver.isPwc())
+				return ver;
+		}
+		return null;
+	}
+
+	public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+			List<String> requestedIds) {
+
+		DocumentVersion pwc = getPwc();
+
+		super.fillProperties(properties, objFactory, requestedIds);
+
+		// overwrite the version related properties
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(
+					PropertyIds.VERSION_SERIES_ID, getId()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
+			properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(
+					PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(
+					PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(
+					PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+		}
+
+	}
 
 }

Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java Fri Apr 16 14:00:23 2010
@@ -40,245 +40,239 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.inmemory.TypeCreator;
 
 public class DefaultTypeSystemCreator implements TypeCreator {
-  static public List<TypeDefinition> singletonTypes = buildTypesList();
-  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 LEVEL1_TYPE = "DocumentLevel1";;
-  public static final String LEVEL2_TYPE = "DocumentLevel2";
-
-  /**
-   * in the public interface of this class we return the singleton containing the required types for
-   * testing
-   */
-  public List<TypeDefinition> createTypesList() {
-    return singletonTypes;
-  }
-
-  public static List<TypeDefinition> getTypesList() {
-    return singletonTypes;
-  }
-
-  static public TypeDefinition getTypeById(String typeId) {
-    for (TypeDefinition typeDef : singletonTypes)
-      if (typeDef.getId().equals(typeId))
-        return typeDef;
-    return null;
-  }
-
-  /**
-   * create root types and a collection of sample types
-   * 
-   * @return typesMap map filled with created types
-   */
-  private static List<TypeDefinition> buildTypesList() {
-    // always add CMIS default types
-    List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
-
-    InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
-        "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-    typesList.add(cmisType1);
-
-    InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
-        "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-    typesList.add(cmisType2);
-
-    InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
-        "My Type 3 Level 2", cmisType1);
-    typesList.add(cmisType11);
-
-    InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
-        "My Type 4 Level 3", cmisType11);
-    typesList.add(cmisType111);
-
-    InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
-        "My Type 5 Level 3", cmisType11);
-    typesList.add(cmisType112);
-
-    InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
-        "My Type 6 Level 2", cmisType1);
-    typesList.add(cmisType12);
-
-    InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
-        "My Type 7 Level 2", cmisType2);
-    typesList.add(cmisType21);
-
-    InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
-        "My Type 8 Level 2", cmisType2);
-    typesList.add(cmisType22);
-    InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
-        "My Type 9 Level 2", cmisType2);
-    typesList.add(cmisType23);
-    DocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4",
-        "My Type 10 Level 2", cmisType2);
-    typesList.add(cmisType24);
-    InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
-        "My Type 11 Level 2", cmisType2);
-    typesList.add(cmisType25);
-
-    InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
-        "My Type 12 Level 2", cmisType2);
-    typesList.add(cmisType26);
-    InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
-        "My Type 13 Level 2", cmisType2);
-    typesList.add(cmisType27);
-    InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
-        "My Type 14 Level 2", cmisType2);
-    typesList.add(cmisType28);
-    InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
-        "My Type 15 Level 2", cmisType2);
-    typesList.add(cmisType29);
-
-    // create a complex type with properties
-    InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
-        "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-    // create a boolean property definition
-
-    Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-    PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition(
-        "BooleanProp", "Sample Boolean Property");
-    propertyDefinitions.put(prop.getId(), prop);
-
-    prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
-        "Sample Boolean multi-value Property");
-    propertyDefinitions.put(prop.getId(), prop);
-
-    PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition(
-        "DateTimeProp", "Sample DateTime Property");
-    propertyDefinitions.put(prop2.getId(), prop2);
-
-    prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
-        "Sample DateTime multi-value Property");
-    propertyDefinitions.put(prop2.getId(), prop2);
-
-    PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition(
-        "DecimalProp", "Sample Decimal Property");
-    propertyDefinitions.put(prop3.getId(), prop3);
-
-    prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV",
-        "Sample Decimal multi-value Property");
-    propertyDefinitions.put(prop3.getId(), prop3);
-
-    PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
-        "Sample Html Property");
-    propertyDefinitions.put(prop4.getId(), prop4);
-
-    prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV",
-        "Sample Html multi-value Property");
-    propertyDefinitions.put(prop4.getId(), prop4);
-
-    PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp",
-        "Sample Id Property");
-    propertyDefinitions.put(prop5.getId(), prop5);
-
-    prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV",
-        "Sample Id Html multi-value Property");
-    propertyDefinitions.put(prop5.getId(), prop5);
-
-    PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition(
-        "IntProp", "Sample Int Property");
-    propertyDefinitions.put(prop6.getId(), prop6);
-
-    prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV",
-        "Sample Int multi-value Property");
-    propertyDefinitions.put(prop6.getId(), prop6);
-
-    PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition(
-        "StringProp", "Sample String Property");
-    propertyDefinitions.put(prop7.getId(), prop7);
-
-    PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp",
-        "Sample Uri Property");
-    propertyDefinitions.put(prop8.getId(), prop8);
-
-    prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV",
-        "Sample Uri multi-value Property");
-    propertyDefinitions.put(prop8.getId(), prop8);
-
-    PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(
-        "PickListProp", "Sample Pick List Property");
-    List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-    ChoiceImpl<String> elem = new ChoiceImpl<String>();
-    elem.setValue(Collections.singletonList("red"));
-    choiceList.add(elem);
-    elem = new ChoiceImpl<String>();
-    elem.setValue(Collections.singletonList("green"));
-    choiceList.add(elem);
-    elem = new ChoiceImpl<String>();
-    elem.setValue(Collections.singletonList("blue"));
-    choiceList.add(elem);
-    elem = new ChoiceImpl<String>();
-    elem.setValue(Collections.singletonList("black"));
-    choiceList.add(elem);
-    prop9.setChoices(choiceList);
-    prop9.setDefaultValue(Collections.singletonList("blue"));
-
-    /*
-     * try short form: * / PropertyCreationHelper.addElemToPicklist(prop9, "red");
-     * PropertyCreationHelper.addElemToPicklist(prop9, "green");
-     * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
-     * PropertyCreationHelper.addElemToPicklist(prop9, "black");
-     * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /*
-     */
-
-    cmisComplexType.setPropertyDefinitions(propertyDefinitions);
-
-    // add type to types collection
-    typesList.add(cmisComplexType);
-
-    // create a type hierarchy with inherited properties
-    InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
-        "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-    InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
-        "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-
-    InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
-        "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-
-    propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-    PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition(
-        "StringPropTopLevel", "Sample String Property");
-    propertyDefinitions.put(propTop.getId(), propTop);
-    cmisDocTypeTopLevel.setPropertyDefinitions(propertyDefinitions);
-
-    propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-    PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition(
-        "StringPropLevel1", "String Property Level 1");
-    propertyDefinitions.put(propLevel1.getId(), propLevel1);
-    cmisDocTypeLevel1.setPropertyDefinitions(propertyDefinitions);
-
-    propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-    PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition(
-        "StringPropLevel2", "String Property Level 2");
-    propertyDefinitions.put(propLevel2.getId(), propLevel2);
-    cmisDocTypeLevel2.setPropertyDefinitions(propertyDefinitions);
-
-    // add type to types collection
-    typesList.add(cmisDocTypeTopLevel);
-    typesList.add(cmisDocTypeLevel1);
-    typesList.add(cmisDocTypeLevel2);
-
-    // Create a type that is versionable
-    InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
-        "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-    
-    // create a single String property definition
-    
-    propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-    
-    PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp", "Sample String Property");
-    propertyDefinitions.put(prop1.getId(), prop1);
-    
-    cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);    
-    cmisVersionedType.setIsVersionable(true); // make it a versionable type;
-    
-    // add type to types collection
-    typesList.add(cmisVersionedType);
+	static public List<TypeDefinition> singletonTypes = buildTypesList();
+	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 LEVEL1_TYPE = "DocumentLevel1";;
+	public static final String LEVEL2_TYPE = "DocumentLevel2";
+
+	/**
+	 * in the public interface of this class we return the singleton containing
+	 * the required types for testing
+	 */
+	public List<TypeDefinition> createTypesList() {
+		return singletonTypes;
+	}
+
+	public static List<TypeDefinition> getTypesList() {
+		return singletonTypes;
+	}
+
+	static public TypeDefinition getTypeById(String typeId) {
+		for (TypeDefinition typeDef : singletonTypes)
+			if (typeDef.getId().equals(typeId))
+				return typeDef;
+		return null;
+	}
+
+	/**
+	 * create root types and a collection of sample types
+	 * 
+	 * @return typesMap map filled with created types
+	 */
+	private static List<TypeDefinition> buildTypesList() {
+		// always add CMIS default types
+		List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+
+		InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
+				"My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+		typesList.add(cmisType1);
+
+		InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
+				"My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+		typesList.add(cmisType2);
+
+		InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
+				"My Type 3 Level 2", cmisType1);
+		typesList.add(cmisType11);
+
+		InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
+				"My Type 4 Level 3", cmisType11);
+		typesList.add(cmisType111);
+
+		InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
+				"My Type 5 Level 3", cmisType11);
+		typesList.add(cmisType112);
+
+		InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
+				"My Type 6 Level 2", cmisType1);
+		typesList.add(cmisType12);
+
+		InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
+				"My Type 7 Level 2", cmisType2);
+		typesList.add(cmisType21);
+
+		InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
+				"My Type 8 Level 2", cmisType2);
+		typesList.add(cmisType22);
+		InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
+				"My Type 9 Level 2", cmisType2);
+		typesList.add(cmisType23);
+		DocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4", "My Type 10 Level 2",
+				cmisType2);
+		typesList.add(cmisType24);
+		InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
+				"My Type 11 Level 2", cmisType2);
+		typesList.add(cmisType25);
+
+		InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
+				"My Type 12 Level 2", cmisType2);
+		typesList.add(cmisType26);
+		InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
+				"My Type 13 Level 2", cmisType2);
+		typesList.add(cmisType27);
+		InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
+				"My Type 14 Level 2", cmisType2);
+		typesList.add(cmisType28);
+		InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
+				"My Type 15 Level 2", cmisType2);
+		typesList.add(cmisType29);
+
+		// create a complex type with properties
+		InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
+				"Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+		// create a boolean property definition
+
+		Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+
+		PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
+				"Sample Boolean Property");
+		propertyDefinitions.put(prop.getId(), prop);
+
+		prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
+				"Sample Boolean multi-value Property");
+		propertyDefinitions.put(prop.getId(), prop);
+
+		PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
+				"Sample DateTime Property");
+		propertyDefinitions.put(prop2.getId(), prop2);
+
+		prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
+				"Sample DateTime multi-value Property");
+		propertyDefinitions.put(prop2.getId(), prop2);
+
+		PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
+				"Sample Decimal Property");
+		propertyDefinitions.put(prop3.getId(), prop3);
+
+		prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property");
+		propertyDefinitions.put(prop3.getId(), prop3);
+
+		PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
+				"Sample Html Property");
+		propertyDefinitions.put(prop4.getId(), prop4);
+
+		prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property");
+		propertyDefinitions.put(prop4.getId(), prop4);
+
+		PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property");
+		propertyDefinitions.put(prop5.getId(), prop5);
+
+		prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property");
+		propertyDefinitions.put(prop5.getId(), prop5);
+
+		PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
+				"Sample Int Property");
+		propertyDefinitions.put(prop6.getId(), prop6);
+
+		prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property");
+		propertyDefinitions.put(prop6.getId(), prop6);
+
+		PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
+				"Sample String Property");
+		propertyDefinitions.put(prop7.getId(), prop7);
+
+		PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property");
+		propertyDefinitions.put(prop8.getId(), prop8);
+
+		prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property");
+		propertyDefinitions.put(prop8.getId(), prop8);
+
+		PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+				"Sample Pick List Property");
+		List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+		ChoiceImpl<String> elem = new ChoiceImpl<String>();
+		elem.setValue(Collections.singletonList("red"));
+		choiceList.add(elem);
+		elem = new ChoiceImpl<String>();
+		elem.setValue(Collections.singletonList("green"));
+		choiceList.add(elem);
+		elem = new ChoiceImpl<String>();
+		elem.setValue(Collections.singletonList("blue"));
+		choiceList.add(elem);
+		elem = new ChoiceImpl<String>();
+		elem.setValue(Collections.singletonList("black"));
+		choiceList.add(elem);
+		prop9.setChoices(choiceList);
+		prop9.setDefaultValue(Collections.singletonList("blue"));
+
+		/*
+		 * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
+		 * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
+		 * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
+		 * PropertyCreationHelper.addElemToPicklist(prop9, "black");
+		 * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
+		 */
+
+		cmisComplexType.setPropertyDefinitions(propertyDefinitions);
+
+		// add type to types collection
+		typesList.add(cmisComplexType);
+
+		// create a type hierarchy with inherited properties
+		InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
+				"Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+		InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
+				"Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
+
+		InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
+				"Document type with inherited properties, Level 3", cmisDocTypeLevel1);
+
+		propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+		PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
+				"Sample String Property");
+		propertyDefinitions.put(propTop.getId(), propTop);
+		cmisDocTypeTopLevel.setPropertyDefinitions(propertyDefinitions);
+
+		propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+		PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
+				"String Property Level 1");
+		propertyDefinitions.put(propLevel1.getId(), propLevel1);
+		cmisDocTypeLevel1.setPropertyDefinitions(propertyDefinitions);
+
+		propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+		PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
+				"String Property Level 2");
+		propertyDefinitions.put(propLevel2.getId(), propLevel2);
+		cmisDocTypeLevel2.setPropertyDefinitions(propertyDefinitions);
+
+		// add type to types collection
+		typesList.add(cmisDocTypeTopLevel);
+		typesList.add(cmisDocTypeLevel1);
+		typesList.add(cmisDocTypeLevel2);
+
+		// Create a type that is versionable
+		InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
+				"VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+		// create a single String property definition
+
+		propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+
+		PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
+				"Sample String Property");
+		propertyDefinitions.put(prop1.getId(), prop1);
 
-    return typesList;
-  }
+		cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
+		cmisVersionedType.setIsVersionable(true); // make it a versionable type;
+
+		// add type to types collection
+		typesList.add(cmisVersionedType);
+
+		return typesList;
+	}
 
 }