Class SessionDelegate


  • public class SessionDelegate
    extends java.lang.Object
    TODO document
    • Constructor Detail

      • SessionDelegate

        public SessionDelegate​(@NotNull
                               @NotNull ContentSession contentSession,
                               @NotNull
                               @NotNull SecurityProvider securityProvider,
                               @NotNull
                               @NotNull RefreshStrategy refreshStrategy,
                               @NotNull
                               @NotNull java.lang.ThreadLocal<java.lang.Long> threadSaveCount,
                               @NotNull
                               @NotNull StatisticManager statisticManager,
                               @NotNull
                               @NotNull Clock clock)
        Create a new session delegate for a ContentSession. The refresh behaviour of the session is governed by the value of the refreshInterval argument: if the session has been idle longer than that value, an implicit refresh will take place. In addition a refresh can always be scheduled from the next access by an explicit call to refreshAtNextAccess(). This is typically done from within the observation event dispatcher in order.
        Parameters:
        contentSession - the content session
        securityProvider - the security provider
        refreshStrategy - the refresh strategy used for auto refreshing this session
        statisticManager - the statistics manager for tracking session operations
    • Method Detail

      • getSessionStats

        @NotNull
        public @NotNull SessionStats getSessionStats()
      • refreshAtNextAccess

        public void refreshAtNextAccess()
      • sync

        public <T> java.util.Iterator<T> sync​(java.util.Iterator<T> iterator)
        Wrap the passed iterator in an iterator that synchronizes all access to the underlying session.
        Type Parameters:
        T -
        Parameters:
        iterator - iterator to synchronized
        Returns:
        synchronized iterator
      • perform

        @NotNull
        public <T> T perform​(@NotNull
                             @NotNull SessionOperation<T> sessionOperation)
                      throws RepositoryException
        Performs the passed SessionOperation in a safe execution context. This context ensures that the session is refreshed if necessary and that refreshing occurs before the session operation is performed and the refreshing is done only once.
        Type Parameters:
        T - return type of sessionOperation
        Parameters:
        sessionOperation - the SessionOperation to perform
        Returns:
        the result of sessionOperation.perform()
        Throws:
        RepositoryException
        See Also:
        getRoot()
      • safePerform

        @NotNull
        public <T> T safePerform​(SessionOperation<T> sessionOperation)
        Same as perform(SessionOperation) unless this method expects SessionOperation.perform() not to throw a RepositoryException. Such exceptions will be wrapped into a RuntimeException and rethrown as they are considered an internal error.
        Type Parameters:
        T - return type of sessionOperation
        Parameters:
        sessionOperation - the SessionOperation to perform
        Returns:
        the result of sessionOperation.perform()
        See Also:
        getRoot()
      • safePerformNullable

        @Nullable
        public <T> T safePerformNullable​(SessionOperation<T> sessionOperation)
        Same as performNullable(SessionOperation) unless this method expects SessionOperation.performNullable() not to throw a RepositoryException. Such exceptions will be wrapped into a RuntimeException and rethrown as they are considered an internal error.
        Type Parameters:
        T - return type of sessionOperation
        Parameters:
        sessionOperation - the SessionOperation to perform
        Returns:
        the result of sessionOperation.performNullable()
      • getContentSession

        @NotNull
        public @NotNull ContentSession getContentSession()
      • isAlive

        public boolean isAlive()
        Determine whether this session is alive and has not been logged out or become stale by other means.
        Returns:
        true if this session is alive, false otherwise.
      • getUpdateCount

        public long getUpdateCount()
        Returns:
        session update counter
      • setUserData

        public void setUserData​(java.lang.String userData)
      • commit

        public void commit​(Root root)
                    throws CommitFailedException
        Commits the changes applied to the given root. The user data (if any) currently attached to this session is passed as the commit message. Used both for normal save() calls and for the various direct-to-workspace operations.
        Throws:
        CommitFailedException - if the commit failed
      • getAuthInfo

        @NotNull
        public @NotNull AuthInfo getAuthInfo()
      • logout

        public void logout()
      • getRootNode

        @Nullable
        public @Nullable NodeDelegate getRootNode()
      • getNode

        @Nullable
        public @Nullable NodeDelegate getNode​(java.lang.String path)
        NodeDelegate at the given path
        Parameters:
        path - Oak path
        Returns:
        The NodeDelegate at path or null if none exists or not accessible.
      • getItem

        @Nullable
        public @Nullable ItemDelegate getItem​(java.lang.String path)
        Returns the node or property delegate at the given path.
        Parameters:
        path - Oak path
        Returns:
        node or property delegate, or null if none exists
      • getNodeByIdentifier

        @Nullable
        public @Nullable NodeDelegate getNodeByIdentifier​(java.lang.String id)
      • treeLookedUpByIdentifier

        protected void treeLookedUpByIdentifier​(@NotNull
                                                @NotNull Tree tree)
      • getProperty

        @Nullable
        public @Nullable PropertyDelegate getProperty​(java.lang.String path)
        PropertyDelegate at the given path
        Parameters:
        path - Oak path
        Returns:
        The PropertyDelegate at path or null if none exists or not accessible.
      • hasPendingChanges

        public boolean hasPendingChanges()
      • save

        public void save​(java.lang.String path)
                  throws RepositoryException
        Save the subtree rooted at the given path, or the entire transient space if given the root path or null.

        This implementation only performs the save if the subtree rooted at path contains all transient changes and will throw an UnsupportedRepositoryOperationException otherwise.

        Parameters:
        path -
        Throws:
        RepositoryException
      • refresh

        public void refresh​(boolean keepChanges)
      • getWorkspaceName

        @NotNull
        public @NotNull java.lang.String getWorkspaceName()
      • move

        public void move​(java.lang.String srcPath,
                         java.lang.String destPath,
                         boolean transientOp)
                  throws RepositoryException
        Move a node
        Parameters:
        srcPath - oak path to the source node to copy
        destPath - oak path to the destination
        transientOp - whether or not to perform the move in transient space
        Throws:
        RepositoryException
      • getQueryEngine

        @NotNull
        public @NotNull QueryEngine getQueryEngine()
      • getPermissionProvider

        @NotNull
        public @NotNull PermissionProvider getPermissionProvider()
      • getRoot

        @NotNull
        public @NotNull Root getRoot()
        The current Root instance this session delegate instance operates on. To ensure the returned root reflects the correct repository revision access should only be done from within a SessionOperation closure through perform(SessionOperation).
        Returns:
        current root
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object