org.apache.chemistry.opencmis.inmemory.storedobj.impl
Class ObjectStoreImpl

java.lang.Object
  extended by org.apache.chemistry.opencmis.inmemory.storedobj.impl.ObjectStoreImpl
All Implemented Interfaces:
ObjectStore

public class ObjectStoreImpl
extends java.lang.Object
implements ObjectStore

The object store is the central core of the in-memory repository. It is based on huge HashMap map mapping ids to objects in memory. To allow access from multiple threads a Java concurrent HashMap is used that allows parallel access methods.

Certain methods in the in-memory repository must guarantee constraints. For example a folder enforces that each child has a unique name. Therefore certain operations must occur in an atomic manner. In the example it must be guaranteed that no write access occurs to the map between acquiring the iterator to find the children and finishing the add operation when no name conflicts can occur. For this purpose this class has methods to lock an unlock the state of the repository. It is very important that the caller acquiring the lock enforces an unlock under all circumstances. Typical code is:

 ObjectStoreImpl os = ... ;
 try {
     os.lock();
 } finally {
     os.unlock();
 }
 
The locking is very coarse-grained. Productive implementations would probably implement finer grained locks on a folder or document rather than the complete repository.


Constructor Summary
ObjectStoreImpl(java.lang.String repositoryId)
           
 
Method Summary
 void clear()
          Clear repository and remove all data.
 Document createDocument(java.lang.String name, java.util.Map<java.lang.String,PropertyData<?>> propMap, java.lang.String user, Folder folder, Acl addACEs, Acl removeACEs)
          Create a document as initial step.
 Folder createFolder(java.lang.String name)
           
 Folder createFolder(java.lang.String name, java.util.Map<java.lang.String,PropertyData<?>> propMap, java.lang.String user, Folder parent, Acl addACEs, Acl removeACEs)
          Create a folder as initial step.
 StoredObject createRelationship(StoredObject sourceObject, StoredObject targetObject, java.util.Map<java.lang.String,PropertyData<?>> propMap, java.lang.String user, Acl addACEs, Acl removeACEs)
          Create a relationship.
 DocumentVersion createVersionedDocument(java.lang.String name, java.util.Map<java.lang.String,PropertyData<?>> propMap, java.lang.String user, Folder folder, Acl addACEs, Acl removeACEs, ContentStream contentStream, VersioningState versioningState)
          Create a document that supports versions as initial step.
 void deleteObject(java.lang.String objectId, java.lang.Boolean allVersions, java.lang.String user)
          Deletes an object from the store.
 java.util.List<StoredObject> getCheckedOutDocuments(java.lang.String orderBy, java.lang.String user, IncludeRelationships includeRelationships)
          Return a list of all documents that are checked out in the repository.
 java.util.Set<java.lang.String> getIds()
           
 StoredObject getObjectById(java.lang.String objectId)
          get an object by its id
 StoredObject getObjectByPath(java.lang.String path, java.lang.String user)
          return an object by path.
 long getObjectCount()
          For statistics: return the number of objects contained in the system
 Folder getRootFolder()
          Get the root folder of this object store
 void lock()
           
 void removeVersion(DocumentVersion vers)
           
 java.lang.String storeObject(StoredObject so)
           
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectStoreImpl

public ObjectStoreImpl(java.lang.String repositoryId)
Method Detail

lock

public void lock()

unlock

public void unlock()

getRootFolder

public Folder getRootFolder()
Description copied from interface: ObjectStore
Get the root folder of this object store

Specified by:
getRootFolder in interface ObjectStore
Returns:
the root folder of this store

getObjectByPath

public StoredObject getObjectByPath(java.lang.String path,
                                    java.lang.String user)
Description copied from interface: ObjectStore
return an object by path.

Specified by:
getObjectByPath in interface ObjectStore
Parameters:
path - the path to the object
Returns:
the stored object with this path

getObjectById

public StoredObject getObjectById(java.lang.String objectId)
Description copied from interface: ObjectStore
get an object by its id

Specified by:
getObjectById in interface ObjectStore
Parameters:
objectId - the id of the object
Returns:
the object identified by this id

deleteObject

public void deleteObject(java.lang.String objectId,
                         java.lang.Boolean allVersions,
                         java.lang.String user)
Description copied from interface: ObjectStore
Deletes an object from the store. For a folders the folder must be empty.

Specified by:
deleteObject in interface ObjectStore
allVersions - is TRUE all version of the document are deleted, otherwise just this one

removeVersion

public void removeVersion(DocumentVersion vers)

storeObject

public java.lang.String storeObject(StoredObject so)

getIds

public java.util.Set<java.lang.String> getIds()

clear

public void clear()
Clear repository and remove all data.

Specified by:
clear in interface ObjectStore

getObjectCount

public long getObjectCount()
Description copied from interface: ObjectStore
For statistics: return the number of objects contained in the system

Specified by:
getObjectCount in interface ObjectStore
Returns:
number of stored objects

createDocument

public Document createDocument(java.lang.String name,
                               java.util.Map<java.lang.String,PropertyData<?>> propMap,
                               java.lang.String user,
                               Folder folder,
                               Acl addACEs,
                               Acl removeACEs)
Description copied from interface: ObjectStore
Create a document as initial step. The document is created but still temporary It is not yet persisted and does not have an id yet. After this call additional actions can take place (like assigning properties and a type) before it is persisted.

Specified by:
createDocument in interface ObjectStore
Parameters:
name - name of the document
propMap - map of properties
user - the user who creates the document
folder - the parent folder
addACEs - aces that are added
removeACEs - aces that are removed
Returns:
document object

createVersionedDocument

public DocumentVersion createVersionedDocument(java.lang.String name,
                                               java.util.Map<java.lang.String,PropertyData<?>> propMap,
                                               java.lang.String user,
                                               Folder folder,
                                               Acl addACEs,
                                               Acl removeACEs,
                                               ContentStream contentStream,
                                               VersioningState versioningState)
Description copied from interface: ObjectStore
Create a document that supports versions as initial step. The document is created but still temporary. It is not yet persisted and does not have an id yet. After this call additional actions can take place (like assigning properties and a type) before it is persisted.

Specified by:
createVersionedDocument in interface ObjectStore
Parameters:
name - name of the document * @param propMap map of properities
user - the user who creates the document
folder - the parent folder
addACEs - aces that are added
removeACEs - aces that are removed
Returns:
versioned document object

createFolder

public Folder createFolder(java.lang.String name,
                           java.util.Map<java.lang.String,PropertyData<?>> propMap,
                           java.lang.String user,
                           Folder parent,
                           Acl addACEs,
                           Acl removeACEs)
Description copied from interface: ObjectStore
Create a folder as initial step. The folder is created but still temporary It is not yet persisted and does not have an id yet. After this call additional actions can take place (like assigning properties and a type) before it is persisted.

Specified by:
createFolder in interface ObjectStore
Parameters:
name - name of the folder
propMap - map of properties
user - the user who creates the document
parent - the parent folder
addACEs - aces that are added
removeACEs - aces that are removed
Returns:
folder object

createFolder

public Folder createFolder(java.lang.String name)

getCheckedOutDocuments

public java.util.List<StoredObject> getCheckedOutDocuments(java.lang.String orderBy,
                                                           java.lang.String user,
                                                           IncludeRelationships includeRelationships)
Description copied from interface: ObjectStore
Return a list of all documents that are checked out in the repository.

Specified by:
getCheckedOutDocuments in interface ObjectStore
Parameters:
orderBy - orderBy specification according to CMIS spec.
user - user id of user calling
includeRelationships - if true include all relationships in the response
Returns:
list of checked out documents in the repository

createRelationship

public StoredObject createRelationship(StoredObject sourceObject,
                                       StoredObject targetObject,
                                       java.util.Map<java.lang.String,PropertyData<?>> propMap,
                                       java.lang.String user,
                                       Acl addACEs,
                                       Acl removeACEs)
Description copied from interface: ObjectStore
Create a relationship. The relationship is created but still temporary. It is not yet persisted and does not have an id yet. After this call additional actions can take place (like assigning properties and a type) before it is persisted.

Specified by:
createRelationship in interface ObjectStore
Parameters:
sourceObject - source of the relationship
targetObject - target of the relationship
propMap - map of properities
user - the user who creates the document
addACEs - aces that are added
removeACEs - aces that are removed
Returns:
versioned document object


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.