chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r912517 [2/3] - in /incubator/chemistry/trunk/opencmis: opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/ opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/clientprovider/...
Date Mon, 22 Feb 2010 08:58:41 GMT
Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java Mon Feb 22 08:58:39 2010
@@ -19,6 +19,7 @@
 package org.apache.opencmis.inmemory.server;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -32,7 +33,6 @@
 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.MapConfigReader;
 import org.apache.opencmis.inmemory.NavigationServiceImpl;
 import org.apache.opencmis.inmemory.ObjectServiceImpl;
 import org.apache.opencmis.inmemory.RepositoryServiceImpl;
@@ -40,6 +40,7 @@
 import org.apache.opencmis.inmemory.storedobj.impl.StoreManagerFactory;
 import org.apache.opencmis.inmemory.storedobj.impl.StoreManagerImpl;
 import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
 import org.apache.opencmis.server.spi.CmisDiscoveryService;
 import org.apache.opencmis.server.spi.CmisNavigationService;
 import org.apache.opencmis.server.spi.CmisObjectService;
@@ -50,12 +51,7 @@
 public class ServiceFactory extends AbstractServicesFactory {
 
   private static final Log LOG = LogFactory.getLog(ServiceFactory.class.getName());
-  private static StoreManager STORE_MANAGER; // singleton root of everything
-  public static StoreManager getInstance() {
-    if (null == STORE_MANAGER)
-      throw new RuntimeException("Application not initialized correctly");
-    return STORE_MANAGER;
-  }
+  private  StoreManager fStoreManager; // singleton root of everything
 
   private InMemoryRepositoryService fRepositoryService;
   private InMemoryNavigationService fNavigationService;
@@ -63,6 +59,10 @@
   private InMemoryVersioningService fVersioningService;
   private InMemoryDiscoveryService fDiscoveryService;
 
+  public StoreManager getStoreManager() {
+    return fStoreManager;
+  }
+  
   @Override
   public void init(Map<String, String> parameters) {
     LOG.info("Initializing in-memory repository...");
@@ -72,51 +72,44 @@
     if (null==repositoryClassName)
       repositoryClassName = StoreManagerImpl.class.getName();
     
-    if (null == STORE_MANAGER)
-      STORE_MANAGER = StoreManagerFactory.createInstance(repositoryClassName);
+    if (null == fStoreManager)
+      fStoreManager = StoreManagerFactory.createInstance(repositoryClassName);
 
-    MapConfigReader cfgReader = new MapConfigReader(parameters);
-    STORE_MANAGER.setConfigReader(cfgReader);
     String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
     
-    List<String> allAvailableRepositories = STORE_MANAGER.getAllRepositoryIds();
+    List<String> allAvailableRepositories = fStoreManager.getAllRepositoryIds();
     
     // init existing repositories
     for (String existingRepId : allAvailableRepositories)
-      STORE_MANAGER.initRepository(existingRepId, false);
+      fStoreManager.initRepository(existingRepId);
 
-    // create repository
+    // create repository if configured as a startup parameter
     if (null != repositoryId) {
       if (allAvailableRepositories.contains(repositoryId)) 
         LOG.warn("Repostory " + repositoryId + " already exists and will not be created.");
       else {
-        STORE_MANAGER.createRepository(repositoryId);
-        // then create/initialize type system
         String typeCreatorClassName = parameters.get(ConfigConstants.TYPE_CREATOR_CLASS);        
-        STORE_MANAGER.initTypeSystem(repositoryId, typeCreatorClassName);
-        // then init repository (note: loads root folder which requires cmis:folder type available)
-        
-        STORE_MANAGER.initRepository(repositoryId, true);
+        fStoreManager.createAndInitRepository(repositoryId, typeCreatorClassName);
       }
     }
 
-    if (repositoryId != null) {
-      String repoInfoCreatorClassName = parameters.get(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS);
-      STORE_MANAGER.initRepositoryInfo(repositoryId, repoInfoCreatorClassName);    
-    }
+//    if (repositoryId != null) {
+//      String repoInfoCreatorClassName = parameters.get(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS);
+//      fStoreManager.initRepositoryInfo(repositoryId, repoInfoCreatorClassName);    
+//    }
     
     // initialize services
-    fRepositoryService = new InMemoryRepositoryService(STORE_MANAGER);
-    fNavigationService = new InMemoryNavigationService(STORE_MANAGER);
-    fObjectService = new InMemoryObjectService(STORE_MANAGER);
-    fVersioningService = new InMemoryVersioningService(STORE_MANAGER, fObjectService.getObjectService());
+    fRepositoryService = new InMemoryRepositoryService(fStoreManager);
+    fNavigationService = new InMemoryNavigationService(fStoreManager);
+    fObjectService = new InMemoryObjectService(fStoreManager);
+    fVersioningService = new InMemoryVersioningService(fStoreManager, fObjectService.getObjectService());
     // Begin temporary implementation for discover service
-    fDiscoveryService = new InMemoryDiscoveryService(STORE_MANAGER, fRepositoryService.getRepositoryService(),  fNavigationService.getNavigationService());
+    fDiscoveryService = new InMemoryDiscoveryService(fStoreManager, fRepositoryService.getRepositoryService(),  fNavigationService.getNavigationService());
     // End temporary implementation
     
     // With some special configuration settings fill the repository with some documents and folders if is empty
     if (!allAvailableRepositories.contains(repositoryId))
-      fillRepositoryIfConfigured(cfgReader, repositoryId);
+      fillRepositoryIfConfigured(parameters, repositoryId);
     
     LOG.info("...initialized in-memory repository.");
   }
@@ -151,9 +144,31 @@
     return fDiscoveryService;
   }
     
-  private void fillRepositoryIfConfigured(MapConfigReader cfgReader, String repositoryId) {
+  private void fillRepositoryIfConfigured(Map<String, String> parameters, String repositoryId) {
+    class DummyCallContext implements CallContext {
+
+      public String get(String key) {
+        return null;
+      }
+
+      public String getBinding() {
+        return null;
+      }
+
+      public String getLocale() {
+        return null;
+      }
+
+      public String getPassword() {
+        return null;
+      }
+
+      public String getUsername() {
+        return null;
+      }
+    }
     
-    String doFillRepositoryStr = cfgReader.get(ConfigConstants.USE_REPOSITORY_FILER);
+    String doFillRepositoryStr = parameters.get(ConfigConstants.USE_REPOSITORY_FILER);
     boolean doFillRepository = doFillRepositoryStr == null ? false : Boolean
         .parseBoolean(doFillRepositoryStr);
 
@@ -161,35 +176,35 @@
       return;
     
     ProviderObjectFactory objectFactory = new ProviderObjectFactoryImpl();
-    NavigationService navSvc = new NavigationServiceImpl(STORE_MANAGER);
-    ObjectService objSvc = new ObjectServiceImpl(STORE_MANAGER);
-    RepositoryService repSvc = new RepositoryServiceImpl(STORE_MANAGER);
+    NavigationService navSvc = new NavigationServiceImpl(fStoreManager);
+    ObjectService objSvc = new ObjectServiceImpl(fStoreManager);
+    RepositoryService repSvc = new RepositoryServiceImpl(fStoreManager);
         
-    String levelsStr = cfgReader.get(ConfigConstants.FILLER_DEPTH);
+    String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
     int levels = 1;
     if (null!=levelsStr)
       levels = Integer.parseInt(levelsStr);  
        
-    String docsPerLevelStr = cfgReader.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
+    String docsPerLevelStr = parameters.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
     int docsPerLevel = 1;
     if (null!=docsPerLevelStr)
       docsPerLevel = Integer.parseInt(docsPerLevelStr);
 
-    String childrenPerLevelStr = cfgReader.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
+    String childrenPerLevelStr = parameters.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
     int childrenPerLevel = 2;
     if (null!=childrenPerLevelStr)
       childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
     
-    String documentTypeId =  cfgReader.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
+    String documentTypeId =  parameters.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
     if (null == documentTypeId)
       documentTypeId = BaseObjectTypeIds.CMIS_DOCUMENT.value();
     
-    String folderTypeId =  cfgReader.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
+    String folderTypeId =  parameters.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
     if (null == folderTypeId)
       folderTypeId = BaseObjectTypeIds.CMIS_FOLDER.value();
 
     int contentSizeKB = 0;
-    String contentSizeKBStr = cfgReader.get(ConfigConstants.FILLER_CONTENT_SIZE);
+    String contentSizeKBStr = parameters.get(ConfigConstants.FILLER_CONTENT_SIZE);
     if (null!=contentSizeKBStr)
       contentSizeKB = Integer.parseInt(contentSizeKBStr);
 
@@ -211,19 +226,19 @@
     // set the properties the generator should fill with values for documents:
     // Note: must be valid properties in configured document and folder type
    
-    List<String> propsToSet = readPropertiesToSetFromConfig(cfgReader,
+    List<String> propsToSet = readPropertiesToSetFromConfig(parameters,
         ConfigConstants.FILLER_DOCUMENT_PROPERTY);
     if (null != propsToSet)
       gen.setDocumentPropertiesToGenerate(propsToSet);
     
-    propsToSet = readPropertiesToSetFromConfig(cfgReader,
+    propsToSet = readPropertiesToSetFromConfig(parameters,
         ConfigConstants.FILLER_FOLDER_PROPERTY);
     if (null != propsToSet)
       gen.setFolderPropertiesToGenerate(propsToSet);
 
     // Simulate a runtime context with configuration parameters
     // Attach the CallContext to a thread local context that can be accessed from everywhere
-    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
+    RuntimeContext.getRuntimeConfig().attachCfg(new DummyCallContext());
 
     // Build the tree
     RepositoryInfoData rep = repSvc.getRepositoryInfo(repositoryId, null);
@@ -240,11 +255,11 @@
 
   }
   
-  private List<String> readPropertiesToSetFromConfig(MapConfigReader cfgReader, String keyPrefix) {
+  private List<String> readPropertiesToSetFromConfig(Map<String, String> parameters, String keyPrefix) {
     List<String> propsToSet = new ArrayList<String>();
     for (int i=0; ; ++i) {
       String propertyKey = keyPrefix + Integer.toString(i);
-      String propertyToAdd = cfgReader.get(propertyKey);
+      String propertyToAdd = parameters.get(propertyKey);
       if (null == propertyToAdd)
         break;
       else

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java Mon Feb 22 08:58:39 2010
@@ -57,7 +57,7 @@
 
   /**
    * get all the children of this folder. To support paging an initial offset and a
-   * maximum number of childrent to retrieve can be passed
+   * maximum number of children to retrieve can be passed
    * 
    * @param maxItems
    *    max. number of items to return

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java Mon Feb 22 08:58:39 2010
@@ -26,7 +26,7 @@
    * @return
    *    object containing mime-type, length and a stream with content
    */
-  ContentStreamData getContent();
+  ContentStreamData getContent(long offset, long length);
 
   /**
    * Assign content do a document. Existing content gets overwritten.

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java Mon Feb 22 08:58:39 2010
@@ -27,6 +27,6 @@
  * @author Jens
  *
  */
-public interface DocumentVersion extends Version, Content, StoredObject {
+public interface DocumentVersion extends Version, Content, StoredObject, Path {
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java Mon Feb 22 08:58:39 2010
@@ -24,7 +24,6 @@
 import org.apache.opencmis.commons.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 import org.apache.opencmis.commons.provider.RepositoryInfoData;
-import org.apache.opencmis.inmemory.ConfigMap;
 import org.apache.opencmis.inmemory.RepositoryInfo;
 
 /**
@@ -44,14 +43,17 @@
   List<String> getAllRepositoryIds();
   
   /**
-   * Initialize the store for the given repository (first call done on a StoreManager after creation)
+   * Initialize the store for the given repository. Only called for repositories
+   * that exist on startup (i.e. for each repository id returned in a previous
+   * getAllRepositoryIds() call.
+   * 
    * @param repositoryId
    *    id of repository to initialize
    * @param isCreated
    *    true if the repository was just created and is initialized for the first time
    *    false if it existed before and is reloaded
    */
-  public void initRepository(String repositoryId, boolean isCreated);
+  public void initRepository(String repositoryId);
   
   /**
    * get the object store for the given repository id.
@@ -62,12 +64,16 @@
   ObjectStore getObjectStore(String repositoryId);
 
   /**
-   * create a new repository with the given id
+   * create a new repository with the given id. Create the repository, initiate
+   * the type system and initialize it so that it is ready for use
    * 
    * @param repositoryId
    *    id of repository
+   * @param typeCreatorClassName
+   *    class implementing the type creation, the class must implement the interface
+   *    TypeCreator
    */
-  void createRepository(String repositoryId);
+  void createAndInitRepository(String repositoryId, String typeCreatorClassName);
   
   /**
    * load an existing repository with the given id
@@ -79,16 +85,6 @@
   
   
   /**
-   * retrieve a parameter that a client has attached to a session
-   * 
-   * @param parameter
-   *    name of the parameter
-   * @return
-   *    value of the parameter
-   */
-  String getParameter(String parameter);
-
-  /**
    * retrieve a list with all type definitions. 
    * @param repositoryId
    *    id of repository 
@@ -139,36 +135,4 @@
    */
   RepositoryInfoData getRepositoryInfo(String repositoryId);
 
-  /**
-   * Initialize the type system. Helper class to create types in the repository
-   * implemented in an implementation specific way. CMIS does not yet provide a 
-   * standard to create type definitions. The SPI will call this method in case
-   * a class name was attached to the session. The implementation of this method
-   * should call initTypeSystem of the StoreManager to add the types to the 
-   * system. 
-   * 
-   * @param repositoryId
-   *    id of repository where this type gets stored
-   * @param typeCreatorClassName
-   *    class implementing the type creation, the class must implement the interface
-   *    TypeCreator
-   *    
-   */
-  void initTypeSystem(String repositoryId, String typeCreatorClassName);
-
-  /**
-   * Initialize the repository information. A client can assign specific values that
-   * should be set for subsequent getRepositoryInfo() call. Mainly uses for unit tests.
-   * 
-   * @param repoInfoCreatorClassName
-   *    class name of class setting repository information. The class must implement
-   *    the interface RepositoryInfoCreator
-   */
-  void initRepositoryInfo(String repositoryInfo, String repoInfoCreatorClassName);
-
-  /**
-   * Assign a reader that can retrieve context parameters to this repository manager
-   * @param session
-   */
-  void setConfigReader(ConfigMap configMap);  
 }
\ No newline at end of file

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java Mon Feb 22 08:58:39 2010
@@ -203,7 +203,7 @@
    */
   void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user);
 
-  void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+  void fillProperties(Map<String, PropertyData<?>> properties, ProviderObjectFactory objFactory,
       List<String> requestedIds);
 
   /**

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java Mon Feb 22 08:58:39 2010
@@ -36,6 +36,17 @@
   
   DocumentVersion addVersion(ContentStreamData content, VersioningState verState, String user);
   
+  /**
+   * delete a version from this object, throw exception if document is checked out
+   * or document does not contain this version
+   * @param version
+   *    version to be removed
+   * @return
+   *    true if version could be removed, and other versions exist,
+   *    false if the deleted version was the last version in this document
+   */
+  boolean deleteVersion(DocumentVersion version);
+  
   boolean isCheckedOut();
   
   void cancelCheckOut(String user);
@@ -44,7 +55,7 @@
   
   void checkIn(boolean isMajor, String checkinComment, String user);
   
-  List<DocumentVersion> getAllVersions(String filter);
+  List<DocumentVersion> getAllVersions();
   
   DocumentVersion getLatestVersion(boolean major);
   

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java Mon Feb 22 08:58:39 2010
@@ -40,20 +40,15 @@
     Path {
 
   protected FolderImpl fParent;
-  protected ObjectStoreImpl fObjStore;
 
   protected AbstractPathImpl(ObjectStoreImpl objStore) {
-    fObjStore = objStore;
+    super(objStore);
   }
-  
-  public String getId() {
-    return getPath();
-  }
-  
+    
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
+   * @see org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
    */
   public String getPath() {
     StringBuffer path= new StringBuffer(getName());
@@ -76,14 +71,14 @@
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent()
+   * @see org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent()
    */
   public Folder getParent() {
     return fParent;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath#setParent(org.apache.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
+   * @see org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath#setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
    */
   public void setParent(Folder parent) {
     fParent = (FolderImpl) parent;
@@ -98,16 +93,16 @@
       throw new IllegalArgumentException("Cannot rename object to " + newName
           + ". This path already exists.");
 
-    String oldPath = getPath(); 
+//    String oldPath = getPath(); 
     setName(newName);
-    String newPath = getPath();
-    fObjStore.changePath(this, oldPath, newPath);    
+//    String newPath = getPath();
+//    fObjStore.changePath(this, oldPath, newPath);    
   }
   
   public void move(Folder newParent) {
     // we delegate this to the folder class because we need access to the global map to move
     if (this instanceof Document || this instanceof VersionedDocument)
-      fParent.moveChildDocument((Document) this, newParent);    
+      fParent.moveChildDocument(this, newParent);    
     else {// it must be a folder
       if (getParent() == null)
         throw new IllegalArgumentException("Root folder cannot be moved.");
@@ -117,11 +112,11 @@
         throw new IllegalArgumentException(
             "Cannot move folder, this name already exists in target.");
 
-      String oldPath = getPath(); // old path
+//      String oldPath = getPath(); // old path
       setParent(newParent);
-      String newPath = getPath(); // new path
+//      String newPath = getPath(); // new path
 
-      fObjStore.renameAllIdsWithPrefix(oldPath, newPath);
+//      fObjStore.renameAllIdsWithPrefix(oldPath, newPath);
 //      fId = newPath;
     }
 //    fId = getPath(); // as we use path the id will change

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java Mon Feb 22 08:58:39 2010
@@ -17,9 +17,14 @@
 
   private String fFileName;
 
-  byte[] fContent;
+  private byte[] fContent;
+  
+  private long fStreamLimitOffset;
+  
+  private long fStreamLimitLength;
 
   public void setContent (InputStream in) throws IOException {
+    fStreamLimitOffset = fStreamLimitLength = -1;
     if (null == in) {
       fContent = null; // delete content
       fLength = 0;
@@ -64,10 +69,25 @@
   public InputStream getStream() {
     if (null == fContent)
       return null;
-    else
+    else if (fStreamLimitOffset <= 0 && fStreamLimitLength < 0)
       return new ByteArrayInputStream(fContent);
+    else 
+      return new ByteArrayInputStream(fContent, (int)(fStreamLimitOffset<0 ? 0 : fStreamLimitOffset),
+          (int)(fStreamLimitLength<0 ? fLength : fStreamLimitLength));      
+  }
+
+  public ContentStreamData getCloneWithLimits(long offset, long length) {
+    ContentStreamDataImpl clone = new ContentStreamDataImpl();
+    clone.fFileName = fFileName;
+    clone.fLength = fLength;
+    clone.fContent = fContent;
+    clone.fMimeType = fMimeType;
+    clone.fStreamLimitOffset = offset;
+    clone.fStreamLimitLength = length;
+    return clone;
   }
-
+  
+  
   public List<Object> getExtensions() {
     return null;
   }

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java Mon Feb 22 08:58:39 2010
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,17 +50,20 @@
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IDocument#getContent()
+   * @see org.opencmis.client.provider.spi.inmemory.IDocument#getContent()
    */
-  public ContentStreamData getContent() {
-    return fContent;
+  public ContentStreamData getContent(long offset, long length) {
+    if (offset<=0 && length<0)
+      return fContent;
+    else
+      return fContent.getCloneWithLimits(offset, length);
   }
 
   /*
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.apache.opencmis.client.provider
+   * org.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.opencmis.client.provider
    * .ContentStreamData)
    */
   public void setContent(ContentStreamData content, boolean mustPersist) {
@@ -80,12 +84,7 @@
     }
   }
 
-  public void persist() {
-    // The in-memory provider doesn't have to do anything here, but sets the id
-    fId = getPath();
-  }
-
-  public void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+  public void fillProperties(Map<String, PropertyData<?>> properties, ProviderObjectFactory objFactory,
       List<String> requestedIds) {
 
     super.fillProperties(properties, objFactory, requestedIds);
@@ -93,29 +92,29 @@
     // fill the version related properties (versions should override this but the spec requires some
     // properties always to be set
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_VERSION, true));
+      properties.put(PropertyIds.CMIS_IS_LATEST_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_VERSION, true));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_MAJOR_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_MAJOR_VERSION, true));
+      properties.put(PropertyIds.CMIS_IS_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_MAJOR_VERSION, true));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, true));
+      properties.put(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, true));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_ID, requestedIds)) {
       // return id of document itself
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, getId()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, getId()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, false));
+      properties.put(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, false));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, (String)null));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, (String)null));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, (String)null));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, (String)null));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_CHECKIN_COMMENT, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_CHECKIN_COMMENT, (String)null));
+      properties.put(PropertyIds.CMIS_CHECKIN_COMMENT, objFactory.createPropertyStringData(PropertyIds.CMIS_CHECKIN_COMMENT, (String)null));
     }
     
     // optional:

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Mon Feb 22 08:58:39 2010
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import org.apache.opencmis.commons.PropertyIds;
@@ -30,6 +31,7 @@
 import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 import org.apache.opencmis.inmemory.FilterParser;
 import org.apache.opencmis.inmemory.storedobj.api.DocumentVersion;
+import org.apache.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.opencmis.inmemory.storedobj.api.VersionedDocument;
 
 /**
@@ -47,7 +49,8 @@
   boolean fIsPwc; // true if this is the PWC
   
   public DocumentVersionImpl(String repositoryId, VersionedDocument container, ContentStreamData content,
-      VersioningState verState) {
+      VersioningState verState, ObjectStoreImpl objStore) {
+    super(objStore);
     setRepositoryId(repositoryId);
     fContainer = container;
     setContent(content, false);
@@ -80,7 +83,7 @@
   public String getVersionLabel() {
     int majorNo = 0;
     int minorNo = 0;
-    List<DocumentVersion> allVersions = fContainer.getAllVersions(null);
+    List<DocumentVersion> allVersions = fContainer.getAllVersions();
     for (DocumentVersion ver : allVersions) {
       if (ver.isMajor()) {
         ++majorNo;
@@ -105,8 +108,11 @@
     fIsMajor = isMajor;
   }
   
-  public ContentStreamData getContent() {
-    return fContent;
+  public ContentStreamData getContent(long offset, long length) {
+    if (offset<=0 && length<0)
+      return fContent;
+    else
+      return fContent.getCloneWithLimits(offset, length);
   }
   
   public VersionedDocument getParentDocument() {
@@ -114,7 +120,7 @@
   }
 
   private boolean isLatestVersion() {
-    List<DocumentVersion> allVers = fContainer.getAllVersions(null);
+    List<DocumentVersion> allVers = fContainer.getAllVersions();
     boolean isLatestVersion;
     if (isPwc())
       isLatestVersion = allVers.size()>1 && allVers.get(allVers.size()-2).equals(this);
@@ -127,7 +133,7 @@
     if (!fIsMajor)
       return false;
     
-    List<DocumentVersion> allVersions = fContainer.getAllVersions(null);
+    List<DocumentVersion> allVersions = fContainer.getAllVersions();
     DocumentVersion latestMajor=null;
     
     for (DocumentVersion ver : allVersions)
@@ -138,12 +144,12 @@
     return isLatestMajorVersion;
   }
   
-  public void persist() {
-    if (null==fId)
-      fId = UUID.randomUUID().toString();
-  }
+//  public void persist() {
+//    if (null==fId)
+//      fId = UUID.randomUUID().toString();
+//  }
   
-  public void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+  public void fillProperties(Map<String, PropertyData<?>> properties, ProviderObjectFactory objFactory,
       List<String> requestedIds) {
     
     DocumentVersion pwc = fContainer.getPwc();
@@ -157,32 +163,48 @@
     
     // fill the version related properties 
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_VERSION, isLatestVersion()));
+      properties.put(PropertyIds.CMIS_IS_LATEST_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_VERSION, isLatestVersion()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_MAJOR_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_MAJOR_VERSION, fIsMajor));
+      properties.put(PropertyIds.CMIS_IS_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_MAJOR_VERSION, fIsMajor));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
+      properties.put(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_ID, requestedIds)) { 
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, fContainer.getId()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, fContainer.getId()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, fContainer.isCheckedOut()));
+      properties.put(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, fContainer.isCheckedOut()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, fContainer.getCheckedOutBy()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, fContainer.getCheckedOutBy()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_CHECKIN_COMMENT, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_CHECKIN_COMMENT, fComment));
+      properties.put(PropertyIds.CMIS_CHECKIN_COMMENT, objFactory.createPropertyStringData(PropertyIds.CMIS_CHECKIN_COMMENT, fComment));
     }    
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_LABEL, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_LABEL, getVersionLabel()));
+      properties.put(PropertyIds.CMIS_VERSION_LABEL, objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_LABEL, getVersionLabel()));
     }
   }
+
+  public Folder getParent() {
+    return fContainer.getParent();
+  }
+
+  public String getPath() {
+    return fContainer.getPath();
+  }
+
+  public void move(Folder newParent) {
+    fContainer.move(newParent);
+  }
+
+  public void setParent(Folder parent) {
+    fContainer.setParent(parent);    
+  }
   
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/FolderImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/FolderImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/FolderImpl.java Mon Feb 22 08:58:39 2010
@@ -4,6 +4,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -13,6 +14,7 @@
 import org.apache.opencmis.inmemory.FilterParser;
 import org.apache.opencmis.inmemory.NameValidator;
 import org.apache.opencmis.inmemory.storedobj.api.Document;
+import org.apache.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.opencmis.inmemory.storedobj.api.Path;
 import org.apache.opencmis.inmemory.storedobj.api.StoredObject;
@@ -38,14 +40,14 @@
       throw new RuntimeException("Cannot create folder " + name
           + ". Name already exists in parent folder");
     folder.setParent(this);
-    fObjStore.storeObject(folder.getPath(), folder);
+    folder.persist();
   }
 
   /*
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.inmemory.IFolder#addChildDocument(org.apache.opencmis.client.provider
+   * org.opencmis.client.provider.spi.inmemory.IFolder#addChildDocument(org.opencmis.client.provider
    * .spi.inmemory.storedobj.impl.DocumentImpl)
    */
   public void addChildDocument(Document doc) {
@@ -73,23 +75,28 @@
     else
       documentPath += PATH_SEPARATOR + name;
     ((Path)so).setParent(this);
-    fObjStore.storeObject(documentPath, so);    
+    so.persist();
   }
   
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IFolder#getChildren()
+   * @see org.opencmis.client.provider.spi.inmemory.IFolder#getChildren()
    */
   public List<StoredObject> getChildren(int maxItems, int skipCount) {
     List<StoredObject> result = new ArrayList<StoredObject>();
-    String path = getPath();
     for (String id : fObjStore.getIds()) {
       StoredObject obj = fObjStore.getObject(id);
-      if (obj instanceof Path) {
-        Path pathObj = (Path) obj;
-        if (pathObj.getParent() != null && path.equals(pathObj.getParent().getPath()))
-            result.add(obj);
+      Path pathObj = (Path) obj;
+      if (pathObj.getParent() == this) {
+        if (pathObj instanceof VersionedDocument) {
+          DocumentVersion ver = ((VersionedDocument) pathObj).getLatestVersion(false);
+          result.add(ver);
+          } else if (pathObj instanceof DocumentVersion) {
+          // ignore
+        } else {
+          result.add(obj);
+        }
       }
     }
     sortFolderList(result);
@@ -107,19 +114,16 @@
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IFolder#getFolderChildren()
+   * @see org.opencmis.client.provider.spi.inmemory.IFolder#getFolderChildren()
    */
   public List<Folder> getFolderChildren(int maxItems, int skipCount) {
     List<Folder> result = new ArrayList<Folder>();
-    String path = getPath();
     for (String id : fObjStore.getIds()) {
       StoredObject obj = fObjStore.getObject(id);
       if (obj instanceof Path) {
         Path pathObj = (Path) obj;
-        if (pathObj.getParent() != null && path.equals(pathObj.getParent().getPath())
-            && pathObj instanceof Folder)
+        if (pathObj.getParent() == this && pathObj instanceof Folder)
           result.add((Folder)obj);
-        
       }
     }
     sortFolderList(result);
@@ -132,48 +136,48 @@
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IFolder#hasChild(java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IFolder#hasChild(java.lang.String)
    */
   public boolean hasChild(String name) {
-    String path = getPath();
-    if (path.equals(PATH_SEPARATOR))
-      path = path + name;
-    else
-      path = path + PATH_SEPARATOR + name;
-    for (String objPath : fObjStore.getIds()) {
-      if (path.equals(objPath))
-        return true;
+//    String path = getPath();
+//    if (path.equals(PATH_SEPARATOR))
+//      path = path + name;
+//    else
+//      path = path + PATH_SEPARATOR + name;
+    for (String id : fObjStore.getIds()) {
+      StoredObject obj = fObjStore.getObject(id);
+      if (obj instanceof Path) {
+        Path pathObj = (Path) obj;
+        if (pathObj.getParent() == this && obj.getName().equals(name))
+          return true;
+      }
     }
     return false;
   }
 
-  public void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+  public void fillProperties(Map<String, PropertyData<?>> properties, ProviderObjectFactory objFactory,
       List<String> requestedIds) {
 
     super.fillProperties(properties, objFactory, requestedIds);
 
     // add folder specific properties
-    if (FilterParser.isContainedInFilter(PropertyIds.CMIS_OBJECT_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_ID, getPath()));
-      // for folders we use the path as id in this provider
-    }
 
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_PARENT_ID, requestedIds)) {
       String parentId = getParent() == null ? null : getParent().getId();
       if ( parentId != null )
-        properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_PARENT_ID, parentId));
+        properties.put(PropertyIds.CMIS_PARENT_ID, objFactory.createPropertyStringData(PropertyIds.CMIS_PARENT_ID, parentId));
     }
 
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS,
         requestedIds)) {
       String allowedChildObjects = "*"; // TODO: not yet supported
-      properties.add(objFactory.createPropertyStringData(
+      properties.put(PropertyIds.CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS, objFactory.createPropertyStringData(
           PropertyIds.CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS, allowedChildObjects));
     }
 
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_PATH, requestedIds)) {
       String path = getPath();
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_PATH, path));
+      properties.put(PropertyIds.CMIS_PATH, objFactory.createPropertyStringData(PropertyIds.CMIS_PATH, path));
     }
   }
 
@@ -201,21 +205,17 @@
     Collections.sort(list, new FolderComparator());
   }
 
-  public void persist() {
-    // The in-memory implementation doesn't have to do anything here, but sets the id
-//    fId = getPath();
-  }
-
-  public void moveChildDocument(Document doc, Folder newParent) {
-    if (newParent.hasChild(doc.getName()))
+  public void moveChildDocument(StoredObject so, Folder newParent) {
+    if (newParent.hasChild(so.getName()))
       throw new IllegalArgumentException(
-          "Cannot move folder, this name already exists in target.");
-
-    String oldPath = doc.getPath(); // old path of document to move
-    doc.setParent(newParent);
-    String newPath = doc.getPath(); // new path of document to move
-    fObjStore.removeObject(oldPath);
-    fObjStore.storeObject(newPath, doc);
+          "Cannot move object, this name already exists in target.");
+    if (!(so instanceof Path))
+      throw new IllegalArgumentException(
+      "Cannot move object, object does not have a path.");
+    
+    Path pathObj = (Path) so;
+    pathObj.setParent(newParent);
+    // so.persist(); // not needed for in memory
   }
 
   public List<String> getAllowedChildObjectTypeIds() {

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java Mon Feb 22 08:58:39 2010
@@ -29,6 +29,7 @@
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.opencmis.inmemory.storedobj.api.Document;
+import org.apache.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.opencmis.inmemory.storedobj.api.Path;
@@ -45,6 +46,11 @@
 public class ObjectStoreImpl implements ObjectStore {
 
   /**
+   * Simple id generator that uses just an integer 
+   */
+  private static int NEXT_UNUSED_ID = 100;
+  
+  /**
    * Maps the absolute folder path to the corresponding folder object
    */
   private Map<String, StoredObject> fStoredObjectMap = new HashMap<String, StoredObject>();
@@ -56,12 +62,15 @@
     createRootFolder();
   }
 
+  private static synchronized Integer getNextId() {
+    return NEXT_UNUSED_ID++;
+  }
   
 
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getRootFolder()
+   * @see org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getRootFolder()
    */
   public Folder getRootFolder() {
     return fRootFolder;
@@ -71,19 +80,26 @@
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getFolderByPath(java.lang
+   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getFolderByPath(java.lang
    * .String)
    */
   public StoredObject getObjectByPath(String path) {
-    StoredObject obj = fStoredObjectMap.get(path);
-    return obj;
+    
+    for (StoredObject so : fStoredObjectMap.values()) {
+      if (so instanceof Path) {
+        String soPath = ((Path) so).getPath();
+        if (soPath.equals(path))
+          return so;
+      }
+    }
+    return null;
   }
 
   /*
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getObjectById(java.lang
+   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getObjectById(java.lang
    * .String)
    */
   public StoredObject getObjectById(String objectId) {
@@ -96,7 +112,7 @@
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#deleteObject(java.lang
+   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#deleteObject(java.lang
    * .String)
    */
   public void deleteObject(String objectId) {
@@ -110,23 +126,47 @@
     if (obj instanceof FolderImpl) {
       deleteFolder(objectId);
     }
+    else if (obj instanceof DocumentVersion ){
+      DocumentVersion vers = (DocumentVersion) obj;
+      VersionedDocument parentDoc = vers.getParentDocument();
+      fStoredObjectMap.remove(path);
+      boolean otherVersionsExist =  vers.getParentDocument().deleteVersion(vers);
+      if (!otherVersionsExist)
+        fStoredObjectMap.remove(parentDoc.getId());
+    }
     else {
       fStoredObjectMap.remove(path);
     }
   }
+  public void removeVersion(DocumentVersion vers) {
+    StoredObject found = fStoredObjectMap.remove(vers.getId());
 
-  public void changePath(StoredObject obj, String oldPath, String newPath) {
-    fStoredObjectMap.remove(oldPath);
-    fStoredObjectMap.put(newPath, obj);
+    if (null == found)
+      throw new RuntimeException("Cannot delete object with id  " + vers.getId()
+          + ". Object does not exist.");    
   }
+  
+//  public void changePath(StoredObject obj, String oldPath, String newPath) {
+//    fStoredObjectMap.remove(oldPath);
+//    fStoredObjectMap.put(newPath, obj);
+//  }
 
   // /////////////////////////////////////////
   // methods used by folders and documents, but not for public use
   
-  void storeObject(String id, StoredObject sop) {
-    fStoredObjectMap.put(id, sop);
+//  void storeObject(String id, StoredObject sop) {
+//    fStoredObjectMap.put(id, sop);
+//  }
+
+  public String storeObject(StoredObject so) {    
+    String id = so.getId();
+    // check if update or create
+    if (null == id)
+      id = getNextId().toString();
+    fStoredObjectMap.put(id, so);
+    return id;
   }
-
+  
   StoredObject getObject(String id) {
     return fStoredObjectMap.get(id);
   }
@@ -140,24 +180,24 @@
    return entries;
   }
   
-  void renameAllIdsWithPrefix(String oldPath, String newPath) {
-    Iterator<Entry<String, StoredObject>> it = fStoredObjectMap.entrySet().iterator();
-    Map<String, StoredObject> newMap = new HashMap<String, StoredObject>();
-    while (it.hasNext()) {
-      Map.Entry<String, StoredObject> entry = (Map.Entry<String, StoredObject>) it
-          .next();
-
-      if (entry.getKey().startsWith(oldPath)) {
-        if (entry.getValue() instanceof Path) {
-          newPath = ((Path)entry.getValue()).getPath();
-          it.remove(); // the only safe way to modify while iteration
-          newMap.put(newPath, entry.getValue()); // we can't add to the current collection while
-                                                 // iterating          
-        }
-      }
-    }
-    fStoredObjectMap.putAll(newMap); // add all at once when iteration is complete  
-  }
+//  void renameAllIdsWithPrefix(String oldPath, String newPath) {
+//    Iterator<Entry<String, StoredObject>> it = fStoredObjectMap.entrySet().iterator();
+//    Map<String, StoredObject> newMap = new HashMap<String, StoredObject>();
+//    while (it.hasNext()) {
+//      Map.Entry<String, StoredObject> entry = (Map.Entry<String, StoredObject>) it
+//          .next();
+//
+//      if (entry.getKey().startsWith(oldPath)) {
+//        if (entry.getValue() instanceof Path) {
+//          newPath = ((Path)entry.getValue()).getPath();
+//          it.remove(); // the only safe way to modify while iteration
+//          newMap.put(newPath, entry.getValue()); // we can't add to the current collection while
+//                                                 // iterating          
+//        }
+//      }
+//    }
+//    fStoredObjectMap.putAll(newMap); // add all at once when iteration is complete  
+//  }
   
   // /////////////////////////////////////////
   // private helper methods
@@ -171,8 +211,7 @@
     rootFolder.setModifiedBy("Admin");
     rootFolder.setModifiedAtNow();
     rootFolder.setRepositoryId(fRepositoryId);
-
-    fStoredObjectMap.put(Path.PATH_SEPARATOR, rootFolder);
+    rootFolder.persist();
     fRootFolder =  rootFolder;
   }
 
@@ -212,23 +251,20 @@
   }
   
   private void deleteFolder(String folderId) {
-    String path = folderId; // we use path as id
-    StoredObject obj = fStoredObjectMap.get(path);
-    if (obj != null) {
-      if (!(obj instanceof FolderImpl))
-        throw new RuntimeException("Cannot delete folder with path:  " + path
+    StoredObject folder = fStoredObjectMap.get(folderId);
+    if (folder != null) {
+      if (!(folder instanceof FolderImpl))
+        throw new RuntimeException("Cannot delete folder with id:  " + folderId
             + ". Object exists but is not a folder.");
     }
 
     // check if children exist
-    fStoredObjectMap.remove(path);
-    for (String objPath : fStoredObjectMap.keySet()) {
-      if (objPath.startsWith(path)) {
-        fStoredObjectMap.put(path, obj); // restore object
-        throw new CmisConstraintException("Cannot delete folder with path:  " + path
-            + ". Folder is not empty.");
-      }
-    }
+    List<StoredObject> children = ((Folder)folder).getChildren(-1, -1);
+    if (children!=null && !children.isEmpty())
+      throw new CmisConstraintException("Cannot delete folder with id:  " + folderId
+          + ". Folder is not empty.");
+      
+    fStoredObjectMap.remove(folderId);    
   }
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Mon Feb 22 08:58:39 2010
@@ -27,6 +27,7 @@
 
 import org.apache.opencmis.commons.api.TypeDefinition;
 import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.enums.CapabilityAcl;
 import org.apache.opencmis.commons.enums.CapabilityChanges;
 import org.apache.opencmis.commons.enums.CapabilityContentStreamUpdates;
 import org.apache.opencmis.commons.enums.CapabilityJoin;
@@ -37,7 +38,6 @@
 import org.apache.opencmis.commons.impl.dataobjects.RepositoryInfoDataImpl;
 import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 import org.apache.opencmis.commons.provider.RepositoryInfoData;
-import org.apache.opencmis.inmemory.ConfigMap;
 import org.apache.opencmis.inmemory.RepositoryInfo;
 import org.apache.opencmis.inmemory.RepositoryInfoCreator;
 import org.apache.opencmis.inmemory.TypeCreator;
@@ -54,7 +54,6 @@
 public class StoreManagerImpl implements StoreManager {
 
   protected ProviderObjectFactory fObjectFactory;
-  protected ConfigMap fConfigMap;
   protected RepositoryInfoData fRepositoryInfo;
   
   /**
@@ -77,10 +76,6 @@
     fObjectFactory = new ProviderObjectFactoryImpl();
   }
 
-  public void setConfigReader(ConfigMap configMap) {
-    fConfigMap = configMap;
-  }
-
   public List<String> getAllRepositoryIds() {
     Set<String> repIds = fMapRepositoryToObjectStore.keySet();
     List<String> result = new ArrayList<String>();
@@ -88,18 +83,24 @@
     return result;
   }
 
-  public void initRepository(String repositoryId, boolean isCreated) {
-    TypeManager typeManager;
-    if (isCreated)
-      typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-    else {
-      typeManager = new TypeManager();
-      fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));  
-      fMapRepositoryToTypeManager.put(repositoryId, typeManager);      
-    }
-   
+  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);
   }
@@ -108,10 +109,6 @@
     return fObjectFactory;
   }
 
-  public String getParameter(String parameter) {
-    return fConfigMap.get(parameter);
-  }
-
   public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
     TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
     if (null == typeManager)
@@ -150,7 +147,7 @@
     return repoInfo;
   }
 
-  public void initTypeSystem(String repositoryId, String typeCreatorClassName) {
+  private void initTypeSystem(String repositoryId, String typeCreatorClassName) {
 
     List<TypeDefinition> typeDefs = null;
     TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
@@ -209,22 +206,14 @@
       createDefaultRepositoryInfo(repositoryId);
     }
   }
-
-  public void createRepository(String repositoryId) {
-    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());
-  }
   
   public RepositoryInfo loadRepository(String repositoryId) {
     return null;
   }
   
   private RepositoryInfoData createDefaultRepositoryInfo(String repositoryId) {
+    ObjectStore objStore = getObjectStore(repositoryId);
+    String rootFolderId = objStore.getRootFolder().getId();
     // repository info
     RepositoryInfoDataImpl repoInfo;
     repoInfo = new RepositoryInfoDataImpl();
@@ -233,7 +222,7 @@
     repoInfo.setRepositoryDescription("InMemory Test Repository");
     repoInfo.setCmisVersionSupported("1.0");
     repoInfo.setRepositoryCapabilities(null);
-    repoInfo.setRootFolder("/");
+    repoInfo.setRootFolder(rootFolderId);
     repoInfo.setPrincipalAnonymous("anonymous");
     repoInfo.setPrincipalAnyone("anyone");
     repoInfo.setThinClientUri(null);
@@ -247,9 +236,9 @@
     // set capabilities
     RepositoryCapabilitiesDataImpl caps = new RepositoryCapabilitiesDataImpl();
     caps.setAllVersionsSearchable(false);
-    caps.setCapabilityAcl(org.apache.opencmis.commons.enums.CapabilityAcl.NONE);
+    caps.setCapabilityAcl(CapabilityAcl.NONE);
     caps.setCapabilityChanges(CapabilityChanges.PROPERTIES); // just for testing
-    caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
+    caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.PWCONLY);
     caps.setCapabilityJoin(CapabilityJoin.NONE);
     caps.setCapabilityQuery(CapabilityQuery.METADATAONLY); // just for testing
     caps.setCapabilityRendition(CapabilityRendition.NONE);

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java Mon Feb 22 08:58:39 2010
@@ -54,100 +54,102 @@
   protected GregorianCalendar fModifiedAt;
   protected String fRepositoryId;
   protected Map<String, PropertyData<?>> fProperties;
+  protected ObjectStoreImpl fObjStore;
   
-  StoredObjectImpl() {  // visibility should be package    
+  StoredObjectImpl(ObjectStoreImpl objStore) {  // visibility should be package    
     GregorianCalendar now = getNow();
     now.setTime(new Date());
     fCreatedAt = now;
     fModifiedAt = now;
+    fObjStore = objStore;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
    */
   public String getId() {
     return fId;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
    */
   public String getName() {
     return fName;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.lang.String)
    */
   public void setName(String name) {
     fName = name;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
    */
   public String getTypeId() {
     return fTypeId;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java.lang.String)
    */
   public void setTypeId(String type) {
     fTypeId = type;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
    */
   public String getCreatedBy() {
     return fCreatedBy;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(java.lang.String)
    */
   public void setCreatedBy(String createdBy) {
     this.fCreatedBy = createdBy;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
    */
   public String getModifiedBy() {
     return fModifiedBy;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy(java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy(java.lang.String)
    */
   public void setModifiedBy(String modifiedBy) {
     this.fModifiedBy = modifiedBy;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
    */
   public GregorianCalendar getCreatedAt() {
     return fCreatedAt;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(java.util.GregorianCalendar)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(java.util.GregorianCalendar)
    */
   public void setCreatedAt(GregorianCalendar createdAt) {
     this.fCreatedAt = createdAt;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
    */
   public GregorianCalendar getModifiedAt() {
     return fModifiedAt;
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow()
    */
   public void setModifiedAtNow() {
     this.fModifiedAt = getNow();
@@ -162,20 +164,20 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties(java.util.Map)
+   * @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.apache.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
    */
   public Map<String, PropertyData<?>> getProperties() {
     return fProperties;
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#getChangeToken()
+   * @see org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#getChangeToken()
    */
   public String getChangeToken() {
     GregorianCalendar lastModified = getModifiedAt();
@@ -189,7 +191,7 @@
   }
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
    */
   public void createSystemBasePropertiesWhenCreated(
       Map<String, PropertyData<?>> properties,
@@ -198,7 +200,7 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
    */
   public void updateSystemBasePropertiesWhenModified(
       Map<String, PropertyData<?>> properties,
@@ -207,45 +209,45 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties(java.util.List, org.apache.opencmis.client.provider.ProviderObjectFactory, java.util.List)
+   * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties(java.util.List, org.opencmis.client.provider.ProviderObjectFactory, java.util.List)
    */
-  public void fillProperties(List<PropertyData<?>> properties,
+  public void fillProperties(Map<String, PropertyData<?>> properties,
       ProviderObjectFactory objFactory, List<String> requestedIds) {
     
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_NAME, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_NAME, getName()));
+      properties.put(PropertyIds.CMIS_NAME, objFactory.createPropertyStringData(PropertyIds.CMIS_NAME, getName()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_OBJECT_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_ID, getId()));
+      properties.put(PropertyIds.CMIS_OBJECT_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_ID, getId()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_OBJECT_TYPE_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, getTypeId()));
+      properties.put(PropertyIds.CMIS_OBJECT_TYPE_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_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.CMIS_CREATED_BY, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_CREATED_BY, getCreatedBy()));
+      properties.put(PropertyIds.CMIS_CREATED_BY, objFactory.createPropertyStringData(PropertyIds.CMIS_CREATED_BY, getCreatedBy()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_CREATION_DATE, requestedIds)) {
-      properties.add(objFactory.createPropertyDateTimeData(PropertyIds.CMIS_CREATION_DATE, getCreatedAt()));
+      properties.put(PropertyIds.CMIS_CREATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CMIS_CREATION_DATE, getCreatedAt()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_LAST_MODIFIED_BY, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_LAST_MODIFIED_BY, getModifiedBy()));
+      properties.put(PropertyIds.CMIS_LAST_MODIFIED_BY, objFactory.createPropertyStringData(PropertyIds.CMIS_LAST_MODIFIED_BY, getModifiedBy()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_LAST_MODIFICATION_DATE, requestedIds)) {
-      properties.add(objFactory.createPropertyDateTimeData(PropertyIds.CMIS_LAST_MODIFICATION_DATE, getModifiedAt()));
+      properties.put(PropertyIds.CMIS_LAST_MODIFICATION_DATE, objFactory.createPropertyDateTimeData(PropertyIds.CMIS_LAST_MODIFICATION_DATE, getModifiedAt()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_CHANGE_TOKEN, requestedIds)) {
       String token = getChangeToken();
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_CHANGE_TOKEN, token));
+      properties.put(PropertyIds.CMIS_CHANGE_TOKEN, objFactory.createPropertyStringData(PropertyIds.CMIS_CHANGE_TOKEN, token));
     }
 
     // add custom properties of type definition to the collection
     if (null != fProperties) {
       for (Entry<String, PropertyData<?>> prop: fProperties.entrySet()) {
-        properties.add(prop.getValue());      
+        properties.put(prop.getKey(), prop.getValue());      
       }
     }
   }
@@ -255,7 +257,7 @@
   // private helper methods
   
   /* (non-Javadoc)
-   * @see org.apache.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties(java.util.Map)
+   * @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
@@ -407,6 +409,8 @@
 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/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java Mon Feb 22 08:58:39 2010
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.enums.VersioningState;
@@ -50,10 +51,9 @@
     if (isCheckedOut())
         throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
     
-    DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState);
+    DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
     ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy name and type id from version series.
     ver.persist();
-    fObjStore.storeObject(ver.getId(), ver);
     fVersions.add(ver);
     if (verState == VersioningState.CHECKEDOUT) {
       fCheckedOutUser = user;
@@ -63,10 +63,23 @@
     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.deleteObject(pwc.getId());
+    fObjStore.removeVersion(pwc);
+    fIsCheckedOut = false;
+    fCheckedOutUser = null;
   }
 
   public void checkIn(boolean isMajor, String checkinComment, String user) {
@@ -96,8 +109,7 @@
     return pwc;
   }
 
-  public List<DocumentVersion> getAllVersions(String filter) {
-    //TODO: implement filter
+  public List<DocumentVersion> getAllVersions() {
     return fVersions;
   }
 
@@ -131,7 +143,7 @@
     return null;
   }
 
-  public void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+  public void fillProperties(Map<String, PropertyData<?>> properties, ProviderObjectFactory objFactory,
       List<String> requestedIds) {
     
     DocumentVersion pwc = getPwc();
@@ -140,16 +152,16 @@
     
     // overwrite the version related properties 
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_ID, requestedIds)) { 
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, getId()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, getId()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-      properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
+      properties.put(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, isCheckedOut()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-      properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, getCheckedOutBy()));
     }
     if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-      properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+      properties.put(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
     }
     
   }

Modified: 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=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/types/PropertyCreationHelper.java Mon Feb 22 08:58:39 2010
@@ -20,15 +20,17 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 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.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.enums.Cardinality;
 import org.apache.opencmis.commons.enums.IncludeRelationships;
 import org.apache.opencmis.commons.enums.PropertyType;
@@ -206,7 +208,7 @@
     // build properties collection 
     
     ProviderObjectFactory objectFactory = storeManager.getObjectFactory();
-    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
     so.fillProperties(properties, objectFactory, requestedIds);
 
     String typeId = so.getTypeId();
@@ -219,10 +221,11 @@
       } else {
         TypeDefinition typeDef = typeDefC.getTypeDefinition();
         String baseTypeId = typeDef.getBaseId().value();
-        properties.add(objectFactory.createPropertyIdData(PropertyIds.CMIS_BASE_TYPE_ID, baseTypeId));
+        properties.put(PropertyIds.CMIS_BASE_TYPE_ID, objectFactory.createPropertyIdData(PropertyIds.CMIS_BASE_TYPE_ID, baseTypeId));
       }
     }    
-    PropertiesData props = objectFactory.createPropertiesData(properties);
+    List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>> (properties.values());
+    PropertiesData props = objectFactory.createPropertiesData(propertiesList);
     return props;    
   }
   



Mime
View raw message