Class ReadOnlyVersionManager
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager
-
- Direct Known Subclasses:
ReadWriteVersionManager
,ReadWriteVersionManager
public abstract class ReadOnlyVersionManager extends Object
ReadOnlyVersionManager
provides implementations for read-only version operations modeled after the ones available inVersionManager
.
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyVersionManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected @NotNull Tree
checkVersionable(@NotNull Tree tree)
Checks if the giventree
is versionable and throws aUnsupportedRepositoryOperationException
if it is not.@Nullable Tree
getBaseVersion(@NotNull Tree versionable)
Returns the tree representing the base version of the given versionable tree ornull
if none exists yet.protected IdentifierManager
getIdentifierManager()
static @NotNull ReadOnlyVersionManager
getInstance(Root root, NamePathMapper namePathMapper)
Return a new instance ofReadOnlyVersionManager
that reads version information from the tree atVersionConstants.VERSION_STORE_PATH
.protected abstract @NotNull ReadOnlyNodeTypeManager
getNodeTypeManager()
@Nullable Tree
getVersion(@NotNull String uuid)
Returns the version tree with the given uuid.@Nullable Tree
getVersionable(@NotNull Tree versionTree, @NotNull String workspaceName)
Tries to retrieve the tree corresponding to specifiedversionTree
outside of the version storage based on versionable path information stored with the version history.@Nullable Tree
getVersionHistory(@NotNull Tree versionable)
Returns the tree representing the version history of the given versionable tree ornull
if none exists yet.@NotNull String
getVersionHistoryPath(@NotNull String uuid)
Returns the path of the version history for the givenuuid
.protected abstract @NotNull Tree
getVersionStorage()
protected abstract @NotNull Root
getWorkspaceRoot()
/**boolean
isCheckedOut(@NotNull Tree tree)
Returnstrue
if the tree is checked out; otherwisefalse
.protected boolean
isVersionable(@NotNull Tree tree)
Returnstrue
if the giventree
is of typemix:versionable
;false
otherwise.static boolean
isVersionStoreTree(@NotNull Tree tree)
Returnstrue
if the specified tree hasVersionConstants.REP_VERSIONSTORAGE
defines as primary node type i.e.
-
-
-
Method Detail
-
getVersionStorage
@NotNull protected abstract @NotNull Tree getVersionStorage()
- Returns:
- the read-only
Tree
for the jcr:versionStorage node. The returnedTree
instance must be up-to-date with theRoot
returned bygetWorkspaceRoot()
.
-
getWorkspaceRoot
@NotNull protected abstract @NotNull Root getWorkspaceRoot()
/**- Returns:
- the
Root
of the workspace.
-
getNodeTypeManager
@NotNull protected abstract @NotNull ReadOnlyNodeTypeManager getNodeTypeManager()
- Returns:
- the node type manager of this repository.
-
getInstance
@NotNull public static @NotNull ReadOnlyVersionManager getInstance(Root root, NamePathMapper namePathMapper)
Return a new instance ofReadOnlyVersionManager
that reads version information from the tree atVersionConstants.VERSION_STORE_PATH
.- Parameters:
root
- The root to read version information from.namePathMapper
- TheNamePathMapper
to use.- Returns:
- a new instance of
ReadOnlyVersionManager
.
-
isCheckedOut
public boolean isCheckedOut(@NotNull @NotNull Tree tree)
Returnstrue
if the tree is checked out; otherwisefalse
. The root node is always considered checked out.- Parameters:
tree
- the tree to check.- Returns:
- whether the tree is checked out or not.
-
getVersionHistory
@Nullable public @Nullable Tree getVersionHistory(@NotNull @NotNull Tree versionable) throws UnsupportedRepositoryOperationException, RepositoryException
Returns the tree representing the version history of the given versionable tree ornull
if none exists yet.- Parameters:
versionable
- the versionable tree.- Returns:
- the version history or
null
if none exists yet. - Throws:
UnsupportedRepositoryOperationException
- if the versionable tree is not actually versionable.RepositoryException
- if an error occurs while checking the node type of the tree.
-
getVersion
@Nullable public @Nullable Tree getVersion(@NotNull @NotNull String uuid)
Returns the version tree with the given uuid.- Parameters:
uuid
- the uuid of the version tree.- Returns:
- the version tree or
null
if there is none.
-
getVersionHistoryPath
@NotNull public @NotNull String getVersionHistoryPath(@NotNull @NotNull String uuid)
Returns the path of the version history for the givenuuid
. The returned path is relative to the version storage tree as returned bygetVersionStorage()
.- Parameters:
uuid
- the uuid of the versionable node- Returns:
- the relative path of the version history for the given uuid.
-
getBaseVersion
@Nullable public @Nullable Tree getBaseVersion(@NotNull @NotNull Tree versionable) throws UnsupportedRepositoryOperationException, RepositoryException
Returns the tree representing the base version of the given versionable tree ornull
if none exists yet. This is the case when a versionable node is created, but is not yet saved.- Parameters:
versionable
- the versionable tree.- Returns:
- the tree representing the base version or
null
. - Throws:
UnsupportedRepositoryOperationException
- if the versionable tree is not actually versionable.RepositoryException
- if an error occurs while checking the node type of the tree.
-
isVersionStoreTree
public static boolean isVersionStoreTree(@NotNull @NotNull Tree tree)
Returnstrue
if the specified tree hasVersionConstants.REP_VERSIONSTORAGE
defines as primary node type i.e. is part of the intermediate version storage structure that contains the version histories and the versions.- Parameters:
tree
- The tree to be tested.- Returns:
true
if the target node hasVersionConstants.REP_VERSIONSTORAGE
defines as primary node type;false
otherwise.
-
getVersionable
@Nullable public @Nullable Tree getVersionable(@NotNull @NotNull Tree versionTree, @NotNull @NotNull String workspaceName)
Tries to retrieve the tree corresponding to specifiedversionTree
outside of the version storage based on versionable path information stored with the version history. The following cases are distinguished:- Version History: If the given tree is a version history the
associated versionable tree in the specified workspace is being returned
based on the information stored in the versionable path property. If
no versionable path property is present
null
is returned. - Version: Same as for version history.
- Version Labels: Same as for version history.
- Frozen Node: If the given tree forms part of a frozen node the path of the target node is computed from the versionable path and the relative path of the frozen node.
- Other Nodes: If the specified tree is not part of the tree structure
defined by a version history,
null
will be returned.
- Parameters:
versionTree
- The tree from within the version storage for which that versionable correspondent should be retrieved.workspaceName
- The name of the workspace for which the target should be retrieved.- Returns:
- A existing or non-existing tree pointing to the location of the
correspondent tree outside of the version storage or
null
if the versionable path property for the specified workspace is missing or if the given tree is not located within the tree structure defined by a version history. - See Also:
VersionConstants.MIX_REP_VERSIONABLE_PATHS
- Version History: If the given tree is a version history the
associated versionable tree in the specified workspace is being returned
based on the information stored in the versionable path property. If
no versionable path property is present
-
getIdentifierManager
protected IdentifierManager getIdentifierManager()
- Returns:
- an identifier manager that is able to resolve identifiers of nodes in the version storage.
-
checkVersionable
@NotNull protected @NotNull Tree checkVersionable(@NotNull @NotNull Tree tree) throws UnsupportedRepositoryOperationException, RepositoryException
Checks if the giventree
is versionable and throws aUnsupportedRepositoryOperationException
if it is not.- Parameters:
tree
- the tree to check.- Returns:
- the passed tree.
- Throws:
UnsupportedRepositoryOperationException
- if the tree is not versionable.RepositoryException
- if an error occurs while checking the node type of the tree.
-
isVersionable
protected boolean isVersionable(@NotNull @NotNull Tree tree)
Returnstrue
if the giventree
is of typemix:versionable
;false
otherwise.- Parameters:
tree
- the tree to check.- Returns:
- whether the
tree
is versionable.
-
-