Class ReadWriteVersionManager
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager
-
- org.apache.jackrabbit.oak.plugins.version.ReadWriteVersionManager
-
public class ReadWriteVersionManager extends ReadOnlyVersionManager
Extends theReadOnlyVersionManager
with methods to modify the version store.
-
-
Constructor Summary
Constructors Constructor Description ReadWriteVersionManager(NodeBuilder versionStorageNode, NodeBuilder workspaceRoot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
calculateVersion(@NotNull NodeBuilder history, @NotNull NodeBuilder versionable)
Copied from Apache Jackrabbit Corevoid
checkin(@NotNull NodeBuilder versionable)
void
checkout(NodeBuilder versionable)
protected @NotNull ReadOnlyNodeTypeManager
getNodeTypeManager()
@NotNull NodeBuilder
getOrCreateVersionHistory(@NotNull NodeBuilder versionable, @NotNull Map<String,Object> infoMap)
Gets or creates the version history for the givenversionable
node.protected @NotNull Tree
getVersionStorage()
protected @NotNull Root
getWorkspaceRoot()
/**void
removeVersionLabel(@NotNull String historyRelPath, @NotNull String label)
Removes a version label from the jcr:versionLabels node of the referenced version history.void
restore(@NotNull NodeBuilder versionable, @NotNull String versionUUID, @Nullable org.apache.jackrabbit.oak.plugins.version.VersionSelector selector)
-
Methods inherited from class org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager
checkVersionable, getBaseVersion, getIdentifierManager, getInstance, getVersion, getVersionable, getVersionHistory, getVersionHistoryPath, isCheckedOut, isVersionable, isVersionStoreTree
-
-
-
-
Constructor Detail
-
ReadWriteVersionManager
public ReadWriteVersionManager(NodeBuilder versionStorageNode, NodeBuilder workspaceRoot)
-
-
Method Detail
-
getVersionStorage
@NotNull protected @NotNull Tree getVersionStorage()
- Specified by:
getVersionStorage
in classReadOnlyVersionManager
- Returns:
- the read-only
Tree
for the jcr:versionStorage node. The returnedTree
instance must be up-to-date with theRoot
returned byReadOnlyVersionManager.getWorkspaceRoot()
.
-
getWorkspaceRoot
@NotNull protected @NotNull Root getWorkspaceRoot()
Description copied from class:ReadOnlyVersionManager
/**- Specified by:
getWorkspaceRoot
in classReadOnlyVersionManager
- Returns:
- the
Root
of the workspace.
-
getNodeTypeManager
@NotNull protected @NotNull ReadOnlyNodeTypeManager getNodeTypeManager()
- Specified by:
getNodeTypeManager
in classReadOnlyVersionManager
- Returns:
- the node type manager of this repository.
-
getOrCreateVersionHistory
@NotNull public @NotNull NodeBuilder getOrCreateVersionHistory(@NotNull @NotNull NodeBuilder versionable, @NotNull @NotNull Map<String,Object> infoMap)
Gets or creates the version history for the givenversionable
node.- Parameters:
versionable
- the versionable node.infoMap
- The additional information as provided byCommitInfo.getInfo()
- Returns:
- the version history node.
- Throws:
IllegalArgumentException
- if the given node does not have ajcr:uuid
property.
-
checkout
public void checkout(NodeBuilder versionable)
-
checkin
public void checkin(@NotNull @NotNull NodeBuilder versionable) throws CommitFailedException
- Throws:
CommitFailedException
-
restore
public void restore(@NotNull @NotNull NodeBuilder versionable, @NotNull @NotNull String versionUUID, @Nullable @Nullable org.apache.jackrabbit.oak.plugins.version.VersionSelector selector) throws CommitFailedException
- Throws:
CommitFailedException
-
removeVersionLabel
public void removeVersionLabel(@NotNull @NotNull String historyRelPath, @NotNull @NotNull String label) throws CommitFailedException
Removes a version label from the jcr:versionLabels node of the referenced version history.- Parameters:
historyRelPath
- relative path from the jcr:versionStorage node to the version history node.label
- the version label.- Throws:
CommitFailedException
- if there is no such version history or if there is no label with the given name.
-
calculateVersion
protected String calculateVersion(@NotNull @NotNull NodeBuilder history, @NotNull @NotNull NodeBuilder versionable) throws IllegalStateException
Copied from Apache Jackrabbit CoreCalculates the name of the new version that will be created by a checkin call. The name is determined as follows:
- first the predecessor version with the shortest name is searched.
- if that predecessor version is the root version, the new version gets the name "{number of successors}+1" + ".0"
- if that predecessor version has no successor, the last digit of it's version number is incremented.
- if that predecessor version has successors but the incremented name does not exist, that name is used.
- otherwise a ".0" is added to the name until a non conflicting name is found.
Example Graph:
jcr:rootVersion | | 1.0 2.0 | 1.1 | 1.2 ---\ ------\ | \ \ 1.3 1.2.0 1.2.0.0 | | 1.4 1.2.1 ----\ | | \ 1.5 1.2.2 1.2.1.0 | | | 1.6 | 1.2.1.1 |-----/ 1.7
- Parameters:
history
- the version historyversionable
- the node to checkin- Returns:
- the new version name
- Throws:
IllegalStateException
- if mandatory version properties are missing.
-
-