public class DBSDocument extends Object implements Document
Document
for Document-Based Storage. The document is stored as a JSON-like Map. The keys
of the Map are the property names (including special names for system properties), and the values Map are
Serializable values, either:
Constructor and Description |
---|
DBSDocument(DBSDocumentState docState,
DocumentType type,
DBSSession session,
boolean readonly) |
Modifier and Type | Method and Description |
---|---|
Document |
addChild(String name,
String typeName)
Creates a new child document of the given type.
|
boolean |
addFacet(String facet)
Adds a facet to this document.
|
Document |
checkIn(String label,
String checkinComment)
Creates a new version.
|
void |
checkOut() |
boolean |
equals(Object other) |
void |
followTransition(String transition)
Follows a given life cycle transition.
|
Set<String> |
getAllFacets()
Gets the facets available on this document (from the type and the instance facets).
|
Collection<String> |
getAllowedStateTransitions()
Returns the allowed state transitions for this document.
|
Document |
getBaseVersion()
Gets the version to which a checked in document is linked.
|
String |
getCheckinComment()
Gets the version check in comment of this document if it's a version or a proxy.
|
Document |
getChild(String name)
Gets a child document given its name.
|
Iterator<Document> |
getChildren()
Gets an iterator over the children of the document.
|
List<String> |
getChildrenIds()
Gets a list of the children ids.
|
String[] |
getFacets()
Gets the facets defined on this document instance.
|
Document |
getLastVersion()
Gets the last version of this document.
|
String |
getLifeCyclePolicy()
Gets the life cycle policy of this document.
|
String |
getLifeCycleState()
Gets the life cycle state of this document.
|
Lock |
getLock()
Gets the lock if one set on this document.
|
String |
getName()
Gets the name of this document.
|
Document |
getParent()
Gets the parent document, or
null if this is the root document. |
String |
getPath()
Gets the path of this document.
|
Long |
getPos()
Gets the document's position in its containing folder (if ordered).
|
Serializable |
getPropertyValue(String name)
Gets a property value.
|
String |
getRepositoryName()
Gets the repository in which the document lives.
|
Session |
getSession()
Gets the session that owns this document.
|
Document |
getSourceDocument()
Gets the source for this document.
|
<T extends Serializable> |
getSystemProp(String name,
Class<T> type)
Gets a system property.
|
Document |
getTargetDocument()
Gets the document (version or live document) to which this proxy points.
|
DocumentType |
getType()
Gets the type of this document.
|
String |
getUUID()
Gets this document's UUID.
|
Document |
getVersion(String label)
Gets a version of this document, given its label.
|
Calendar |
getVersionCreationDate()
Gets the version creation date of this document if it's a version or a proxy.
|
String |
getVersionLabel()
Gets the version label.
|
List<Document> |
getVersions()
Gets the versions for this document.
|
String |
getVersionSeriesId()
Gets the version series id.
|
List<String> |
getVersionsIds()
Gets the list of version ids for this document.
|
Document |
getWorkingCopy()
Gets the working copy for this document.
|
boolean |
hasChild(String name)
Checks whether this document has a child of the given name.
|
boolean |
hasChildren()
Tests if the document has any children.
|
boolean |
hasFacet(String facet)
Checks whether this document has a given facet, either from its type or added on the instance.
|
int |
hashCode() |
boolean |
isCheckedOut()
Checks whether this document is checked out.
|
boolean |
isFolder()
Checks whether this document is a folder.
|
boolean |
isLatestMajorVersion()
Checks whether this document is the latest major version.
|
boolean |
isLatestVersion()
Checks whether this document is the latest version.
|
boolean |
isMajorVersion()
Checks whether this document is a major version.
|
boolean |
isProxy()
Checks whether or not this document is a proxy.
|
boolean |
isReadOnly()
Checks whether this document is readonly or not.
|
boolean |
isVersion()
Checks whether this document is a version document.
|
boolean |
isVersionSeriesCheckedOut()
Checks if there is a checked out working copy for the version series of this document.
|
void |
orderBefore(String src,
String dest)
Orders the given source child before the destination child.
|
void |
readDocumentPart(DocumentPart dp)
Loads a
DocumentPart from storage. |
Map<String,Serializable> |
readPrefetch(ComplexType complexType,
Set<String> xpaths)
Reads a set of prefetched fields.
|
void |
remove()
Removes this document and all its children, if any.
|
boolean |
removeFacet(String facet)
Removes a facet from this document.
|
Lock |
removeLock(String owner)
Removes a lock from this document.
|
void |
restore(Document version)
Replaces this document's content with the version specified.
|
void |
setCurrentLifeCycleState(String lifeCycleState)
Sets the life cycle state of this document.
|
void |
setLifeCyclePolicy(String policy)
Sets the life cycle policy of this document.
|
Lock |
setLock(Lock lock)
Sets a lock on this document.
|
void |
setPropertyValue(String name,
Serializable value)
Sets a property value.
|
void |
setReadOnly(boolean readonly)
Sets this document as readonly or not.
|
void |
setSystemProp(String name,
Serializable value)
Sets a system property.
|
void |
setTargetDocument(Document target)
Sets the document (version or live document) to which this proxy points.
|
String |
toString() |
void |
writeDocumentPart(DocumentPart dp)
Writes a
DocumentPart to storage. |
public static final String SYSPROP_FULLTEXT_SIMPLE
public static final String SYSPROP_FULLTEXT_BINARY
public static final String SYSPROP_FULLTEXT_JOBID
public static final String KEY_PREFIX
public static final String KEY_ID
public static final String KEY_PARENT_ID
public static final String KEY_ANCESTOR_IDS
public static final String KEY_PRIMARY_TYPE
public static final String KEY_MIXIN_TYPES
public static final String KEY_NAME
public static final String KEY_POS
public static final String KEY_ACP
public static final String KEY_ACL_NAME
public static final String KEY_PATH_INTERNAL
public static final String KEY_ACL
public static final String KEY_ACE_USER
public static final String KEY_ACE_PERMISSION
public static final String KEY_ACE_GRANT
public static final String KEY_READ_ACL
public static final String KEY_IS_CHECKED_IN
public static final String KEY_IS_VERSION
public static final String KEY_IS_LATEST_VERSION
public static final String KEY_IS_LATEST_MAJOR_VERSION
public static final String KEY_MAJOR_VERSION
public static final String KEY_MINOR_VERSION
public static final String KEY_VERSION_SERIES_ID
public static final String KEY_VERSION_CREATED
public static final String KEY_VERSION_LABEL
public static final String KEY_VERSION_DESCRIPTION
public static final String KEY_BASE_VERSION_ID
public static final String KEY_IS_PROXY
public static final String KEY_PROXY_TARGET_ID
public static final String KEY_PROXY_VERSION_SERIES_ID
public static final String KEY_PROXY_IDS
public static final String KEY_LIFECYCLE_POLICY
public static final String KEY_LIFECYCLE_STATE
public static final String KEY_LOCK_OWNER
public static final String KEY_LOCK_CREATED
public static final String KEY_BLOB_NAME
public static final String KEY_BLOB_MIME_TYPE
public static final String KEY_BLOB_ENCODING
public static final String KEY_BLOB_DIGEST
public static final String KEY_BLOB_LENGTH
public static final String KEY_BLOB_DATA
public static final String KEY_FULLTEXT_SIMPLE
public static final String KEY_FULLTEXT_BINARY
public static final String KEY_FULLTEXT_JOBID
public static final String KEY_FULLTEXT_SCORE
public static final String APPLICATION_OCTET_STREAM
public DBSDocument(DBSDocumentState docState, DocumentType type, DBSSession session, boolean readonly)
public DocumentType getType()
Document
public Session getSession()
Document
getSession
in interface Document
public String getRepositoryName()
Document
getRepositoryName
in interface Document
public String getUUID()
Document
public String getName()
Document
public Long getPos()
Document
public Document getParent() throws DocumentException
Document
null
if this is the root document.getParent
in interface Document
null
DocumentException
public boolean isProxy()
Document
public boolean isVersion()
Document
public String getPath() throws DocumentException
Document
getPath
in interface Document
DocumentException
public Document getChild(String name) throws DocumentException
Document
Throws NoSuchDocumentException
if the document could not be found.
getChild
in interface Document
name
- the name of the child to retrieveNoSuchDocumentException
- if the child does not existDocumentException
public Iterator<Document> getChildren() throws DocumentException
Document
Returns an empty iterator for non-folder documents.
getChildren
in interface Document
DocumentException
public List<String> getChildrenIds() throws DocumentException
Document
Returns an empty list for non-folder documents.
getChildrenIds
in interface Document
DocumentException
public boolean hasChild(String name) throws DocumentException
Document
Returns false
for non-folder documents.
hasChild
in interface Document
name
- the name of the child to checktrue
if the child exists, false
otherwiseDocumentException
public boolean hasChildren() throws DocumentException
Document
Returns false
for non-folder documents.
hasChildren
in interface Document
true
if the document has children, false
otherwiseDocumentException
public Document addChild(String name, String typeName) throws DocumentException
Document
Throws an error if this document is not a folder.
addChild
in interface Document
name
- the name of the new child to createtypeName
- the type of the child to createDocumentException
public void orderBefore(String src, String dest) throws DocumentException
Document
Both source and destination must be names that point to child documents of this document. The source document
will be placed before the destination one. If destination is null
, the source document will be appended
at the end of the children list.
orderBefore
in interface Document
src
- the document to movedest
- the document before which to place the source documentDocumentException
- if this document is not an orderable folderpublic Serializable getPropertyValue(String name) throws DocumentException
Document
getPropertyValue
in interface Document
name
- the name of the property to getnull
if the property is not setDocumentException
public void setPropertyValue(String name, Serializable value) throws DocumentException
Document
setPropertyValue
in interface Document
name
- the name of the property to setvalue
- the value to setDocumentException
public Document checkIn(String label, String checkinComment) throws DocumentException
Document
checkIn
in interface Document
label
- the version labelcheckinComment
- the checkin commentDocumentException
public void checkOut() throws DocumentException
checkOut
in interface Document
DocumentException
public List<String> getVersionsIds() throws DocumentException
Document
getVersionsIds
in interface Document
DocumentException
public List<Document> getVersions() throws DocumentException
Document
getVersions
in interface Document
DocumentException
public Document getLastVersion() throws DocumentException
Document
Returns null
if there is no version at all.
getLastVersion
in interface Document
null
if there is no versionDocumentException
public Document getSourceDocument() throws DocumentException
Document
For a version, it's the working copy.
For a proxy, it's the version the proxy points to.
getSourceDocument
in interface Document
DocumentException
public void restore(Document version) throws DocumentException
Document
restore
in interface Document
version
- the version to replace withDocumentException
public Document getVersion(String label) throws DocumentException
Document
getVersion
in interface Document
label
- the version labelDocumentException
public Document getBaseVersion() throws DocumentException
Document
Returns null
for a checked out document or a version or a proxy.
getBaseVersion
in interface Document
null
DocumentException
public boolean isCheckedOut() throws DocumentException
Document
isCheckedOut
in interface Document
true
if the document is checked out, or false
otherwiseDocumentException
public String getVersionSeriesId() throws DocumentException
Document
getVersionSeriesId
in interface Document
DocumentException
public Calendar getVersionCreationDate() throws DocumentException
Document
getVersionCreationDate
in interface Document
null
if it's not a version or a proxyDocumentException
public String getVersionLabel() throws DocumentException
Document
getVersionLabel
in interface Document
DocumentException
public String getCheckinComment() throws DocumentException
Document
getCheckinComment
in interface Document
null
if it's not a version or a proxyDocumentException
public boolean isLatestVersion() throws DocumentException
Document
isLatestVersion
in interface Document
true
if this is the latest version, or false
otherwiseDocumentException
public boolean isMajorVersion() throws DocumentException
Document
isMajorVersion
in interface Document
true
if this is a major version, or false
otherwiseDocumentException
public boolean isLatestMajorVersion() throws DocumentException
Document
isLatestMajorVersion
in interface Document
true
if this is the latest major version, or false
otherwiseDocumentException
public boolean isVersionSeriesCheckedOut() throws DocumentException
Document
isVersionSeriesCheckedOut
in interface Document
true
if there is a checked out working copyDocumentException
public Document getWorkingCopy() throws DocumentException
Document
getWorkingCopy
in interface Document
DocumentException
public Lock setLock(Lock lock) throws DocumentException
Document
setLock
in interface Document
lock
- the lock to setnull
if locking succeeded, or the existing lock if locking failedDocumentException
public Lock removeLock(String owner) throws DocumentException
Document
removeLock
in interface Document
null
if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner
mismatchDocumentException
public Lock getLock() throws DocumentException
Document
getLock
in interface Document
null
if no lock is setDocumentException
public boolean isFolder()
Document
public void setReadOnly(boolean readonly)
Document
setReadOnly
in interface Document
public boolean isReadOnly()
Document
isReadOnly
in interface Document
public void remove() throws DocumentException
Document
remove
in interface Document
DocumentException
public String getLifeCycleState() throws LifeCycleException
Document
getLifeCycleState
in interface Document
LifeCycleException
public void setCurrentLifeCycleState(String lifeCycleState) throws LifeCycleException
Document
setCurrentLifeCycleState
in interface Document
lifeCycleState
- the life cycle stateLifeCycleException
public String getLifeCyclePolicy() throws LifeCycleException
Document
getLifeCyclePolicy
in interface Document
LifeCycleException
public void setLifeCyclePolicy(String policy) throws LifeCycleException
Document
setLifeCyclePolicy
in interface Document
policy
- the life cycle policyLifeCycleException
public void followTransition(String transition) throws LifeCycleException
Document
This will update the life cycle state of the document.
followTransition
in interface Document
transition
- the name of the transition to followLifeCycleException
public Collection<String> getAllowedStateTransitions() throws LifeCycleException
Document
getAllowedStateTransitions
in interface Document
LifeCycleException
public void setSystemProp(String name, Serializable value) throws DocumentException
Document
setSystemProp
in interface Document
DocumentException
public <T extends Serializable> T getSystemProp(String name, Class<T> type) throws DocumentException
Document
getSystemProp
in interface Document
DocumentException
public void readDocumentPart(DocumentPart dp) throws PropertyException
Document
DocumentPart
from storage.
Reading data is done by DocumentPart
because of per-proxy schemas.
readDocumentPart
in interface Document
PropertyException
public Map<String,Serializable> readPrefetch(ComplexType complexType, Set<String> xpaths) throws PropertyException
Document
Reading data is done by ComplexType
because of per-proxy schemas.
readPrefetch
in interface Document
PropertyException
public void writeDocumentPart(DocumentPart dp) throws PropertyException
Document
DocumentPart
to storage.
Writing data is done by DocumentPart
because of per-proxy schemas.
writeDocumentPart
in interface Document
PropertyException
public Set<String> getAllFacets()
Document
getAllFacets
in interface Document
public String[] getFacets()
Document
public boolean hasFacet(String facet)
Document
public boolean addFacet(String facet) throws DocumentException
Document
Does nothing if the facet was already present on the document.
addFacet
in interface Document
facet
- the facet nametrue
if the facet was added, or false
if it is already presentDocumentException
- if the facet does not existpublic boolean removeFacet(String facet) throws DocumentException
Document
It's not possible to remove a facet coming from the document type.
removeFacet
in interface Document
facet
- the facet nametrue
if the facet was removed, or false
if it isn't present or is present on the type or
does not exitDocumentException
public Document getTargetDocument() throws DocumentException
Document
getTargetDocument
in interface Document
DocumentException
public void setTargetDocument(Document target) throws DocumentException
Document
setTargetDocument
in interface Document
DocumentException
Copyright © 2015 Nuxeo SA. All rights reserved.