Class DocumentModelImpl
- java.lang.Object
-
- org.nuxeo.ecm.core.api.impl.DocumentModelImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,DocumentModel
public class DocumentModelImpl extends Object implements DocumentModel, Cloneable
Standard implementation of aDocumentModel
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.api.DocumentModel
DocumentModel.DocumentModelRefresh
-
-
Field Summary
Fields Modifier and Type Field Description protected ACP
acp
protected HashMap<Class<?>,Object>
adapters
protected String
changeToken
protected String
checkinComment
protected Calendar
checkinDate
protected Map<String,Serializable>
contextData
protected CoreSession
coreSession
protected String
currentLifeCycleState
protected Map<String,DataModel>
dataModels
static long
F_IMMUTABLE
static long
F_PROXY
static long
F_VERSION
protected Set<String>
facets
Facets including those on instance.boolean
hasLegalHold
protected String
id
Set<String>
instanceFacets
Instance facets.Set<String>
instanceFacetsOrig
Instance facets when the document was read.protected boolean
isACPLoaded
protected boolean
isCheckedOut
boolean
isFlexibleRecord
protected boolean
isLatestMajorVersion
protected boolean
isLatestVersion
protected boolean
isMajorVersion
boolean
isRecord
protected boolean
isStateLoaded
state is lifecycle, version stuff.protected boolean
isTrashed
protected boolean
isVersionSeriesCheckedOut
protected String
lifeCyclePolicy
protected Lock
lock
protected static Lock
LOCK_UNKNOWN
protected DocumentRef
parentRef
protected Path
path
protected Long
pos
protected NuxeoPrincipal
principal
protected DocumentRef
ref
protected String
repositoryName
protected List<String>
retainedProperties
Retained properties.Calendar
retainUntil
protected Set<String>
schemas
Schemas including those from instance facets.protected Set<String>
schemasOrig
Schemas including those from instance facets when the doc was readprotected String
sourceId
protected DocumentType
type
protected String
typeName
protected String
versionSeriesId
-
Fields inherited from interface org.nuxeo.ecm.core.api.DocumentModel
REFRESH_ACP, REFRESH_ACP_IF_LOADED, REFRESH_ACP_LAZY, REFRESH_ALL, REFRESH_CONTENT, REFRESH_CONTENT_IF_LOADED, REFRESH_CONTENT_LAZY, REFRESH_DEFAULT, REFRESH_IF_LOADED, REFRESH_LAZY, REFRESH_PREFETCH, REFRESH_STATE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DocumentModelImpl()
DocumentModelImpl(String typeName)
Constructor to use a document model client side without referencing a document.DocumentModelImpl(String parentPath, String name, String type)
Constructor to be used by clients.DocumentModelImpl(String sid, String type, String id, Path path, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, String repositoryName, boolean isProxy)
Deprecated.since 11.1, sid is unusedDocumentModelImpl(String sid, String type, String id, Path path, Lock lock, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, String repositoryName)
Deprecated.since 11.1, sid and lock are unusedDocumentModelImpl(String type, String id, Path path, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, boolean isProxy, CoreSession coreSession, String repositoryName, NuxeoPrincipal principal)
DocumentModelImpl(DocumentModel parent, String name, String type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
accept(PropertyVisitor visitor, Object arg)
Method that implement the visitor pattern.void
addDataModel(DataModel dataModel)
boolean
addFacet(String facet)
Adds a facet to the document instance.void
attach(CoreSession coreSession)
Reattaches a document to an existing session.DocumentRef
checkIn(VersioningOption option, String description)
Checks in a document and returns the created version.void
checkOut()
Checks out a document.DocumentModel
clone()
Clone operation.DataModel
cloneDataModel(DataModel data)
static DataModel
cloneDataModel(Schema schema, DataModel data)
static Object
cloneField(Field field, String key, Object value)
protected void
computeFacetsAndSchemas(Set<String> instanceFacets, boolean setOrig)
Recomputes all facets and schemas from the instance facets.static Set<String>
computeSchemas(DocumentType type, Collection<String> instanceFacets, boolean isProxy)
Recomputes effective schemas from a type + instance facets.void
copyContent(DocumentModel sourceDoc)
Copies all the data from a source document.void
copyContextData(DocumentModel otherDocument)
Copies the context data from given document to this document.void
detach(boolean loadAll)
Detaches the documentImpl from its existing session, so that it can survive beyond the session's closing.boolean
equals(Object obj)
boolean
followTransition(String transition)
Follows a given life cycle transition.ACP
getACP()
Gets the access control policy (ACP) for this document.<T> T
getAdapter(Class<T> itf)
Adapts the document to the given interface.<T> T
getAdapter(Class<T> itf, boolean refreshCache)
Adapts the document to the given interface.Collection<String>
getAllowedStateTransitions()
Gets the allowed state transitions for this document.Map<String,String>
getBinaryFulltext()
Gets the fulltext extracted from the binary fields.String
getCacheKey()
Returns a cache key.String
getChangeToken()
Gets the current change token for this document.String
getCheckinComment()
Returns the checkin comment if the document model is a version.Calendar
getCheckinDate()
Returns the checkin date (the date the version was created) if the document model is a version.Map<String,Serializable>
getContextData()
Gets the context data associated to this document.Serializable
getContextData(String key)
Gets the context data using the default scope.CoreSession
getCoreSession()
Gets the core session to which this document is tied.String
getCurrentLifeCycleState()
Returns the life cycle of the document.DataModel
getDataModel(String schema)
Deprecated.Map<String,DataModel>
getDataModels()
Gets the data models.Collection<DataModel>
getDataModelsCollection()
Deprecated.DocumentType
getDocumentType()
Gets the document type object.Set<String>
getFacets()
Gets the facets available on this document (from the type and the instance facets).String
getId()
Gets the document UUID.String
getLifeCyclePolicy()
Returns the life cycle policy of the document.Lock
getLockInfo()
Gets the lock info on the document.String
getName()
Gets the document name.PropertyObjectResolver
getObjectResolver(String xpath)
DocumentRef
getParentRef()
Retrieves the parent reference of the current document.DocumentPart
getPart(String schema)
Deprecated.DocumentPart[]
getParts()
Deprecated.Path
getPath()
Gets the document path.String
getPathAsString()
Gets the document path as a string.Long
getPos()
Gets the document's position in its containing folder (if ordered).NuxeoPrincipal
getPrincipal()
Gets the principal attached to this document's session.Map<String,Object>
getProperties(String schemaName)
Gets the values from the given data model as a map.Property
getProperty(String xpath)
Gets a property given a xpath.Object
getProperty(String schemaName, String name)
Gets a property from the given schema.Property
getPropertyObject(String schema, String name)
Gets a property object from the given schema.Collection<Property>
getPropertyObjects(String schema)
Gets theProperty
objects for the given schema.Serializable
getPropertyValue(String xpath)
Gets a property value given a xpath.DocumentRef
getRef()
Gets a reference to the core document that can be used either remotely or locally (opens the core JVM).String
getRepositoryName()
Returns the name of the repository in which the document is stored.List<String>
getRetainedProperties()
Gets the retained properties of this document at the time it became a record.Calendar
getRetainUntil()
Gets the retention date for the document.protected static SchemaManager
getSchemaManager()
String[]
getSchemas()
Gets the schemas available on this document (from the type and the facets).protected CoreSession
getSession()
Gets the CoreSession, or fails if it's not available.String
getSessionId()
Returns the repository name and principal when the document is attached.String
getSourceId()
Returns the source document identifier.<T extends Serializable>
TgetSystemProp(String systemProperty, Class<T> type)
Gets system property of the specified type.String
getTitle()
Gets the title from the dublincore schema.String
getType()
Gets the document type name.String
getVersionLabel()
Returns the version label.String
getVersionSeriesId()
Gets the version series id for this document.static String
getXPathSchemaName(String xpath, Set<String> docSchemas, String[] returnName)
Deprecated.since 2023, useSchemaManager.getXPathSchemaName(String, Set)
instead.boolean
hasFacet(String facet)
Checks if the document has a facet, either from its type or added on the instance.int
hashCode()
boolean
hasLegalHold()
Checks if the document has a legal hold set.boolean
hasSchema(String schema)
Checks if the document has the given schema, either from its type or added on the instance through a facet.boolean
isAttached()
Checks whether this document is attached to a session.boolean
isCheckedOut()
Tests if the document is checked out.boolean
isDirty()
Checks if the document has actual data to write (dirty parts).boolean
isDownloadable()
Checks if this document can be downloaded.boolean
isEnforcedRecord()
Checks if the document is an enforced record.boolean
isFlexibleRecord()
Checks if the document is a flexible record.boolean
isFolder()
Checks if this document is a folder.boolean
isImmutable()
Checks if this document is immutable.boolean
isLatestMajorVersion()
Checks if a document is the latest major version in the version series.boolean
isLatestVersion()
Checks if a document is the latest version in the version series.boolean
isLifeCycleLoaded()
boolean
isLocked()
Tests if the document is locked.boolean
isMajorVersion()
Checks if a document is a major version.boolean
isPrefetched(String xpath)
Checks if a property is prefetched.boolean
isPrefetched(String schemaName, String name)
Checks if a property is prefetched.boolean
isProxy()
Checks if this document is a proxy.boolean
isRecord()
Checks if the document is a record.boolean
isSchemaLoaded(String name)
boolean
isTrashed()
Checks if this document is in the trash.boolean
isUnderRetentionOrLegalHold()
Checks if the document has a retention date in the future or has a legal hold.boolean
isVersion()
Checks if this document is a version.boolean
isVersionable()
Checks if this document can have versions.boolean
isVersionSeriesCheckedOut()
Checks if there is a checked out working copy for the version series of this document.protected DataModel
loadDataModel(String schema)
Lazily loads the given data model.void
makeFlexibleRecord()
void
makeRecord()
void
prefetchCurrentLifecycleState(String lifecycle)
Used to set lifecycle state along with prefetching other properties.void
prefetchLifeCyclePolicy(String lifeCyclePolicy)
Used to set lifecycle policy along with prefetching other properties.void
putContextData(String key, Serializable value)
Sets a context data in the default scope.void
refresh()
Same asDocumentModel.refresh(REFRESH_DEFAULT)
.void
refresh(int refreshFlags, String[] schemas)
Refresh document data from server.boolean
removeFacet(String facet)
Removes a facet from the document instance.Lock
removeLock()
Removes the lock on the document.void
reset()
Clears any prefetched or cached document data.void
setACP(ACP acp, boolean overwrite)
Sets the ACP for this document model.void
setId(String id)
Sets the document id.void
setIsImmutable(boolean isImmutable)
void
setIsProxy(boolean isProxy)
void
setIsVersion(boolean isVersion)
void
setLegalHold(boolean hold)
Lock
setLock()
Sets a lock on the document.void
setPathInfo(String parentPath, String name)
Sets path info.void
setPosInternal(Long pos)
Sets the document's position in its containing folder (if ordered).void
setProperties(String schemaName, Map<String,Object> data)
Sets values for the given data model.void
setProperty(String schemaName, String name, Object value)
Sets the property value from the given schema.void
setPropertyValue(String xpath, Serializable value)
Sets a property value given a xpath.void
setRetainUntil(Calendar retainUntil)
String
toString()
-
-
-
Field Detail
-
F_VERSION
public static final long F_VERSION
- See Also:
- Constant Field Values
-
F_PROXY
public static final long F_PROXY
- See Also:
- Constant Field Values
-
F_IMMUTABLE
public static final long F_IMMUTABLE
- See Also:
- Constant Field Values
-
ref
protected DocumentRef ref
-
type
protected DocumentType type
-
typeName
protected String typeName
-
schemasOrig
protected Set<String> schemasOrig
Schemas including those from instance facets when the doc was read
-
instanceFacetsOrig
public Set<String> instanceFacetsOrig
Instance facets when the document was read.
-
id
protected String id
-
path
protected Path path
-
pos
protected Long pos
-
parentRef
protected DocumentRef parentRef
-
LOCK_UNKNOWN
protected static final Lock LOCK_UNKNOWN
-
lock
protected Lock lock
-
isStateLoaded
protected boolean isStateLoaded
state is lifecycle, version stuff.
-
currentLifeCycleState
protected String currentLifeCycleState
-
lifeCyclePolicy
protected String lifeCyclePolicy
-
isCheckedOut
protected boolean isCheckedOut
-
versionSeriesId
protected String versionSeriesId
-
isLatestVersion
protected boolean isLatestVersion
-
isMajorVersion
protected boolean isMajorVersion
-
isLatestMajorVersion
protected boolean isLatestMajorVersion
-
isVersionSeriesCheckedOut
protected boolean isVersionSeriesCheckedOut
-
checkinComment
protected String checkinComment
-
checkinDate
protected Calendar checkinDate
-
acp
protected transient ACP acp
-
isACPLoaded
protected transient boolean isACPLoaded
-
repositoryName
protected String repositoryName
-
principal
protected transient NuxeoPrincipal principal
-
coreSession
protected transient CoreSession coreSession
-
sourceId
protected String sourceId
-
contextData
protected Map<String,Serializable> contextData
-
changeToken
protected String changeToken
-
isTrashed
protected boolean isTrashed
-
isRecord
public boolean isRecord
-
isFlexibleRecord
public boolean isFlexibleRecord
-
retainUntil
public Calendar retainUntil
-
hasLegalHold
public boolean hasLegalHold
-
-
Constructor Detail
-
DocumentModelImpl
protected DocumentModelImpl()
-
DocumentModelImpl
public DocumentModelImpl(String typeName)
Constructor to use a document model client side without referencing a document.It must at least contain the type.
-
DocumentModelImpl
public DocumentModelImpl(String parentPath, String name, String type)
Constructor to be used by clients.A client constructed data model must contain at least the path and the type.
-
DocumentModelImpl
@Deprecated public DocumentModelImpl(String sid, String type, String id, Path path, Lock lock, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, String repositoryName)
Deprecated.since 11.1, sid and lock are unused
-
DocumentModelImpl
@Deprecated public DocumentModelImpl(String sid, String type, String id, Path path, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, String repositoryName, boolean isProxy)
Deprecated.since 11.1, sid is unused
-
DocumentModelImpl
public DocumentModelImpl(String type, String id, Path path, DocumentRef docRef, DocumentRef parentRef, String[] schemas, Set<String> facets, String sourceId, boolean isProxy, CoreSession coreSession, String repositoryName, NuxeoPrincipal principal)
- Since:
- 11.1
-
DocumentModelImpl
public DocumentModelImpl(DocumentModel parent, String name, String type)
-
-
Method Detail
-
computeSchemas
public static Set<String> computeSchemas(DocumentType type, Collection<String> instanceFacets, boolean isProxy)
Recomputes effective schemas from a type + instance facets.
-
getDocumentType
public DocumentType getDocumentType()
Description copied from interface:DocumentModel
Gets the document type object.- Specified by:
getDocumentType
in interfaceDocumentModel
- Returns:
- the document type object
-
getTitle
public String getTitle()
Gets the title from the dublincore schema.- Specified by:
getTitle
in interfaceDocumentModel
- Returns:
- the title or the internal name if no title could be found
- See Also:
DocumentModel.getTitle()
-
getSessionId
public String getSessionId()
Description copied from interface:DocumentModel
Returns the repository name and principal when the document is attached.- Specified by:
getSessionId
in interfaceDocumentModel
-
getPrincipal
public NuxeoPrincipal getPrincipal()
Description copied from interface:DocumentModel
Gets the principal attached to this document's session.- Specified by:
getPrincipal
in interfaceDocumentModel
- Returns:
- the principal
-
getRef
public DocumentRef getRef()
Description copied from interface:DocumentModel
Gets a reference to the core document that can be used either remotely or locally (opens the core JVM).- Specified by:
getRef
in interfaceDocumentModel
- Returns:
- the document reference
-
getParentRef
public DocumentRef getParentRef()
Description copied from interface:DocumentModel
Retrieves the parent reference of the current document.- Specified by:
getParentRef
in interfaceDocumentModel
- Returns:
- the parent reference or null if no parent
-
getCoreSession
public CoreSession getCoreSession()
Description copied from interface:DocumentModel
Gets the core session to which this document is tied.This may be null if the document has been detached from a session.
- Specified by:
getCoreSession
in interfaceDocumentModel
- Returns:
- the core session
-
getSession
protected CoreSession getSession()
Gets the CoreSession, or fails if it's not available.- Since:
- 9.1
-
detach
public void detach(boolean loadAll)
Description copied from interface:DocumentModel
Detaches the documentImpl from its existing session, so that it can survive beyond the session's closing.- Specified by:
detach
in interfaceDocumentModel
- Parameters:
loadAll
- iftrue
, load all data and ACP from the session before detaching
-
attach
public void attach(CoreSession coreSession)
Description copied from interface:DocumentModel
Reattaches a document to an existing session.- Specified by:
attach
in interfaceDocumentModel
- Parameters:
coreSession
- the session to attach to
-
isAttached
public boolean isAttached()
Description copied from interface:DocumentModel
Checks whether this document is attached to a session.- Specified by:
isAttached
in interfaceDocumentModel
- Returns:
true
if the document is attached to a session
-
getDataModel
@Deprecated public DataModel getDataModel(String schema)
Deprecated.Description copied from interface:DocumentModel
Gets the data model corresponding to the given schema.Null is returned if the document type has no such schema.
- Specified by:
getDataModel
in interfaceDocumentModel
- Parameters:
schema
- the schema name- Returns:
- the data model or null if no such schema is supported
- See Also:
DocumentModel.getSchemas()
,DocumentModel.getProperties(java.lang.String)
,DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,DocumentModel.getPropertyObjects(java.lang.String)
-
getDataModelsCollection
@Deprecated public Collection<DataModel> getDataModelsCollection()
Deprecated.Description copied from interface:DocumentModel
INTERNAL, not for public use.Gets a list with the currently fetched data models.
- Specified by:
getDataModelsCollection
in interfaceDocumentModel
- Returns:
- the data models that are already fetched as a collection
- See Also:
DocumentModel.getSchemas()
,DocumentModel.getProperties(java.lang.String)
,DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,DocumentModel.getPropertyObjects(java.lang.String)
-
addDataModel
public void addDataModel(DataModel dataModel)
-
getSchemas
public String[] getSchemas()
Description copied from interface:DocumentModel
Gets the schemas available on this document (from the type and the facets).- Specified by:
getSchemas
in interfaceDocumentModel
- Returns:
- the schemas
-
hasSchema
public boolean hasSchema(String schema)
Description copied from interface:DocumentModel
Checks if the document has the given schema, either from its type or added on the instance through a facet.- Specified by:
hasSchema
in interfaceDocumentModel
- Parameters:
schema
- the schema name- Returns:
true
if the document has the schema
-
getFacets
public Set<String> getFacets()
Description copied from interface:DocumentModel
Gets the facets available on this document (from the type and the instance facets).- Specified by:
getFacets
in interfaceDocumentModel
- Returns:
- the facets
-
getRetainedProperties
public List<String> getRetainedProperties()
Description copied from interface:DocumentModel
Gets the retained properties of this document at the time it became a record.- Specified by:
getRetainedProperties
in interfaceDocumentModel
- Returns:
- the retained properties
-
hasFacet
public boolean hasFacet(String facet)
Description copied from interface:DocumentModel
Checks if the document has a facet, either from its type or added on the instance.- Specified by:
hasFacet
in interfaceDocumentModel
- Parameters:
facet
- the facet name- Returns:
true
if the document has the facet
-
addFacet
public boolean addFacet(String facet)
Description copied from interface:DocumentModel
Adds a facet to the document instance.Does nothing if the facet was already present on the document.
- Specified by:
addFacet
in interfaceDocumentModel
- Parameters:
facet
- the facet name- Returns:
true
if the facet was added, orfalse
if it is already present
-
removeFacet
public boolean removeFacet(String facet)
Description copied from interface:DocumentModel
Removes a facet from the document instance.It's not possible to remove a facet coming from the document type.
- Specified by:
removeFacet
in interfaceDocumentModel
- 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
-
getId
public String getId()
Description copied from interface:DocumentModel
Gets the document UUID.- Specified by:
getId
in interfaceDocumentModel
- Returns:
- the document UUID
-
getName
public String getName()
Description copied from interface:DocumentModel
Gets the document name.- Specified by:
getName
in interfaceDocumentModel
- Returns:
- the document name
-
getPos
public Long getPos()
Description copied from interface:DocumentModel
Gets the document's position in its containing folder (if ordered).- Specified by:
getPos
in interfaceDocumentModel
- Returns:
- the position, or
null
if the containing folder is not ordered
-
setPosInternal
public void setPosInternal(Long pos)
Sets the document's position in its containing folder (if ordered). Used internally during construction.- Parameters:
pos
- the position- Since:
- 6.0
-
getPathAsString
public String getPathAsString()
Description copied from interface:DocumentModel
Gets the document path as a string.- Specified by:
getPathAsString
in interfaceDocumentModel
- Returns:
- the document path as string
-
getProperties
public Map<String,Object> getProperties(String schemaName)
Description copied from interface:DocumentModel
Gets the values from the given data model as a map.The operation will fetch the data model from the server if not already fetched.
- Specified by:
getProperties
in interfaceDocumentModel
- Parameters:
schemaName
- the data model schema name- Returns:
- the values map
-
getProperty
public Object getProperty(String schemaName, String name)
Description copied from interface:DocumentModel
Gets a property from the given schema.The data model owning the property will be fetched from the server if not already fetched.
- Specified by:
getProperty
in interfaceDocumentModel
- Parameters:
schemaName
- the schema namename
- the property name- Returns:
- the property value or null if no such property exists
-
getPropertyObject
public Property getPropertyObject(String schema, String name)
Description copied from interface:DocumentModel
Gets a property object from the given schema.- Specified by:
getPropertyObject
in interfaceDocumentModel
- Parameters:
schema
- the schema namename
- the property name- Returns:
- the property, or
null
if no such property exists
-
setPathInfo
public void setPathInfo(String parentPath, String name)
Description copied from interface:DocumentModel
Sets path info.path and ref attributes will be set according to info
- Specified by:
setPathInfo
in interfaceDocumentModel
-
isLocked
public boolean isLocked()
Description copied from interface:DocumentModel
Tests if the document is locked.Lock info is cached on the document for performance. Use
CoreSession.getLockInfo(org.nuxeo.ecm.core.api.DocumentRef)
to get the non-cached status.- Specified by:
isLocked
in interfaceDocumentModel
- Returns:
- the lock key if the document is locked or null otherwise
-
setLock
public Lock setLock()
Description copied from interface:DocumentModel
Sets a lock on the document.- Specified by:
setLock
in interfaceDocumentModel
- Returns:
- the lock info that was set
-
getLockInfo
public Lock getLockInfo()
Description copied from interface:DocumentModel
Gets the lock info on the document.Lock info is cached on the document for performance. Use
CoreSession.getLockInfo(org.nuxeo.ecm.core.api.DocumentRef)
to get the non-cached status.- Specified by:
getLockInfo
in interfaceDocumentModel
- Returns:
- the lock info if the document is locked, or
null
otherwise
-
removeLock
public Lock removeLock()
Description copied from interface:DocumentModel
Removes the lock on the document.The caller principal should be the same as the one who set the lock or to belongs to the administrator group, otherwise an exception will be throw.
If the document was not locked, does nothing.
Returns the previous lock info.
- Specified by:
removeLock
in interfaceDocumentModel
- Returns:
- the removed lock info, or
null
if there was no lock
-
isCheckedOut
public boolean isCheckedOut()
Description copied from interface:DocumentModel
Tests if the document is checked out.A checked out document can be modified normally. A checked in document is identical to the last version that it created, and not modifiable.
Only applicable to documents that are live (not versions and not proxies).
- Specified by:
isCheckedOut
in interfaceDocumentModel
- Returns:
true
if the document is checked out,false
if it is checked in
-
checkOut
public void checkOut()
Description copied from interface:DocumentModel
Checks out a document.A checked out document can be modified normally.
Only applicable to documents that are live (not versions and not proxies).
- Specified by:
checkOut
in interfaceDocumentModel
-
checkIn
public DocumentRef checkIn(VersioningOption option, String description)
Description copied from interface:DocumentModel
Checks in a document and returns the created version.A checked in document is identical to the last version that it created, and not modifiable.
Only applicable to documents that are live (not versions and not proxies).
- Specified by:
checkIn
in interfaceDocumentModel
- Parameters:
option
- whether to do create a newVersioningOption.MINOR
orVersioningOption.MAJOR
version during check indescription
- the checkin comment- Returns:
- the version just created
-
getVersionLabel
public String getVersionLabel()
Description copied from interface:DocumentModel
Returns the version label.The label returned is computed by the VersioningService.
- Specified by:
getVersionLabel
in interfaceDocumentModel
- Returns:
- the version label, or
null
-
getVersionSeriesId
public String getVersionSeriesId()
Description copied from interface:DocumentModel
Gets the version series id for this document.All documents and versions derived by a check in or checkout from the same original document share the same version series id.
- Specified by:
getVersionSeriesId
in interfaceDocumentModel
- Returns:
- the version series id
-
isLatestVersion
public boolean isLatestVersion()
Description copied from interface:DocumentModel
Checks if a document is the latest version in the version series.- Specified by:
isLatestVersion
in interfaceDocumentModel
-
isMajorVersion
public boolean isMajorVersion()
Description copied from interface:DocumentModel
Checks if a document is a major version.- Specified by:
isMajorVersion
in interfaceDocumentModel
-
isLatestMajorVersion
public boolean isLatestMajorVersion()
Description copied from interface:DocumentModel
Checks if a document is the latest major version in the version series.- Specified by:
isLatestMajorVersion
in interfaceDocumentModel
-
isVersionSeriesCheckedOut
public boolean isVersionSeriesCheckedOut()
Description copied from interface:DocumentModel
Checks if there is a checked out working copy for the version series of this document.- Specified by:
isVersionSeriesCheckedOut
in interfaceDocumentModel
-
getCheckinComment
public String getCheckinComment()
Description copied from interface:DocumentModel
Returns the checkin comment if the document model is a version.- Specified by:
getCheckinComment
in interfaceDocumentModel
- Returns:
- the checkin comment, or
null
-
getCheckinDate
public Calendar getCheckinDate()
Description copied from interface:DocumentModel
Returns the checkin date (the date the version was created) if the document model is a version.- Specified by:
getCheckinDate
in interfaceDocumentModel
- Returns:
- the checkin date, or
null
-
isRecord
public boolean isRecord()
Description copied from interface:DocumentModel
Checks if the document is a record.- Specified by:
isRecord
in interfaceDocumentModel
- Returns:
true
if the document is a record,false
otherwise
-
isEnforcedRecord
public boolean isEnforcedRecord()
Description copied from interface:DocumentModel
Checks if the document is an enforced record.- Specified by:
isEnforcedRecord
in interfaceDocumentModel
- Returns:
true
if the document is an enforced record,false
otherwise
-
isFlexibleRecord
public boolean isFlexibleRecord()
Description copied from interface:DocumentModel
Checks if the document is a flexible record.- Specified by:
isFlexibleRecord
in interfaceDocumentModel
- Returns:
true
if the document is a flexible record,false
otherwise
-
makeRecord
public void makeRecord()
-
makeFlexibleRecord
public void makeFlexibleRecord()
-
getRetainUntil
public Calendar getRetainUntil()
Description copied from interface:DocumentModel
Gets the retention date for the document.- Specified by:
getRetainUntil
in interfaceDocumentModel
- Returns:
- the retention date, or "SetRetention" for a
retention in the indeterminate future, or
null
if there is no retention date - See Also:
CoreSession.RETAIN_UNTIL_INDETERMINATE
,DocumentModel.isUnderRetentionOrLegalHold()
-
setRetainUntil
public void setRetainUntil(Calendar retainUntil)
-
hasLegalHold
public boolean hasLegalHold()
Description copied from interface:DocumentModel
Checks if the document has a legal hold set.- Specified by:
hasLegalHold
in interfaceDocumentModel
- Returns:
true
if a legal hold has been set on the document,false
otherwise- See Also:
DocumentModel.isUnderRetentionOrLegalHold()
-
setLegalHold
public void setLegalHold(boolean hold)
-
isUnderRetentionOrLegalHold
public boolean isUnderRetentionOrLegalHold()
Description copied from interface:DocumentModel
Checks if the document has a retention date in the future or has a legal hold.- Specified by:
isUnderRetentionOrLegalHold
in interfaceDocumentModel
- Returns:
true
if the document has a retention date in the future or if it has a legal hold,false
otherwise- See Also:
DocumentModel.getRetainUntil()
,DocumentModel.hasLegalHold()
-
getACP
public ACP getACP()
Description copied from interface:DocumentModel
Gets the access control policy (ACP) for this document.Returns null if no security was defined on this document.
The ACP can be used to introspect or to evaluate user privileges on this document.
This is a wrapper for
CoreSession.getACP(DocumentRef)
but it is recommended since it caches the ACP for later usage.- Specified by:
getACP
in interfaceDocumentModel
- Returns:
- the security data model or null if none
-
setACP
public void setACP(ACP acp, boolean overwrite)
Description copied from interface:DocumentModel
Sets the ACP for this document model.This is a wrapper for
CoreSession.setACP(DocumentRef, ACP, boolean)
- Specified by:
setACP
in interfaceDocumentModel
- Parameters:
acp
- the ACP to setoverwrite
- whether to overwrite the old ACP or not- See Also:
CoreSession.setACP(DocumentRef, ACP, boolean)
-
getType
public String getType()
Description copied from interface:DocumentModel
Gets the document type name.- Specified by:
getType
in interfaceDocumentModel
- Returns:
- the document type name
-
setProperties
public void setProperties(String schemaName, Map<String,Object> data)
Description copied from interface:DocumentModel
Sets values for the given data model.This will not fetch the data model if not already fetched.
- Specified by:
setProperties
in interfaceDocumentModel
- Parameters:
schemaName
- the schema namedata
- the values to set
-
setProperty
public void setProperty(String schemaName, String name, Object value)
Description copied from interface:DocumentModel
Sets the property value from the given schema.This operation will not fetch the data model if not already fetched
- Specified by:
setProperty
in interfaceDocumentModel
- Parameters:
schemaName
- the schema namename
- the property namevalue
- the property value
-
getPath
public Path getPath()
Description copied from interface:DocumentModel
Gets the document path.- Specified by:
getPath
in interfaceDocumentModel
- Returns:
- the document path as string
-
getDataModels
public Map<String,DataModel> getDataModels()
Description copied from interface:DocumentModel
Gets the data models.- Specified by:
getDataModels
in interfaceDocumentModel
- Returns:
- the data models that are already fetched.
- See Also:
DocumentModel.getSchemas()
,DocumentModel.getProperties(java.lang.String)
,DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,DocumentModel.getPropertyObjects(java.lang.String)
-
isTrashed
public boolean isTrashed()
Description copied from interface:DocumentModel
Checks if this document is in the trash.- Specified by:
isTrashed
in interfaceDocumentModel
- Returns:
- true if the document is in the trash, false otherwise.
-
isFolder
public boolean isFolder()
Description copied from interface:DocumentModel
Checks if this document is a folder.- Specified by:
isFolder
in interfaceDocumentModel
- Returns:
- true if the document is a folder, false otherwise
-
isVersionable
public boolean isVersionable()
Description copied from interface:DocumentModel
Checks if this document can have versions.- Specified by:
isVersionable
in interfaceDocumentModel
- Returns:
- true if the document can have versions, false otherwise
-
isDownloadable
public boolean isDownloadable()
Description copied from interface:DocumentModel
Checks if this document can be downloaded.- Specified by:
isDownloadable
in interfaceDocumentModel
- Returns:
- true if the document has downloadable content, false otherwise
-
accept
public void accept(PropertyVisitor visitor, Object arg)
Description copied from interface:DocumentModel
Method that implement the visitor pattern.The visitor must return null to stop visiting children otherwise a context object that will be passed as the arg argument to children
- Specified by:
accept
in interfaceDocumentModel
- Parameters:
visitor
- the visitor to acceptarg
- an argument passed to the visitor. This should be used by the visitor to carry on the visiting context.
-
getAdapter
public <T> T getAdapter(Class<T> itf)
Description copied from interface:DocumentModel
Adapts the document to the given interface.Attention, the first computation will cache the adaptation result for later calls.
- Specified by:
getAdapter
in interfaceDocumentModel
- Type Parameters:
T
- the interface type to adapt to- Parameters:
itf
- the interface class- Returns:
- the adapted document
-
getAdapter
public <T> T getAdapter(Class<T> itf, boolean refreshCache)
Description copied from interface:DocumentModel
Adapts the document to the given interface.- Specified by:
getAdapter
in interfaceDocumentModel
- Type Parameters:
T
- the interface type to adapt to- Parameters:
itf
- the interface classrefreshCache
- : readapt and stores in cache if already exists.- Returns:
- the adapted document
-
followTransition
public boolean followTransition(String transition)
Description copied from interface:DocumentModel
Follows a given life cycle transition.This will update the current life cycle of the document.
- Specified by:
followTransition
in interfaceDocumentModel
- Parameters:
transition
- the name of the transition to follow- Returns:
- a boolean representing the status if the operation
-
getAllowedStateTransitions
public Collection<String> getAllowedStateTransitions()
Description copied from interface:DocumentModel
Gets the allowed state transitions for this document.- Specified by:
getAllowedStateTransitions
in interfaceDocumentModel
- Returns:
- a collection of state transitions as string
-
getCurrentLifeCycleState
public String getCurrentLifeCycleState()
Description copied from interface:DocumentModel
Returns the life cycle of the document.- Specified by:
getCurrentLifeCycleState
in interfaceDocumentModel
- Returns:
- the life cycle as a string
-
getLifeCyclePolicy
public String getLifeCyclePolicy()
Description copied from interface:DocumentModel
Returns the life cycle policy of the document.- Specified by:
getLifeCyclePolicy
in interfaceDocumentModel
- Returns:
- the life cycle policy
-
isVersion
public boolean isVersion()
Description copied from interface:DocumentModel
Checks if this document is a version.- Specified by:
isVersion
in interfaceDocumentModel
- Returns:
- true if the document is an older version of another document, false otherwise
-
isProxy
public boolean isProxy()
Description copied from interface:DocumentModel
Checks if this document is a proxy.- Specified by:
isProxy
in interfaceDocumentModel
- Returns:
- true if the document is a proxy false otherwise
-
isImmutable
public boolean isImmutable()
Description copied from interface:DocumentModel
Checks if this document is immutable.- Specified by:
isImmutable
in interfaceDocumentModel
- Returns:
true
if the document is a version or a proxy to a version,false
otherwise
-
setIsVersion
public void setIsVersion(boolean isVersion)
-
setIsProxy
public void setIsProxy(boolean isProxy)
-
setIsImmutable
public void setIsImmutable(boolean isImmutable)
-
isDirty
public boolean isDirty()
Description copied from interface:DocumentModel
Checks if the document has actual data to write (dirty parts).- Specified by:
isDirty
in interfaceDocumentModel
-
getContextData
public Map<String,Serializable> getContextData()
Description copied from interface:DocumentModel
Gets the context data associated to this document.- Specified by:
getContextData
in interfaceDocumentModel
- Returns:
- a map of context data
-
getContextData
public Serializable getContextData(String key)
Description copied from interface:DocumentModel
Gets the context data using the default scope.- Specified by:
getContextData
in interfaceDocumentModel
- Parameters:
key
- the context data key- Returns:
- the value
-
putContextData
public void putContextData(String key, Serializable value)
Description copied from interface:DocumentModel
Sets a context data in the default scope.- Specified by:
putContextData
in interfaceDocumentModel
- Parameters:
key
- the context data keyvalue
- the value
-
copyContextData
public void copyContextData(DocumentModel otherDocument)
Description copied from interface:DocumentModel
Copies the context data from given document to this document.- Specified by:
copyContextData
in interfaceDocumentModel
-
copyContent
public void copyContent(DocumentModel sourceDoc)
Description copied from interface:DocumentModel
Copies all the data from a source document.- Specified by:
copyContent
in interfaceDocumentModel
-
getCacheKey
public String getCacheKey()
Description copied from interface:DocumentModel
Returns a cache key.Cache key will be computed like this :
docUUID + "-" + sessionId + "-" + timestamp
We will use the last modification time if present for the timestamp.
Since 5.6, the timestamp does not hold milliseconds anymore as some databases do not store them, which could interfere with cache key comparisons.
- Specified by:
getCacheKey
in interfaceDocumentModel
- Returns:
- the cache key as a string
-
getRepositoryName
public String getRepositoryName()
Description copied from interface:DocumentModel
Returns the name of the repository in which the document is stored.- Specified by:
getRepositoryName
in interfaceDocumentModel
- Returns:
- the repository name as a string.
-
getSourceId
public String getSourceId()
Description copied from interface:DocumentModel
Returns the source document identifier.This is useful when not interested about the repository UUID itself. Technically, this is the current version UUID.
- Specified by:
getSourceId
in interfaceDocumentModel
- Returns:
- the source id as a string.
-
isSchemaLoaded
public boolean isSchemaLoaded(String name)
-
isPrefetched
public boolean isPrefetched(String xpath)
Description copied from interface:DocumentModel
Checks if a property is prefetched.- Specified by:
isPrefetched
in interfaceDocumentModel
- Parameters:
xpath
- the property xpath- Returns:
true
if it is prefetched
-
isPrefetched
public boolean isPrefetched(String schemaName, String name)
Description copied from interface:DocumentModel
Checks if a property is prefetched.- Specified by:
isPrefetched
in interfaceDocumentModel
- Parameters:
schemaName
- the schema namename
- the property name- Returns:
true
if it is prefetched
-
prefetchCurrentLifecycleState
public void prefetchCurrentLifecycleState(String lifecycle)
Description copied from interface:DocumentModel
Used to set lifecycle state along with prefetching other properties.- Specified by:
prefetchCurrentLifecycleState
in interfaceDocumentModel
-
prefetchLifeCyclePolicy
public void prefetchLifeCyclePolicy(String lifeCyclePolicy)
Description copied from interface:DocumentModel
Used to set lifecycle policy along with prefetching other properties.- Specified by:
prefetchLifeCyclePolicy
in interfaceDocumentModel
-
getSystemProp
public <T extends Serializable> T getSystemProp(String systemProperty, Class<T> type)
Description copied from interface:DocumentModel
Gets system property of the specified type. This is not a lazy loaded property, thus the request is made directly to the server. This is needed as some critical system properties might be changed directly in the core.- Specified by:
getSystemProp
in interfaceDocumentModel
-
isLifeCycleLoaded
public boolean isLifeCycleLoaded()
- Specified by:
isLifeCycleLoaded
in interfaceDocumentModel
-
getPart
@Deprecated public DocumentPart getPart(String schema)
Deprecated.Description copied from interface:DocumentModel
Get a document part given its schema name- Specified by:
getPart
in interfaceDocumentModel
- Parameters:
schema
- the schema- Returns:
- the document aprt or null if none exists for that schema
- See Also:
DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,DocumentModel.getPropertyObjects(java.lang.String)
-
getParts
@Deprecated public DocumentPart[] getParts()
Deprecated.Description copied from interface:DocumentModel
Gets this document's parts.- Specified by:
getParts
in interfaceDocumentModel
- See Also:
DocumentModel.getSchemas()
,DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,DocumentModel.getPropertyObjects(java.lang.String)
-
getPropertyObjects
public Collection<Property> getPropertyObjects(String schema)
Description copied from interface:DocumentModel
Gets theProperty
objects for the given schema.An empty list is returned if the document doesn't have the schema.
- Specified by:
getPropertyObjects
in interfaceDocumentModel
- Parameters:
schema
- the schema- Returns:
- the properties
-
getProperty
public Property getProperty(String xpath)
Description copied from interface:DocumentModel
Gets a property given a xpath.Note that what's called xpath in this context is not an actual XPath as specified by the w3c. Main differences are that in our xpath:
- Indexes start at 0 instead of 1
- You can express
foo/bar[i]/baz
asfoo/i/baz
- Specified by:
getProperty
in interfaceDocumentModel
-
getXPathSchemaName
@Deprecated public static String getXPathSchemaName(String xpath, Set<String> docSchemas, String[] returnName)
Deprecated.since 2023, useSchemaManager.getXPathSchemaName(String, Set)
instead.
-
getPropertyValue
public Serializable getPropertyValue(String xpath) throws PropertyException
Description copied from interface:DocumentModel
Gets a property value given a xpath.Note that what's called xpath in this context is not an actual XPath as specified by the w3c. Main differences are that in our xpath:
- Indexes start at 0 instead of 1
- You can express
foo/bar[i]/baz
asfoo/i/baz
- Specified by:
getPropertyValue
in interfaceDocumentModel
- Throws:
PropertyException
-
setPropertyValue
public void setPropertyValue(String xpath, Serializable value) throws PropertyException
Description copied from interface:DocumentModel
Sets a property value given a xpath.- Specified by:
setPropertyValue
in interfaceDocumentModel
- Throws:
PropertyException
-
clone
public DocumentModel clone() throws CloneNotSupportedException
Description copied from interface:DocumentModel
Clone operation. Must be made public instead of just protected as in Object.- Specified by:
clone
in interfaceDocumentModel
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
reset
public void reset()
Description copied from interface:DocumentModel
Clears any prefetched or cached document data.This will force the document to lazily update its data when required.
- Specified by:
reset
in interfaceDocumentModel
-
refresh
public void refresh()
Description copied from interface:DocumentModel
Same asDocumentModel.refresh(REFRESH_DEFAULT)
.- Specified by:
refresh
in interfaceDocumentModel
-
refresh
public void refresh(int refreshFlags, String[] schemas)
Description copied from interface:DocumentModel
Refresh document data from server.The data models will be removed and all prefetch and system data will be refreshed from the server
The refreshed data contains:
- document life cycle
- document lock state, acp if required
- acp if required - otherwise acp info will be cleared so that it will be refetched in lazy way
- document parts if required - otherwise parts data will be removed to be refreshed lazy
DocumentModel.REFRESH_STATE
DocumentModel.REFRESH_ACP_IF_LOADED
DocumentModel.REFRESH_ACP_LAZY
DocumentModel.REFRESH_ACP
DocumentModel.REFRESH_CONTENT_IF_LOADED
DocumentModel.REFRESH_CONTENT_LAZY
DocumentModel.REFRESH_CONTENT
DocumentModel.REFRESH_DEFAULT
same as REFRESH_STATE | REFRESH_DEFAULT | REFRESH_ACP_IF_LOADED | REFRESH_CONTENT_IF_LOADEDDocumentModel.REFRESH_ALL
same as REFRESH_STATE | REFRESH_PREFTECH | REFRESH_ACP | REFRESH_CONTENT
- Specified by:
refresh
in interfaceDocumentModel
- Parameters:
refreshFlags
- the refresh flagsschemas
- the document parts (schemas) that should be refreshed now
-
computeFacetsAndSchemas
protected void computeFacetsAndSchemas(Set<String> instanceFacets, boolean setOrig)
Recomputes all facets and schemas from the instance facets.- Since:
- 7.1
-
getChangeToken
public String getChangeToken()
Description copied from interface:DocumentModel
Gets the current change token for this document.The change token is an opaque string which is modified every time the document is changed.
Before saving a document through
CoreSession.saveDocument(org.nuxeo.ecm.core.api.DocumentModel)
it's possible to pass an expected change token in the document context data throughdoc.putContextData(CoreSession.CHANGE_TOKEN, expectedChangeToken)
. If the change token does not match the stored one, it means that a concurrent update happened, and aConcurrentUpdateException
will be thrown.- Specified by:
getChangeToken
in interfaceDocumentModel
- Returns:
- the change token
- See Also:
DocumentModel.putContextData(java.lang.String, java.io.Serializable)
,CoreSession.CHANGE_TOKEN
,CoreSession.getChangeToken(org.nuxeo.ecm.core.api.DocumentRef)
-
setId
public void setId(String id)
Sets the document id. May be useful when detaching from a repo and attaching to another one or when unmarshalling a documentModel from a XML or JSON representation- Since:
- 5.7.2
-
getBinaryFulltext
public Map<String,String> getBinaryFulltext()
Description copied from interface:DocumentModel
Gets the fulltext extracted from the binary fields.- Specified by:
getBinaryFulltext
in interfaceDocumentModel
-
getObjectResolver
public PropertyObjectResolver getObjectResolver(String xpath)
- Specified by:
getObjectResolver
in interfaceDocumentModel
- Parameters:
xpath
- the property xpath- Returns:
- A
PropertyObjectResolver
to manage the property reference to external entities, null if this property's type has no resolver.
-
getSchemaManager
protected static SchemaManager getSchemaManager()
- Returns:
SchemaManager
service or throws an exception if no one is available- Since:
- 9.3
-
-