Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.api.impl
Class DocumentModelImpl

java.lang.Object
  extended by org.nuxeo.ecm.core.api.impl.DocumentModelImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DocumentModel
Direct Known Subclasses:
ResultDocumentModel

public class DocumentModelImpl
extends java.lang.Object
implements DocumentModel, java.lang.Cloneable

Version:
$Revision: 1.0 $
Author:
Bogdan Stefanescu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.api.DocumentModel
DocumentModel.DocumentModelRefresh
 
Field Summary
static long F_DETACHED
           
static long F_DIRTY
           
static long F_IMMUTABLE
           
static long F_LOCKED
           
static long F_PROXY
           
static long F_STORED
           
static long F_VERSION
           
static java.lang.ThreadLocal<java.util.HashMap<java.lang.String,CoreSession>> reentrantCoreSession
           
static java.lang.String STRICT_LAZY_LOADING_POLICY_KEY
           
 
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
DocumentModelImpl(DocumentModel parent, java.lang.String name, java.lang.String type)
          Constructor for DocumentModelImpl.
DocumentModelImpl(DocumentModel parent, java.lang.String name, java.lang.String type, DataModelMap data)
          Constructor for DocumentModelImpl.
DocumentModelImpl(java.lang.String type)
          Constructor to use a document model client side without referencing a document.
DocumentModelImpl(java.lang.String sid, java.lang.String type)
          Constructor to use a document model client side without referencing a document.
DocumentModelImpl(java.lang.String parentPath, java.lang.String name, java.lang.String type)
          Constructor to be used by clients.
DocumentModelImpl(java.lang.String parentPath, java.lang.String name, java.lang.String type, DataModelMap data)
          Constructor for DocumentModelImpl.
DocumentModelImpl(java.lang.String sid, java.lang.String type, java.lang.String id, Path path, DocumentRef docRef, DocumentRef parentRef, java.lang.String[] schemas, java.util.Set<java.lang.String> facets)
          Constructor to be used on server side to create a document model.
DocumentModelImpl(java.lang.String sid, java.lang.String type, java.lang.String id, Path path, java.lang.String lock, DocumentRef docRef, DocumentRef parentRef, java.lang.String[] schemas, java.util.Set<java.lang.String> facets)
          Deprecated. 
DocumentModelImpl(java.lang.String sid, java.lang.String type, java.lang.String id, Path path, java.lang.String lock, DocumentRef docRef, DocumentRef parentRef, java.lang.String[] schemas, java.util.Set<java.lang.String> facets, java.lang.String sourceId, java.lang.String repositoryName)
          Constructor for DocumentModelImpl.
 
Method Summary
 void addDataModel(DataModel dataModel)
           
 DocumentRef checkIn(VersioningOption option, java.lang.String description)
          Checks in a document and returns the created version.
 void checkOut()
          Checks out a document.
 void clearFlags()
           
 void clearFlags(long flags)
           
 DocumentModel clone()
          Clone operation.
 DataModel cloneDataModel(DataModel data)
           
static DataModel cloneDataModel(Schema schema, DataModel data)
           
static java.lang.Object cloneField(Field field, java.lang.String key, java.lang.Object value)
           
 void copyContent(DocumentModel sourceDoc)
          Copies all the data from a source document.
 void copyContentInto(DocumentModelImpl other)
           
 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(java.lang.Object obj)
           
 boolean followTransition(java.lang.String transition)
          Follows a given life cycle transition.
 ACP getACP()
          Gets the access control policy (ACP) for this document.
<T> T
getAdapter(java.lang.Class<T> itf)
          Adapts the document to the given interface.
<T> T
getAdapter(java.lang.Class<T> itf, boolean refreshCache)
          Adapts the document to the given interface.
 java.util.Collection<java.lang.String> getAllowedStateTransitions()
          Gets the allowed state transitions for this document.
 java.lang.String getCacheKey()
          Returns a cache key.
 java.lang.String getCheckinComment()
          Returns the checkin comment if the document model is a version.
 CoreSession getClient()
          Deprecated. use getCoreSession() instead.
 ScopedMap getContextData()
          Gets the context data associated to this document.
 java.io.Serializable getContextData(ScopeType scope, java.lang.String key)
          Gets the context data associated to this document for given scope and given key.
 java.io.Serializable getContextData(java.lang.String key)
          Gets the context data using the default scope.
 CoreSession getCoreSession()
          Gets the core session to which this document is tied.
 java.lang.String getCurrentLifeCycleState()
          Returns the life cycle of the document.
 DataModel getDataModel(java.lang.String schema)
          Gets the data model corresponding to the given schema.
 DataModelMap getDataModels()
          Gets the data models.
 java.util.Collection<DataModel> getDataModelsCollection()
          Gets a list with the currently fetched data models.
 java.util.Set<java.lang.String> getDeclaredFacets()
          Gets the facets defined by this document type.
 java.lang.String[] getDeclaredSchemas()
          Gets the schemas defined by this document type.
 DocumentType getDocumentType()
          Gets the document type object.
 long getFlags()
          Returns the flags set on the document model.
 java.lang.String getId()
          Gets the document UUID.
 java.lang.String getLifeCyclePolicy()
          Returns the life cycle policy of the document.
 java.lang.String getLock()
          Gets the lock key if the document is locked.
 java.lang.String getName()
          Gets the document name.
 DocumentRef getParentRef()
          Retrieves the parent reference of the current document.
 DocumentPart getPart(java.lang.String schema)
          Get a document part given its schema name
 DocumentPart[] getParts()
          Gets this document's parts.
 Path getPath()
          Gets the document path.
 java.lang.String getPathAsString()
          Gets the document path as a string.
 java.util.Map<java.lang.String,java.io.Serializable> getPrefetch()
          Returns the map of prefetched values.
 java.util.Map<java.lang.String,java.lang.Object> getProperties(java.lang.String schemaName)
          Gets the values from the given data model as a map.
 Property getProperty(java.lang.String xpath)
          Gets a property given a xpath.
 java.lang.Object getProperty(java.lang.String schemaName, java.lang.String name)
          Gets property.
 java.io.Serializable getPropertyValue(java.lang.String path)
          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).
 java.lang.String getRepositoryName()
          Returns the name of the repository in which the document is stored.
 java.lang.String getSessionId()
          Retrieves the session id corresponding to this object.
 java.lang.String getSourceId()
          Returns the source document identifier.
<T extends java.io.Serializable>
T
getSystemProp(java.lang.String systemProperty, java.lang.Class<T> type)
          Gets system property of the specified type.
 java.lang.String getTitle()
          Gets the title from the dublincore schema.
 java.lang.String getType()
          Gets the document type name.
 java.lang.String getVersionLabel()
          Returns the version label.
 java.lang.String getVersionSeriesId()
          Gets the version series id for this document.
 boolean hasFacet(java.lang.String facet)
          Checks if this document has the given facet.
 boolean hasFlags(long flags)
           
 int hashCode()
           
 boolean hasSchema(java.lang.String schema)
          Checks whether this document model has the given schema.
 boolean isCheckedOut()
          Tests if the document is checked out.
 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 isProxy()
          Checks if this document is a proxy.
 boolean isSchemaLoaded(java.lang.String name)
           
 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(java.lang.String lifecycle)
          Used to set lifecycle state along with prefetching other properties.
 void prefetchLifeCyclePolicy(java.lang.String lifeCyclePolicy)
          Used to set lifecycle policy along with prefetching other properties.
 void prefetchProperty(java.lang.String id, java.lang.Object value)
          Store a value in the prefetched inner map.
 void putContextData(ScopeType scope, java.lang.String key, java.io.Serializable value)
          Adds mapping to the context data for given scope.
 void putContextData(java.lang.String key, java.io.Serializable value)
          Sets a context data in the default scope.
 void refresh()
          Same as DocumentModel.refresh(REFRESH_DEFAULT).
 void refresh(int refreshFlags, java.lang.String[] schemas)
          Refresh document data from server.
 void reset()
          Clears any prefetched or cached document data.
 void setACP(ACP acp, boolean overwrite)
          Sets the ACP for this document model.
 void setFlags(long flags)
           
 void setIsImmutable(boolean isImmutable)
           
 void setIsProxy(boolean isProxy)
           
 void setIsVersion(boolean isVersion)
           
 void setLock(java.lang.String key)
          Locks this document using the given key.
 void setPathInfo(java.lang.String parentPath, java.lang.String name)
          Sets path info.
 void setProperties(java.lang.String schemaName, java.util.Map<java.lang.String,java.lang.Object> data)
          Sets values for the given data model.
 void setProperty(java.lang.String schemaName, java.lang.String name, java.lang.Object value)
          Sets the property value from the given schema.
 void setPropertyValue(java.lang.String path, java.io.Serializable value)
          Sets a property value given a xpath.
 java.lang.String toString()
           
 void unlock()
          Unlocks the given document.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STRICT_LAZY_LOADING_POLICY_KEY

public static final java.lang.String STRICT_LAZY_LOADING_POLICY_KEY
See Also:
Constant Field Values

F_STORED

public static final long F_STORED
See Also:
Constant Field Values

F_DETACHED

public static final long F_DETACHED
See Also:
Constant Field Values

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_LOCKED

public static final long F_LOCKED
See Also:
Constant Field Values

F_DIRTY

public static final long F_DIRTY
See Also:
Constant Field Values

F_IMMUTABLE

public static final long F_IMMUTABLE
See Also:
Constant Field Values

reentrantCoreSession

public static java.lang.ThreadLocal<java.util.HashMap<java.lang.String,CoreSession>> reentrantCoreSession
Constructor Detail

DocumentModelImpl

public DocumentModelImpl(java.lang.String type)
Constructor to use a document model client side without referencing a document.

It must at least contain the type.

Parameters:
type - String

DocumentModelImpl

public DocumentModelImpl(java.lang.String sid,
                         java.lang.String type)
Constructor to use a document model client side without referencing a document.

It must at least contain the type.

Parameters:
sid - String
type - String

DocumentModelImpl

public DocumentModelImpl(java.lang.String parentPath,
                         java.lang.String name,
                         java.lang.String type)
Constructor to be used by clients.

A client constructed data model must contain at least the path and the type.

Parameters:
parentPath -
name -
type -

DocumentModelImpl

public DocumentModelImpl(DocumentModel parent,
                         java.lang.String name,
                         java.lang.String type)
Constructor for DocumentModelImpl.

Parameters:
parent - DocumentModel
name - String
type - String

DocumentModelImpl

public DocumentModelImpl(DocumentModel parent,
                         java.lang.String name,
                         java.lang.String type,
                         DataModelMap data)
Constructor for DocumentModelImpl.

Parameters:
parent - DocumentModel
name - String
type - String
data - DataModelMap

DocumentModelImpl

public DocumentModelImpl(java.lang.String parentPath,
                         java.lang.String name,
                         java.lang.String type,
                         DataModelMap data)
Constructor for DocumentModelImpl.

Parameters:
parentPath -
name -
type -
data - allows to initialize a document with initial data

DocumentModelImpl

public DocumentModelImpl(java.lang.String sid,
                         java.lang.String type,
                         java.lang.String id,
                         Path path,
                         DocumentRef docRef,
                         DocumentRef parentRef,
                         java.lang.String[] schemas,
                         java.util.Set<java.lang.String> facets)
Constructor to be used on server side to create a document model.

Parameters:
sid -
type -
id -
path -
docRef -
parentRef -
schemas -
facets -

DocumentModelImpl

@Deprecated
public DocumentModelImpl(java.lang.String sid,
                                    java.lang.String type,
                                    java.lang.String id,
                                    Path path,
                                    java.lang.String lock,
                                    DocumentRef docRef,
                                    DocumentRef parentRef,
                                    java.lang.String[] schemas,
                                    java.util.Set<java.lang.String> facets)
Deprecated. 

Constructor for DocumentModelImpl.

Parameters:
sid - String
type - String
id - String
path - Path
lock - String
docRef - DocumentRef
parentRef - DocumentRef
schemas - String[]
facets -

DocumentModelImpl

public DocumentModelImpl(java.lang.String sid,
                         java.lang.String type,
                         java.lang.String id,
                         Path path,
                         java.lang.String lock,
                         DocumentRef docRef,
                         DocumentRef parentRef,
                         java.lang.String[] schemas,
                         java.util.Set<java.lang.String> facets,
                         java.lang.String sourceId,
                         java.lang.String repositoryName)
Constructor for DocumentModelImpl.

Parameters:
sid - String
type - String
id - String
path - Path
lock - String
docRef - DocumentRef
parentRef - DocumentRef
schemas - String[]
facets -
sourceId - String
repositoryName - String
Method Detail

getDocumentType

public DocumentType getDocumentType()
Description copied from interface: DocumentModel
Gets the document type object.

Specified by:
getDocumentType in interface DocumentModel
Returns:
the document type object

getTitle

public java.lang.String getTitle()
                          throws ClientException
Gets the title from the dublincore schema.

Specified by:
getTitle in interface DocumentModel
Returns:
String
Throws:
ClientException
See Also:
DocumentModel.getTitle()

getSessionId

public java.lang.String getSessionId()
Description copied from interface: DocumentModel
Retrieves the session id corresponding to this object.

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.

Specified by:
getSessionId in interface DocumentModel
Returns:
the session id the session ID for server side created doc models or null for client side models (used for data transportation)

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 interface DocumentModel
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 interface DocumentModel
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 interface DocumentModel
Returns:
the core session

getClient

@Deprecated
public final CoreSession getClient()
                            throws ClientException
Deprecated. use getCoreSession() instead.

Throws:
ClientException

detach

public void detach(boolean loadAll)
            throws ClientException
Detaches the documentImpl from its existing session, so that it can survive beyond the session's closing.

Parameters:
loadAll - if true, load all data from the session before detaching
Throws:
ClientException

getDataModel

public DataModel getDataModel(java.lang.String schema)
                       throws ClientException
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 interface DocumentModel
Parameters:
schema - the schema name
Returns:
the data model or null if no such schema is supported
Throws:
ClientException

getDataModelsCollection

public java.util.Collection<DataModel> getDataModelsCollection()
Description copied from interface: DocumentModel
Gets a list with the currently fetched data models.

Specified by:
getDataModelsCollection in interface DocumentModel
Returns:
the data models that are already fetched as a collection

addDataModel

public void addDataModel(DataModel dataModel)

getDeclaredSchemas

public java.lang.String[] getDeclaredSchemas()
Description copied from interface: DocumentModel
Gets the schemas defined by this document type.

Specified by:
getDeclaredSchemas in interface DocumentModel
Returns:
the defined schemas

getDeclaredFacets

public java.util.Set<java.lang.String> getDeclaredFacets()
Description copied from interface: DocumentModel
Gets the facets defined by this document type.

Specified by:
getDeclaredFacets in interface DocumentModel
Returns:
the defined facets

getId

public java.lang.String getId()
Description copied from interface: DocumentModel
Gets the document UUID.

Specified by:
getId in interface DocumentModel
Returns:
the document UUID

getName

public java.lang.String getName()
Description copied from interface: DocumentModel
Gets the document name.

Specified by:
getName in interface DocumentModel
Returns:
the document name

getPathAsString

public java.lang.String getPathAsString()
Description copied from interface: DocumentModel
Gets the document path as a string.

Specified by:
getPathAsString in interface DocumentModel
Returns:
the document path as string

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties(java.lang.String schemaName)
                                                               throws ClientException
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 interface DocumentModel
Parameters:
schemaName - the data model schema name
Returns:
the values map
Throws:
ClientException

getProperty

public java.lang.Object getProperty(java.lang.String schemaName,
                                    java.lang.String name)
                             throws ClientException
Gets property.

Get property is also consulting the prefetched properties.

Specified by:
getProperty in interface DocumentModel
Parameters:
schemaName - String
name - String
Returns:
Object
Throws:
ClientException
See Also:
DocumentModel.getProperty(String, String)

setPathInfo

public void setPathInfo(java.lang.String parentPath,
                        java.lang.String name)
Description copied from interface: DocumentModel
Sets path info.

path and ref attributes will be set according to info

Specified by:
setPathInfo in interface DocumentModel

getLock

public java.lang.String getLock()
Description copied from interface: DocumentModel
Gets the lock key if the document is locked.

This uses the cached lock information and doesn't connect to the server.

To get fresh information from the server, use CoreSession.getLock(DocumentRef).

Specified by:
getLock in interface DocumentModel
Returns:
the lock key if the document is locked or null otherwise

isLocked

public boolean isLocked()
Description copied from interface: DocumentModel
Tests if the document is locked.

This is using the cached lock information and doesn't connect to the server

To get fresh information from the server use CoreSession.getLock(DocumentRef).

Specified by:
isLocked in interface DocumentModel
Returns:
the lock key if the document is locked or null otherwise

setLock

public void setLock(java.lang.String key)
             throws ClientException
Description copied from interface: DocumentModel
Locks this document using the given key.

This is a wrapper for CoreSession.setLock(DocumentRef, String).

Specified by:
setLock in interface DocumentModel
Parameters:
key - the key to use when locking
Throws:
ClientException - if the document is already locked or other error occurs

unlock

public void unlock()
            throws ClientException
Description copied from interface: DocumentModel
Unlocks the given document.

This is a wrapper for CoreSession.unlock(DocumentRef)

Specified by:
unlock in interface DocumentModel
Throws:
ClientException - if the document is already locked or other error occurs

isCheckedOut

public boolean isCheckedOut()
                     throws ClientException
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 interface DocumentModel
Returns:
true if the document is checked out, false if it is checked in
Throws:
ClientException

checkOut

public void checkOut()
              throws ClientException
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 interface DocumentModel
Throws:
ClientException

checkIn

public DocumentRef checkIn(VersioningOption option,
                           java.lang.String description)
                    throws ClientException
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 interface DocumentModel
Parameters:
option - whether to do create a new VersioningOption.MINOR or VersioningOption.MAJOR version during check in
description - the checkin comment
Returns:
the version just created
Throws:
ClientException

getVersionLabel

public java.lang.String getVersionLabel()
Description copied from interface: DocumentModel
Returns the version label.

The label returned is computed by the VersioningService.

Specified by:
getVersionLabel in interface DocumentModel
Returns:
the version label, or null

getVersionSeriesId

public java.lang.String getVersionSeriesId()
                                    throws ClientException
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 interface DocumentModel
Returns:
the version series id
Throws:
ClientException

isLatestVersion

public boolean isLatestVersion()
                        throws ClientException
Description copied from interface: DocumentModel
Checks if a document is the latest version in the version series.

Specified by:
isLatestVersion in interface DocumentModel
Throws:
ClientException

isMajorVersion

public boolean isMajorVersion()
                       throws ClientException
Description copied from interface: DocumentModel
Checks if a document is a major version.

Specified by:
isMajorVersion in interface DocumentModel
Throws:
ClientException

isLatestMajorVersion

public boolean isLatestMajorVersion()
                             throws ClientException
Description copied from interface: DocumentModel
Checks if a document is the latest major version in the version series.

Specified by:
isLatestMajorVersion in interface DocumentModel
Throws:
ClientException

isVersionSeriesCheckedOut

public boolean isVersionSeriesCheckedOut()
                                  throws ClientException
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 interface DocumentModel
Throws:
ClientException

getCheckinComment

public java.lang.String getCheckinComment()
                                   throws ClientException
Description copied from interface: DocumentModel
Returns the checkin comment if the document model is a version.

Specified by:
getCheckinComment in interface DocumentModel
Returns:
the checkin comment, or null
Throws:
ClientException

getACP

public ACP getACP()
           throws ClientException
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 interface DocumentModel
Returns:
the security data model or null if none
Throws:
ClientException

setACP

public void setACP(ACP acp,
                   boolean overwrite)
            throws ClientException
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 interface DocumentModel
Parameters:
acp - the ACP to set
overwrite - whether to overwrite the old ACP or not
Throws:
ClientException
See Also:
CoreSession#setACP(DocumentRef, ACP, boolean)}

getType

public java.lang.String getType()
Description copied from interface: DocumentModel
Gets the document type name.

Specified by:
getType in interface DocumentModel
Returns:
the document type name

setProperties

public void setProperties(java.lang.String schemaName,
                          java.util.Map<java.lang.String,java.lang.Object> data)
                   throws ClientException
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 interface DocumentModel
Parameters:
schemaName - the schema name
data - the values to set
Throws:
ClientException

setProperty

public void setProperty(java.lang.String schemaName,
                        java.lang.String name,
                        java.lang.Object value)
                 throws ClientException
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 interface DocumentModel
Parameters:
schemaName - the schema name
name - the property name
value - the property value
Throws:
ClientException

hasSchema

public boolean hasSchema(java.lang.String schema)
Description copied from interface: DocumentModel
Checks whether this document model has the given schema.

Specified by:
hasSchema in interface DocumentModel
Parameters:
schema - the schema name to check
Returns:
true if the document has this schema, false otherwise

hasFacet

public boolean hasFacet(java.lang.String facet)
Description copied from interface: DocumentModel
Checks if this document has the given facet.

Specified by:
hasFacet in interface DocumentModel
Parameters:
facet - the facet to check
Returns:
true if the document has this facet, false otherwise

getPath

public Path getPath()
Description copied from interface: DocumentModel
Gets the document path.

Specified by:
getPath in interface DocumentModel
Returns:
the document path as string

getDataModels

public DataModelMap getDataModels()
Description copied from interface: DocumentModel
Gets the data models.

Specified by:
getDataModels in interface DocumentModel
Returns:
the data models that are already fetched.

copyContentInto

public void copyContentInto(DocumentModelImpl other)

isFolder

public boolean isFolder()
Description copied from interface: DocumentModel
Checks if this document is a folder.

Specified by:
isFolder in interface DocumentModel
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 interface DocumentModel
Returns:
true if the document can have versions, false otherwise

isDownloadable

public boolean isDownloadable()
                       throws ClientException
Description copied from interface: DocumentModel
Checks if this document can be downloaded.

Specified by:
isDownloadable in interface DocumentModel
Returns:
true if the document has downloadable content, false otherwise
Throws:
ClientException

getAdapter

public <T> T getAdapter(java.lang.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 interface DocumentModel
Type Parameters:
T - the interface type to adapt to
Parameters:
itf - the interface class
Returns:
the adapted document

getAdapter

public <T> T getAdapter(java.lang.Class<T> itf,
                        boolean refreshCache)
Description copied from interface: DocumentModel
Adapts the document to the given interface.

Specified by:
getAdapter in interface DocumentModel
Type Parameters:
T - the interface type to adapt to
Parameters:
itf - the interface class
refreshCache - : readapt and stores in cache if already exists.
Returns:
the adapted document

followTransition

public boolean followTransition(java.lang.String transition)
                         throws ClientException
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 interface DocumentModel
Parameters:
transition - the name of the transition to follow
Returns:
a boolean representing the status if the operation
Throws:
ClientException

getAllowedStateTransitions

public java.util.Collection<java.lang.String> getAllowedStateTransitions()
                                                                  throws ClientException
Description copied from interface: DocumentModel
Gets the allowed state transitions for this document.

Specified by:
getAllowedStateTransitions in interface DocumentModel
Returns:
a collection of state transitions as string
Throws:
ClientException

getCurrentLifeCycleState

public java.lang.String getCurrentLifeCycleState()
                                          throws ClientException
Description copied from interface: DocumentModel
Returns the life cycle of the document.

Specified by:
getCurrentLifeCycleState in interface DocumentModel
Returns:
the life cycle as a string
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

getLifeCyclePolicy

public java.lang.String getLifeCyclePolicy()
                                    throws ClientException
Description copied from interface: DocumentModel
Returns the life cycle policy of the document.

Specified by:
getLifeCyclePolicy in interface DocumentModel
Returns:
the life cycle policy
Throws:
ClientException
See Also:
org.nuxeo.ecm.core.lifecycle

isVersion

public boolean isVersion()
Description copied from interface: DocumentModel
Checks if this document is a version.

Specified by:
isVersion in interface DocumentModel
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 interface DocumentModel
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 interface DocumentModel
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)

getContextData

public ScopedMap getContextData()
Description copied from interface: DocumentModel
Gets the context data associated to this document.

Specified by:
getContextData in interface DocumentModel
Returns:
serializable map of context data.

getContextData

public java.io.Serializable getContextData(ScopeType scope,
                                           java.lang.String key)
Description copied from interface: DocumentModel
Gets the context data associated to this document for given scope and given key.

Specified by:
getContextData in interface DocumentModel

putContextData

public void putContextData(ScopeType scope,
                           java.lang.String key,
                           java.io.Serializable value)
Description copied from interface: DocumentModel
Adds mapping to the context data for given scope.

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).

Specified by:
putContextData in interface DocumentModel

getContextData

public java.io.Serializable getContextData(java.lang.String key)
Description copied from interface: DocumentModel
Gets the context data using the default scope.

Specified by:
getContextData in interface DocumentModel
Parameters:
key - the context data key
Returns:
the value

putContextData

public void putContextData(java.lang.String key,
                           java.io.Serializable value)
Description copied from interface: DocumentModel
Sets a context data in the default scope.

Specified by:
putContextData in interface DocumentModel
Parameters:
key - the context data key
value - 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 interface DocumentModel

copyContent

public void copyContent(DocumentModel sourceDoc)
                 throws ClientException
Description copied from interface: DocumentModel
Copies all the data from a source document.

Specified by:
copyContent in interface DocumentModel
Throws:
ClientException

cloneField

public static java.lang.Object cloneField(Field field,
                                          java.lang.String key,
                                          java.lang.Object value)

cloneDataModel

public static DataModel cloneDataModel(Schema schema,
                                       DataModel data)

cloneDataModel

public DataModel cloneDataModel(DataModel data)

getCacheKey

public java.lang.String getCacheKey()
                             throws ClientException
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.

Specified by:
getCacheKey in interface DocumentModel
Returns:
the cache key as a string
Throws:
ClientException

getRepositoryName

public java.lang.String getRepositoryName()
Description copied from interface: DocumentModel
Returns the name of the repository in which the document is stored.

Specified by:
getRepositoryName in interface DocumentModel
Returns:
the repository name as a string.

getSourceId

public java.lang.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 interface DocumentModel
Returns:
the source id as a string.

isSchemaLoaded

public boolean isSchemaLoaded(java.lang.String name)

prefetchProperty

public void prefetchProperty(java.lang.String id,
                             java.lang.Object value)
Description copied from interface: DocumentModel
Store a value in the prefetched inner map.

Specified by:
prefetchProperty in interface DocumentModel

prefetchCurrentLifecycleState

public void prefetchCurrentLifecycleState(java.lang.String lifecycle)
Description copied from interface: DocumentModel
Used to set lifecycle state along with prefetching other properties.

Specified by:
prefetchCurrentLifecycleState in interface DocumentModel

prefetchLifeCyclePolicy

public void prefetchLifeCyclePolicy(java.lang.String lifeCyclePolicy)
Description copied from interface: DocumentModel
Used to set lifecycle policy along with prefetching other properties.

Specified by:
prefetchLifeCyclePolicy in interface DocumentModel

setFlags

public void setFlags(long flags)

clearFlags

public void clearFlags(long flags)

clearFlags

public void clearFlags()

getFlags

public long getFlags()
Description copied from interface: DocumentModel
Returns the flags set on the document model.

Specified by:
getFlags in interface DocumentModel

hasFlags

public boolean hasFlags(long flags)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPrefetch

public java.util.Map<java.lang.String,java.io.Serializable> getPrefetch()
Description copied from interface: DocumentModel
Returns the map of prefetched values.

Specified by:
getPrefetch in interface DocumentModel
Returns:
the map of prefetched values.

getSystemProp

public <T extends java.io.Serializable> T getSystemProp(java.lang.String systemProperty,
                                                        java.lang.Class<T> type)
                                             throws ClientException,
                                                    DocumentException
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 interface DocumentModel
Throws:
ClientException
DocumentException

isLifeCycleLoaded

public boolean isLifeCycleLoaded()
Specified by:
isLifeCycleLoaded in interface DocumentModel

getPart

public DocumentPart getPart(java.lang.String schema)
                     throws ClientException
Description copied from interface: DocumentModel
Get a document part given its schema name

Specified by:
getPart in interface DocumentModel
Parameters:
schema - the schema
Returns:
the document aprt or null if none exists for that schema
Throws:
ClientException

getParts

public DocumentPart[] getParts()
                        throws ClientException
Description copied from interface: DocumentModel
Gets this document's parts.

Specified by:
getParts in interface DocumentModel
Throws:
ClientException

getProperty

public Property getProperty(java.lang.String xpath)
                     throws ClientException
Description copied from interface: DocumentModel
Gets a property given a xpath.

Specified by:
getProperty in interface DocumentModel
Throws:
ClientException

getPropertyValue

public java.io.Serializable getPropertyValue(java.lang.String path)
                                      throws PropertyException,
                                             ClientException
Description copied from interface: DocumentModel
Gets a property value given a xpath.

Specified by:
getPropertyValue in interface DocumentModel
Throws:
PropertyException
ClientException

setPropertyValue

public void setPropertyValue(java.lang.String path,
                             java.io.Serializable value)
                      throws PropertyException,
                             ClientException
Description copied from interface: DocumentModel
Sets a property value given a xpath.

Specified by:
setPropertyValue in interface DocumentModel
Throws:
PropertyException
ClientException

clone

public DocumentModel clone()
                    throws java.lang.CloneNotSupportedException
Description copied from interface: DocumentModel
Clone operation. Must be made public instead of just protected as in Object.

Specified by:
clone in interface DocumentModel
Overrides:
clone in class java.lang.Object
Throws:
java.lang.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 interface DocumentModel

refresh

public void refresh()
             throws ClientException
Description copied from interface: DocumentModel
Same as DocumentModel.refresh(REFRESH_DEFAULT).

Specified by:
refresh in interface DocumentModel
Throws:
ClientException

refresh

public void refresh(int refreshFlags,
                    java.lang.String[] schemas)
             throws ClientException
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:

The refresh flags are: If XX_IF_LOADED is used then XX will be refreshed only if already loaded in the document - otherwise a lazy refresh will be done

Specified by:
refresh in interface DocumentModel
Parameters:
refreshFlags - the refresh flags
schemas - the document parts (schemas) that should be refreshed now
Throws:
ClientException

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.