public class ShallowDocumentModel extends Object implements DocumentModel
DocumentModel
implementation Only holds DocumentRef
, RepositoryName, name, path and
context data. Used to reduce memory footprint of Event
stacked in EventBundle
.DocumentModel.DocumentModelRefresh
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 and Description |
---|
ShallowDocumentModel(DocumentModel doc) |
ShallowDocumentModel(String id,
String repoName,
String name,
Path path,
String type,
boolean isFolder,
boolean isVersion,
boolean isProxy,
boolean isImmutable,
Map<String,Serializable> contextData,
Set<String> facets,
String lifecycleState) |
Modifier and Type | Method and Description |
---|---|
void |
accept(PropertyVisitor visitor,
Object arg)
Method that implement the visitor pattern.
|
boolean |
addFacet(String facet)
Adds a facet to the document instance.
|
void |
attach(String sid)
Reattaches a document impl to an existing session.
|
DocumentRef |
checkIn(VersioningOption option,
String checkinComment)
Checks in a document and returns the created version.
|
void |
checkOut()
Checks out a document.
|
DocumentModel |
clone()
Clone operation.
|
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 |
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.
|
ScopedMap |
getContextData()
Gets the context data associated to this document.
|
Serializable |
getContextData(ScopeType scope,
String key)
Gets the context data associated to this document for given scope and given key.
|
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()
Deprecated.
|
Collection<DataModel> |
getDataModelsCollection()
Deprecated.
|
Set<String> |
getDeclaredFacets()
Gets the facets available on this document (from the type and the instance facets).
|
String[] |
getDeclaredSchemas()
Gets the schemas available on this document (from the type and the facets).
|
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).
|
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 the
Property 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.
|
String[] |
getSchemas()
Gets the schemas available on this document (from the type and the facets).
|
String |
getSessionId()
Retrieves the session id corresponding to this object.
|
String |
getSourceId()
Returns the source document identifier.
|
<T extends Serializable> |
getSystemProp(String systemProperty,
Class<T> type)
Gets system property of the specified type.
|
String |
getTitle()
Get a text suitable to be shown in a UI for this document.
|
String |
getType()
Gets the document type name.
|
String |
getVersionLabel()
Returns the version label.
|
String |
getVersionSeriesId()
Gets the version series id for this document.
|
boolean |
hasFacet(String facet)
Checks if the document has a facet, either from its type or added on the instance.
|
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 |
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 |
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 |
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.
|
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(ScopeType scope,
String key,
Serializable value)
Adds mapping to the context data for given scope.
|
void |
putContextData(String key,
Serializable value)
Sets a context data in the default scope.
|
void |
refresh()
Same as
DocumentModel.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.
|
Lock |
setLock()
Sets a lock on the document.
|
void |
setPathInfo(String parentPath,
String name)
Sets path info.
|
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.
|
public ShallowDocumentModel(DocumentModel doc)
public String getId()
DocumentModel
getId
in interface DocumentModel
public DocumentRef getRef()
DocumentModel
getRef
in interface DocumentModel
public String getRepositoryName()
DocumentModel
getRepositoryName
in interface DocumentModel
public String getName()
DocumentModel
getName
in interface DocumentModel
public Long getPos()
DocumentModel
getPos
in interface DocumentModel
null
if the containing folder is not orderedpublic Path getPath()
DocumentModel
getPath
in interface DocumentModel
public String getPathAsString()
DocumentModel
getPathAsString
in interface DocumentModel
public DocumentRef getParentRef()
DocumentModel
getParentRef
in interface DocumentModel
public String getType()
DocumentModel
getType
in interface DocumentModel
public boolean isFolder()
DocumentModel
isFolder
in interface DocumentModel
public boolean isVersion()
DocumentModel
isVersion
in interface DocumentModel
public void copyContent(DocumentModel sourceDoc)
DocumentModel
copyContent
in interface DocumentModel
public void copyContextData(DocumentModel otherDocument)
DocumentModel
copyContextData
in interface DocumentModel
public boolean followTransition(String transition)
DocumentModel
This will update the current life cycle of the document.
followTransition
in interface DocumentModel
transition
- the name of the transition to followpublic ACP getACP()
DocumentModel
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.
getACP
in interface DocumentModel
public void accept(PropertyVisitor visitor, Object arg)
DocumentModel
The visitor must return null to stop visiting children otherwise a context object that will be passed as the arg argument to children
accept
in interface DocumentModel
visitor
- the visitor to acceptarg
- an argument passed to the visitor. This should be used by the visitor to carry on the visiting
context.public <T> T getAdapter(Class<T> itf)
DocumentModel
Attention, the first computation will cache the adaptation result for later calls.
getAdapter
in interface DocumentModel
T
- the interface type to adapt toitf
- the interface classpublic <T> T getAdapter(Class<T> itf, boolean refreshCache)
DocumentModel
getAdapter
in interface DocumentModel
T
- the interface type to adapt toitf
- the interface classrefreshCache
- : readapt and stores in cache if already exists.public Collection<String> getAllowedStateTransitions()
DocumentModel
getAllowedStateTransitions
in interface DocumentModel
public String getCacheKey()
DocumentModel
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.
getCacheKey
in interface DocumentModel
public ScopedMap getContextData()
DocumentModel
NOTE since 9.1 the ScopedMap
return type is deprecated, use java.util.Map<String, Serializable>
instead
getContextData
in interface DocumentModel
public Serializable getContextData(ScopeType scope, String key)
DocumentModel
getContextData
in interface DocumentModel
public CoreSession getCoreSession()
DocumentModel
This may be null if the document has been detached from a session.
getCoreSession
in interface DocumentModel
public void detach(boolean loadAll)
DocumentModel
detach
in interface DocumentModel
loadAll
- if true
, load all data and ACP from the session before detachingpublic void attach(String sid)
DocumentModel
attach
in interface DocumentModel
sid
- the session idpublic String getCurrentLifeCycleState()
DocumentModel
getCurrentLifeCycleState
in interface DocumentModel
org.nuxeo.ecm.core.lifecycle
@Deprecated public DataModel getDataModel(String schema)
DocumentModel
Null is returned if the document type has no such schema.
getDataModel
in interface DocumentModel
schema
- the schema nameDocumentModel.getSchemas()
,
DocumentModel.getProperties(java.lang.String)
,
DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,
DocumentModel.getPropertyObjects(java.lang.String)
@Deprecated public Map<String,DataModel> getDataModels()
DocumentModel
getDataModels
in interface DocumentModel
DocumentModel.getSchemas()
,
DocumentModel.getProperties(java.lang.String)
,
DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,
DocumentModel.getPropertyObjects(java.lang.String)
@Deprecated public Collection<DataModel> getDataModelsCollection()
DocumentModel
Gets a list with the currently fetched data models.
getDataModelsCollection
in interface DocumentModel
DocumentModel.getSchemas()
,
DocumentModel.getProperties(java.lang.String)
,
DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,
DocumentModel.getPropertyObjects(java.lang.String)
public Set<String> getFacets()
DocumentModel
getFacets
in interface DocumentModel
public Set<String> getDeclaredFacets()
DocumentModel
getDeclaredFacets
in interface DocumentModel
public String[] getSchemas()
DocumentModel
getSchemas
in interface DocumentModel
public String[] getDeclaredSchemas()
DocumentModel
getDeclaredSchemas
in interface DocumentModel
public DocumentType getDocumentType()
DocumentModel
getDocumentType
in interface DocumentModel
public String getLifeCyclePolicy()
DocumentModel
getLifeCyclePolicy
in interface DocumentModel
org.nuxeo.ecm.core.lifecycle
@Deprecated public DocumentPart getPart(String schema)
DocumentModel
getPart
in interface DocumentModel
schema
- the schemaDocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,
DocumentModel.getPropertyObjects(java.lang.String)
@Deprecated public DocumentPart[] getParts()
DocumentModel
getParts
in interface DocumentModel
DocumentModel.getSchemas()
,
DocumentModel.getPropertyObject(java.lang.String, java.lang.String)
,
DocumentModel.getPropertyObjects(java.lang.String)
public Collection<Property> getPropertyObjects(String schema)
DocumentModel
Property
objects for the given schema.
An empty list is returned if the document doesn't have the schema.
getPropertyObjects
in interface DocumentModel
schema
- the schemapublic Map<String,Object> getProperties(String schemaName)
DocumentModel
The operation will fetch the data model from the server if not already fetched.
getProperties
in interface DocumentModel
schemaName
- the data model schema namepublic Property getProperty(String xpath) throws PropertyException
DocumentModel
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:
foo/bar[i]/baz
as foo/i/baz
getProperty
in interface DocumentModel
PropertyException
public Object getProperty(String schemaName, String name)
DocumentModel
The data model owning the property will be fetched from the server if not already fetched.
getProperty
in interface DocumentModel
schemaName
- the schema namename
- the property namepublic Property getPropertyObject(String schema, String name)
DocumentModel
getPropertyObject
in interface DocumentModel
schema
- the schema namename
- the property namenull
if no such property existspublic Serializable getPropertyValue(String xpath) throws PropertyException
DocumentModel
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:
foo/bar[i]/baz
as foo/i/baz
getPropertyValue
in interface DocumentModel
PropertyException
public String getSessionId()
DocumentModel
This method should rarely be used, use DocumentModel.getCoreSession()
directly instead.
Using the session id you can retrieve the core session that created the object.
Document models created by the user on the client side are not bound to any session. They are simple DTO used to transport data.
getSessionId
in interface DocumentModel
public String getSourceId()
DocumentModel
This is useful when not interested about the repository UUID itself. Technically, this is the current version UUID.
getSourceId
in interface DocumentModel
public <T extends Serializable> T getSystemProp(String systemProperty, Class<T> type)
DocumentModel
getSystemProp
in interface DocumentModel
public String getTitle()
DocumentModel
getTitle
in interface DocumentModel
public String getVersionLabel()
DocumentModel
The label returned is computed by the VersioningService.
getVersionLabel
in interface DocumentModel
null
public String getCheckinComment()
DocumentModel
getCheckinComment
in interface DocumentModel
null
public boolean hasFacet(String facet)
DocumentModel
hasFacet
in interface DocumentModel
facet
- the facet nametrue
if the document has the facetpublic boolean hasSchema(String schema)
DocumentModel
hasSchema
in interface DocumentModel
schema
- the schema nametrue
if the document has the schemapublic boolean addFacet(String facet)
DocumentModel
Does nothing if the facet was already present on the document.
addFacet
in interface DocumentModel
facet
- the facet nametrue
if the facet was added, or false
if it is already presentpublic boolean removeFacet(String facet)
DocumentModel
It's not possible to remove a facet coming from the document type.
removeFacet
in interface DocumentModel
facet
- the facet nametrue
if the facet was removed, or false
if it isn't present or is present on the type or
does not exitpublic boolean isDownloadable()
DocumentModel
isDownloadable
in interface DocumentModel
public boolean isLifeCycleLoaded()
isLifeCycleLoaded
in interface DocumentModel
public boolean isLocked()
DocumentModel
Lock info is cached on the document for performance. Use CoreSession.getLockInfo(org.nuxeo.ecm.core.api.DocumentRef)
to get the non-cached
status.
isLocked
in interface DocumentModel
public boolean isProxy()
DocumentModel
isProxy
in interface DocumentModel
public boolean isImmutable()
DocumentModel
isImmutable
in interface DocumentModel
true
if the document is a version or a proxy to a version, false
otherwisepublic boolean isDirty()
DocumentModel
isDirty
in interface DocumentModel
public boolean isVersionable()
DocumentModel
isVersionable
in interface DocumentModel
public boolean isPrefetched(String xpath)
DocumentModel
isPrefetched
in interface DocumentModel
xpath
- the property xpathtrue
if it is prefetchedpublic boolean isPrefetched(String schemaName, String name)
DocumentModel
isPrefetched
in interface DocumentModel
schemaName
- the schema namename
- the property nametrue
if it is prefetchedpublic void prefetchCurrentLifecycleState(String lifecycle)
DocumentModel
prefetchCurrentLifecycleState
in interface DocumentModel
public void prefetchLifeCyclePolicy(String lifeCyclePolicy)
DocumentModel
prefetchLifeCyclePolicy
in interface DocumentModel
public void putContextData(String key, Serializable value)
DocumentModel
putContextData
in interface DocumentModel
key
- the context data keyvalue
- the valuepublic void putContextData(ScopeType scope, String key, Serializable value)
DocumentModel
Context data is like a request map set on the document model to pass additional information to components interacting with the document model (events processing for instance).
putContextData
in interface DocumentModel
public void refresh()
DocumentModel
DocumentModel.refresh(REFRESH_DEFAULT)
.refresh
in interface DocumentModel
public void refresh(int refreshFlags, String[] schemas)
DocumentModel
The data models will be removed and all prefetch and system data will be refreshed from the server
The refreshed data contains:
DocumentModel.REFRESH_STATE
DocumentModel.REFRESH_PREFETCH
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_LOADED
DocumentModel.REFRESH_ALL
same as REFRESH_STATE | REFRESH_PREFTECH | REFRESH_ACP | REFRESH_CONTENT
refresh
in interface DocumentModel
refreshFlags
- the refresh flagsschemas
- the document parts (schemas) that should be refreshed nowpublic void reset()
DocumentModel
This will force the document to lazily update its data when required.
reset
in interface DocumentModel
public void setACP(ACP acp, boolean overwrite)
DocumentModel
This is a wrapper for CoreSession.setACP(DocumentRef, ACP, boolean)
setACP
in interface DocumentModel
acp
- the ACP to setoverwrite
- whether to overwrite the old ACP or notCoreSession#setACP(DocumentRef, ACP, boolean)}
public Lock setLock()
DocumentModel
setLock
in interface DocumentModel
public Lock getLockInfo()
DocumentModel
Lock info is cached on the document for performance. Use CoreSession.getLockInfo(org.nuxeo.ecm.core.api.DocumentRef)
to get the non-cached
status.
getLockInfo
in interface DocumentModel
null
otherwisepublic Lock removeLock()
DocumentModel
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.
removeLock
in interface DocumentModel
null
if there was no lockpublic void setPathInfo(String parentPath, String name)
DocumentModel
path and ref attributes will be set according to info
setPathInfo
in interface DocumentModel
public void setProperties(String schemaName, Map<String,Object> data)
DocumentModel
This will not fetch the data model if not already fetched.
setProperties
in interface DocumentModel
schemaName
- the schema namedata
- the values to setpublic void setProperty(String schemaName, String name, Object value)
DocumentModel
This operation will not fetch the data model if not already fetched
setProperty
in interface DocumentModel
schemaName
- the schema namename
- the property namevalue
- the property valuepublic void setPropertyValue(String xpath, Serializable value)
DocumentModel
setPropertyValue
in interface DocumentModel
public DocumentModel clone() throws CloneNotSupportedException
DocumentModel
clone
in interface DocumentModel
clone
in class Object
CloneNotSupportedException
public Serializable getContextData(String key)
DocumentModel
getContextData
in interface DocumentModel
key
- the context data keypublic boolean isCheckedOut()
DocumentModel
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).
isCheckedOut
in interface DocumentModel
true
if the document is checked out, false
if it is checked inpublic void checkOut()
DocumentModel
A checked out document can be modified normally.
Only applicable to documents that are live (not versions and not proxies).
checkOut
in interface DocumentModel
public DocumentRef checkIn(VersioningOption option, String checkinComment)
DocumentModel
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).
checkIn
in interface DocumentModel
option
- whether to do create a new VersioningOption.MINOR
or VersioningOption.MAJOR
version
during check incheckinComment
- the checkin commentpublic String getVersionSeriesId()
DocumentModel
All documents and versions derived by a check in or checkout from the same original document share the same version series id.
getVersionSeriesId
in interface DocumentModel
public boolean isLatestVersion()
DocumentModel
isLatestVersion
in interface DocumentModel
public boolean isMajorVersion()
DocumentModel
isMajorVersion
in interface DocumentModel
public boolean isLatestMajorVersion()
DocumentModel
isLatestMajorVersion
in interface DocumentModel
public boolean isVersionSeriesCheckedOut()
DocumentModel
isVersionSeriesCheckedOut
in interface DocumentModel
public String getChangeToken()
DocumentModel
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 through doc.putContextData(CoreSession.CHANGE_TOKEN, expectedChangeToken)
.
If the change token does not match the stored one, it means that a concurrent update happened, and a
ConcurrentUpdateException
will be thrown.
getChangeToken
in interface DocumentModel
DocumentModel.putContextData(org.nuxeo.common.collections.ScopeType, java.lang.String, java.io.Serializable)
,
CoreSession.CHANGE_TOKEN
,
CoreSession.getChangeToken(org.nuxeo.ecm.core.api.DocumentRef)
public Map<String,String> getBinaryFulltext()
DocumentModel
getBinaryFulltext
in interface DocumentModel
public PropertyObjectResolver getObjectResolver(String xpath)
getObjectResolver
in interface DocumentModel
xpath
- the property xpathPropertyObjectResolver
to manage the property reference to external entities, null if this
property's type has no resolver.Copyright © 2018 Nuxeo. All rights reserved.