Class SessionDelegate
java.lang.Object
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate
TODO document
-
Constructor Summary
ConstructorsConstructorDescriptionSessionDelegate(@NotNull ContentSession contentSession, @NotNull SecurityProvider securityProvider, @NotNull RefreshStrategy refreshStrategy, @NotNull ThreadLocal<Long> threadSaveCount, @NotNull StatisticManager statisticManager, @NotNull Clock clock, @NotNull SessionSaveDelayer sessionSaveDelayer) Create a new session delegate for aContentSession. -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck that this session is alive.voidcheckProtectedNode(String path) voidcommit()Commits the changes currently in the transient space.voidCommits the changes applied to the given root.@NotNull AuthInfo@NotNull ContentSession@NotNull IdentifierManager@Nullable ItemDelegateReturns the node or property delegate at the given path.@Nullable NodeDelegateNodeDelegateat the given path@Nullable NodeDelegate@NotNull PermissionProvider@Nullable PropertyDelegategetProperty(String path) PropertyDelegateat the given path@NotNull QueryEngine@NotNull RootgetRoot()The currentRootinstance this session delegate instance operates on.@Nullable NodeDelegate@NotNull SessionStatslong@NotNull StringbooleanbooleanisAlive()Determine whether this session is alive and has not been logged out or become stale by other means.voidlogout()voidMove a node<T> Tperform(@NotNull SessionOperation<T> sessionOperation) Performs the passedSessionOperationin a safe execution context.<T> TperformNullable(@NotNull SessionOperation<T> sessionOperation) Same asperform(org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation)but with the option to returnnull; thus callingSessionOperation.performNullable()voidperformVoid(SessionOperation<Void> sessionOperation) Same asperform(org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation)for calls that don't expect any return value; thus callingSessionOperation.performVoid().voidrefresh(boolean keepChanges) void<T> TsafePerform(SessionOperation<T> sessionOperation) Same asperform(SessionOperation)unless this method expectsSessionOperation.perform()not to throw aRepositoryException.<T> TsafePerformNullable(SessionOperation<T> sessionOperation) Same asperformNullable(SessionOperation)unless this method expectsSessionOperation.performNullable()not to throw aRepositoryException.voidSave the subtree rooted at the givenpath, or the entire transient space if given the root path ornull.voidsetUserData(String userData) <T> Iterator<T>Wrap the passediteratorin an iterator that synchronizes all access to the underlying session.toString()protected voidtreeLookedUpByIdentifier(@NotNull Tree tree)
-
Constructor Details
-
SessionDelegate
public SessionDelegate(@NotNull @NotNull ContentSession contentSession, @NotNull @NotNull SecurityProvider securityProvider, @NotNull @NotNull RefreshStrategy refreshStrategy, @NotNull @NotNull ThreadLocal<Long> threadSaveCount, @NotNull @NotNull StatisticManager statisticManager, @NotNull @NotNull Clock clock, @NotNull @NotNull SessionSaveDelayer sessionSaveDelayer) Create a new session delegate for aContentSession. The refresh behaviour of the session is governed by the value of therefreshIntervalargument: 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 torefreshAtNextAccess(). This is typically done from within the observation event dispatcher in order.- Parameters:
contentSession- the content sessionsecurityProvider- the security providerrefreshStrategy- the refresh strategy used for auto refreshing this sessionstatisticManager- the statistics manager for tracking session operationssessionSaveDelayer- the session save delay mechanism
-
-
Method Details
-
getSessionStats
-
refreshAtNextAccess
public void refreshAtNextAccess() -
sync
Wrap the passediteratorin 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 passedSessionOperationin 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 ofsessionOperation- Parameters:
sessionOperation- theSessionOperationto perform- Returns:
- the result of
sessionOperation.perform() - Throws:
RepositoryException- See Also:
-
performNullable
@Nullable public <T> T performNullable(@NotNull @NotNull SessionOperation<T> sessionOperation) throws RepositoryException Same asperform(org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation)but with the option to returnnull; thus callingSessionOperation.performNullable()- Type Parameters:
T- return type ofsessionOperation- Parameters:
sessionOperation- theSessionOperationto perform- Returns:
- the result of
sessionOperation.performNullable(), which might also benull. - Throws:
RepositoryException- See Also:
-
performVoid
Same asperform(org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation)for calls that don't expect any return value; thus callingSessionOperation.performVoid().- Parameters:
sessionOperation- theSessionOperationto perform.- Throws:
RepositoryException- See Also:
-
safePerform
Same asperform(SessionOperation)unless this method expectsSessionOperation.perform()not to throw aRepositoryException. Such exceptions will be wrapped into aRuntimeExceptionand rethrown as they are considered an internal error.- Type Parameters:
T- return type ofsessionOperation- Parameters:
sessionOperation- theSessionOperationto perform- Returns:
- the result of
sessionOperation.perform() - See Also:
-
safePerformNullable
Same asperformNullable(SessionOperation)unless this method expectsSessionOperation.performNullable()not to throw aRepositoryException. Such exceptions will be wrapped into aRuntimeExceptionand rethrown as they are considered an internal error.- Type Parameters:
T- return type ofsessionOperation- Parameters:
sessionOperation- theSessionOperationto perform- Returns:
- the result of
sessionOperation.performNullable()
-
getContentSession
-
isAlive
public boolean isAlive()Determine whether this session is alive and has not been logged out or become stale by other means.- Returns:
trueif this session is alive,falseotherwise.
-
checkAlive
Check that this session is alive.- Throws:
RepositoryException- if this session is not alive- See Also:
-
getUpdateCount
public long getUpdateCount()- Returns:
- session update counter
-
setUserData
-
commit
Commits the changes currently in the transient space. TODO: Consolidate with save().- Throws:
CommitFailedException- if the commit failed
-
commit
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
-
checkProtectedNode
- Throws:
RepositoryException
-
getAuthInfo
-
logout
public void logout() -
getIdManager
-
getRootNode
-
getNode
NodeDelegateat the given path- Parameters:
path- Oak path- Returns:
- The
NodeDelegateatpathornullif none exists or not accessible.
-
getItem
Returns the node or property delegate at the given path.- Parameters:
path- Oak path- Returns:
- node or property delegate, or
nullif none exists
-
getNodeByIdentifier
-
treeLookedUpByIdentifier
-
getProperty
PropertyDelegateat the given path- Parameters:
path- Oak path- Returns:
- The
PropertyDelegateatpathornullif none exists or not accessible.
-
hasPendingChanges
public boolean hasPendingChanges() -
save
Save the subtree rooted at the givenpath, or the entire transient space if given the root path ornull.This implementation only performs the save if the subtree rooted at
pathcontains all transient changes and will throw anUnsupportedRepositoryOperationExceptionotherwise.- Parameters:
path-- Throws:
RepositoryException
-
refresh
public void refresh(boolean keepChanges) -
getWorkspaceName
-
move
Move a node- Parameters:
srcPath- oak path to the source node to copydestPath- oak path to the destinationtransientOp- whether or not to perform the move in transient space- Throws:
RepositoryException
-
getQueryEngine
-
getPermissionProvider
-
getRoot
The currentRootinstance this session delegate instance operates on. To ensure the returned root reflects the correct repository revision access should only be done from within aSessionOperationclosure throughperform(SessionOperation).- Returns:
- current root
-
toString
-
getNamespaces
-