Interface Document
-
- All Known Subinterfaces:
SQLDocument
- All Known Implementing Classes:
BaseDocument,DBSDocument,SQLDocumentLive,SQLDocumentProxy,SQLDocumentVersion
public interface DocumentA low-level document from aSession.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDocument.BlobAccessorAn accessor that can read or write a blob and know its xpath.static interfaceDocument.WriteContextContext passed to write operations to optionally record things to do atDocument.WriteContext.flush(org.nuxeo.ecm.core.model.Document)time.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description DocumentaddChild(String name, String typeName)Creates a new child document of the given type.booleanaddFacet(String facet)Adds a facet to this document.DocumentcheckIn(String label, String checkinComment)Creates a new version.voidcheckOut()voidfollowTransition(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.DocumentgetBaseVersion()Gets the version to which a checked in document is linked.default String[]getBlobKeys()StringgetChangeToken()Gets the current change token for this document.StringgetCheckinComment()Gets the version check in comment of this document if it's a version or a proxy.DocumentgetChild(String name)Gets a child document given its name.List<Document>getChildren()Gets 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.DocumentgetLastVersion()Gets the last version of this document.StringgetLifeCyclePolicy()Gets the life cycle policy of this document.StringgetLifeCycleState()Gets the life cycle state of this document.LockgetLock()Gets the lock if one set on this document.StringgetName()Gets the name of this document.DocumentgetParent()Gets the parent document, ornullif this is the root document.StringgetPath()Gets the path of this document.LonggetPos()Gets the document's position in its containing folder (if ordered).SerializablegetPropertyValue(String name)Gets a simple property value.StringgetRepositoryName()Gets the repository in which the document lives.String[]getRetainedProperties()Gets the retained property xpaths of this document instance at the time it became a record.CalendargetRetainUntil()Gets the retention date for the document.SessiongetSession()Gets the session that owns this document.DocumentgetSourceDocument()Gets the source for this document.<T extends Serializable>
TgetSystemProp(String name, Class<T> type)Gets a system property.DocumentgetTargetDocument()Gets the document (version or live document) to which this proxy points.DocumentTypegetType()Gets the type of this document.StringgetUUID()Gets this document's UUID.ObjectgetValue(String xpath)Gets a property value.DocumentgetVersion(String label)Gets a version of this document, given its label.CalendargetVersionCreationDate()Gets the version creation date of this document if it's a version or a proxy.StringgetVersionLabel()Gets the version label.List<Document>getVersions()Gets the versions for this document.StringgetVersionSeriesId()Gets the version series id.List<String>getVersionsIds()Gets the list of version ids for this document.DocumentgetWorkingCopy()Gets the working copy for this document.Document.WriteContextgetWriteContext()Gets a write context for the current document.booleanhasChild(String name)Checks whether this document has a child of the given name.booleanhasChildren()Tests if the document has any children.booleanhasFacet(String facet)Checks whether this document has a given facet, either from its type or added on the instance.booleanhasLegalHold()Checks if the document has a legal hold set.booleanisCheckedOut()Checks whether this document is checked out.default booleanisEnforcedRecord()default booleanisFlexibleRecord()booleanisFolder()Checks whether this document is a folder.booleanisLatestMajorVersion()Checks whether this document is the latest major version.booleanisLatestVersion()Checks whether this document is the latest version.booleanisMajorVersion()Checks whether this document is a major version.booleanisProxy()Checks whether or not this document is a proxy.booleanisReadOnly()Checks whether this document is readonly or not.booleanisRecord()Checks if the document is a record.booleanisRetainable(String xpath)Can the property be put under retention or legal hold.booleanisRetained(String xpath)Is the property under retention or legal hold.booleanisRetentionActive()Deprecated.since 11.1, unused, usehasLegalHold()insteadbooleanisUnderRetentionOrLegalHold()Checks if the document has a retention date in the future or has a legal hold.booleanisVersion()Checks whether this document is a version document.booleanisVersionSeriesCheckedOut()Checks if there is a checked out working copy for the version series of this document.default voidmakeFlexibleRecord()Turns the document into a flexible record.voidmakeRecord()Turns the document into an enforced record.voidmarkUserChange()Marks the document as being modified by a user change.voidorderBefore(String src, String dest)Orders the given source child before the destination child.voidreadDocumentPart(DocumentPart dp)Loads aDocumentPartfrom storage.voidremove()Removes this document and all its children, if any.voidremove(NuxeoPrincipal principal)Removes this document and all its children, if any.booleanremoveFacet(String facet)Removes a facet from this document.LockremoveLock(String owner)Removes a lock from this document.voidremoveSingleton()Removes this document only, without its children.StringreplaceBlobDigest(String key, String newKey, String newDigest)Visits the blobs of this document and, for those with a matching key, replace their key and digest with new ones.voidrestore(Document version)Replaces this document's content with the version specified.voidsetCurrentLifeCycleState(String state)Sets the life cycle state of this document.voidsetLegalHold(boolean hold)Sets or removes a legal hold on the document (a record).voidsetLifeCyclePolicy(String policy)Sets the life cycle policy of this document.LocksetLock(Lock lock)Sets a lock on this document.voidsetPropertyValue(String name, Serializable value)Sets a simple property value.voidsetReadOnly(boolean readonly)Sets this document as readonly or not.voidsetRetainUntil(Calendar retainUntil)Sets a retention date for the document (a record).voidsetRetentionActive(boolean retentionActive)Deprecated.since 11.1, unused, usesetLegalHold(boolean)insteadvoidsetSystemProp(String name, Serializable value)Sets a system property.voidsetTargetDocument(Document target)Sets the document (version or live document) to which this proxy points.voidsetValue(String xpath, Object value)Sets a property value.booleanvalidateUserVisibleChangeToken(String changeToken)Validates that the passed user-visible change token is compatible with the one for this document.voidvisitBlobs(Consumer<Document.BlobAccessor> blobVisitor)Visits all the blobs of this document and calls the passed blob visitor on each one.default booleanwriteDocumentPart(DocumentPart dp, Document.WriteContext writeContext)Deprecated.since 11.1, use the signature withcreateinsteadbooleanwriteDocumentPart(DocumentPart dp, Document.WriteContext writeContext, boolean create)Writes aDocumentPartto storage.
-
-
-
Method Detail
-
getSession
Session getSession()
Gets the session that owns this document.- Returns:
- the session
-
getName
String getName()
Gets the name of this document.- Returns:
- the document name
-
getPos
Long getPos()
Gets the document's position in its containing folder (if ordered).- Returns:
- the position
- Since:
- 6.0
-
getUUID
String getUUID()
Gets this document's UUID.- Returns:
- the document UUID
-
getParent
Document getParent()
Gets the parent document, ornullif this is the root document.- Returns:
- the parent document, or
null
-
getType
DocumentType getType()
Gets the type of this document.- Returns:
- the document type
-
getPath
String getPath()
Gets the path of this document.- Returns:
- the path
-
setPropertyValue
void setPropertyValue(String name, Serializable value)
Sets a simple property value.For more generic properties described by an xpath, use
setValue(java.lang.String, java.lang.Object)instead.- Parameters:
name- the name of the property to setvalue- the value to set- See Also:
setValue(java.lang.String, java.lang.Object)
-
setValue
void setValue(String xpath, Object value) throws PropertyException
Sets a property value.The xpath may point to a partial path, in which case the value may be a complex
ListorMap.- Parameters:
xpath- the xpath of the property to setvalue- the value to set- Throws:
PropertyException- if the property does not exist or the value is of the wrong type- Since:
- 7.3
-
getPropertyValue
Serializable getPropertyValue(String name)
Gets a simple property value.For more generic properties described by an xpath, use
getValue(java.lang.String)instead.- Parameters:
name- the name of the property to get- Returns:
- the property value or
nullif the property is not set - See Also:
getValue(java.lang.String)
-
getValue
Object getValue(String xpath) throws PropertyException
Gets a property value.The xpath may point to a partial path, in which case the value may be a complex
ListorMap.- Parameters:
xpath- the xpath of the property to set- Returns:
- the property value or
nullif the property is not set - Throws:
PropertyException- if the property does not exist
-
visitBlobs
void visitBlobs(Consumer<Document.BlobAccessor> blobVisitor) throws PropertyException
Visits all the blobs of this document and calls the passed blob visitor on each one.- Throws:
PropertyException- Since:
- 7.3
-
replaceBlobDigest
String replaceBlobDigest(String key, String newKey, String newDigest)
Visits the blobs of this document and, for those with a matching key, replace their key and digest with new ones.- Parameters:
key- the bob key to look fornewKey- the new keynewDigest- the new digest- Returns:
- the old digest if at least one replacement was done,
nullotherwise - Since:
- 11.5
-
isFolder
boolean isFolder()
Checks whether this document is a folder.- Returns:
trueif the document is a folder,falseotherwise
-
setReadOnly
void setReadOnly(boolean readonly)
Sets this document as readonly or not.- Since:
- 5.9.2
-
isReadOnly
boolean isReadOnly()
Checks whether this document is readonly or not.- Since:
- 5.9.2
-
remove
void remove()
Removes this document and all its children, if any.
-
remove
void remove(NuxeoPrincipal principal)
Removes this document and all its children, if any.- Parameters:
principal- the caller- Since:
- 11.1
-
removeSingleton
void removeSingleton()
Removes this document only, without its children.- Since:
- 11.1
-
getBlobKeys
default String[] getBlobKeys()
- Since:
- 2023
-
makeRecord
void makeRecord()
Turns the document into an enforced record.A record is a document with specific capabilities related to mandatory retention until a given date, and legal holds. In addition, its main blob receives special treatment from the document blob manager to make sure it's never shared with another blob at the storage level, and is deleted as soon as the record is deleted.
If the document is already a record, this method has no effect.
The permission "MakeRecord" is required.
- Since:
- 11.1
- See Also:
isRecord()
-
makeFlexibleRecord
default void makeFlexibleRecord()
Turns the document into a flexible record.A record is a document with specific capabilities related to mandatory retention until a given date, and legal holds.
If the document is already a flexible record, this method has no effect. An enforced record cannot be turned into a flexible record.
The permission "MakeRecord" is required.
- Throws:
IllegalStateException- if the document is an enforced record- Since:
- 2023.1
- See Also:
isFlexibleRecord()
-
isEnforcedRecord
default boolean isEnforcedRecord()
- Returns:
trueif the document is a enforced record,falseotherwise- Since:
- 2023.1
-
isFlexibleRecord
default boolean isFlexibleRecord()
- Returns:
trueif the document is a flexible record,falseotherwise- Since:
- 2023.1
-
isRecord
boolean isRecord()
Checks if the document is a record.- Returns:
trueif the document is a record,falseotherwise- Since:
- 11.1
- See Also:
makeRecord()
-
getRetainedProperties
String[] getRetainedProperties()
Gets the retained property xpaths of this document instance at the time it became a record.- Returns:
- the retained properties
- Throws:
PropertyException- if document is not a record- Since:
- 2021.32
-
isRetainable
boolean isRetainable(String xpath)
Can the property be put under retention or legal hold.- Parameters:
xpath- the xpath- Returns:
- true if the property is retainable
- Since:
- 2021.32
-
isRetained
boolean isRetained(String xpath)
Is the property under retention or legal hold.- Parameters:
xpath- the xpath- Returns:
- true if the property is retained and cannot be deleted/edited
- Since:
- 2021.32
-
setRetainUntil
void setRetainUntil(Calendar retainUntil) throws PropertyException
Sets a retention date for the document (a record).If no previous retention date was set, or if the previous retention date was indeterminate, or if the previous retention date was before the given value, then the retention date is set to the given value.
If the previous retention date was after the given value (that is, if trying to reduce the retention time), an exception is thrown.
If the given value is
nulland the previous retention date is in the past (it has already expired), then the retention date is set tonull.The permission "SetRetention" is required.
- Parameters:
retainUntil- the new retention date- Throws:
PropertyException- if trying to reduce the retention time, or if the document is not a record- Since:
- 11.1
- See Also:
getRetainUntil(),CoreSession.RETAIN_UNTIL_INDETERMINATE
-
getRetainUntil
Calendar getRetainUntil()
Gets the retention date for the document.- Returns:
- the retention date, or "SetRetention" for a
retention in the indeterminate future, or
nullif there is no retention date - Since:
- 11.1
- See Also:
setRetainUntil(java.util.Calendar),CoreSession.RETAIN_UNTIL_INDETERMINATE
-
setLegalHold
void setLegalHold(boolean hold)
Sets or removes a legal hold on the document (a record).The permission "ManageLegalHold" is required.
- Parameters:
hold-trueto set a legal hold,falseto remove it- Throws:
PropertyException- if the document is not a record- Since:
- 11.1
- See Also:
hasLegalHold()
-
hasLegalHold
boolean hasLegalHold()
Checks if the document has a legal hold set.- Returns:
trueif a legal hold has been set on the document,falseotherwise- Since:
- 11.1
- See Also:
setLegalHold(boolean)
-
isUnderRetentionOrLegalHold
boolean isUnderRetentionOrLegalHold()
Checks if the document has a retention date in the future or has a legal hold.- Returns:
trueif the document has a retention date in the future or if it has a legal hold,falseotherwise- Since:
- 11.1
- See Also:
getRetainUntil(),hasLegalHold()
-
isRetentionActive
@Deprecated boolean isRetentionActive()
Deprecated.since 11.1, unused, usehasLegalHold()insteadChecks whether this document is under active retention.- Since:
- 9.3
-
setRetentionActive
@Deprecated void setRetentionActive(boolean retentionActive)
Deprecated.since 11.1, unused, usesetLegalHold(boolean)insteadSets or unsets this document as under active retention.- Since:
- 9.3
-
getLifeCycleState
String getLifeCycleState()
Gets the life cycle state of this document.- Returns:
- the life cycle state
-
setCurrentLifeCycleState
void setCurrentLifeCycleState(String state)
Sets the life cycle state of this document.- Parameters:
state- the life cycle state
-
getLifeCyclePolicy
String getLifeCyclePolicy()
Gets the life cycle policy of this document.- Returns:
- the life cycle policy
-
setLifeCyclePolicy
void setLifeCyclePolicy(String policy)
Sets the life cycle policy of this document.- Parameters:
policy- the life cycle policy
-
followTransition
void followTransition(String transition) throws LifeCycleException
Follows a given life cycle transition.This will update the life cycle state of the document.
- Parameters:
transition- the name of the transition to follow- Throws:
LifeCycleException
-
getAllowedStateTransitions
Collection<String> getAllowedStateTransitions()
Returns the allowed state transitions for this document.- Returns:
- a collection of state transitions
-
isProxy
boolean isProxy()
Checks whether or not this document is a proxy.- Returns:
trueif this document is a proxy,falseotherwise
-
getRepositoryName
String getRepositoryName()
Gets the repository in which the document lives.- Returns:
- the repository name.
-
setSystemProp
void setSystemProp(String name, Serializable value)
Sets a system property.
-
getSystemProp
<T extends Serializable> T getSystemProp(String name, Class<T> type)
Gets a system property.
-
getChangeToken
String getChangeToken()
Gets the current change token for this document.- Returns:
- the change token
- Since:
- 9.1
-
validateUserVisibleChangeToken
boolean validateUserVisibleChangeToken(String changeToken)
Validates that the passed user-visible change token is compatible with the one for this document.- Returns:
falseif the change token is not valid- Since:
- 9.2
-
markUserChange
void markUserChange()
Marks the document as being modified by a user change.This causes an additional change token increment and check during save.
- Since:
- 9.2
-
readDocumentPart
void readDocumentPart(DocumentPart dp) throws PropertyException
Loads aDocumentPartfrom storage.Reading data is done by
DocumentPartbecause of per-proxy schemas.- Throws:
PropertyException
-
getWriteContext
Document.WriteContext getWriteContext()
Gets a write context for the current document.- Since:
- 7.3
-
writeDocumentPart
boolean writeDocumentPart(DocumentPart dp, Document.WriteContext writeContext, boolean create) throws PropertyException
Writes aDocumentPartto storage.Writing data is done by
DocumentPartbecause of per-proxy schemas.- Parameters:
dp- the document partwriteContext- the write contextcreate- whether this is for a document creation- Returns:
trueif something changed- Throws:
PropertyException- Since:
- 11.1
-
writeDocumentPart
@Deprecated default boolean writeDocumentPart(DocumentPart dp, Document.WriteContext writeContext) throws PropertyException
Deprecated.since 11.1, use the signature withcreateinsteadWrites aDocumentPartto storage.Writing data is done by
DocumentPartbecause of per-proxy schemas.- Returns:
trueif something changed- Throws:
PropertyException
-
getAllFacets
Set<String> getAllFacets()
Gets the facets available on this document (from the type and the instance facets).- Returns:
- the facets
- Since:
- 5.4.2
-
getFacets
String[] getFacets()
Gets the facets defined on this document instance. The type facets are not returned.- Returns:
- the facets
- Since:
- 5.4.2
-
hasFacet
boolean hasFacet(String facet)
Checks whether this document has a given facet, either from its type or added on the instance.- Parameters:
facet- the facet name- Returns:
trueif the document has the facet- Since:
- 5.4.2
-
addFacet
boolean addFacet(String facet)
Adds a facet to this document.Does nothing if the facet was already present on the document.
- Parameters:
facet- the facet name- Returns:
trueif the facet was added, orfalseif it is already present- Throws:
IllegalArgumentException- if the facet does not exist- Since:
- 5.4.2
-
removeFacet
boolean removeFacet(String facet)
Removes a facet from this document.It's not possible to remove a facet coming from the document type.
- Parameters:
facet- the facet name- Returns:
trueif the facet was removed, orfalseif it isn't present or is present on the type or does not exit- Since:
- 5.4.2
-
setLock
Lock setLock(Lock lock)
Sets a lock on this document.- Parameters:
lock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed
-
removeLock
Lock removeLock(String owner)
Removes a lock from this document.- Parameters:
owner- the owner to check, ornullfor no check- Returns:
nullif there was no lock or if removal succeeded, or a lock if it blocks removal due to owner mismatch
-
getLock
Lock getLock()
Gets the lock if one set on this document.- Returns:
- the lock, or
nullif no lock is set
-
getChild
Document getChild(String name)
Gets a child document given its name.Throws
DocumentNotFoundExceptionif the document could not be found.- Parameters:
name- the name of the child to retrieve- Returns:
- the child if exists
- Throws:
DocumentNotFoundException- if the child does not exist
-
getChildrenIds
List<String> getChildrenIds()
Gets a list of the children ids.- Returns:
- a list of children ids.
- Since:
- 1.4.1
-
hasChild
boolean hasChild(String name)
Checks whether this document has a child of the given name.- Parameters:
name- the name of the child to check- Returns:
trueif the child exists,falseotherwise
-
hasChildren
boolean hasChildren()
Tests if the document has any children.- Returns:
trueif the document has children,falseotherwise
-
addChild
Document addChild(String name, String typeName)
Creates a new child document of the given type.- Parameters:
name- the name of the new child to createtypeName- the type of the child to create- Returns:
- the newly created document
-
orderBefore
void orderBefore(String src, String dest)
Orders the given source child before the destination child.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.- Parameters:
src- the document to movedest- the document before which to place the source document
-
checkIn
Document checkIn(String label, String checkinComment)
Creates a new version.- Parameters:
label- the version labelcheckinComment- the checkin comment- Returns:
- the created version
-
checkOut
void checkOut()
-
getVersionsIds
List<String> getVersionsIds()
Gets the list of version ids for this document.- Returns:
- the list of version ids
- Since:
- 1.4.1
-
getVersions
List<Document> getVersions()
Gets the versions for this document.- Returns:
- the versions of the document, or an empty list if there are no versions
-
getLastVersion
Document getLastVersion()
Gets the last version of this document.Returns
nullif there is no version at all.- Returns:
- the last version, or
nullif there is no version
-
getSourceDocument
Document getSourceDocument()
Gets the source for this document.For a version, it's the working copy.
For a proxy, it's the version the proxy points to.
- Returns:
- the source document
-
restore
void restore(Document version)
Replaces this document's content with the version specified.- Parameters:
version- the version to replace with
-
getVersion
Document getVersion(String label)
Gets a version of this document, given its label.- Parameters:
label- the version label- Returns:
- the version
-
isVersion
boolean isVersion()
Checks whether this document is a version document.- Returns:
trueif it's a version,falseotherwise
-
getBaseVersion
Document getBaseVersion()
Gets the version to which a checked in document is linked.Returns
nullfor a checked out document or a version or a proxy.- Returns:
- the version, or
null
-
isCheckedOut
boolean isCheckedOut()
Checks whether this document is checked out.- Returns:
trueif the document is checked out, orfalseotherwise
-
getVersionCreationDate
Calendar getVersionCreationDate()
Gets the version creation date of this document if it's a version or a proxy.- Returns:
- the version creation date, or
nullif it's not a version or a proxy
-
getCheckinComment
String getCheckinComment()
Gets the version check in comment of this document if it's a version or a proxy.- Returns:
- the check in comment, or
nullif it's not a version or a proxy
-
getVersionSeriesId
String getVersionSeriesId()
Gets the version series id.- Returns:
- the version series id
-
getVersionLabel
String getVersionLabel()
Gets the version label.- Returns:
- the version label
-
isLatestVersion
boolean isLatestVersion()
Checks whether this document is the latest version.- Returns:
trueif this is the latest version, orfalseotherwise
-
isMajorVersion
boolean isMajorVersion()
Checks whether this document is a major version.- Returns:
trueif this is a major version, orfalseotherwise
-
isLatestMajorVersion
boolean isLatestMajorVersion()
Checks whether this document is the latest major version.- Returns:
trueif this is the latest major version, orfalseotherwise
-
isVersionSeriesCheckedOut
boolean isVersionSeriesCheckedOut()
Checks if there is a checked out working copy for the version series of this document.- Returns:
trueif there is a checked out working copy
-
getWorkingCopy
Document getWorkingCopy()
Gets the working copy for this document.- Returns:
- the working copy
-
getTargetDocument
Document getTargetDocument()
Gets the document (version or live document) to which this proxy points.
-
setTargetDocument
void setTargetDocument(Document target)
Sets the document (version or live document) to which this proxy points.
-
-