Class SQLSession

java.lang.Object
org.nuxeo.ecm.core.model.BaseSession
org.nuxeo.ecm.core.storage.sql.coremodel.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 Details

    • 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:
    • 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:
    • ORDER_BY_PATH_ASC

      protected static final Pattern ORDER_BY_PATH_ASC
    • ORDER_BY_PATH_DESC

      protected static final Pattern ORDER_BY_PATH_DESC
  • Constructor Details

  • Method Details

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

      protected String idToString(Serializable id)
    • idFromString

      protected Serializable idFromString(String id)
    • 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.
    • getDocumentByUUID

      public Document getDocumentByUUID(String uuid) throws DocumentNotFoundException
      Description copied from interface: Session
      Gets a document given its ID.
      Parameters:
      uuid - the document id
      Returns:
      the document
      Throws:
      DocumentNotFoundException - if the document doesn't exist
    • resolvePath

      public Document resolvePath(String path) throws DocumentNotFoundException
      Description copied from interface: Session
      Gets the document at the given path, if any.
      Throws:
      DocumentNotFoundException - if the document doesn't exist
    • 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
    • query

      public PartialList<Document> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
      Description copied from interface: Session
      Does a query.
    • queryAndFetch

      public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object[] params)
      Description copied from interface: Session
      Does a query and fetch the individual results as maps.
    • queryProjection

      public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object[] params)
      Description copied from interface: Session
      Does a query and fetch the individual results as maps.
    • getDocumentById

      protected Document getDocumentById(Serializable id)
    • getDocumentsById

      protected List<Document> getDocumentsById(List<Serializable> ids)
    • getParent

      protected Document getParent(Node node)
    • getPath

      protected String getPath(Node node)
    • getChild

      protected Document getChild(Node node, String name) throws DocumentNotFoundException
      Throws:
      DocumentNotFoundException
    • getChildProperty

      protected Node getChildProperty(Node node, String name, String typeName)
    • getChildPropertyForWrite

      protected Node getChildPropertyForWrite(Node node, String name, String typeName)
    • getChildren

      protected List<Document> getChildren(Node node)
    • hasChild

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

      protected boolean hasChildren(Node node)
    • addChild

      protected Document addChild(Node parent, String name, Long pos, String typeName)
    • addChildProperty

      protected Node addChildProperty(Node parent, String name, Long pos, String typeName)
    • importChild

      protected Document importChild(String uuid, Node parent, String name, Long pos, String typeName, Map<String,Serializable> props)
    • addMixinType

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

      protected boolean removeMixinType(Node node, String mixin)
    • getComplexList

      protected List<Node> getComplexList(Node node, String name)
    • remove

      protected void remove(Node node)
    • notifyDocumentRemove

      protected void notifyDocumentRemove(Node node)
    • notifyDocumentBlobManagerBeforeRemove

      protected void notifyDocumentBlobManagerBeforeRemove(Node node)
    • removeProperty

      protected void removeProperty(Node node)
    • checkIn

      protected Document checkIn(Node node, String label, String checkinComment)
    • checkOut

      protected void checkOut(Node node)
    • restore

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

      protected Document getVersionByLabel(String versionSeriesId, String label)
    • getVersions

      protected List<Document> getVersions(String versionSeriesId)
    • getLastVersion

      public Document getLastVersion(String versionSeriesId)
    • getNodeById

      protected Node getNodeById(Serializable id)
    • 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.