Class SessionImpl

    • Method Detail

      • getMapper

        public Mapper getMapper()
        Description copied from interface: Session
        Gets the low-level Mapper for this session.
        Specified by:
        getMapper in interface Session
        Returns:
        the mapper
      • clearCaches

        protected int clearCaches()
        Clears all the caches. Called by RepositoryManagement.
      • save

        public void save()
        Description copied from interface: Session
        Saves the modifications to persistent storage.

        Modifications will be actually written only upon transaction commit.

        Specified by:
        save in interface Session
      • flush

        protected void flush()
      • doFlush

        protected void doFlush()
      • getFulltextWorks

        protected List<WorkgetFulltextWorks()
        Gets the fulltext updates to do. Called at save() time.
        Returns:
        a list of Work instances to schedule post-commit.
      • markIndexingInProgress

        protected void markIndexingInProgress​(Set<Serializable> dirtyIds)
        Mark indexing in progress, so that future copies (including versions) will be indexed as well.
      • sendInvalidationsToOthers

        protected void sendInvalidationsToOthers()
        Post-transaction invalidations notification.

        Called post-transaction by session commit/rollback or transactionless save.

      • processReceivedInvalidations

        protected void processReceivedInvalidations()
        Processes all invalidations accumulated.

        Called pre-transaction by start or transactionless save;

      • getParentNode

        public Node getParentNode​(Node node)
        Description copied from interface: Session
        Gets the parent of a node.

        The root has a null parent.

        Specified by:
        getParentNode in interface Session
        Parameters:
        node - the node
        Returns:
        the parent node, or null for the root's parent
      • getPath

        public String getPath​(Node node)
        Description copied from interface: Session
        Gets the absolute path of a node.
        Specified by:
        getPath in interface Session
        Parameters:
        node - the node
        Returns:
        the path
      • getNodeByPath

        public Node getNodeByPath​(String path,
                                  Node node)
        Description copied from interface: Session
        Gets a node given its absolute path, or given an existing node and a relative path.
        Specified by:
        getNodeByPath in interface Session
        Parameters:
        path - the path
        node - the node (ignored for absolute paths)
        Returns:
        the node, or null if not found
      • addMixinType

        public boolean addMixinType​(Node node,
                                    String mixin)
        Description copied from interface: Session
        Adds a mixin to a node.

        Does nothing if the mixin was already present on the node.

        Specified by:
        addMixinType in interface Session
        Parameters:
        node - the node
        mixin - the mixin name
        Returns:
        true if the mixin was added, or false if it is already present
      • removeMixinType

        public boolean removeMixinType​(Node node,
                                       String mixin)
        Description copied from interface: Session
        Removes a mixin from a node.

        It's not possible to remove a mixin coming from the primary type.

        Specified by:
        removeMixinType in interface Session
        Parameters:
        node - the node
        mixin - the mixin
        Returns:
        true if the mixin was removed, or false if it isn't present or is present on the type or does not exist
      • scroll

        public ScrollResult<Stringscroll​(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.
        Specified by:
        scroll in interface Session
      • scroll

        public ScrollResult<Stringscroll​(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.
        Specified by:
        scroll in interface Session
      • addChildNode

        public Node addChildNode​(Node parent,
                                 String name,
                                 Long pos,
                                 String typeName,
                                 boolean complexProp)
        Description copied from interface: Session
        Creates a new child node.
        Specified by:
        addChildNode in interface Session
        Parameters:
        parent - the parent to which the child is added
        name - the child name
        pos - the child position, or null
        typeName - the child type
        complexProp - whether this is a complex property (true) or a regular child (false)
        Returns:
        the new node
      • addChildNode

        public Node addChildNode​(Serializable id,
                                 Node parent,
                                 String name,
                                 Long pos,
                                 String typeName,
                                 boolean complexProp)
        Description copied from interface: Session
        Creates a new child node with given id (used for import).
        Specified by:
        addChildNode in interface Session
        Parameters:
        id - the id
        parent - the parent to which the child is added
        name - the child name
        pos - the child position, or null
        typeName - the child type
        complexProp - whether this is a complex property (true) or a regular child (false)
        Returns:
        the new node
      • addProxy

        public Node addProxy​(Serializable targetId,
                             Serializable versionableId,
                             Node parent,
                             String name,
                             Long pos)
        Description copied from interface: Session
        Creates a proxy for a version node.
        Specified by:
        addProxy in interface Session
        Parameters:
        targetId - the target id
        versionableId - the version series id
        parent - the parent to which the proxy is added
        name - the proxy name
        pos - the proxy position
        Returns:
        the new proxy node
      • hasChildNode

        public boolean hasChildNode​(Node parent,
                                    String name,
                                    boolean complexProp)
        Description copied from interface: Session
        Checks if a child node with the given name exists.

        There are two kinds of children, the regular children documents and the complex properties. The boolean complexProp allows a choice between those.

        Specified by:
        hasChildNode in interface Session
        Parameters:
        parent - the parent node
        name - the child name
        complexProp - whether to check complex properties or regular children
        Returns:
        true if a child node with that name exists
      • getChildNode

        public Node getChildNode​(Node parent,
                                 String name,
                                 boolean complexProp)
        Description copied from interface: Session
        Gets a child node given its parent and name.
        Specified by:
        getChildNode in interface Session
        Parameters:
        parent - the parent node
        name - the child name
        complexProp - whether to check complex properties or regular children
        Returns:
        the child node, or null is not found
      • hasChildren

        public boolean hasChildren​(Node parent,
                                   boolean complexProp)
        Description copied from interface: Session
        Checks it a node has children.
        Specified by:
        hasChildren in interface Session
        Parameters:
        parent - the parent node
        complexProp - whether to check complex properties or regular children
        Returns:
        true if the parent has children
      • getChildren

        public List<NodegetChildren​(Node parent,
                                      String name,
                                      boolean complexProp)
        Description copied from interface: Session
        Gets the children of a node.
        Specified by:
        getChildren in interface Session
        Parameters:
        parent - the parent node
        name - the children name to get (for lists of complex properties), or null for all
        complexProp - whether to check complex properties or regular children
        Returns:
        the collection of children
      • orderBefore

        public void orderBefore​(Node parent,
                                Node source,
                                Node dest)
        Description copied from interface: Session
        Order the given source child node before the destination child node. The source node will be placed before the destination one. If destination is null, the source node will be appended at the end of the children list.
        Specified by:
        orderBefore in interface Session
        Parameters:
        parent - the parent node
        source - the child node to move
        dest - the child node before which to place the source node, or null to move at the end
      • move

        public Node move​(Node source,
                         Node parent,
                         String name)
        Description copied from interface: Session
        Moves a node to a new location with a new name.

        A Session.save() is automatically done first.

        Specified by:
        move in interface Session
        Parameters:
        source - the node to move
        parent - the new parent to which the node is moved
        name - the new node name
        Returns:
        the moved node
      • copy

        public Node copy​(Node source,
                         Node parent,
                         String name,
                         Consumer<Node> afterRecordCopy)
        Description copied from interface: Session
        Copies a node to a new location with a new name.

        A Session.save() is automatically done first.

        Specified by:
        copy in interface Session
        Parameters:
        source - the node to copy
        parent - the new parent to which the node is copied
        name - the new node name
        afterRecordCopy - a consumer called on nodes that were records before copy
        Returns:
        the copied node
      • checkIn

        public Node checkIn​(Node node,
                            String label,
                            String checkinComment)
        Description copied from interface: Session
        Checks in a checked-out node: creates a new version with a copy of its information.

        A Session.save() is automatically done first.

        Specified by:
        checkIn in interface Session
        Parameters:
        node - the node to check in
        label - the label for the version
        checkinComment - the description for the version
        Returns:
        the created version
      • checkOut

        public void checkOut​(Node node)
        Description copied from interface: Session
        Checks out a checked-in node.
        Specified by:
        checkOut in interface Session
        Parameters:
        node - the node to check out
      • restore

        public void restore​(Node node,
                            Node version)
        Description copied from interface: Session
        Restores a node to a given version.

        The restored node is checked in.

        Specified by:
        restore in interface Session
        Parameters:
        node - the node to restore
        version - the version to restore from
      • getVersionByLabel

        public Node getVersionByLabel​(Serializable versionSeriesId,
                                      String label)
        Description copied from interface: Session
        Gets a version given its version series id and label.
        Specified by:
        getVersionByLabel in interface Session
        Parameters:
        versionSeriesId - the version series id
        label - the label
        Returns:
        the version node, or null if not found
      • getLastVersion

        public Node getLastVersion​(Serializable versionSeriesId)
        Description copied from interface: Session
        Gets the last version for a given version series id.

        A Session.save() is automatically done first.

        Specified by:
        getLastVersion in interface Session
        Parameters:
        versionSeriesId - the version series id
        Returns:
        the last version, or null if no versions exist
      • getVersions

        public List<NodegetVersions​(Serializable versionSeriesId)
        Description copied from interface: Session
        Gets all the versions for a given version series id.

        A Session.save() is automatically done first.

        Specified by:
        getVersions in interface Session
        Parameters:
        versionSeriesId - the version series id
        Returns:
        the list of versions
      • getProxies

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

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

        Otherwise all proxies to the same version series than the document are retrieved.

        A Session.save() is automatically done first.

        Specified by:
        getProxies in interface Session
        Parameters:
        document - the document
        parent - the parent, or null
        Returns:
        the list of proxies
      • getProxies

        public List<NodegetProxies​(Node document)
        Description copied from interface: Session
        Finds the proxies for a document. (The document may be a version or a live document)
        Specified by:
        getProxies in interface Session
        Parameters:
        document - the document
        Returns:
        the list of proxies, or an empty list
      • query

        public PartialList<Serializablequery​(String query,
                                               QueryFilter queryFilter,
                                               boolean countTotal)
        Description copied from interface: Session
        Makes a NXQL query to the database.
        Specified by:
        query in interface Session
        Parameters:
        query - the query
        queryFilter - the query filter
        countTotal - if true, also count the total size without offset/limit
        Returns:
        the resulting list with total size included
      • query

        public PartialList<Serializablequery​(String query,
                                               String queryType,
                                               QueryFilter queryFilter,
                                               long countUpTo)
        Description copied from interface: Session
        Makes a query to the database.
        Specified by:
        query in interface Session
        Parameters:
        query - the query
        queryType - the query type
        queryFilter - the query filter
        countUpTo - if -1, also count the total size without offset/limit.
        If 0, don't count the total size.
        If n, count the total number if there are less than n documents otherwise set the size to -1.
        Returns:
        the resulting list with total size included
      • queryAndFetch

        public IterableQueryResult queryAndFetch​(String query,
                                                 String queryType,
                                                 QueryFilter queryFilter,
                                                 Object... params)
        Description copied from interface: Session
        Makes a query to the database and returns an iterable (which must be closed when done).
        Specified by:
        queryAndFetch in interface Session
        Parameters:
        query - the query
        queryType - the query type
        queryFilter - the query filter
        params - optional query-type-dependent parameters
        Returns:
        an iterable, which must be closed when done
      • queryAndFetch

        public IterableQueryResult queryAndFetch​(String query,
                                                 String queryType,
                                                 QueryFilter queryFilter,
                                                 boolean distinctDocuments,
                                                 Object... params)
        Description copied from interface: Session
        Makes a query to the database and returns an iterable (which must be closed when done).
        Specified by:
        queryAndFetch in interface Session
        Parameters:
        query - the query
        queryType - the query type
        queryFilter - the query filter
        distinctDocuments - if true then a maximum of one row per document will be returned
        params - optional query-type-dependent parameters
        Returns:
        an iterable, which must be closed when done
      • queryProjection

        public PartialList<Map<String,​Serializable>> queryProjection​(String query,
                                                                           String queryType,
                                                                           QueryFilter queryFilter,
                                                                           boolean distinctDocuments,
                                                                           long countUpTo,
                                                                           Object... params)
        Description copied from interface: Session
        Makes a query to the database.
        Specified by:
        queryProjection in interface Session
        Parameters:
        query - the query
        queryType - the query type
        queryFilter - the query filter
        distinctDocuments - if true then a maximum of one row per document will be returned
        countUpTo - if -1, also count the total size without offset/limit.
        If 0, don't count the total size.
        If n, count the total number if there are less than n documents otherwise set the size to -1.
        params - optional query-type-dependent parameters
        Returns:
        a projection
      • requireReadAclsUpdate

        public void requireReadAclsUpdate()
        Description copied from interface: Session
        Read ACLs are optimized ACLs for the read permission, they need to be updated after document creation or ACL change.

        This method flag the current session, the read ACLs update will be done automatically at save time.

        Specified by:
        requireReadAclsUpdate in interface Session
      • start

        public void start()
      • end

        public void end()
      • commit

        public void commit()
      • isFulltextStoredInBlob

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

        public void markUserChange​(Serializable id)
        Description copied from interface: Session
        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 Session
        Parameters:
        id - the document id