Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql.coremodel
Class SQLDocumentLive

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
      extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
          extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive
All Implemented Interfaces:
Document, DocumentContainer, Lockable, Property, PropertyContainer, SQLDocument, VersionableDocument
Direct Known Subclasses:
SQLDocumentVersion

public class SQLDocumentLive
extends SQLComplexProperty
implements SQLDocument

Author:
Florent Guillaume

Field Summary
 
Fields inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
DC_ISSUED, RELATED_TEXT_RESOURCES
 
Fields inherited from interface org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument
BINARY_TEXT_SYS_PROP, FULLTEXT_JOBID_SYS_PROP
 
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 checkinComment)
          Creates a new version.
 void checkOut()
           
 boolean equals(Object other)
           
 boolean followTransition(String transition)
          Follows a given life cycle transition.
 Property getACLProperty()
          Returns the property holding the ACL.
 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.
 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.
 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.
 Document getParent()
          Gets the parent document or null if this is the root document.
 String getPath()
          Gets the path of this document.
 Property getProperty(String name)
          Gets the children property given its name.
 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.
<T extends Serializable>
T
getSystemProp(String name, Class<T> type)
          Get system property of the specified type.
 DocumentType getType()
          Gets the property 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.
 int hashCode()
           
 boolean hasVersions()
          Tells the caller if this document has versions or not.
 boolean isCheckedOut()
           
 boolean isFolder()
          Tests whether this document represent a folder or a leaf document.
 boolean isLatestMajorVersion()
           
 boolean isLatestVersion()
           
 boolean isMajorVersion()
           
 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)
          Reads into the DocumentPart the values from this SQLDocument.
 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.
 Document resolvePath(String path)
          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 setCurrentLifeCycleState(String state)
          Sets the lifecycle state of the document.
 void setLifeCyclePolicy(String policy)
          Sets the life cycle policy of this document.
 Lock setLock(Lock lock)
          Sets a lock on the current document.
<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.
 String toString()
           
 void writeDocumentPart(DocumentPart dp)
          Writes into this SQLDocument the values from the DocumentPart.
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
exportFlatMap, exportMap, exportMap, getBoolean, getContent, getDate, getDirtyFields, getDouble, getLong, getName, getNode, getProperties, getPropertyIterator, getPropertyValue, getString, getValue, importFlatMap, importMap, isPropertySet, removeProperty, setBoolean, setContent, setDate, setDouble, setLong, setPropertyValue, setString, setValue
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
checkWritable, isNull, isSpecialSystemProperty, setNull
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument
checkWritable, getNode
 
Methods inherited from interface org.nuxeo.ecm.core.model.Document
getName
 
Methods inherited from interface org.nuxeo.ecm.core.model.PropertyContainer
exportFlatMap, exportMap, exportMap, getBoolean, getContent, getDate, getDirtyFields, getDouble, getLong, getProperties, getPropertyIterator, getPropertyValue, getString, importFlatMap, importMap, isPropertySet, removeProperty, setBoolean, setContent, setDate, setDouble, setLong, setPropertyValue, setString
 
Methods inherited from interface org.nuxeo.ecm.core.model.Property
getName, getProperties, getPropertyIterator, getValue, isNull, isPropertySet, setNull, setValue
 

Method Detail

getACLProperty

public Property getACLProperty()
                        throws DocumentException
Description copied from interface: SQLDocument
Returns the property holding the ACL.

Specified by:
getACLProperty in interface SQLDocument
Throws:
DocumentException

getType

public DocumentType getType()
Description copied from interface: Property
Gets the property type.

Specified by:
getType in interface Document
Specified by:
getType in interface Property
Overrides:
getType in class SQLBaseProperty
Returns:
the property type

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

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

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)

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

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

getLastModified

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

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

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

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.

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

readDocumentPart

public void readDocumentPart(DocumentPart dp)
                      throws Exception
Reads into the DocumentPart the values from this SQLDocument.

Specified by:
readDocumentPart in interface Document
Throws:
Exception

getProperty

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

Specified by:
getProperty in interface Property
Specified by:
getProperty in interface PropertyContainer
Overrides:
getProperty in class SQLComplexProperty
Parameters:
name - the property name
Returns:
the property
Throws:
DocumentException - if any error occurs

writeDocumentPart

public void writeDocumentPart(DocumentPart dp)
                       throws Exception
Writes into this SQLDocument the values from the DocumentPart.

Specified by:
writeDocumentPart in interface Document
Throws:
Exception

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

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

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

setLifeCyclePolicy

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

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

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

setCurrentLifeCycleState

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

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

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

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

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

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

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

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

checkIn

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

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

checkOut

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

isCheckedOut

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

isMajorVersion

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

isLatestVersion

public boolean isLatestVersion()
                        throws DocumentException
Specified by:
isLatestVersion 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

getVersionLabel

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

getCheckinComment

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

getWorkingCopy

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

getVersionCreationDate

public Calendar getVersionCreationDate()
                                throws DocumentException
Specified by:
getVersionCreationDate in interface VersionableDocument
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

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

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

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

resolvePath

public Document resolvePath(String path)
                     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:
path - the path relative to this document
Returns:
the resolved 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

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

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

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

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

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.