Class SQLDocumentLive

    • Field Detail

      • node

        protected final Node node
      • type

        protected final Type type
      • proxySchemas

        protected final List<Schema> proxySchemas
        Proxy-induced types.
      • readonly

        protected boolean readonly
        Read-only flag, used to allow/disallow writes on versions.
      • systemPropNameMap

        protected static final Map<String,​String> systemPropNameMap
    • Constructor Detail

    • Method Detail

      • setReadOnly

        public void setReadOnly​(boolean readonly)
        Description copied from interface: Document
        Sets this document as readonly or not.
        Specified by:
        setReadOnly in interface Document
      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: Document
        Checks whether this document is readonly or not.
        Specified by:
        isReadOnly in interface Document
      • getNode

        public Node getNode()
        Description copied from interface: SQLDocument
        Returns the node with info about the hierarchy location.
        Specified by:
        getNode in interface SQLDocument
      • getName

        public String getName()
        Description copied from interface: Document
        Gets the name of this document.
        Specified by:
        getName in interface Document
        Returns:
        the document name
      • getPos

        public Long getPos()
        Description copied from interface: Document
        Gets the document's position in its containing folder (if ordered).
        Specified by:
        getPos in interface Document
        Returns:
        the position
      • getType

        public DocumentType getType()
        Description copied from interface: Document
        Gets the type of this document.
        Specified by:
        getType in interface Document
        Returns:
        the document type
      • getSession

        public SQLSession 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
        Checks whether this document is a folder.
        Specified by:
        isFolder in interface Document
        Returns:
        true if the document is a folder, 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
      • getParent

        public Document getParent()
        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
      • getPath

        public String getPath()
        Description copied from interface: Document
        Gets the path of this document.
        Specified by:
        getPath in interface Document
        Returns:
        the path
      • isProxy

        public boolean isProxy()
        Description copied from interface: Document
        Checks whether or not this document is a proxy.
        Specified by:
        isProxy in interface Document
        Returns:
        true if this document is a proxy, false otherwise
      • getRepositoryName

        public String getRepositoryName()
        Description copied from interface: Document
        Gets the repository in which the document lives.
        Specified by:
        getRepositoryName in interface Document
        Returns:
        the repository name.
      • remove

        public void remove()
        Description copied from interface: Document
        Removes this document and all its children, if any.
        Specified by:
        remove in interface Document
      • remove

        public void remove​(NuxeoPrincipal principal)
        Description copied from interface: Document
        Removes this document and all its children, if any.
        Specified by:
        remove in interface Document
        Parameters:
        principal - the caller
      • removeSingleton

        public void removeSingleton()
        Description copied from interface: Document
        Removes this document only, without its children.
        Specified by:
        removeSingleton in interface Document
      • getValue

        public Object getValue​(String xpath)
                        throws PropertyException
        Description copied from interface: Document
        Gets a property value.

        The xpath may point to a partial path, in which case the value may be a complex List or Map.

        Specified by:
        getValue in interface Document
        Parameters:
        xpath - the xpath of the property to set
        Returns:
        the property value or null if the property is not set
        Throws:
        PropertyException - if the property does not exist
      • setValue

        public void setValue​(String xpath,
                             Object value)
                      throws PropertyException
        Description copied from interface: Document
        Sets a property value.

        The xpath may point to a partial path, in which case the value may be a complex List or Map.

        Specified by:
        setValue in interface Document
        Parameters:
        xpath - the xpath of the property to set
        value - the value to set
        Throws:
        PropertyException - if the property does not exist or the value is of the wrong type
      • replaceBlobDigest

        public String replaceBlobDigest​(String key,
                                        String newKey,
                                        String newDigest)
        Description copied from interface: Document
        Visits the blobs of this document and, for those with a matching key, replace their key and digest with new ones.
        Specified by:
        replaceBlobDigest in interface Document
        Parameters:
        key - the bob key to look for
        newKey - the new key
        newDigest - the new digest
        Returns:
        the old digest if at least one replacement was done, null otherwise
      • getChangeToken

        public String getChangeToken()
        Description copied from interface: Document
        Gets the current change token for this document.
        Specified by:
        getChangeToken in interface Document
        Returns:
        the change token
      • validateUserVisibleChangeToken

        public boolean validateUserVisibleChangeToken​(String userVisibleChangeToken)
        Description copied from interface: Document
        Validates that the passed user-visible change token is compatible with the one for this document.
        Specified by:
        validateUserVisibleChangeToken in interface Document
        Returns:
        false if the change token is not valid
      • markUserChange

        public void markUserChange()
        Description copied from interface: Document
        Marks the document as being modified by a user change.

        This causes an additional change token increment and check during save.

        Specified by:
        markUserChange in interface Document
      • makeFlexibleRecord

        public void makeFlexibleRecord()
        Description copied from interface: Document
        Turns the document into a flexible record.

        A record is a document with specific capabilities related to mandatory retention until a given date, and legal holds.

        If the document is already a flexible record, this method has no effect. An enforced record cannot be turned into a flexible record.

        The permission "MakeRecord" is required.

        Specified by:
        makeFlexibleRecord in interface Document
        See Also:
        Document.isFlexibleRecord()
      • makeRecord

        public void makeRecord()
        Description copied from interface: Document
        Turns the document into an enforced record.

        A record is a document with specific capabilities related to mandatory retention until a given date, and legal holds. In addition, its main blob receives special treatment from the document blob manager to make sure it's never shared with another blob at the storage level, and is deleted as soon as the record is deleted.

        If the document is already a record, this method has no effect.

        The permission "MakeRecord" is required.

        Specified by:
        makeRecord in interface Document
        See Also:
        Document.isRecord()
      • makeRecord

        protected void makeRecord​(boolean flexible)
      • isRecord

        public boolean isRecord()
        Description copied from interface: Document
        Checks if the document is a record.
        Specified by:
        isRecord in interface Document
        Returns:
        true if the document is a record, false otherwise
        See Also:
        Document.makeRecord()
      • isFlexibleRecord

        public boolean isFlexibleRecord()
        Specified by:
        isFlexibleRecord in interface Document
        Returns:
        true if the document is a flexible record, false otherwise
      • setRetainUntil

        public void setRetainUntil​(Calendar retainUntil)
        Description copied from interface: Document
        Sets a retention date for the document (a record).

        If no previous retention date was set, or if the previous retention date was indeterminate, or if the previous retention date was before the given value, then the retention date is set to the given value.

        If the previous retention date was after the given value (that is, if trying to reduce the retention time), an exception is thrown.

        If the given value is null and the previous retention date is in the past (it has already expired), then the retention date is set to null.

        The permission "SetRetention" is required.

        Specified by:
        setRetainUntil in interface Document
        Parameters:
        retainUntil - the new retention date
        See Also:
        Document.getRetainUntil(), CoreSession.RETAIN_UNTIL_INDETERMINATE
      • setLegalHold

        public void setLegalHold​(boolean hold)
        Description copied from interface: Document
        Sets or removes a legal hold on the document (a record).

        The permission "ManageLegalHold" is required.

        Specified by:
        setLegalHold in interface Document
        Parameters:
        hold - true to set a legal hold, false to remove it
        See Also:
        Document.hasLegalHold()
      • hasLegalHold

        public boolean hasLegalHold()
        Description copied from interface: Document
        Checks if the document has a legal hold set.
        Specified by:
        hasLegalHold in interface Document
        Returns:
        true if a legal hold has been set on the document, false otherwise
        See Also:
        Document.setLegalHold(boolean)
      • setRetentionActive

        public void setRetentionActive​(boolean retentionActive)
        Description copied from interface: Document
        Sets or unsets this document as under active retention.
        Specified by:
        setRetentionActive in interface Document
      • isRetentionActive

        public boolean isRetentionActive()
        Description copied from interface: Document
        Checks whether this document is under active retention.
        Specified by:
        isRetentionActive in interface Document
      • getLifeCyclePolicy

        public String getLifeCyclePolicy()
        Description copied from interface: Document
        Gets the life cycle policy of this document.
        Specified by:
        getLifeCyclePolicy in interface Document
        Returns:
        the life cycle policy
      • 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 life cycle policy
      • getLifeCycleState

        public String getLifeCycleState()
        Description copied from interface: Document
        Gets the life cycle state of this document.
        Specified by:
        getLifeCycleState in interface Document
        Returns:
        the life cycle state
      • setCurrentLifeCycleState

        public void setCurrentLifeCycleState​(String state)
        Description copied from interface: Document
        Sets the life cycle state of this document.
        Specified by:
        setCurrentLifeCycleState in interface Document
        Parameters:
        state - the life cycle state
      • followTransition

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

        This will update the life cycle state of the document.

        Specified by:
        followTransition in interface Document
        Parameters:
        transition - the name of the transition to follow
        Throws:
        LifeCycleException
      • getAllowedStateTransitions

        public Collection<String> getAllowedStateTransitions()
        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
      • isVersion

        public boolean isVersion()
        Description copied from interface: Document
        Checks whether this document is a version document.
        Specified by:
        isVersion in interface Document
        Returns:
        true if it's a version, false otherwise
      • getBaseVersion

        public Document getBaseVersion()
        Description copied from interface: Document
        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 Document
        Returns:
        the version, or null
      • getVersionSeriesId

        public String getVersionSeriesId()
        Description copied from interface: Document
        Gets the version series id.
        Specified by:
        getVersionSeriesId in interface Document
        Returns:
        the version series id
      • getSourceDocument

        public Document getSourceDocument()
        Description copied from interface: Document
        Gets the source for this document.

        For a version, it's the working copy.

        For a proxy, it's the version the proxy points to.

        Specified by:
        getSourceDocument in interface Document
        Returns:
        the source document
      • checkIn

        public Document checkIn​(String label,
                                String checkinComment)
        Description copied from interface: Document
        Creates a new version.
        Specified by:
        checkIn in interface Document
        Parameters:
        label - the version label
        checkinComment - the checkin comment
        Returns:
        the created version
      • checkOut

        public void checkOut()
        Specified by:
        checkOut in interface Document
      • isCheckedOut

        public boolean isCheckedOut()
        Description copied from interface: Document
        Checks whether this document is checked out.
        Specified by:
        isCheckedOut in interface Document
        Returns:
        true if the document is checked out, or false otherwise
      • isMajorVersion

        public boolean isMajorVersion()
        Description copied from interface: Document
        Checks whether this document is a major version.
        Specified by:
        isMajorVersion in interface Document
        Returns:
        true if this is a major version, or false otherwise
      • isLatestVersion

        public boolean isLatestVersion()
        Description copied from interface: Document
        Checks whether this document is the latest version.
        Specified by:
        isLatestVersion in interface Document
        Returns:
        true if this is the latest version, or false otherwise
      • isLatestMajorVersion

        public boolean isLatestMajorVersion()
        Description copied from interface: Document
        Checks whether this document is the latest major version.
        Specified by:
        isLatestMajorVersion in interface Document
        Returns:
        true if this is the latest major version, or false otherwise
      • isVersionSeriesCheckedOut

        public boolean isVersionSeriesCheckedOut()
        Description copied from interface: Document
        Checks if there is a checked out working copy for the version series of this document.
        Specified by:
        isVersionSeriesCheckedOut in interface Document
        Returns:
        true if there is a checked out working copy
      • getVersionLabel

        public String getVersionLabel()
        Description copied from interface: Document
        Gets the version label.
        Specified by:
        getVersionLabel in interface Document
        Returns:
        the version label
      • getCheckinComment

        public String getCheckinComment()
        Description copied from interface: Document
        Gets the version check in comment of this document if it's a version or a proxy.
        Specified by:
        getCheckinComment in interface Document
        Returns:
        the check in comment, or null if it's not a version or a proxy
      • getWorkingCopy

        public Document getWorkingCopy()
        Description copied from interface: Document
        Gets the working copy for this document.
        Specified by:
        getWorkingCopy in interface Document
        Returns:
        the working copy
      • getVersionCreationDate

        public Calendar getVersionCreationDate()
        Description copied from interface: Document
        Gets the version creation date of this document if it's a version or a proxy.
        Specified by:
        getVersionCreationDate in interface Document
        Returns:
        the version creation date, or null if it's not a version or a proxy
      • restore

        public void restore​(Document version)
        Description copied from interface: Document
        Replaces this document's content with the version specified.
        Specified by:
        restore in interface Document
        Parameters:
        version - the version to replace with
      • getVersionsIds

        public List<String> getVersionsIds()
        Description copied from interface: Document
        Gets the list of version ids for this document.
        Specified by:
        getVersionsIds in interface Document
        Returns:
        the list of version ids
      • getVersion

        public Document getVersion​(String label)
        Description copied from interface: Document
        Gets a version of this document, given its label.
        Specified by:
        getVersion in interface Document
        Parameters:
        label - the version label
        Returns:
        the version
      • getVersions

        public List<Document> getVersions()
        Description copied from interface: Document
        Gets the versions for this document.
        Specified by:
        getVersions in interface Document
        Returns:
        the versions of the document, or an empty list if there are no versions
      • getLastVersion

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

        Returns null if there is no version at all.

        Specified by:
        getLastVersion in interface Document
        Returns:
        the last version, or null if there is no version
      • getChild

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

        Throws DocumentNotFoundException if the document could not be found.

        Specified by:
        getChild in interface Document
        Parameters:
        name - the name of the child to retrieve
        Returns:
        the child if exists
      • getChildren

        public List<Document> getChildren()
        Description copied from interface: Document
        Gets the children of the document.
        Specified by:
        getChildren in interface Document
        Returns:
        the children
      • getChildrenIds

        public List<String> getChildrenIds()
        Description copied from interface: Document
        Gets a list of the children ids.
        Specified by:
        getChildrenIds in interface Document
        Returns:
        a list of children ids.
      • hasChild

        public boolean hasChild​(String name)
        Description copied from interface: Document
        Checks whether this document has a child of the given name.
        Specified by:
        hasChild in interface Document
        Parameters:
        name - the name of the child to check
        Returns:
        true if the child exists, false otherwise
      • hasChildren

        public boolean hasChildren()
        Description copied from interface: Document
        Tests if the document has any children.
        Specified by:
        hasChildren in interface Document
        Returns:
        true if the document has children, false otherwise
      • addChild

        public Document addChild​(String name,
                                 String typeName)
        Description copied from interface: Document
        Creates a new child document of the given type.
        Specified by:
        addChild in interface Document
        Parameters:
        name - the name of the new child to create
        typeName - the type of the child to create
        Returns:
        the newly created document
      • orderBefore

        public void orderBefore​(String src,
                                String dest)
        Description copied from interface: Document
        Orders the given source child before the destination child.

        Both source and destination must be names that point to child documents of this 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 Document
        Parameters:
        src - the document to move
        dest - the document before which to place the source document
      • 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
      • getRetainedProperties

        public String[] getRetainedProperties()
        Description copied from interface: Document
        Gets the retained property xpaths of this document instance at the time it became a record.
        Specified by:
        getRetainedProperties in interface Document
        Returns:
        the retained properties
      • hasFacet

        public boolean hasFacet​(String facet)
        Description copied from interface: Document
        Checks whether this document has a given 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)
        Description copied from interface: Document
        Adds a facet to this document.

        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
      • removeFacet

        public boolean removeFacet​(String facet)
        Description copied from interface: Document
        Removes a facet from this document.

        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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getTargetDocument

        public Document getTargetDocument()
        Description copied from interface: Document
        Gets the document (version or live document) to which this proxy points.
        Specified by:
        getTargetDocument in interface Document
      • setTargetDocument

        public void setTargetDocument​(Document target)
        Description copied from interface: Document
        Sets the document (version or live document) to which this proxy points.
        Specified by:
        setTargetDocument in interface Document
      • getDocumentLock

        protected Lock getDocumentLock()
        Description copied from class: BaseDocument
        Gets the lock from this recently created and unsaved document.
        Specified by:
        getDocumentLock in class BaseDocument<Node>
        Returns:
        the lock, or null if no lock is set
      • setDocumentLock

        protected Lock setDocumentLock​(Lock lock)
        Description copied from class: BaseDocument
        Sets a lock on this recently created and unsaved document.
        Specified by:
        setDocumentLock in class BaseDocument<Node>
        Parameters:
        lock - the lock to set
        Returns:
        null if locking succeeded, or the existing lock if locking failed
      • removeDocumentLock

        protected Lock removeDocumentLock​(String owner)
        Description copied from class: BaseDocument
        Removes a lock from this recently created and unsaved document.
        Specified by:
        removeDocumentLock in class BaseDocument<Node>
        Parameters:
        owner - the owner to check, or null for no check
        Returns:
        null if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner mismatch