chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r910572 [31/36] - in /incubator/chemistry/trunk/opencmis: ./ _dev/ opencmis-client/ opencmis-client/opencmis-client-api/ opencmis-client/opencmis-client-api/src/ opencmis-client/opencmis-client-api/src/main/ opencmis-client/opencmis-client-...
Date Tue, 16 Feb 2010 16:04:07 GMT
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/DocumentTypeCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/DocumentTypeCreationHelper.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/DocumentTypeCreationHelper.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/DocumentTypeCreationHelper.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opencmis.inmemory.types;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.enums.Cardinality;
+import org.apache.opencmis.commons.enums.Updatability;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+
+public class DocumentTypeCreationHelper {
+
+  static private  List<TypeDefinition> defaultTypes = createCmisDefaultTypes();
+  
+  static public List<TypeDefinition> createMapWithDefaultTypes() {
+    List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+    typesList.addAll(defaultTypes);
+    return typesList;
+  }
+  
+  static public final List<TypeDefinition> getDefaultTypes() {
+    return defaultTypes;
+  }  
+  
+  static private List<TypeDefinition> createCmisDefaultTypes() {
+    List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
+
+    // create root types:
+    TypeDefinition cmisType = InMemoryDocumentTypeDefinition.getRootDocumentType();
+    typesList.add(cmisType);
+
+    cmisType = InMemoryFolderTypeDefinition.getRootFolderType();
+    typesList.add(cmisType);
+
+//    cmisType = RelationshipTypeDefinition.getRootRelationshipType();
+//    typesList.add(cmisType);
+//
+//    cmisType = PolicyTypeDefinition.getRootPolicyType();
+//    typesList.add(cmisType);
+
+    return typesList;
+  }
+  
+  /**
+   * create root types and a collection of sample types
+   * 
+   * @return typesMap map filled with created types
+   */
+  static public  List<TypeDefinition> createDefaultTypes() {
+    List<TypeDefinition> typesList = createCmisDefaultTypes();
+
+    return typesList;
+  }
+
+  public static void setBasicPropertyDefinitions(
+      Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+    PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_NAME, "CMIS Name Property");
+    propS.setUpdatability(Updatability.READWRITE);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_OBJECT_ID, "CMIS Object Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_OBJECT_TYPE_ID, "CMIS Object Type Id Property");
+    propId.setUpdatability(Updatability.ONCREATE);
+    propId.setIsRequired(true);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_BASE_TYPE_ID, "CMIS Base Type Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_CREATED_BY, "CMIS Created By Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    PropertyDateTimeDefinitionImpl propD = PropertyCreationHelper.createDateTimeDefinition(
+        PropertyIds.CMIS_CREATION_DATE, "CMIS Creation Date Property");
+    propD.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propD.getId(), propD);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_LAST_MODIFIED_BY, "CMIS Last Modified By Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    propD = PropertyCreationHelper.createDateTimeDefinition(
+        PropertyIds.CMIS_LAST_MODIFICATION_DATE, "CMIS Last Modification Date Property");
+    propD.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propD.getId(), propD);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_CHANGE_TOKEN, "CMIS Change Token Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+  }
+
+  public static void setBasicDocumentPropertyDefinitions(
+      Map<String, PropertyDefinition<?>> propertyDefinitions) {
+    
+    setBasicPropertyDefinitions(propertyDefinitions);
+    PropertyBooleanDefinitionImpl propB = PropertyCreationHelper.createBooleanDefinition(
+        PropertyIds.CMIS_IS_IMMUTABLE, "CMIS Is Immutable Property");
+    propB.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propB.getId(), propB);
+    
+    propB = PropertyCreationHelper.createBooleanDefinition(
+        PropertyIds.CMIS_IS_LATEST_VERSION, "CMIS Is Latest Version Property");
+    propB.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propB.getId(), propB);
+    
+    propB = PropertyCreationHelper.createBooleanDefinition(
+        PropertyIds.CMIS_IS_MAJOR_VERSION, "CMIS Is Major Version Property");
+    propB.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propB.getId(), propB);
+    
+    propB = PropertyCreationHelper.createBooleanDefinition(
+        PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, "CMIS Is Latest Major Version Property");
+    propB.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propB.getId(), propB);
+    
+    PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_VERSION_LABEL, "CMIS Version Label Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_VERSION_SERIES_ID, "CMIS Version Series Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propB = PropertyCreationHelper.createBooleanDefinition(
+        PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, "CMIS Is Version Series Checked Out Property");
+    propB.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propB.getId(), propS);
+        
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, "CMIS Version Series Checked Out By Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, "CMIS Version Series Checked Out Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_CHECKIN_COMMENT, "CMIS Checkin Comment Property");
+    propId.setUpdatability(Updatability.READONLY); // Note: spec says read-only, because not set as property
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    PropertyIntegerDefinitionImpl propI= PropertyCreationHelper.createIntegerDefinition(
+        PropertyIds.CMIS_CONTENT_STREAM_LENGTH, "CMIS Content Stream Length Property");
+    propI.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propI.getId(), propI);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_CONTENT_STREAM_MIME_TYPE, "CMIS Content Stream Mime Type Property");
+    propS.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_CONTENT_STREAM_FILE_NAME, "CMIS Content Stream File Name Property");
+    propertyDefinitions.put(propS.getId(), propS);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_CONTENT_STREAM_ID, "CMIS Stream Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+
+  }
+
+  public static void setBasicFolderPropertyDefinitions(
+      Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+    setBasicPropertyDefinitions(propertyDefinitions);
+    PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_PARENT_ID, "CMIS Parent Id Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS, "CMIS Allowed Childe Object Type Ids Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propId.setCardinality(Cardinality.MULTI);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_PATH, "CMIS Path Property");
+    propId.setUpdatability(Updatability.READONLY);
+    propertyDefinitions.put(propS.getId(), propS);
+
+  }
+
+  public static void setBasicPolicyPropertyDefinitions(
+      Map<String, PropertyDefinition<?>> propertyDefinitions) {
+
+    setBasicPropertyDefinitions(propertyDefinitions);
+    PropertyStringDefinitionImpl propS = PropertyCreationHelper.createStringDefinition(
+        PropertyIds.CMIS_POLICY_TEXT, "CMIS Policy Text Property");
+    propS.setIsRequired(true);
+    propertyDefinitions.put(propS.getId(), propS);    
+  }
+
+  public static void setBasicRelationshipPropertyDefinitions(
+      Map<String, PropertyDefinition<?>> propertyDefinitions) {
+  
+    setBasicPropertyDefinitions(propertyDefinitions);
+    PropertyIdDefinitionImpl propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_SOURCE_ID, "CMIS Source Id Property");
+    propId.setIsRequired(true);
+    propertyDefinitions.put(propId.getId(), propId);
+    
+    propId = PropertyCreationHelper.createIdDefinition(
+        PropertyIds.CMIS_TARGET_ID, "CMIS Target Id Property");
+    propId.setIsRequired(true);
+    propertyDefinitions.put(propId.getId(), propId);
+  }
+
+  public static void mergePropertyDefinitions(Map<String, PropertyDefinition<?>> existingPpropertyDefinitions, Map<String, PropertyDefinition<?>> newPropertyDefinitions) {
+    for (String propId : newPropertyDefinitions.keySet()) {
+      if (existingPpropertyDefinitions.containsKey(propId))
+        throw new RuntimeException("You can't set a property with id " + propId
+            + ". This property id already exists already or exists in supertype");
+    }
+    existingPpropertyDefinitions.putAll(newPropertyDefinitions);
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/DocumentTypeCreationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.opencmis.commons.enums.ContentStreamAllowed;
+import org.apache.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.opencmis.inmemory.NameValidator;
+
+/**
+ * A small convenience class simplifying document type creation
+ * 
+ */
+
+public class InMemoryDocumentTypeDefinition extends DocumentTypeDefinitionImpl {
+
+  private static final long serialVersionUID = 1L;
+  private static InMemoryDocumentTypeDefinition DOCUMENT_TYPE = new InMemoryDocumentTypeDefinition();
+
+  public static InMemoryDocumentTypeDefinition getRootDocumentType() {
+    return DOCUMENT_TYPE;
+  }
+
+  /* This constructor is just for creating the root document */
+  public InMemoryDocumentTypeDefinition() {
+    init(BaseObjectTypeIds.CMIS_DOCUMENT.value(), "CMIS Document");
+    setParentId(null);
+    // set base properties
+    Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+    DocumentTypeCreationHelper.setBasicDocumentPropertyDefinitions(props);
+  }
+
+  public InMemoryDocumentTypeDefinition(String id, String displayName) {
+    init(id, displayName);
+    setParentId(DOCUMENT_TYPE.getId());
+  }
+
+  public InMemoryDocumentTypeDefinition(String id, String displayName, InMemoryDocumentTypeDefinition parentType) {
+    // get root type
+    init(id, displayName);
+    if (parentType != null)
+      setBaseId(parentType.getBaseId());
+    else
+      throw new IllegalArgumentException(
+          "Must provide a parent type when creating a document type definition");
+    setParentId(parentType.getId());
+  }
+
+  /* 
+   * Set the property definitions for this type. The parameter propertyDefinitions should only
+   * contain the custom property definitions for this type. The standard property definitions are
+   * added automatically.
+   * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#setPropertyDefinitions(java.util.Map)
+   */
+  public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+    DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+  }
+
+//  public void setProperties() {
+//    Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+//    this.setPropertyDefinitions(propertyDefinitions);    
+//  }
+  
+  private void init(String id, String displayName) {
+    if (!NameValidator.isValidId(id))
+      throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_ID);
+
+    setBaseId(BaseObjectTypeIds.CMIS_DOCUMENT);
+    setId(id);
+    if (displayName == null)
+      displayName = '#' + id + '#';
+    setDisplayName(displayName);
+    // create some suitable defaults for convenience
+    setDescription("Description of " + getDisplayName() + " Type");
+    setLocalName(id);
+    setLocalNamespace("local");
+    setQueryName(id);
+    setIsControllableAcl(false);
+    setIsControllablePolicy(false);
+    setIsCreatable(true);
+    setIsFileable(true);
+    setIsFulltextIndexed(false);
+    setIsIncludedInSupertypeQuery(true);
+    setIsQueryable(false);
+    
+    Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+    setPropertyDefinitions(props); // set initial empty set of properties
+
+    // document specifics:
+    setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+    setIsVersionable(false);    
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryDocumentTypeDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
+import org.apache.opencmis.inmemory.NameValidator;
+
+public class InMemoryFolderTypeDefinition extends FolderTypeDefinitionImpl {
+
+  private static final long serialVersionUID = 1L;
+  private static InMemoryFolderTypeDefinition FOLDER_TYPE = new InMemoryFolderTypeDefinition();
+
+  public static InMemoryFolderTypeDefinition getRootFolderType() {
+    return FOLDER_TYPE;
+  }
+
+  /* This constructor is just for creating the root document */
+  public InMemoryFolderTypeDefinition() {
+    init(BaseObjectTypeIds.CMIS_FOLDER.value(), "CMIS Folder");
+    setParentId(null);
+    // set base properties
+    Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+    DocumentTypeCreationHelper.setBasicFolderPropertyDefinitions(props);
+  }
+
+  public InMemoryFolderTypeDefinition(String id, String displayName) {
+    init(id, displayName);
+    setParentId(FOLDER_TYPE.getId());
+  }
+
+  public InMemoryFolderTypeDefinition(String id, String displayName, InMemoryFolderTypeDefinition parentType) {
+    // get root type
+    init(id, displayName);
+    if (parentType != null)
+      setBaseId(parentType.getBaseId());
+    else
+      throw new IllegalArgumentException(
+          "Must provide a parent type when creating a folder type definition");
+    setParentId(parentType.getId());
+  }
+
+  /* 
+   * Set the property definitions for this type. The parameter propertyDefinitions should only
+   * contain the custom property definitions for this type. The standard property definitions are
+   * added automatically.
+   * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#setPropertyDefinitions(java.util.Map)
+   */
+  public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+    DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+  }
+
+  private void init(String id, String displayName) {
+    if (!NameValidator.isValidId(id))
+        throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+    setBaseId(BaseObjectTypeIds.CMIS_FOLDER);
+    setId(id);
+    if (displayName == null)
+      displayName = '#' + id + '#';
+    setDisplayName(displayName);
+    // create some suitable defaults for convenience
+    setDescription("Description of " + getDisplayName() + " Type");
+    setLocalName(id);
+    setLocalNamespace("local");
+    setQueryName(id);
+    setIsControllableAcl(false);
+    setIsControllablePolicy(false);
+    setIsCreatable(true);
+    setIsFileable(true);
+    setIsFulltextIndexed(false);
+    setIsIncludedInSupertypeQuery(true);
+    setIsQueryable(false);
+
+    Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+    setPropertyDefinitions(props); // set initial empty set of properties    
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryFolderTypeDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.opencmis.commons.impl.dataobjects.PolicyTypeDefinitionImpl;
+import org.apache.opencmis.inmemory.NameValidator;
+
+public class InMemoryPolicyTypeDefinition extends PolicyTypeDefinitionImpl {
+
+  private static final long serialVersionUID = 1L;
+  private static InMemoryPolicyTypeDefinition POLICY_TYPE = new InMemoryPolicyTypeDefinition();
+
+  public static InMemoryPolicyTypeDefinition getRootPolicyType() {
+    return POLICY_TYPE;
+  }
+
+  /* This constructor is just for creating the root document */
+  public InMemoryPolicyTypeDefinition() {
+    init(BaseObjectTypeIds.CMIS_POLICY.value(), "CMIS Policy");
+    setParentId(null);
+
+    Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+    DocumentTypeCreationHelper.setBasicPolicyPropertyDefinitions(props);
+  }
+
+  public InMemoryPolicyTypeDefinition(String id, String displayName) {
+    init(id, displayName);
+    setParentId(POLICY_TYPE.getId());
+  }
+
+  public InMemoryPolicyTypeDefinition(String id, String displayName, InMemoryPolicyTypeDefinition parentType) {
+    // get root type
+    init(id, displayName);
+    if (parentType != null)
+      setBaseId(parentType.getBaseId());
+    else
+      throw new IllegalArgumentException(
+          "Must provide a parent type when creating a policy definition");
+    setParentId(parentType.getId());
+  }
+
+  /* 
+   * Set the property definitions for this type. The parameter propertyDefinitions should only
+   * contain the custom property definitions for this type. The standard property definitions are
+   * added automatically.
+   * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#setPropertyDefinitions(java.util.Map)
+   */
+  public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+    DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+  }
+
+  private void init(String id, String displayName) {
+    if (!NameValidator.isValidId(id))
+      throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+    setBaseId(BaseObjectTypeIds.CMIS_POLICY);
+    setId(id);
+    if (displayName == null)
+      displayName = '#' + id + '#';
+    setDisplayName(displayName);
+    // create some suitable defaults for convenience
+    setDescription("Description of " + getDisplayName() + " Type");
+    setLocalName(id);
+    setLocalNamespace("local");
+    setQueryName(id);
+    setIsControllableAcl(false);
+    setIsControllablePolicy(false);
+    setIsCreatable(true);
+    setIsFileable(true);
+    setIsFulltextIndexed(false);
+    setIsIncludedInSupertypeQuery(true);
+    setIsQueryable(false);
+    
+    // set base properties
+    Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+    setPropertyDefinitions(props); // set initial empty set of properties 
+
+    // policy specifics: none
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryPolicyTypeDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opencmis.inmemory.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
+import org.apache.opencmis.inmemory.NameValidator;
+
+public class InMemoryRelationshipTypeDefinition extends RelationshipTypeDefinitionImpl {
+
+  private static final long serialVersionUID = 1L;
+  private static InMemoryRelationshipTypeDefinition RELATIONSHIP_TYPE = new InMemoryRelationshipTypeDefinition();
+
+  public static InMemoryRelationshipTypeDefinition getRootRelationshipType() {
+    return RELATIONSHIP_TYPE;
+  }
+
+  /* This constructor is just for creating the root document */
+  public InMemoryRelationshipTypeDefinition() {
+    init(BaseObjectTypeIds.CMIS_RELATIONSHIP.value(), "CMIS Relation");
+    setParentId(null);
+
+    Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
+    DocumentTypeCreationHelper.setBasicRelationshipPropertyDefinitions(props);
+  }
+
+  public InMemoryRelationshipTypeDefinition(String id, String displayName) {
+    init(id, displayName);
+    setParentId(RELATIONSHIP_TYPE.getId());
+  }
+
+  public InMemoryRelationshipTypeDefinition(String id, String displayName,
+      InMemoryRelationshipTypeDefinition parentType) {
+    // get root type
+    init(id, displayName);
+    if (parentType != null)
+      setBaseId(parentType.getBaseId());
+    else
+      throw new IllegalArgumentException(
+          "Must provide a parent type when creating a relationship definition");
+    setParentId(parentType.getId());
+  }
+
+  /* 
+   * Set the property definitions for this type. The parameter propertyDefinitions should only
+   * contain the custom property definitions for this type. The standard property definitions are
+   * added automatically.
+   * @see org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#setPropertyDefinitions(java.util.Map)
+   */
+  public void addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
+    DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
+  }
+
+  private void init(String id, String displayName) {
+    if (!NameValidator.isValidId(id))
+      throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+    setBaseId(BaseObjectTypeIds.CMIS_RELATIONSHIP);
+    setId(id);
+    if (displayName == null)
+      displayName = '#' + id + '#';
+    setDisplayName(displayName);
+    // create some suitable defaults for convenience
+    setDescription("Description of " + getDisplayName() + " Type");
+    setLocalName(id);
+    setLocalNamespace("local");
+    setQueryName(id);
+    setIsControllableAcl(false);
+    setIsControllablePolicy(false);
+    setIsCreatable(true);
+    setIsFileable(true);
+    setIsFulltextIndexed(false);
+    setIsIncludedInSupertypeQuery(true);
+    setIsQueryable(false);
+
+    // relationship specifics
+    setAllowedSourceTypes(null);
+    setAllowedTargetTypes(null);
+    
+    // set base properties
+    Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
+    setPropertyDefinitions(props); // set initial empty set of properties
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/InMemoryRelationshipTypeDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.opencmis.inmemory.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.api.Choice;
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.enums.Cardinality;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.enums.PropertyType;
+import org.apache.opencmis.commons.enums.Updatability;
+import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
+import org.apache.opencmis.commons.impl.dataobjects.ChoiceImpl;
+import org.apache.opencmis.commons.impl.dataobjects.ObjectDataImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
+import org.apache.opencmis.commons.provider.AllowableActionsData;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.inmemory.DataObjectCreator;
+import org.apache.opencmis.inmemory.FilterParser;
+import org.apache.opencmis.inmemory.NameValidator;
+import org.apache.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.opencmis.inmemory.storedobj.api.StoredObject;
+
+/**
+ * @author Jens
+ * 
+ */
+
+public class PropertyCreationHelper {
+  private static Log log = LogFactory.getLog(PropertyCreationHelper.class);
+  
+  public static PropertyBooleanDefinitionImpl createBooleanDefinition(String id, String displayName) {    
+    PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyBooleanDefinitionImpl createBooleanMultiDefinition(String id, String displayName) {
+    PropertyBooleanDefinitionImpl prop = new PropertyBooleanDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.BOOLEAN, displayName, Cardinality.MULTI);
+    return prop;
+  }
+  
+  public static PropertyDateTimeDefinitionImpl createDateTimeDefinition(String id, String displayName) {    
+    PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyDateTimeDefinitionImpl createDateTimeMultiDefinition(String id, String displayName) {
+    PropertyDateTimeDefinitionImpl prop = new PropertyDateTimeDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.DATETIME, displayName, Cardinality.MULTI);
+    return prop;
+  }
+  
+  public static PropertyDecimalDefinitionImpl createDecimalDefinition(String id, String displayName) {    
+    PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyDecimalDefinitionImpl createDecimalMultiDefinition(String id, String displayName) {
+    PropertyDecimalDefinitionImpl prop = new PropertyDecimalDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.DECIMAL, displayName, Cardinality.MULTI);
+    return prop;
+  }
+  
+  public static PropertyHtmlDefinitionImpl createHtmlDefinition(String id, String displayName) {    
+    PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyHtmlDefinitionImpl createHtmlMultiDefinition(String id, String displayName) {
+    PropertyHtmlDefinitionImpl prop = new PropertyHtmlDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.HTML, displayName, Cardinality.MULTI);
+    return prop;
+  }
+
+  public static PropertyIdDefinitionImpl createIdDefinition(String id, String displayName) {    
+    PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyIdDefinitionImpl createIdMultiDefinition(String id, String displayName) {
+    PropertyIdDefinitionImpl prop = new PropertyIdDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.ID, displayName, Cardinality.MULTI);
+    return prop;
+  }
+
+  public static PropertyIntegerDefinitionImpl createIntegerDefinition(String id, String displayName) {    
+    PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyIntegerDefinitionImpl createIntegerMultiDefinition(String id, String displayName) {
+    PropertyIntegerDefinitionImpl prop = new PropertyIntegerDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.INTEGER, displayName, Cardinality.MULTI);
+    return prop;
+  }
+  
+  public static PropertyStringDefinitionImpl createStringDefinition(String id, String displayName) {    
+    PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyStringDefinitionImpl createStringMultiDefinition(String id, String displayName) {
+    PropertyStringDefinitionImpl prop = new PropertyStringDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.STRING, displayName, Cardinality.MULTI);
+    return prop;
+  }
+
+  public static PropertyUriDefinitionImpl createUriDefinition(String id, String displayName) {    
+    PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.SINGLE);    
+    return prop;
+  }
+
+  public static PropertyUriDefinitionImpl createUriMultiDefinition(String id, String displayName) {
+    PropertyUriDefinitionImpl prop = new PropertyUriDefinitionImpl();
+    createStandardDefinition(prop, id, PropertyType.URI, displayName, Cardinality.MULTI);
+    return prop;
+  }
+  
+  
+    public static<T> void  addElemToPicklist(AbstractPropertyDefinition<T> prop, T value) {
+      List<Choice<T>> choiceList = prop.getChoices();
+      if (choiceList == null)
+        choiceList = new ArrayList<Choice<T>>();
+
+      ChoiceImpl<T> elem = new ChoiceImpl<T>();
+      elem.setValue( Collections.singletonList(value));
+      choiceList.add(elem);
+    }    
+    
+    public static<T> void setDefaultValue(AbstractPropertyDefinition<T> prop , T defVal) {
+      prop.setDefaultValue(Collections.singletonList(defVal));
+    }    
+
+  
+  // internal helpers
+  private static void createStandardDefinition(AbstractPropertyDefinition<?> prop,
+      String id, PropertyType propType, String displayName, Cardinality card) {
+
+    if (!NameValidator.isValidId(id))
+      if (!NameValidator.isValidId(id))
+        throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+    prop.setId(id);
+    if (displayName == null)
+      prop.setDisplayName("Sample " + prop.getId() + " boolean property");
+    else
+      prop.setDisplayName(displayName);
+    prop.setLocalName(id);
+    prop.setLocalNamespace("local");
+    prop.setQueryName(id);
+    prop.setIsInherited(false);
+    prop.setCardinality(card);
+    prop.setIsOpenChoice(false);
+    prop.setIsQueryable(true);
+    prop.setIsRequired(false);
+    prop.setPropertyType(propType);
+    prop.setUpdatability(Updatability.READWRITE);
+  }
+  
+  public static PropertiesData getPropertiesFromObject(String repositoryId, StoredObject so,
+      StoreManager storeManager, List<String> requestedIds) {
+    // build properties collection 
+    
+    ProviderObjectFactory objectFactory = storeManager.getObjectFactory();
+    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    so.fillProperties(properties, objectFactory, requestedIds);
+
+    String typeId = so.getTypeId();
+      // (String) props.getProperties().get(PropertyIds.CMIS_OBJECT_TYPE_ID).getFirstValue();
+    if (FilterParser.isContainedInFilter(PropertyIds.CMIS_BASE_TYPE_ID, requestedIds)) {
+      TypeDefinitionContainer typeDefC = storeManager.getTypeById(repositoryId, typeId);
+      if (typeDefC == null) {
+        log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
+            + " is unknown");
+      } else {
+        TypeDefinition typeDef = typeDefC.getTypeDefinition();
+        String baseTypeId = typeDef.getBaseId().value();
+        properties.add(objectFactory.createPropertyIdData(PropertyIds.CMIS_BASE_TYPE_ID, baseTypeId));
+      }
+    }    
+    PropertiesData props = objectFactory.createPropertiesData(properties);
+    return props;    
+  }
+  
+  public static ObjectData getObjectData(StoreManager sm, StoredObject so, String filter,
+      Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+      String renditionFilter, Boolean includePolicyIds, Boolean includeACL, ExtensionsData extension) {
+
+    ObjectDataImpl od = new ObjectDataImpl();
+
+    if (so == null)
+      throw new CmisObjectNotFoundException("Illegal object id: null");
+
+    // build properties collection
+    List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+    PropertiesData props = getPropertiesFromObject(so.getRepositoryId(), so,
+        sm, requestedIds);
+
+    // fill output object
+    if (null != includeAllowableActions && includeAllowableActions) {
+      AllowableActionsData allowableActions = DataObjectCreator.fillAllowableActions(so);
+      od.setAllowableActions(allowableActions);
+    }
+    if (null != includeACL && includeACL)
+      od.setAcl(null);
+    od.setIsExactAcl(true);
+
+    if (null != includePolicyIds && includePolicyIds)
+      od.setPolicyIds(DataObjectCreator.fillPolicyIds(so));
+
+    if (null != includeRelationships && includeRelationships != IncludeRelationships.NONE)
+      od.setRelationships(DataObjectCreator.fillRelationships(includeRelationships, so));
+
+    if (renditionFilter != null && renditionFilter.length() > 0)
+      od.setRenditions(DataObjectCreator.fillRenditions(so));
+
+    od.setProperties(props);
+
+    // Note: do not set change event info for this call
+    log.debug("stop getObject()");
+    return od;
+  }
+  
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties Tue Feb 16 16:03:38 2010
@@ -0,0 +1,33 @@
+class=org.apache.opencmis.inmemory.server.ServiceFactory
+
+repository.id=dummy-rep
+repository.name=Dummy Repository
+
+# In Memory Settings
+InMemoryServer.RepositoryId=A1
+# InMemoryServer.RepositoryInfoCreatorClass=org.apache.opencmis.client.provider.inmemory.UnitTestRepositoryInfo
+InMemoryServer.User=dummyuser
+InMemoryServer.Password=dummysecret
+InMemoryServer.TypesCreatorClass=org.apache.opencmis.inmemory.types.DefaultTypeSystemCreator
+
+# settings for init repository with data
+  # enable or disable
+RepositoryFiller.Enable=true
+  # Type id of documents that are created
+RepositoryFiller.DocumentTypeId=ComplexType
+  # Type id of folders that are created
+RepositoryFiller.FolderTypeId=cmis:folder
+  # Number of documents created per folder
+RepositoryFiller.DocsPerFolder=3
+  # Number of folders created per folder
+RepositoryFiller.FolderPerFolder=2
+  # number of folder levels created (depth of hierarchy)
+RepositoryFiller.Depth=3
+  # Size of content for documents (0=do not create content), default=0
+RepositoryFiller.ContentSizeInKB=32
+  # properties to set for a document
+RepositoryFiller.DocumentProperty.0=StringProp
+#RepositoryFiller.DocumentProperty.1=StringPropMV
+  # properties to set for a folder
+#RepositoryFiller.FolderProperty.0=StringFolderProp
+  
\ No newline at end of file

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/FolderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/FolderTest.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/FolderTest.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/FolderTest.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.opencmis.inmemory;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.opencmis.inmemory.storedobj.api.ObjectStore;
+import org.apache.opencmis.inmemory.storedobj.api.Path;
+import org.apache.opencmis.inmemory.storedobj.api.StoredObject;
+import org.apache.opencmis.inmemory.storedobj.impl.FolderImpl;
+import org.apache.opencmis.inmemory.storedobj.impl.ObjectStoreImpl;
+
+/**
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * @author Jens
+ */
+
+/* Some test directly against the in-memory folder object
+ * 
+ */
+
+public class FolderTest  extends TestCase {
+  
+  private ObjectStore fStore;
+  private FolderImpl fRoot;
+  private FolderImpl f1;
+  private FolderImpl f2;
+  private FolderImpl f3;
+  private FolderImpl f4;
+  private FolderImpl f11;
+  private static final String TEST_REPOSITORY_ID = "TestRepositoryId";
+
+  protected void setUp() throws Exception {
+    fStore = new ObjectStoreImpl(TEST_REPOSITORY_ID);
+    createFolders();
+  }
+    
+  public void testCreatAndGetFolders() {
+    try {
+      Folder childFolder = fStore.createFolder("Folder 1");
+      fRoot.addChildFolder(childFolder);
+      fail("Should throw exception if folder already exists.");
+    } catch (Exception e) {
+    }
+    assertEquals(f1.getName(), "Folder 1");
+    assertEquals(f11.getName(), "Folder 1.1");
+    assertNull(fRoot.getParent());
+    assertEquals(fRoot, f1.getParent());
+    assertEquals(f1, f11.getParent());
+    assertEquals(Path.PATH_SEPARATOR, fRoot.getPath());
+    assertEquals("/Folder 1", f1.getPath());
+    assertEquals("/Folder 1/Folder 1.1", f11.getPath());
+    StoredObject fTest = fStore.getObjectByPath("/");
+    assertEquals(fRoot, fTest);
+    fTest = fStore.getObjectByPath("/Folder 1");
+    assertEquals(f1, fTest);
+    fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1");
+    assertEquals(f11, fTest); 
+    List<StoredObject> subFolders = fRoot.getChildren(-1, -1);
+    assertEquals(4, subFolders.size()); 
+    subFolders = f2.getChildren(-1, -1);
+    assertEquals(0, subFolders.size()); 
+    subFolders = f1.getChildren(-1, -1);
+    assertEquals(1, subFolders.size()); 
+  }
+
+  public void testRenameFolder() {
+    // rename top level folder
+    String newName = "Folder B";
+    String oldPath = f2.getPath();
+    f2.rename(newName);
+    assertEquals(f2.getName(), newName);
+    assertEquals(f2.getPath(), Path.PATH_SEPARATOR + newName);
+    assertNull(fStore.getObjectByPath(oldPath));
+    assertEquals(f2, fStore.getObjectByPath(Path.PATH_SEPARATOR + newName));
+    try {
+      f2.rename("Folder 3");
+      fail("Should not allow to rename a folder to an existing name");
+    } catch (Exception e) {      
+    }
+    
+    // rename sub folder
+    oldPath = f11.getPath();
+    f11.rename(newName);
+    assertEquals(f11.getName(), newName);
+    assertEquals(f11.getPath(), "/Folder 1/Folder B");
+    assertNull(fStore.getObjectByPath(oldPath));
+    assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B"));
+    try {
+      f2.rename(newName);
+      fail("Should not allow to rename a folder to an existing name");
+    } catch (Exception e) {      
+    }
+    try {
+      f2.rename("illegal/name");
+      fail("Should not allow to rename a folder to a name with illegal name");
+    } catch (Exception e) {      
+    }
+    
+    // rename root folder
+    try {
+      fRoot.rename("abc");
+      fail("Should not be possible to rename root folder");
+    } catch (Exception e) {      
+    }    
+  }
+  
+  public void testMoveFolder() {
+    String oldPath = f1.getPath();
+    f1.move(f3);
+    assertNull(fStore.getObjectByPath(oldPath));
+    assertEquals(f1.getPath(), "/Folder 3/Folder 1");
+    assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1"));
+    
+    f2.rename("Folder 1");
+    try {
+      f2.move(f3);
+      fail("Should not be possible to move folder to a folder that has a child with same name");
+    } catch (Exception e) {            
+    }
+  }
+  
+  public void testDeleteFolder() {
+    String oldPath = f2.getPath();
+    fStore.deleteObject(f2.getId());
+    assertNull(fStore.getObjectByPath(oldPath));
+
+    try {
+      fStore.deleteObject(f1.getId());
+      fail("Should not be possible to move folder that has children");
+    } catch (Exception e) {            
+    }
+    
+    
+  }
+
+  private void createFolders() {
+    fRoot = (FolderImpl)fStore.getRootFolder();
+    f1 = (FolderImpl) fStore.createFolder("Folder 1");
+    fRoot.addChildFolder(f1);
+    
+    f2 =  (FolderImpl) fStore.createFolder("Folder 2");
+    fRoot.addChildFolder(f2);
+    
+    f3 =  (FolderImpl) fStore.createFolder("Folder 3");
+    fRoot.addChildFolder(f3);
+
+    f4 =  (FolderImpl) fStore.createFolder("Folder 4");
+    fRoot.addChildFolder(f4);
+
+    f11 =  (FolderImpl) fStore.createFolder("Folder 1.1");
+    f1.addChildFolder(f11);
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/FolderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.opencmis.inmemory;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.client.provider.factory.CmisProviderFactory;
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.SessionParameter;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.opencmis.commons.provider.CmisProvider;
+import org.apache.opencmis.commons.provider.NavigationService;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.ObjectInFolderContainer;
+import org.apache.opencmis.commons.provider.ObjectInFolderData;
+import org.apache.opencmis.commons.provider.ObjectInFolderList;
+import org.apache.opencmis.commons.provider.ObjectService;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.commons.provider.RepositoryService;
+import org.apache.opencmis.inmemory.ConfigConstants;
+import org.apache.opencmis.inmemory.ConfigMap;
+import org.apache.opencmis.inmemory.MapConfigReader;
+import org.apache.opencmis.inmemory.RepositoryServiceTest.UnitTestRepositoryInfo;
+import org.apache.opencmis.inmemory.clientprovider.CmisInMemorySpi;
+import org.apache.opencmis.inmemory.server.RuntimeContext;
+import org.apache.opencmis.inmemory.storedobj.impl.SessionConfigReader;
+import org.apache.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.opencmis.util.repository.ObjectGenerator;
+
+
+/**
+ * @author Jens
+ */
+public class NavigationServiceTest extends TestCase {
+  private static Log log = LogFactory.getLog(NavigationServiceTest.class);
+  private static final String REPOSITORY_ID = "UnitTestRepository";
+  private ProviderObjectFactory fFactory;
+  private CmisProvider fProvider;
+  private static final int NUM_ROOT_FOLDERS = 10;
+  private String fLevel1FolderId;
+  String fRootFolderId;
+  private String fRepositoryId;
+
+  protected void setUp() throws Exception {
+
+    Map<String, String> parameters = new HashMap<String, String>();
+    parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisProviderFactory.BINDING_SPI_INMEMORY);
+    // attach repository info to the session:
+    parameters
+        .put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
+    parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
+    
+    // get factory and create provider
+    CmisProviderFactory factory = CmisProviderFactory.newInstance();
+    fProvider = factory.createCmisProvider(parameters);
+    assertNotNull(fProvider);
+    fFactory = fProvider.getObjectFactory();
+    RepositoryService repSvc = fProvider.getRepositoryService();
+    RepositoryInfoData rep = repSvc.getRepositoryInfo(REPOSITORY_ID, null);
+    fRootFolderId = rep.getRootFolderId();
+    fRepositoryId = rep.getRepositoryId();
+    // Attach the CallContext to a thread local context that can be accessed from everywhere
+    ConfigMap cfgReader = new MapConfigReader(parameters);  
+    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
+  }
+
+  protected void tearDown() throws Exception {
+  }
+
+  public void testGetChildren() {
+    log.info("starting testGetChildren() ...");
+    createLevel1Folders();
+    NavigationService navSvc = fProvider.getNavigationService();
+
+    log.info("test getting all objects with getChildren");
+    BigInteger maxItems = BigInteger.valueOf(NUM_ROOT_FOLDERS *2);
+    BigInteger skipCount = BigInteger.valueOf(0);
+    ObjectInFolderList result = navSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
+        IncludeRelationships.NONE, null, true, maxItems, skipCount, null);
+    List<ObjectInFolderData> folders = result.getObjects();
+    log.info(" found " + folders.size() + " folders in getChildren()");
+    for (ObjectInFolderData folder : folders) {
+      log.info("   found folder id " + folder.getObject().getId() + " path segment "
+          + folder.getPathSegment());
+    }
+    assertEquals(NUM_ROOT_FOLDERS, folders.size());
+    
+    log.info("test paging with getChildren");
+    maxItems = BigInteger.valueOf(3);
+    skipCount = BigInteger.valueOf(3);    
+    result = navSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
+        IncludeRelationships.NONE, null, true, maxItems, skipCount, null);
+    folders = result.getObjects();
+    log.info(" found " + folders.size() + " folders in getChildren()");
+    for (ObjectInFolderData folder : folders) {
+      log.info("   found folder id " + folder.getObject().getId() + " path segment "
+          + folder.getPathSegment());
+    }
+    assertEquals(3, folders.size());
+    assertEquals("Folder 3", folders.get(0).getPathSegment());
+    log.info("... testGetChildren() finished.");
+  }
+
+  public void testGetFolderTree() {
+    log.info("starting testGetFolderTree() ...");    
+    createFolderHierachy(3, 5);
+    //createLevel1Folders();
+    NavigationService navSvc = fProvider.getNavigationService();
+
+    log.info("test getting all objects with getFolderTree");
+    BigInteger depth = BigInteger.valueOf(-1);
+    Boolean includePathSegments = true;
+    String propertyFilter = "*";
+    String renditionFilter = null;
+    Boolean includeAllowableActions = false;
+    String objectId = fRootFolderId;
+    
+    List<ObjectInFolderContainer> tree = navSvc.getFolderTree(fRepositoryId, objectId,
+        depth, propertyFilter, includeAllowableActions, IncludeRelationships.NONE, renditionFilter,
+        includePathSegments, null);    
+    
+    log.info("Descendants for object id " + objectId + " are: ");
+    for (ObjectInFolderContainer folder : tree) {
+      logFolderContainer(folder, 0);
+    }
+    
+    log.info("... testGetFolderTree() finished.");
+  }
+
+  private void logFolderContainer(ObjectInFolderContainer folder, int depth) {
+    StringBuilder prefix = new StringBuilder();
+    for (int i=0; i<depth; i++)
+      prefix.append("   ");
+    
+    log.info(prefix + "name: " + folder.getObject().getPathSegment());
+    List<ObjectInFolderContainer> children = folder.getChildren();
+    if (null != children) {
+      for (ObjectInFolderContainer child: children) {
+        logFolderContainer(child, depth+1);
+      } 
+    }
+  }
+
+  public void testGetDescendants() {
+    log.info("starting testGetDescendants() ...");
+    final int numLevels = 3;
+    final int childrenPerLevel = 3;
+    int objCount = createFolderHierachy(numLevels, childrenPerLevel);
+    NavigationService navSvc = fProvider.getNavigationService();
+
+    log.info("test getting all objects with getDescendants");
+    List<ObjectInFolderContainer> result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(-1),
+        "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
+    
+    for (ObjectInFolderContainer obj: result) {
+      log.info("   found folder id " + obj.getObject().getObject().getId() + " path segment "
+          + obj.getObject().getPathSegment());
+    }
+    int sizeOfDescs = getSizeOfDescendants(result);
+    assertEquals(objCount, sizeOfDescs);
+
+    log.info("test getting one level with getDescendants");
+    result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(1),
+        "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
+    
+    for (ObjectInFolderContainer obj: result) {
+      log.info("   found folder id " + obj.getObject().getObject().getId() + " path segment "
+          + obj.getObject().getPathSegment());
+    }
+    sizeOfDescs = getSizeOfDescendants(result);
+    assertEquals(childrenPerLevel, sizeOfDescs);
+    
+    log.info("test getting two levels with getDescendants");
+    result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(2),
+        "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
+    
+    for (ObjectInFolderContainer obj: result) {
+      log.info("   found folder id " + obj.getObject().getObject().getId() + " path segment "
+          + obj.getObject().getPathSegment());
+    }
+    sizeOfDescs = getSizeOfDescendants(result);
+    assertEquals(childrenPerLevel*childrenPerLevel+childrenPerLevel, sizeOfDescs);
+
+    log.info("... testGetDescendants() finished.");
+  }
+  
+  public void testGetFolderParent() {
+    log.info("starting testGetFolderParent() ...");
+    createLevel1Folders();
+    NavigationService navSvc = fProvider.getNavigationService();
+    String folderId = fLevel1FolderId;
+    
+    ObjectData result = navSvc.getFolderParent(fRepositoryId, folderId, null, null);
+    log.info(" found parent for id \'" + folderId + "\' is \'" + result.getId() + "\'");
+    assertEquals(fRootFolderId, result.getId()); // should be root folder 
+    
+    folderId = fRootFolderId;
+    try {
+      result = navSvc.getFolderParent(fRepositoryId, folderId, null, null);
+      log.info(" found parent for id " + folderId + " is " + result.getId());
+      fail("Should not be possible to get parent for root folder");
+    } catch (Exception e) {
+      assertEquals(CmisInvalidArgumentException.class, e.getClass());
+      log.info(" getParent() for root folder raised expected exception");      
+    }
+    log.info("... testGetFolderParent() finished.");
+  }
+
+  private int getSizeOfDescendants(List<ObjectInFolderContainer> objs) {
+    int sum = objs.size();
+    if (null != objs) {
+      for (ObjectInFolderContainer obj: objs) {
+        if (null != obj.getChildren())
+          sum += getSizeOfDescendants(obj.getChildren());
+      }
+    }
+    return sum;
+  }
+  
+  private void createLevel1Folders() {
+    ObjectService objSvc = fProvider.getObjectService();
+    for (int i = 0; i < NUM_ROOT_FOLDERS; i++) {
+      List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+      properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, "Folder " + i));
+      properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID,
+          InMemoryFolderTypeDefinition.getRootFolderType().getId()));
+      PropertiesData props = fFactory.createPropertiesData(properties);      
+      String id = objSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
+      if (i==3) // store one
+        fLevel1FolderId = id;
+    }
+  }
+  
+  private int createFolderHierachy(int levels, int childrenPerLevel) {
+    NavigationService navSvc = fProvider.getNavigationService();
+    ObjectService objSvc = fProvider.getObjectService();
+
+    ObjectGenerator gen = new ObjectGenerator(fFactory, navSvc, objSvc, fRepositoryId);
+    gen.createFolderHierachy(levels, childrenPerLevel, fRootFolderId);
+    int objCount = gen.getObjectsInTotal();
+    return objCount;
+  }
+  
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectCreator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectCreator.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectCreator.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectCreator.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.opencmis.inmemory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.enums.VersioningState;
+import org.apache.opencmis.commons.impl.dataobjects.ContentStreamDataImpl;
+import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.commons.provider.ContentStreamData;
+import org.apache.opencmis.commons.provider.Holder;
+import org.apache.opencmis.commons.provider.ObjectService;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.PropertyStringData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+
+public class ObjectCreator {
+  
+  private ProviderObjectFactory fFactory;
+  private ObjectService fObjSvc;
+  private String fRepositoryId;
+
+  public ObjectCreator(ProviderObjectFactory factory, ObjectService objSvc, String repositoryId) {
+    fObjSvc = objSvc;
+    fFactory = factory;
+    fRepositoryId = repositoryId;
+  }
+  
+  public String createDocument(String name, String typeId, String folderId, VersioningState versioningState, Map<String, String> propsToSet) {
+    ContentStreamData contentStream = null;
+    List<String> policies = null;
+    AccessControlList addACEs = null;
+    AccessControlList removeACEs = null;
+    ExtensionsData extension = null;
+
+    PropertiesData props = createStringDocumentProperties(name, typeId, propsToSet);
+
+    contentStream = createContent();
+
+    String id = null;
+    id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
+        policies, addACEs, removeACEs, extension);
+    if (null == id)
+      junit.framework.Assert.fail("createDocument failed.");
+
+    return id;
+  }
+  
+  public PropertiesData createStringDocumentProperties(String name, String typeId, Map<String, String> propsToSet) {
+    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, name));
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId));
+    if (null != propsToSet)
+      for (Entry<String, String> propToSet : propsToSet.entrySet()) {
+        properties.add(fFactory.createPropertyStringData(propToSet.getKey(), propToSet.getValue()));      
+      }
+    PropertiesData props = fFactory.createPropertiesData(properties);
+    return props;
+  }
+
+  public ContentStreamData createContent() {
+    ContentStreamDataImpl content = new ContentStreamDataImpl();
+    content.setFilename("data.txt");
+    content.setMimeType("text/plain");
+    int len = 32 * 1024;
+    byte[] b = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,     
+                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a
+                }; // 32 Bytes
+    ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+    try {
+      for (int i=0; i<1024; i++)
+        ba.write(b);
+    } catch (IOException e) {
+        throw new RuntimeException("Failed to fill content stream with data", e) ;
+    }
+    content.setStream(new ByteArrayInputStream(ba.toByteArray()));
+    content.setLength(BigInteger.valueOf(len));
+    return content;
+  }
+  
+  public ContentStreamData createAlternateContent() {
+    ContentStreamDataImpl content = new ContentStreamDataImpl();
+    content.setFilename("data.txt");
+    content.setMimeType("text/plain");
+    int len = 32 * 1024;
+    byte[] b = {0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
+        0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,     
+        0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
+        0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61
+    }; // 32 Bytes
+    ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+    try {
+      for (int i=0; i<1024; i++)
+        ba.write(b);
+    } catch (IOException e) {
+        throw new RuntimeException("Failed to fill content stream with data", e) ;
+    }
+    content.setStream(new ByteArrayInputStream(ba.toByteArray()));
+    content.setLength(BigInteger.valueOf(len));
+    return content;
+  }
+
+  /**
+   * Compare two streams and return true if they are equal
+   * @param csd1
+   * @param csd2
+   * @return
+   */
+  public boolean verifyContent(ContentStreamData csd1, ContentStreamData csd2) {
+    if (!csd1.getFilename().equals(csd2.getFilename()))
+        return false;
+    if (!csd1.getLength().equals(csd2.getLength()))
+        return false;
+    if (!csd1.getMimeType().equals(csd2.getMimeType()))
+        return false;
+    long len = csd1.getLength().longValue();
+    InputStream s1 = csd1.getStream();
+    InputStream s2 = csd2.getStream();
+    try {
+      for (int i=0; i<len; i++) {
+        int val1 = s1.read();
+        int val2 = s2.read();
+        if (val1 != val2)
+          return false;
+        }
+    }
+    catch (IOException e) {
+      e.printStackTrace();
+      return false;
+    }    
+    return true;
+  }
+  
+  public void updateProperty(String id, String propertyId, String propertyValue) {
+    PropertiesData properties = getUpdatePropertyList(propertyId, propertyValue);
+
+    Holder<String> idHolder = new Holder<String>(id);
+    Holder<String> changeTokenHolder = new Holder<String>();
+    fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, properties, null);    
+  }
+
+  public PropertiesData getUpdatePropertyList(String propertyId, String propertyValue) {
+    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    properties.add(fFactory.createPropertyStringData(propertyId, propertyValue));      
+    PropertiesData newProps = fFactory.createPropertiesData(properties);
+    return newProps;
+  }
+
+  public boolean verifyProperty(String id, String propertyId, String propertyValue) {
+      PropertiesData props = fObjSvc.getProperties(fRepositoryId, id, "*", null);
+      Map<String, PropertyData<?>> propsMap = props.getProperties();
+      PropertyStringData pd = (PropertyStringData) propsMap.get(propertyId);
+      return propertyValue.equals(pd.getFirstValue());      
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message