Class SQLSession

  • All Implemented Interfaces:
    Session<QueryFilter>

    public class SQLSession
    extends BaseSession
    This class is the bridge between the Nuxeo SPI Session and the actual low-level implementation of the SQL storage session.
    Author:
    Florent Guillaume
    • Field Detail

      • log

        protected final Log log
      • ALLOW_NEGATIVE_ACL_PROPERTY

        public static final String ALLOW_NEGATIVE_ACL_PROPERTY
        Framework property to control whether negative ACLs (deny) are allowed.
        Since:
        6.0
        See Also:
        Constant Field Values
      • COPY_FINDFREENAME_DISABLED_PROP

        public static final String COPY_FINDFREENAME_DISABLED_PROP
        Framework property to disabled free-name collision detection for copy. This is useful when constraints have been added to the database to detect collisions at the database level and raise a ConcurrentUpdateException, thus letting the high-level application deal with collisions.
        Since:
        7.3
        See Also:
        Constant Field Values
      • ORDER_BY_PATH_ASC

        protected static final Pattern ORDER_BY_PATH_ASC
      • ORDER_BY_PATH_DESC

        protected static final Pattern ORDER_BY_PATH_DESC
    • Method Detail

      • getRootDocument

        public Document getRootDocument()
        Description copied from interface: Session
        Gets the root document in this repository.
        Returns:
        the root document
      • getNullDocument

        public Document getNullDocument()
        Description copied from interface: Session
        Gets the null document, to be used as a fake parent to add placeless children.
        Returns:
        the null document
      • destroy

        public void destroy()
        Description copied from interface: Session
        Destroys this session.
      • save

        public void save()
        Description copied from interface: Session
        Saves this session.
      • getRepositoryName

        public String getRepositoryName()
        Description copied from interface: Session
        Gets the repository that created this session.
        Returns:
        the repository
      • scroll

        public ScrollResult<String> scroll​(String query,
                                           int batchSize,
                                           int keepAliveSeconds)
        Description copied from interface: Session
        Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.
      • scroll

        public ScrollResult<String> scroll​(String query,
                                           QueryFilter queryFilter,
                                           int batchSize,
                                           int keepAliveSeconds)
        Description copied from interface: Session
        Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.
      • scroll

        public ScrollResult<String> scroll​(String scrollId)
        Description copied from interface: Session
        Get the next batch of result containing id of documents.
      • orderBefore

        protected void orderBefore​(Node node,
                                   Node src,
                                   Node dest)
      • move

        public Document move​(Document source,
                             Document parent,
                             String name)
        Description copied from interface: Session
        Moves the source document to the given folder.

        If the destination document is not a folder an exception is thrown.

        Parameters:
        source - the source document to move
        parent - the destination folder
        name - the new name of the document or null if the original name should be preserved
      • findFreeName

        protected String findFreeName​(Node parentNode,
                                      String name)
      • copy

        public Document copy​(Document source,
                             Document parent,
                             String name)
        Description copied from interface: Session
        Copies the source document to the given folder.

        If the destination document is not a folder, an exception is thrown.

      • notifyDocumentBlobManagerAfterCopy

        protected void notifyDocumentBlobManagerAfterCopy​(Node node)
      • getVersion

        public Document getVersion​(String versionableId,
                                   VersionModel versionModel)
        Description copied from interface: Session
        Gets a version of a document, given its versionable id and label.

        The version model contains the label of the version to look for. On return, it is filled with the version's description and creation date.

        Parameters:
        versionableId - the versionable id
        versionModel - the version model
        Returns:
        the version, or null if not found
      • createProxy

        public Document createProxy​(Document doc,
                                    Document folder)
        Description copied from interface: Session
        Creates a generic proxy to the given document inside the given folder.
        Parameters:
        doc - the document
        folder - the folder
        Returns:
        the proxy
      • getProxies

        public List<Document> getProxies​(Document document,
                                         Document parent)
        Description copied from interface: Session
        Finds the proxies for a document. If the folder is not null, the search will be limited to its children.

        If the document is a version, then only proxies to that version will be looked up.

        Parameters:
        document - the document or version
        parent - the folder, or null
        Returns:
        the list of proxies if any is found otherwise an empty list
      • getProxies

        public List<Document> getProxies​(Document doc)
        Description copied from interface: Session
        Finds the proxies for a document. (The document may be a version or a live document)
        Parameters:
        doc - the document or version
        Returns:
        the list of proxies if any is found otherwise an empty list
      • setProxyTarget

        public void setProxyTarget​(Document proxy,
                                   Document target)
        Description copied from interface: Session
        Sets a proxies' target.

        The target must have the same version series as the proxy.

        Parameters:
        proxy - the proxy
        target - the new target
      • importDocument

        public Document importDocument​(String uuid,
                                       Document parent,
                                       String name,
                                       String typeName,
                                       Map<String,​Serializable> properties)
        Description copied from interface: Session
        Imports a document with a given id and parent.

        The document can then be filled with the normal imported properties.

        Parameters:
        uuid - the document uuid
        parent - the document parent, or null for a version
        name - the document name in its parent
        typeName - the document type, or ecm:proxy for a proxy
        properties - system properties of the document, which will vary depending whether it's a live document, a version or a proxy (see the various IMPORT_* constants of CoreSession)
        Returns:
        a writable Document, even for proxies and versions
      • getPath

        protected String getPath​(Node node)
      • getChildPropertyForWrite

        protected Node getChildPropertyForWrite​(Node node,
                                                String name,
                                                String typeName)
      • hasChild

        protected boolean hasChild​(Node node,
                                   String name)
      • hasChildren

        protected boolean hasChildren​(Node node)
      • addMixinType

        protected boolean addMixinType​(Node node,
                                       String mixin)
      • removeMixinType

        protected boolean removeMixinType​(Node node,
                                          String mixin)
      • remove

        protected void remove​(Node node)
      • notifyDocumentRemove

        protected void notifyDocumentRemove​(Node node)
      • notifyDocumentBlobManagerBeforeRemove

        protected void notifyDocumentBlobManagerBeforeRemove​(Node node)
      • removeProperty

        protected void removeProperty​(Node node)
      • checkOut

        protected void checkOut​(Node node)
      • restore

        protected void restore​(Node node,
                               Node version)
      • getVersionByLabel

        protected Document getVersionByLabel​(String versionSeriesId,
                                             String label)
      • getLastVersion

        public Document getLastVersion​(String versionSeriesId)
      • getLockManager

        public LockManager getLockManager()
        Description copied from interface: Session
        Gets the lock manager for this session.
        Returns:
        the lock manager
      • isNegativeAclAllowed

        public boolean isNegativeAclAllowed()
        Description copied from interface: Session
        Returns true if negative ACLs are allowed.

        Negative ACLs are ACLs that include an ACE with a deny (isGranted=false). This does not include the full-blocking ACE for Everyone/Everything, which is always allowed.

        Returns:
        true if negative ACLs are allowed
      • updateReadACLs

        public void updateReadACLs​(Collection<String> docIds)
        Description copied from interface: Session
        Updates the Read ACLs for some documents.
        Parameters:
        docIds - the document ids
      • setACP

        public void setACP​(Document doc,
                           ACP acp,
                           boolean overwrite)
      • getACP

        public ACP getACP​(Document doc)
        Description copied from class: BaseSession
        Gets the ACP for the document (without any inheritance).
        Specified by:
        getACP in class BaseSession
        Parameters:
        doc - the document
        Returns:
        the ACP
      • aclRowsToACP

        protected static ACP aclRowsToACP​(ACLRow[] acls)
      • acpToAclRows

        protected static ACLRow[] acpToAclRows​(ACP acp)
      • updateAclRows

        protected static ACLRow[] updateAclRows​(ACLRow[] aclrows,
                                                ACP acp)
      • getACEkey

        protected static String getACEkey​(ACE ace)
        Key to distinguish ACEs
      • getACLrowKey

        protected static String getACLrowKey​(ACLRow aclrow)
        Key to distinguish ACLRows
      • addACLRow

        protected static void addACLRow​(List<ACLRow> aclrows,
                                        String name,
                                        ACE ace)
      • isFulltextStoredInBlob

        public boolean isFulltextStoredInBlob()
        Description copied from interface: Session
        Checks if fulltext extracted from the binary fields is internally stored as a blob.
        Returns:
        true if fulltext from binaries is store as a blob
      • getBinaryFulltext

        public Map<String,​String> getBinaryFulltext​(String id)
        Description copied from interface: Session
        Gets the fulltext extracted from the binary fields.
      • removeDocument

        public void removeDocument​(String id)
        Description copied from interface: Session
        Removes a document. In DBS, this removal is done without checking if proxies are targeting the document, or if it has any children.
        Parameters:
        id - the document id
      • isChangeTokenEnabled

        public boolean isChangeTokenEnabled()
      • markUserChange

        public void markUserChange​(Serializable id)
      • start

        public void start()
        Description copied from interface: Session
        Start the transaction.
      • end

        public void end()
        Description copied from interface: Session
        Called just before the transaction is committed or rolled back.
      • commit

        public void commit()
        Description copied from interface: Session
        Commit the transaction.
      • rollback

        public void rollback()
        Description copied from interface: Session
        Rollback the transaction.