Interface Document
- All Known Subinterfaces:
SQLDocument
- All Known Implementing Classes:
BaseDocument
,DBSDocument
,SQLDocumentLive
,SQLDocumentProxy
,SQLDocumentVersion
Session
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An accessor that can read or write a blob and know its xpath.static interface
Context passed to write operations to optionally record things to do atDocument.WriteContext.flush(org.nuxeo.ecm.core.model.Document)
time. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new child document of the given type.boolean
Adds a facet to this document.Creates a new version.void
checkOut()
void
followTransition
(String transition) Follows a given life cycle transition.Gets the facets available on this document (from the type and the instance facets).Returns the allowed state transitions for this document.Gets the version to which a checked in document is linked.default String[]
Gets the current change token for this document.Gets the version check in comment of this document if it's a version or a proxy.Gets a child document given its name.Gets the children of the document.Gets a list of the children ids.String[]
Gets the facets defined on this document instance.Gets the last version of this document.Gets the life cycle policy of this document.Gets the life cycle state of this document.getLock()
Gets the lock if one set on this document.getName()
Gets the name of this document.Gets the parent document, ornull
if this is the root document.getPath()
Gets the path of this document.getPos()
Gets the document's position in its containing folder (if ordered).getPropertyValue
(String name) Gets a simple property value.Gets the repository in which the document lives.String[]
Gets the retained property xpaths of this document instance at the time it became a record.Gets the retention date for the document.Gets the session that owns this document.Gets the source for this document.<T extends Serializable>
TgetSystemProp
(String name, Class<T> type) Gets a system property.Gets the document (version or live document) to which this proxy points.getType()
Gets the type of this document.getUUID()
Gets this document's UUID.Gets a property value.getVersion
(String label) Gets a version of this document, given its label.Gets the version creation date of this document if it's a version or a proxy.Gets the version label.Gets the versions for this document.Gets the version series id.Gets the list of version ids for this document.Gets the working copy for this document.Gets a write context for the current document.boolean
Checks whether this document has a child of the given name.boolean
Tests if the document has any children.boolean
Checks whether this document has a given facet, either from its type or added on the instance.boolean
Checks if the document has a legal hold set.boolean
Checks whether this document is checked out.default boolean
default boolean
boolean
isFolder()
Checks whether this document is a folder.boolean
Checks whether this document is the latest major version.boolean
Checks whether this document is the latest version.boolean
Checks whether this document is a major version.boolean
isProxy()
Checks whether or not this document is a proxy.boolean
Checks whether this document is readonly or not.boolean
isRecord()
Checks if the document is a record.boolean
isRetainable
(String xpath) Can the property be put under retention or legal hold.boolean
isRetained
(String xpath) Is the property under retention or legal hold.boolean
Deprecated.boolean
Checks if the document has a retention date in the future or has a legal hold.boolean
Checks whether this document is a version document.boolean
Checks if there is a checked out working copy for the version series of this document.default void
Turns the document into a flexible record.void
Turns the document into an enforced record.void
Marks the document as being modified by a user change.void
orderBefore
(String src, String dest) Orders the given source child before the destination child.void
Loads aDocumentPart
from storage.void
remove()
Removes this document and all its children, if any.void
remove
(NuxeoPrincipal principal) Removes this document and all its children, if any.boolean
removeFacet
(String facet) Removes a facet from this document.removeLock
(String owner) Removes a lock from this document.void
Removes this document only, without its children.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.void
Replaces this document's content with the version specified.void
setCurrentLifeCycleState
(String state) Sets the life cycle state of this document.void
setLegalHold
(boolean hold) Sets or removes a legal hold on the document (a record).void
setLifeCyclePolicy
(String policy) Sets the life cycle policy of this document.Sets a lock on this document.void
setPropertyValue
(String name, Serializable value) Sets a simple property value.void
setReadOnly
(boolean readonly) Sets this document as readonly or not.void
setRetainUntil
(Calendar retainUntil) Sets a retention date for the document (a record).void
setRetentionActive
(boolean retentionActive) Deprecated.since 11.1, unused, usesetLegalHold(boolean)
insteadvoid
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.void
Sets a property value.boolean
validateUserVisibleChangeToken
(String changeToken) Validates that the passed user-visible change token is compatible with the one for this document.void
visitBlobs
(Consumer<Document.BlobAccessor> blobVisitor) Visits all the blobs of this document and calls the passed blob visitor on each one.default boolean
writeDocumentPart
(DocumentPart dp, Document.WriteContext writeContext) Deprecated.since 11.1, use the signature withcreate
insteadboolean
writeDocumentPart
(DocumentPart dp, Document.WriteContext writeContext, boolean create) Writes aDocumentPart
to storage.
-
Method Details
-
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, ornull
if 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
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
Sets a property value.The xpath may point to a partial path, in which case the value may be a complex
List
orMap
.- 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
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
null
if the property is not set - See Also:
-
getValue
Gets a property value.The xpath may point to a partial path, in which case the value may be a complex
List
orMap
.- Parameters:
xpath
- the xpath of the property to set- Returns:
- the property value or
null
if the property is not set - Throws:
PropertyException
- if the property does not exist
-
visitBlobs
Visits all the blobs of this document and calls the passed blob visitor on each one.- Throws:
PropertyException
- Since:
- 7.3
-
replaceBlobDigest
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,
null
otherwise - Since:
- 11.5
-
isFolder
boolean isFolder()Checks whether this document is a folder.- Returns:
true
if the document is a folder,false
otherwise
-
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
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
- 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:
-
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:
-
isEnforcedRecord
default boolean isEnforcedRecord()- Returns:
true
if the document is a enforced record,false
otherwise- Since:
- 2023.1
-
isFlexibleRecord
default boolean isFlexibleRecord()- Returns:
true
if the document is a flexible record,false
otherwise- Since:
- 2023.1
-
isRecord
boolean isRecord()Checks if the document is a record.- Returns:
true
if the document is a record,false
otherwise- Since:
- 11.1
- See Also:
-
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
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
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
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
null
and 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
Calendar getRetainUntil()Gets the retention date for the document.- Returns:
- the retention date, or "SetRetention" for a
retention in the indeterminate future, or
null
if there is no retention date - Since:
- 11.1
- See Also:
-
setLegalHold
void setLegalHold(boolean hold) Sets or removes a legal hold on the document (a record).The permission "ManageLegalHold" is required.
- Parameters:
hold
-true
to set a legal hold,false
to remove it- Throws:
PropertyException
- if the document is not a record- Since:
- 11.1
- See Also:
-
hasLegalHold
boolean hasLegalHold()Checks if the document has a legal hold set.- Returns:
true
if a legal hold has been set on the document,false
otherwise- Since:
- 11.1
- See Also:
-
isUnderRetentionOrLegalHold
boolean isUnderRetentionOrLegalHold()Checks if the document has a retention date in the future or has a legal hold.- Returns:
true
if the document has a retention date in the future or if it has a legal hold,false
otherwise- Since:
- 11.1
- See Also:
-
isRetentionActive
Deprecated.since 11.1, unused, usehasLegalHold()
insteadChecks whether this document is under active retention.- Since:
- 9.3
-
setRetentionActive
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
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
Sets the life cycle policy of this document.- Parameters:
policy
- the life cycle policy
-
followTransition
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:
true
if this document is a proxy,false
otherwise
-
getRepositoryName
String getRepositoryName()Gets the repository in which the document lives.- Returns:
- the repository name.
-
setSystemProp
Sets a system property. -
getSystemProp
Gets a system property. -
getChangeToken
String getChangeToken()Gets the current change token for this document.- Returns:
- the change token
- Since:
- 9.1
-
validateUserVisibleChangeToken
Validates that the passed user-visible change token is compatible with the one for this document.- Returns:
false
if 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
Loads aDocumentPart
from storage.Reading data is done by
DocumentPart
because 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 aDocumentPart
to storage.Writing data is done by
DocumentPart
because of per-proxy schemas.- Parameters:
dp
- the document partwriteContext
- the write contextcreate
- whether this is for a document creation- Returns:
true
if 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 withcreate
insteadWrites aDocumentPart
to storage.Writing data is done by
DocumentPart
because of per-proxy schemas.- Returns:
true
if something changed- Throws:
PropertyException
-
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
Checks whether this document has a given facet, either from its type or added on the instance.- Parameters:
facet
- the facet name- Returns:
true
if the document has the facet- Since:
- 5.4.2
-
addFacet
Adds a facet to this document.Does nothing if the facet was already present on the document.
- Parameters:
facet
- the facet name- Returns:
true
if the facet was added, orfalse
if it is already present- Throws:
IllegalArgumentException
- if the facet does not exist- Since:
- 5.4.2
-
removeFacet
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:
true
if the facet was removed, orfalse
if it isn't present or is present on the type or does not exit- Since:
- 5.4.2
-
setLock
Sets a lock on this document.- Parameters:
lock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed
-
removeLock
Removes a lock from this document.- Parameters:
owner
- the owner to check, ornull
for no check- Returns:
null
if 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
null
if no lock is set
-
getChild
Gets a child document given its name.Throws
DocumentNotFoundException
if 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
-
getChildren
Gets the children of the document.- Returns:
- the children
-
getChildrenIds
Gets a list of the children ids.- Returns:
- a list of children ids.
- Since:
- 1.4.1
-
hasChild
Checks whether this document has a child of the given name.- Parameters:
name
- the name of the child to check- Returns:
true
if the child exists,false
otherwise
-
hasChildren
boolean hasChildren()Tests if the document has any children.- Returns:
true
if the document has children,false
otherwise
-
addChild
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
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
Creates a new version.- Parameters:
label
- the version labelcheckinComment
- the checkin comment- Returns:
- the created version
-
checkOut
void checkOut() -
getVersionsIds
Gets the list of version ids for this document.- Returns:
- the list of version ids
- Since:
- 1.4.1
-
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
null
if there is no version at all.- Returns:
- the last version, or
null
if 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
Replaces this document's content with the version specified.- Parameters:
version
- the version to replace with
-
getVersion
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:
true
if it's a version,false
otherwise
-
getBaseVersion
Document getBaseVersion()Gets the version to which a checked in document is linked.Returns
null
for 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:
true
if the document is checked out, orfalse
otherwise
-
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
null
if 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
null
if 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:
true
if this is the latest version, orfalse
otherwise
-
isMajorVersion
boolean isMajorVersion()Checks whether this document is a major version.- Returns:
true
if this is a major version, orfalse
otherwise
-
isLatestMajorVersion
boolean isLatestMajorVersion()Checks whether this document is the latest major version.- Returns:
true
if this is the latest major version, orfalse
otherwise
-
isVersionSeriesCheckedOut
boolean isVersionSeriesCheckedOut()Checks if there is a checked out working copy for the version series of this document.- Returns:
true
if 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
Sets the document (version or live document) to which this proxy points.
-
hasLegalHold()
instead