public class ObjectStoreImpl extends Object implements ObjectStore
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.
Modifier and Type | Field and Description |
---|---|
static String |
ADMIN_PRINCIPAL_ID
user id for administrator always having all rights
|
Constructor and Description |
---|
ObjectStoreImpl(String repositoryId) |
Modifier and Type | Method and Description |
---|---|
Acl |
applyAcl(StoredObject so,
Acl addAces,
Acl removeAces,
AclPropagation aclPropagation,
String principalId)
Apply a ACLs by relative adding and removing a list of ACEs to/from an object
|
Acl |
applyAcl(StoredObject so,
Acl acl,
AclPropagation aclPropagation,
String principalId)
Apply a ACLs by setting a new list of ACEs to an object
|
void |
checkAllAccess(String principalId,
StoredObject so) |
void |
checkReadAccess(String principalId,
StoredObject so) |
void |
checkWriteAccess(String principalId,
StoredObject so) |
void |
clear()
Clear repository and remove all data.
|
Document |
createDocument(String name,
Map<String,PropertyData<?>> propMap,
String user,
Folder folder,
List<String> policies,
Acl addACEs,
Acl removeACEs)
Create a document as initial step.
|
Folder |
createFolder(String name) |
Folder |
createFolder(String name,
Map<String,PropertyData<?>> propMap,
String user,
Folder parent,
List<String> policies,
Acl addACEs,
Acl removeACEs)
Create a folder as initial step.
|
StoredObject |
createItem(String name,
Map<String,PropertyData<?>> propMap,
String user,
Folder folder,
List<String> policies,
Acl addACEs,
Acl removeACEs)
Create an item as initial step.
|
StoredObject |
createPolicy(String name,
String policyText,
Map<String,PropertyData<?>> propMap,
String user)
Create a policy.
|
StoredObject |
createRelationship(String name,
StoredObject sourceObject,
StoredObject targetObject,
Map<String,PropertyData<?>> propMap,
String user,
Acl addACEs,
Acl removeACEs)
Create a relationship.
|
DocumentVersion |
createVersionedDocument(String name,
Map<String,PropertyData<?>> propMap,
String user,
Folder folder,
List<String> policies,
Acl addACEs,
Acl removeACEs,
ContentStream contentStream,
VersioningState versioningState)
Create a document that supports versions as initial step.
|
void |
deleteObject(String objectId,
Boolean allVersions,
String user)
Deletes an object from the store.
|
Acl |
getAcl(int aclId) |
int |
getAclId(StoredObjectImpl so,
Acl addACEs,
Acl removeACEs) |
List<Integer> |
getAllAclsForUser(String principalId,
Permission permission) |
List<StoredObject> |
getCheckedOutDocuments(String orderBy,
String user,
IncludeRelationships includeRelationships)
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,
String user)
return an object by path.
|
long |
getObjectCount()
For statistics: return the number of objects contained in the system
|
List<StoredObject> |
getRelationships(String objectId,
List<String> typeIds,
RelationshipDirection direction)
Get relationships to and from an object
|
Folder |
getRootFolder()
Get the root folder of this object store
|
boolean |
hasAllAccess(String principalId,
StoredObject so) |
boolean |
hasReadAccess(String principalId,
StoredObject so) |
boolean |
hasWriteAccess(String principalId,
StoredObject so) |
boolean |
isTypeInUse(String typeId)
Check if this store contains any object with the given type id
|
void |
lock() |
void |
removeVersion(DocumentVersion vers) |
String |
storeObject(StoredObject so) |
void |
unlock() |
public static final String ADMIN_PRINCIPAL_ID
public ObjectStoreImpl(String repositoryId)
public void lock()
public void unlock()
public Folder getRootFolder()
ObjectStore
getRootFolder
in interface ObjectStore
public StoredObject getObjectByPath(String path, String user)
ObjectStore
getObjectByPath
in interface ObjectStore
path
- the path to the objectpublic StoredObject getObjectById(String objectId)
ObjectStore
getObjectById
in interface ObjectStore
objectId
- the id of the objectpublic void deleteObject(String objectId, Boolean allVersions, String user)
ObjectStore
deleteObject
in interface ObjectStore
allVersions
- is TRUE all version of the document are deleted, otherwise just this onepublic void removeVersion(DocumentVersion vers)
public String storeObject(StoredObject so)
public void clear()
clear
in interface ObjectStore
public long getObjectCount()
ObjectStore
getObjectCount
in interface ObjectStore
public Document createDocument(String name, Map<String,PropertyData<?>> propMap, String user, Folder folder, List<String> policies, Acl addACEs, Acl removeACEs)
ObjectStore
createDocument
in interface ObjectStore
name
- name of the documentpropMap
- map of propertiesuser
- the user who creates the documentfolder
- the parent folderpolicies
- list of policies to applyaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic StoredObject createItem(String name, Map<String,PropertyData<?>> propMap, String user, Folder folder, List<String> policies, Acl addACEs, Acl removeACEs)
ObjectStore
createItem
in interface ObjectStore
name
- name of the documentpropMap
- map of propertiesuser
- the user who creates the documentfolder
- the parent folderpolicies
- list of policies to applyaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic DocumentVersion createVersionedDocument(String name, Map<String,PropertyData<?>> propMap, String user, Folder folder, List<String> policies, Acl addACEs, Acl removeACEs, ContentStream contentStream, VersioningState versioningState)
ObjectStore
createVersionedDocument
in interface ObjectStore
name
- name of the document
* @param propMap
map of properitiesuser
- the user who creates the documentfolder
- the parent folderpolicies
- list of policies to applyaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic Folder createFolder(String name, Map<String,PropertyData<?>> propMap, String user, Folder parent, List<String> policies, Acl addACEs, Acl removeACEs)
ObjectStore
createFolder
in interface ObjectStore
name
- name of the folderpropMap
- map of propertiesuser
- the user who creates the documentparent
- the parent folderpolicies
- list of policies to applyaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic StoredObject createPolicy(String name, String policyText, Map<String,PropertyData<?>> propMap, String user)
ObjectStore
createPolicy
in interface ObjectStore
name
- name of the documentpolicyText
- policy text to apply to this policypropMap
- map of propertiesuser
- the user who creates the documentpublic List<StoredObject> getCheckedOutDocuments(String orderBy, String user, IncludeRelationships includeRelationships)
ObjectStore
getCheckedOutDocuments
in interface ObjectStore
orderBy
- orderBy specification according to CMIS spec.user
- user id of user callingincludeRelationships
- if true include all relationships in the responsepublic StoredObject createRelationship(String name, StoredObject sourceObject, StoredObject targetObject, Map<String,PropertyData<?>> propMap, String user, Acl addACEs, Acl removeACEs)
ObjectStore
createRelationship
in interface ObjectStore
sourceObject
- source of the relationshiptargetObject
- target of the relationshippropMap
- map of properitiesuser
- the user who creates the documentaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic List<StoredObject> getRelationships(String objectId, List<String> typeIds, RelationshipDirection direction)
ObjectStore
getRelationships
in interface ObjectStore
objectId
- id of object to get relationships withpublic Acl applyAcl(StoredObject so, Acl addAces, Acl removeAces, AclPropagation aclPropagation, String principalId)
ObjectStore
applyAcl
in interface ObjectStore
so
- object where ACLs are appliedaddAces
- list of ACEs to be addedremoveAces
- list of ACEs to be removedaclPropagation
- enum value how to propagate ACLs to child objectspublic Acl applyAcl(StoredObject so, Acl acl, AclPropagation aclPropagation, String principalId)
ObjectStore
applyAcl
in interface ObjectStore
so
- object where ACLs are appliedacl
- list of ACEs to be appliedaclPropagation
- enum value how to propagate ACLs to child objectspublic List<Integer> getAllAclsForUser(String principalId, Permission permission)
public Acl getAcl(int aclId)
public int getAclId(StoredObjectImpl so, Acl addACEs, Acl removeACEs)
public boolean hasReadAccess(String principalId, StoredObject so)
public boolean hasWriteAccess(String principalId, StoredObject so)
public boolean hasAllAccess(String principalId, StoredObject so)
public void checkReadAccess(String principalId, StoredObject so)
public void checkWriteAccess(String principalId, StoredObject so)
public void checkAllAccess(String principalId, StoredObject so)
public boolean isTypeInUse(String typeId)
ObjectStore
isTypeInUse
in interface ObjectStore
typeId
- id of type definition to checkCopyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.