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.
ObjectStore.ChildrenResult
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 |
---|---|
void |
addParent(StoredObject so,
Folder parent)
Add this document to a new parent folder as child object.
|
void |
appendContent(StoredObject so,
ContentStream contentStream)
Append content to an existing content stream.
|
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(Map<String,PropertyData<?>> propMap,
String user,
Folder folder,
ContentStream contentStream,
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,
Acl addACEs,
Acl removeACEs)
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.
|
void |
deleteVersion(DocumentVersion version)
remove a version from the store (after a cancel check-out).
|
Acl |
getAcl(int aclId)
get an ACL object from an ACL id.
|
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.
|
ObjectStore.ChildrenResult |
getChildren(Folder folder,
int maxItemsParam,
int skipCountParam,
String user,
boolean usePwc)
get all the children of this folder.
|
ContentStream |
getContent(StoredObject so,
long offset,
long length)
Retrieve the content of a document.
|
ObjectStore.ChildrenResult |
getFolderChildren(Folder folder,
int maxItems,
int skipCount,
String user)
get all the children of this folder which are folders.
|
String |
getFolderPath(String folderId)
get the path of this folder (for folder in CMIS path is unique).
|
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<String> |
getParentIds(StoredObject so,
String user)
get all parent ids of this object visible for a user.
|
List<StoredObject> |
getRelationships(String objectId,
List<String> typeIds,
RelationshipDirection direction)
Get relationships to and from an object.
|
ContentStream |
getRenditionContent(StoredObject so,
String streamId,
long offset,
long length)
get the rendition of this object.
|
List<RenditionData> |
getRenditions(StoredObject so,
String renditionFilter,
long maxItems,
long skipCount)
get the rendition this objects supports.
|
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 |
move(StoredObject so,
Folder oldParent,
Folder newParent,
String user)
Move an object to a different folder.
|
void |
removeParent(StoredObject so,
Folder parent)
Remove this object from the children of parent.
|
void |
rename(StoredObject so,
String newName,
String user)
Rename an object.
|
ContentStream |
setContent(StoredObject so,
ContentStream contentStream)
Write content and attach it to a document.
|
String |
storeObject(StoredObject so) |
void |
storeVersion(DocumentVersion version)
Persist a new version in the store (created from a check-out).
|
void |
updateObject(StoredObject so,
Map<String,PropertyData<?>> newProperties,
String user)
Modify and store the properties of an object.
|
public static final String ADMIN_PRINCIPAL_ID
public ObjectStoreImpl(String repositoryId)
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 objectuser
- user to check visibilitypublic 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
objectId
- id of object to be deletedallVersions
- is TRUE all version of the document are deleted, otherwise
just this oneuser
- user to check visibilitypublic String storeObject(StoredObject so)
public void clear()
clear
in interface ObjectStore
public long getObjectCount()
ObjectStore
getObjectCount
in interface ObjectStore
public Document createDocument(Map<String,PropertyData<?>> propMap, String user, Folder folder, ContentStream contentStream, List<String> policies, Acl addACEs, Acl removeACEs)
ObjectStore
createDocument
in interface ObjectStore
propMap
- map of propertiesuser
- the user who creates the documentfolder
- the parent foldercontentStream
- the content of the documentpolicies
- 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 removedcontentStream
- content stream of the object to createversioningState
- version state of the object to be created inpublic 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, Acl addACEs, Acl removeACEs)
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 documentaddACEs
- aces that are addedremoveACEs
- aces that are removedpublic StoredObject createRelationship(String name, StoredObject sourceObject, StoredObject targetObject, Map<String,PropertyData<?>> propMap, String user, Acl addACEs, Acl removeACEs)
ObjectStore
createRelationship
in interface ObjectStore
name
- name of relationshipsourceObject
- 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 void storeVersion(DocumentVersion version)
ObjectStore
storeVersion
in interface ObjectStore
version
- version to be storedpublic void deleteVersion(DocumentVersion version)
ObjectStore
deleteVersion
in interface ObjectStore
version
- version to be deletedpublic void updateObject(StoredObject so, Map<String,PropertyData<?>> newProperties, String user)
ObjectStore
updateObject
in interface ObjectStore
so
- object to updatenewProperties
- map containing properties to be updatedpublic 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 List<StoredObject> getRelationships(String objectId, List<String> typeIds, RelationshipDirection direction)
ObjectStore
getRelationships
in interface ObjectStore
objectId
- id of object to get relationships withtypeIds
- list of all types to be includeddirection
- direction of relationshippublic String getFolderPath(String folderId)
ObjectStore
getFolderPath
in interface ObjectStore
folderId
- id of folderpublic 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 objectsprincipalId
- the user who applies ACLpublic 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 objectsprincipalId
- user who executes the call and needs to have permission to
apply ACLpublic List<Integer> getAllAclsForUser(String principalId, Permission permission)
public Acl getAcl(int aclId)
ObjectStore
getAcl
in interface ObjectStore
aclId
- id of ACLpublic int getAclId(StoredObjectImpl so, Acl addACEs, Acl removeACEs)
public ObjectStore.ChildrenResult getChildren(Folder folder, int maxItemsParam, int skipCountParam, String user, boolean usePwc)
ObjectStore
getChildren
in interface ObjectStore
folder
- folder to get children frommaxItemsParam
- max. number of items to returnskipCountParam
- initial offset where to start fetchinguser
- user to determine visible childrenusePwc
- if true return private working copy otherwise return latest
version;public ObjectStore.ChildrenResult getFolderChildren(Folder folder, int maxItems, int skipCount, String user)
ObjectStore
getFolderChildren
in interface ObjectStore
folder
- folder to get children frommaxItems
- max. number of items to returnskipCount
- initial offset where to start fetchinguser
- the user who performs the callpublic void move(StoredObject so, Folder oldParent, Folder newParent, String user)
ObjectStore
move
in interface ObjectStore
so
- object to be movedoldParent
- old parent folder for the objectnewParent
- new parent folder for the objectuser
- user performing the operationpublic void rename(StoredObject so, String newName, String user)
ObjectStore
rename
in interface ObjectStore
so
- object to be renamednewName
- new name to be assigneduser
- user performing the operationpublic List<String> getParentIds(StoredObject so, String user)
ObjectStore
getParentIds
in interface ObjectStore
so
- objects to get parents fromuser
- user who can see parentspublic 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 checkpublic void addParent(StoredObject so, Folder parent)
ObjectStore
addParent
in interface ObjectStore
so
- objects to be addedparent
- parent folder the object is to be added topublic void removeParent(StoredObject so, Folder parent)
ObjectStore
removeParent
in interface ObjectStore
so
- object to be removedparent
- parent folder the object is to be removed frompublic ContentStream getContent(StoredObject so, long offset, long length)
ObjectStore
getContent
in interface ObjectStore
so
- object to get content fromoffset
- offset in content streamlength
- length of content to returnpublic ContentStream setContent(StoredObject so, ContentStream contentStream)
ObjectStore
setContent
in interface ObjectStore
so
- object to set content tocontentStream
- content to be assigned to the document. If null any existing
content is deletedpublic void appendContent(StoredObject so, ContentStream contentStream)
ObjectStore
appendContent
in interface ObjectStore
so
- object to append content tocontentStream
- content to be assigned to the document.public List<RenditionData> getRenditions(StoredObject so, String renditionFilter, long maxItems, long skipCount)
ObjectStore
getRenditions
in interface ObjectStore
so
- object to get renditions fromrenditionFilter
- filter of renditions to returnmaxItems
- max nubmer of items to returnskipCount
- number of objects to skip in resultpublic ContentStream getRenditionContent(StoredObject so, String streamId, long offset, long length)
ObjectStore
getRenditionContent
in interface ObjectStore
so
- object to get renditions fromstreamId
- stream if of renditionoffset
- offset in rendition contentlength
- length of rendition contentCopyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.