Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.model
Class MockDocument

java.lang.Object
  extended by org.nuxeo.ecm.core.model.MockDocument
All Implemented Interfaces:
Document, DocumentContainer, Lockable, PropertyContainer, VersionableDocument

public class MockDocument
extends Object
implements Document

Author:
Anahide Tchertchian

Field Summary
 boolean checkedout
           
 String creator
           
 Lock lock
           
 String uuid
           
 
Constructor Summary
MockDocument(String uuid, String creator)
           
 
Method Summary
 Document addChild(String name, String typeName)
          Creates a new child document given its typename.
 boolean addFacet(String facet)
          Adds a facet to the document instance.
 Document checkIn(String label, String description)
          Creates a new version.
 void checkOut()
           
 Map<String,Object> exportFlatMap(String[] schemas)
          Exports a flat view of properties in this document.
 Map<String,Object> exportMap(String schemaName)
           
 Map<String,Map<String,Object>> exportMap(String[] schemas)
          Exports the properties belonging to the given schemas as a java Map.
 boolean followTransition(String transition)
          Follows a given life cycle transition.
 Set<String> getAllFacets()
          Gets the facets available on this document (from the type and the instance facets).
 Collection<String> getAllowedStateTransitions()
          Returns the allowed state transitions for this document.
 Document getBaseVersion()
          Gets the version to which a checked in document is linked.
 boolean getBoolean(String name)
          Gets the value of a scalar property as a boolean.
 String getCheckinComment()
           
 Document getChild(String name)
          Gets a child document given its name.
 Iterator<Document> getChildren()
          Gets an iterator over the children of the document.
 DocumentIterator getChildren(int start)
           
 List<String> getChildrenIds()
          Gets a list of the children ids.
 Blob getContent(String name)
          Gets the value of the named content property.
 Calendar getDate(String name)
          Gets the value of a scalar property as a date.
 List<String> getDirtyFields()
          Returns fields that were modified.
 double getDouble(String name)
          Gets the value of a scalar property as a double.
 String[] getFacets()
          Gets the facets defined on this document instance.
 Calendar getLastModified()
          Gets the last modification time on this document.
 Document getLastVersion()
          Gets the last version of this document.
 String getLifeCyclePolicy()
          Returns the life cycle policy of this document.
 String getLifeCycleState()
          Returns the life cycle of the document.
 Lock getLock()
          Gets the lock key if a lock exists on the current object.
 long getLong(String name)
          Gets the value of a scalar property as a long.
 String getName()
          Gets the name of this document.
 Document getParent()
          Gets the parent document or null if this is the root document.
 String getPath()
          Gets the path of this document.
 Collection<Property> getProperties()
          Gets the collection of the sub properties in this container.
 Property getProperty(String name)
          Gets a property given its name.
 Iterator<Property> getPropertyIterator()
          Gets an iterator over all existing properties in this container.
 Object getPropertyValue(String name)
          Generic method to retrieve a property value.
 Repository getRepository()
          Returns the repository in which the document lives.
 Session getSession()
          Gets the session that owns this document.
 Document getSourceDocument()
          Gets the head ("live") version of this document.
 String getString(String name)
          Gets the value of a scalar property as a string.
<T extends Serializable>
T
getSystemProp(String name, Class<T> type)
          Get system property of the specified type.
 DocumentType getType()
          Gets this document's type.
 String getUUID()
          Gets this document's UUID.
 Document getVersion(String label)
          Gets a version of this document, given its label.
 Calendar getVersionCreationDate()
           
 String getVersionLabel()
           
 List<Document> getVersions()
           
 String getVersionSeriesId()
          Gets the version series id.
 List<String> getVersionsIds()
          Gets the list of version ids for this document.
 Document getWorkingCopy()
           
 boolean hasChild(String name)
          Tests if the document has the named child.
 boolean hasChildren()
          Tests if the document has any children.
 boolean hasFacet(String facet)
          Checks if the document has a facet, either from its type or added on the instance.
 boolean hasVersions()
          Tells the caller if this document has versions or not.
 void importFlatMap(Map<String,Object> map)
          Imports a flat map of properties into this document.
 void importMap(Map<String,Map<String,Object>> map)
          Imports the tree properties from the given Java Map.
 boolean isCheckedOut()
           
 boolean isFolder()
          Tests whether this document represent a folder or a leaf document.
 boolean isLatestMajorVersion()
           
 boolean isLatestVersion()
           
 boolean isMajorVersion()
           
 boolean isPropertySet(String path)
          Tests whether the property at the given path exists (the property may be either a scalar or a composite one).
 boolean isProxy()
          Checks whether or not this doc is a proxy document.
 boolean isVersion()
          Checks whether or not this doc is a version document.
 boolean isVersionSeriesCheckedOut()
           
 void orderBefore(String src, String dest)
          Orders the given source child before the destination child.
 void readDocumentPart(DocumentPart dp)
          Load document part properties from storage and fill them inside the given document part.
 void remove()
          Removes this document and all its children, if any.
 void removeChild(String name)
          Removes the child having the given name
 boolean removeFacet(String facet)
          Removes a facet from the document instance.
 Lock removeLock(String owner)
          Removes a lock on the current document.
 void removeProperty(String name)
          Removes the property with the given name.
 Document resolvePath(String relPath)
          Resolves a document given its relative path to the current document.
 void restore(Document version)
          Replaces current version with version specified.
 void save()
          Saves any modification done on this document or its children.
 void setBoolean(String name, boolean value)
          Sets the scalar property value to the given boolean value.
 void setContent(String name, Blob value)
          Sets the content property to the given value.
 void setCurrentLifeCycleState(String state)
          Sets the lifecycle state of the document.
 void setDate(String name, Calendar value)
          Sets the scalar property value to the given date value.
 void setDouble(String name, double value)
          Set the scalar property value to the given double value.
 void setLifeCyclePolicy(String policy)
          Sets the life cycle policy of this document.
 Lock setLock(Lock lock)
          Sets a lock on the current document.
 void setLong(String name, long value)
          Sets the scalar property value to the given long value.
 void setPropertyValue(String name, Object value)
          Generic method to set a property value.
 void setString(String name, String value)
          Sets the scalar property value to the given string value.
<T extends Serializable>
void
setSystemProp(String name, T value)
          Set a system property which is a property of by the built-in node type ECM_SYSTEM_ANY.
 void writeDocumentPart(DocumentPart dp)
          Read modifications in the given document part and write them on storage.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uuid

public String uuid

creator

public String creator

lock

public Lock lock

checkedout

public boolean checkedout
Constructor Detail

MockDocument

public MockDocument(String uuid,
                    String creator)
Method Detail

getName

public String getName()
               throws DocumentException
Description copied from interface: Document
Gets the name of this document.

Specified by:
getName in interface Document
Returns:
the document name. Cannot be null
Throws:
DocumentException - if any exception occurred

getUUID

public String getUUID()
Description copied from interface: Document
Gets this document's UUID.

Specified by:
getUUID in interface Document
Returns:
the document UUID (cannot be null)

getSession

public Session getSession()
Description copied from interface: Document
Gets the session that owns this document.

Specified by:
getSession in interface Document
Returns:
the session

getType

public DocumentType getType()
Description copied from interface: Document
Gets this document's type.

Specified by:
getType in interface Document
Returns:
the document type (cannot be null)

getPath

public String getPath()
               throws DocumentException
Description copied from interface: Document
Gets the path of this document.

Specified by:
getPath in interface Document
Returns:
the path
Throws:
DocumentException

getRepository

public Repository getRepository()
Description copied from interface: Document
Returns the repository in which the document lives.

Specified by:
getRepository in interface Document
Returns:
a Repository instance.

setLifeCyclePolicy

public void setLifeCyclePolicy(String policy)
Description copied from interface: Document
Sets the life cycle policy of this document.

Specified by:
setLifeCyclePolicy in interface Document
Parameters:
policy - the policy

setCurrentLifeCycleState

public void setCurrentLifeCycleState(String state)
Description copied from interface: Document
Sets the lifecycle state of the document.

Specified by:
setCurrentLifeCycleState in interface Document
Parameters:
state - the state

followTransition

public boolean followTransition(String transition)
                         throws LifeCycleException
Description copied from interface: Document
Follows a given life cycle transition.

This will update the current life cycle of the document.

Specified by:
followTransition in interface Document
Parameters:
transition - the name of the transition to follow
Returns:
a boolean representing the status if the operation
Throws:
LifeCycleException

getAllowedStateTransitions

public Collection<String> getAllowedStateTransitions()
                                              throws LifeCycleException
Description copied from interface: Document
Returns the allowed state transitions for this document.

Specified by:
getAllowedStateTransitions in interface Document
Returns:
a collection of state transitions as string
Throws:
LifeCycleException

getBaseVersion

public Document getBaseVersion()
                        throws DocumentException
Description copied from interface: VersionableDocument
Gets the version to which a checked in document is linked.

Returns null for a checked out document or a version or a proxy.

Specified by:
getBaseVersion in interface VersionableDocument
Returns:
the version, or null
Throws:
DocumentException

getLifeCycleState

public String getLifeCycleState()
                         throws LifeCycleException
Description copied from interface: Document
Returns the life cycle of the document.

Specified by:
getLifeCycleState in interface Document
Returns:
the life cycle as a string
Throws:
LifeCycleException
See Also:
org.nuxeo.ecm.core.lifecycle

getLastModified

public Calendar getLastModified()
                         throws DocumentException
Description copied from interface: Document
Gets the last modification time on this document.

Specified by:
getLastModified in interface Document
Returns:
last modification time
Throws:
DocumentException

getLifeCyclePolicy

public String getLifeCyclePolicy()
                          throws LifeCycleException
Description copied from interface: Document
Returns the life cycle policy of this document.

Specified by:
getLifeCyclePolicy in interface Document
Returns:
the life cycle policy name of this document as a string
Throws:
LifeCycleException

getParent

public Document getParent()
                   throws DocumentException
Description copied from interface: Document
Gets the parent document or null if this is the root document.

Specified by:
getParent in interface Document
Returns:
the parent document or null if this is the root document
Throws:
DocumentException

getSystemProp

public <T extends Serializable> T getSystemProp(String name,
                                                Class<T> type)
                                     throws DocumentException
Description copied from interface: Document
Get system property of the specified type.

Specified by:
getSystemProp in interface Document
Returns:
Throws:
DocumentException

isFolder

public boolean isFolder()
Description copied from interface: Document
Tests whether this document represent a folder or a leaf document.

Specified by:
isFolder in interface Document
Returns:
true if the document is a folder document, false otherwise

isProxy

public boolean isProxy()
Description copied from interface: Document
Checks whether or not this doc is a proxy document.

Specified by:
isProxy in interface Document
Returns:
true if it's a proxy false otherwise

remove

public void remove()
            throws DocumentException
Description copied from interface: Document
Removes this document and all its children, if any.

Specified by:
remove in interface Document
Throws:
DocumentException - if an error occurs

save

public void save()
          throws DocumentException
Description copied from interface: Document
Saves any modification done on this document or its children.

For some implementations this may do nothing if they are commiting modifications as they are done by calling the corresponding method.

Specified by:
save in interface Document
Throws:
DocumentException - if an error occurs

setSystemProp

public <T extends Serializable> void setSystemProp(String name,
                                                   T value)
                   throws DocumentException
Description copied from interface: Document
Set a system property which is a property of by the built-in node type ECM_SYSTEM_ANY.

Specified by:
setSystemProp in interface Document
Throws:
DocumentException

checkIn

public Document checkIn(String label,
                        String description)
                 throws DocumentException
Description copied from interface: VersionableDocument
Creates a new version.

Specified by:
checkIn in interface VersionableDocument
Parameters:
label - the version label
description - the checkin comment
Returns:
the created version
Throws:
DocumentException

checkOut

public void checkOut()
              throws DocumentException
Specified by:
checkOut in interface VersionableDocument
Throws:
DocumentException

getLastVersion

public Document getLastVersion()
                        throws DocumentException
Description copied from interface: VersionableDocument
Gets the last version of this document.

Specified by:
getLastVersion in interface VersionableDocument
Returns:
the last version
Throws:
DocumentException

getSourceDocument

public Document getSourceDocument()
                           throws DocumentException
Description copied from interface: VersionableDocument
Gets the head ("live") version of this document.

Specified by:
getSourceDocument in interface VersionableDocument
Returns:
Throws:
DocumentException

getVersionsIds

public List<String> getVersionsIds()
                            throws DocumentException
Description copied from interface: VersionableDocument
Gets the list of version ids for this document.

Specified by:
getVersionsIds in interface VersionableDocument
Returns:
the list of version ids
Throws:
DocumentException

getVersion

public Document getVersion(String label)
                    throws DocumentException
Description copied from interface: VersionableDocument
Gets a version of this document, given its label.

Specified by:
getVersion in interface VersionableDocument
Parameters:
label - the version label
Returns:
the version
Throws:
DocumentException

getVersions

public List<Document> getVersions()
                           throws DocumentException
Specified by:
getVersions in interface VersionableDocument
Returns:
all versions of the document, empty list if there's no version
Throws:
DocumentException

hasVersions

public boolean hasVersions()
                    throws DocumentException
Description copied from interface: VersionableDocument
Tells the caller if this document has versions or not.

Needed to know if we need to use checkin/checkout methods when changing a document.

Specified by:
hasVersions in interface VersionableDocument
Returns:
true if there are versions
Throws:
DocumentException

isCheckedOut

public boolean isCheckedOut()
                     throws DocumentException
Specified by:
isCheckedOut in interface VersionableDocument
Throws:
DocumentException

isVersion

public boolean isVersion()
Description copied from interface: VersionableDocument
Checks whether or not this doc is a version document.

Specified by:
isVersion in interface VersionableDocument
Returns:
true if it's a version, false otherwise

getVersionSeriesId

public String getVersionSeriesId()
                          throws DocumentException
Description copied from interface: VersionableDocument
Gets the version series id.

Specified by:
getVersionSeriesId in interface VersionableDocument
Returns:
the version series id
Throws:
DocumentException

restore

public void restore(Document version)
             throws DocumentException
Description copied from interface: VersionableDocument
Replaces current version with version specified.

Specified by:
restore in interface VersionableDocument
Parameters:
version - the version to replace with
Throws:
DocumentException

addChild

public Document addChild(String name,
                         String typeName)
                  throws DocumentException
Description copied from interface: DocumentContainer
Creates a new child document given its typename.

This operation throws an error if the current document is not a folder.

Specified by:
addChild in interface DocumentContainer
Parameters:
name - the name of the new child to create
typeName - the type of the child to create
Returns:
the newly created document
Throws:
DocumentException

getChild

public Document getChild(String name)
                  throws DocumentException
Description copied from interface: DocumentContainer
Gets a child document given its name.

Throws an exception if the document could not be found.

If the supplied name is null, returns the default child of the document if any, otherwise raises an exception.

Specified by:
getChild in interface DocumentContainer
Parameters:
name - the name of the child to retrieve
Returns:
the named child if exists, raises a NoSuchDocumentException otherwise
Throws:
DocumentException

getChildren

public Iterator<Document> getChildren()
                               throws DocumentException
Description copied from interface: DocumentContainer
Gets an iterator over the children of the document.

This operation silently ignores non-folder documents: if the document is not a folder then it returns an empty iterator.

Specified by:
getChildren in interface DocumentContainer
Returns:
the children iterator
Throws:
DocumentException

getChildren

public DocumentIterator getChildren(int start)
                             throws DocumentException
Specified by:
getChildren in interface DocumentContainer
Throws:
DocumentException

getChildrenIds

public List<String> getChildrenIds()
                            throws DocumentException
Description copied from interface: DocumentContainer
Gets a list of the children ids.

Specified by:
getChildrenIds in interface DocumentContainer
Returns:
a list of children ids.
Throws:
DocumentException

hasChild

public boolean hasChild(String name)
                 throws DocumentException
Description copied from interface: DocumentContainer
Tests if the document has the named child.

This operation silently ignores non-folder documents: If the document is not a folder then return false.

Specified by:
hasChild in interface DocumentContainer
Parameters:
name - the name of the child to test
Returns:
true if the named child exists, false otherwise
Throws:
DocumentException

hasChildren

public boolean hasChildren()
                    throws DocumentException
Description copied from interface: DocumentContainer
Tests if the document has any children.

This operation silently ignores non-folder documents: If the document is not a folder then returns false.

Specified by:
hasChildren in interface DocumentContainer
Returns:
true if document has children, false otherwise
Throws:
DocumentException

removeChild

public void removeChild(String name)
                 throws DocumentException
Description copied from interface: DocumentContainer
Removes the child having the given name

If this is not a folder does nothing.

If this is a folder and no child exists with the given name then throws an exception

Specified by:
removeChild in interface DocumentContainer
Parameters:
name - the child name
Throws:
DocumentException

resolvePath

public Document resolvePath(String relPath)
                     throws DocumentException
Description copied from interface: DocumentContainer
Resolves a document given its relative path to the current document.

If the path is absolute then it will be transformed in a relative path (i.e. the leading '/' removed).

Specified by:
resolvePath in interface DocumentContainer
Parameters:
relPath - the path relative to this document
Returns:
the resolved document
Throws:
DocumentException

exportFlatMap

public Map<String,Object> exportFlatMap(String[] schemas)
                                 throws DocumentException
Description copied from interface: PropertyContainer
Exports a flat view of properties in this document.

If the given schemas array is null then all schemas will be exported.

Specified by:
exportFlatMap in interface PropertyContainer
Returns:
Throws:
DocumentException - if any error occurs

exportMap

public Map<String,Object> exportMap(String schemaName)
                             throws DocumentException
Specified by:
exportMap in interface PropertyContainer
Throws:
DocumentException

exportMap

public Map<String,Map<String,Object>> exportMap(String[] schemas)
                                         throws DocumentException
Description copied from interface: PropertyContainer
Exports the properties belonging to the given schemas as a java Map.

If the given schemas array is null then all schemas will be exported

The properties are grouped by schemas

The property tree is recursively traversed and all property in that schema exported as entry of the Map

Specified by:
exportMap in interface PropertyContainer
Returns:
the exported properties as a java Map
Throws:
DocumentException - if any error occurs

getBoolean

public boolean getBoolean(String name)
                   throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a boolean.

This is a shortcut for getScalar(name).getBoolean()

Specified by:
getBoolean in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getBoolean()};

getContent

public Blob getContent(String name)
                throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of the named content property.

Specified by:
getContent in interface PropertyContainer
Throws:
DocumentException - if any error occurs

getDate

public Calendar getDate(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a date.

This is a shortcut for getScalar(name).getDate()

Specified by:
getDate in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getDate()};

getDirtyFields

public List<String> getDirtyFields()
Description copied from interface: PropertyContainer
Returns fields that were modified.

XXX AT: compatibility method for NXP-666

Specified by:
getDirtyFields in interface PropertyContainer

getDouble

public double getDouble(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a double.

This is a shortcut for getScalar(name).getDouble()

Specified by:
getDouble in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getDouble()};

getLong

public long getLong(String name)
             throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a long.

This is a shortcut for getScalar(name).getLong()

Specified by:
getLong in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getLong()};

getProperties

public Collection<Property> getProperties()
                                   throws DocumentException
Description copied from interface: PropertyContainer
Gets the collection of the sub properties in this container.

The returned properties are existing.

Specified by:
getProperties in interface PropertyContainer
Returns:
the existing properties in this container
Throws:
DocumentException - if any error occurs

getProperty

public Property getProperty(String name)
                     throws DocumentException
Description copied from interface: PropertyContainer
Gets a property given its name.

If the named property is specified by schema of the container object this method will always return a property object even if the property was not yet set (doesn't exists).

In this case the method Property.isNull() of the returned property will return true. If the property is not specified by any container schema the NoSuchPropertyException will be thrown returns non null even if the property corresponding to that name was not previously set. The returned object is a scalar, composite or list property.

Specified by:
getProperty in interface PropertyContainer
Parameters:
name - the property name to retrieve
Returns:
the property object
Throws:
DocumentException - if any error occurs

getPropertyIterator

public Iterator<Property> getPropertyIterator()
                                       throws DocumentException
Description copied from interface: PropertyContainer
Gets an iterator over all existing properties in this container.

The returned properties are existing.

Specified by:
getPropertyIterator in interface PropertyContainer
Returns:
the existing properties in this container
Throws:
DocumentException - if any error occurs

getPropertyValue

public Object getPropertyValue(String name)
                        throws DocumentException
Description copied from interface: PropertyContainer
Generic method to retrieve a property value.

This is a shortcut for getProperty(String).getValue()

Specified by:
getPropertyValue in interface PropertyContainer
Parameters:
name - the name of the property to set
Returns:
the property value or null if the property is not set.
Throws:
DocumentException - if any error occurs
See Also:
for the list of supported value objects

getString

public String getString(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a string.

This is a shortcut for getScalar(name).getString()

Specified by:
getString in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getString()};

importFlatMap

public void importFlatMap(Map<String,Object> map)
                   throws DocumentException
Description copied from interface: PropertyContainer
Imports a flat map of properties into this document.

Specified by:
importFlatMap in interface PropertyContainer
Throws:
DocumentException - if any error occurs

importMap

public void importMap(Map<String,Map<String,Object>> map)
               throws DocumentException
Description copied from interface: PropertyContainer
Imports the tree properties from the given Java Map.

The property tree is recursively traversed and all property exported as entry of the Map.

Specified by:
importMap in interface PropertyContainer
Throws:
DocumentException - if any error occurs

isPropertySet

public boolean isPropertySet(String path)
                      throws DocumentException
Description copied from interface: PropertyContainer
Tests whether the property at the given path exists (the property may be either a scalar or a composite one).

Specified by:
isPropertySet in interface PropertyContainer
Parameters:
path - the path to test
Returns:
true if the property at the given path exists, false otherwise
Throws:
DocumentException - if any error occurs

removeProperty

public void removeProperty(String name)
                    throws DocumentException
Description copied from interface: PropertyContainer
Removes the property with the given name.

Specified by:
removeProperty in interface PropertyContainer
Parameters:
name - the property to remove
Throws:
DocumentException - if any error occurs

setBoolean

public void setBoolean(String name,
                       boolean value)
                throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given boolean value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set boolean properties.

Specified by:
setBoolean in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setBoolean(boolean)}

setContent

public void setContent(String name,
                       Blob value)
                throws DocumentException
Description copied from interface: PropertyContainer
Sets the content property to the given value.

If the property with that name doesn't exists, it will be created

Specified by:
setContent in interface PropertyContainer
Throws:
DocumentException - if any error occurs

setDate

public void setDate(String name,
                    Calendar value)
             throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given date value.

If the property with that name doesn't exists, it will be created

This is a shortcut to create or set date properties.

Specified by:
setDate in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setDate(Calendar)}

setDouble

public void setDouble(String name,
                      double value)
               throws DocumentException
Description copied from interface: PropertyContainer
Set the scalar property value to the given double value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set double properties

Specified by:
setDouble in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setDouble(double)}

setLong

public void setLong(String name,
                    long value)
             throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given long value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set long properties.

Specified by:
setLong in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setLong(long)}

setPropertyValue

public void setPropertyValue(String name,
                             Object value)
                      throws DocumentException
Description copied from interface: PropertyContainer
Generic method to set a property value.

This is a shortcut for getProperty(String).setValue(Object)

The following type of objects can be used as values depending on the property type:

Specified by:
setPropertyValue in interface PropertyContainer
Parameters:
name - the name of the property to set
value - the value to set
Throws:
DocumentException - if any error occurs

setString

public void setString(String name,
                      String value)
               throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given string value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set string properties.

Specified by:
setString in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setString(String)}

getLock

public Lock getLock()
             throws DocumentException
Description copied from interface: Lockable
Gets the lock key if a lock exists on the current object.

Specified by:
getLock in interface Lockable
Returns:
the lock or null if no lock exists
Throws:
DocumentException

setLock

public Lock setLock(Lock lock)
             throws DocumentException
Description copied from interface: Lockable
Sets a lock on the current document.

Specified by:
setLock in interface Lockable
Parameters:
lock - the lock to set
Returns:
the existing lock if locking couldn't be done
Throws:
DocumentException

removeLock

public Lock removeLock(String owner)
                throws DocumentException
Description copied from interface: Lockable
Removes a lock on the current document.

Specified by:
removeLock in interface Lockable
Returns:
null if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner mismatch
Throws:
DocumentException

readDocumentPart

public void readDocumentPart(DocumentPart dp)
                      throws Exception
Description copied from interface: Document
Load document part properties from storage and fill them inside the given document part.

Specified by:
readDocumentPart in interface Document
Throws:
Exception

writeDocumentPart

public void writeDocumentPart(DocumentPart dp)
                       throws Exception
Description copied from interface: Document
Read modifications in the given document part and write them on storage.

Specified by:
writeDocumentPart in interface Document
Throws:
Exception

orderBefore

public void orderBefore(String src,
                        String dest)
                 throws DocumentException
Description copied from interface: DocumentContainer
Orders the given source child before the destination child. Both source and destination must be names that point to child documents of the current document. The source document will be placed before the destination one. If destination is null the source document will be appended at the end of the children list.

Specified by:
orderBefore in interface DocumentContainer
Parameters:
src - the document to move
dest - the document before which to place the source document
Throws:
DocumentException - if this document is not an orderable folder or any other exception occurs

getVersionCreationDate

public Calendar getVersionCreationDate()
                                throws DocumentException
Specified by:
getVersionCreationDate in interface VersionableDocument
Throws:
DocumentException

getVersionLabel

public String getVersionLabel()
                       throws DocumentException
Specified by:
getVersionLabel in interface VersionableDocument
Throws:
DocumentException

isLatestVersion

public boolean isLatestVersion()
                        throws DocumentException
Specified by:
isLatestVersion in interface VersionableDocument
Throws:
DocumentException

isMajorVersion

public boolean isMajorVersion()
                       throws DocumentException
Specified by:
isMajorVersion in interface VersionableDocument
Throws:
DocumentException

isLatestMajorVersion

public boolean isLatestMajorVersion()
                             throws DocumentException
Specified by:
isLatestMajorVersion in interface VersionableDocument
Throws:
DocumentException

isVersionSeriesCheckedOut

public boolean isVersionSeriesCheckedOut()
                                  throws DocumentException
Specified by:
isVersionSeriesCheckedOut in interface VersionableDocument
Throws:
DocumentException

getWorkingCopy

public Document getWorkingCopy()
                        throws DocumentException
Specified by:
getWorkingCopy in interface VersionableDocument
Throws:
DocumentException

getCheckinComment

public String getCheckinComment()
                         throws DocumentException
Specified by:
getCheckinComment in interface VersionableDocument
Throws:
DocumentException

getAllFacets

public Set<String> getAllFacets()
Description copied from interface: Document
Gets the facets available on this document (from the type and the instance facets).

Specified by:
getAllFacets in interface Document
Returns:
the facets

getFacets

public String[] getFacets()
Description copied from interface: Document
Gets the facets defined on this document instance. The type facets are not returned.

Specified by:
getFacets in interface Document
Returns:
the facets

hasFacet

public boolean hasFacet(String facet)
Description copied from interface: Document
Checks if the document has a facet, either from its type or added on the instance.

Specified by:
hasFacet in interface Document
Parameters:
facet - the facet name
Returns:
true if the document has the facet

addFacet

public boolean addFacet(String facet)
                 throws DocumentException
Description copied from interface: Document
Adds a facet to the document instance.

Does nothing if the facet was already present on the document.

Specified by:
addFacet in interface Document
Parameters:
facet - the facet name
Returns:
true if the facet was added, or false if it is already present
Throws:
DocumentException - if the facet does not exist

removeFacet

public boolean removeFacet(String facet)
                    throws DocumentException
Description copied from interface: Document
Removes a facet from the document instance.

It's not possible to remove a facet coming from the document type.

Specified by:
removeFacet in interface Document
Parameters:
facet - the facet name
Returns:
true if the facet was removed, or false if it isn't present or is present on the type or does not exit
Throws:
DocumentException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.