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 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(String repositoryId)
           
 
Method Summary
 void clear()
          Clear repository and remove all data.
 Document createDocument(String name)
          Create a document as initial step.
 Folder createFolder(String name)
          Create a folder as initial step.
 VersionedDocument createVersionedDocument(String name)
          Create a document that supports versions as initial step.
 void deleteObject(String objectId)
          Deletes an object from the store.
 List<StoredObject> getCheckedOutDocuments(String orderBy)
          Return a list of all documents that are checked out in the repository.
 Set<String> getIds()
           
 StoredObject getObjectById(String objectId)
          get an object by its id
 StoredObject getObjectByPath(String path)
          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)
           
 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(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(String path)
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(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(String objectId)
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

removeVersion

public void removeVersion(DocumentVersion vers)

storeObject

public String storeObject(StoredObject so)

getIds

public Set<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(String name)
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
Returns:
document object

createVersionedDocument

public VersionedDocument createVersionedDocument(String name)
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
Returns:
versioned document object

createFolder

public Folder createFolder(String name)
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
Returns:
folder object

getCheckedOutDocuments

public List<StoredObject> getCheckedOutDocuments(String orderBy)
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.
Returns:
list of checked out documents in the repository


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