public class StagedNodeTree extends Object
StagedNodeTree provides methods to manipulate a specific revision
of the tree. The changes are recorded and can be persisted by calling
persist(RevisionStore.PutToken).| Constructor and Description |
|---|
StagedNodeTree(RevisionStore store,
Id baseRevisionId)
Creates a new
StagedNodeTree instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String parentNodePath,
String nodeName,
org.apache.jackrabbit.oak.commons.json.JsonObject nodeData)
Creates a new node named
nodeName at parentNodePath. |
void |
copy(String srcPath,
String destPath)
Copies the subtree rooted at
srcPath to destPath. |
boolean |
isEmpty()
Returns
true if there are no staged changes, otherwise returns false. |
Id |
merge(StoredNode ourRoot,
Id newBaseRevisionId,
Id commonAncestorRevisionId,
RevisionStore.PutToken token)
Performs a three-way merge merging our tree (rooted at
ourRoot)
and their tree (identified by newBaseRevisionId),
using the common ancestor revision commonAncestorRevisionId as
base reference. |
void |
move(String srcPath,
String destPath)
Moves the subtree rooted at
srcPath to destPath. |
Id |
persist(RevisionStore.PutToken token)
Persists the staged nodes and returns the
Id of the new root node. |
Id |
rebase(Id baseId,
Id fromId,
Id toId,
RevisionStore.PutToken token) |
void |
remove(String nodePath)
Removes the node at
nodePath. |
void |
reset(Id newBaseRevisionId)
Discards all staged changes and resets the base revision to the
specified new revision id.
|
void |
setProperty(String nodePath,
String propName,
String propValue)
Creates or updates the property named
propName of the specified node. |
public StagedNodeTree(RevisionStore store, Id baseRevisionId)
StagedNodeTree instance.store - revision store used to read from and persist changesbaseRevisionId - id of revision the changes should be based uponpublic void reset(Id newBaseRevisionId)
newBaseRevisionId - id of revision the changes should be based uponpublic boolean isEmpty()
true if there are no staged changes, otherwise returns false.true if there are no staged changes, otherwise returns false.public Id persist(RevisionStore.PutToken token) throws Exception
Id of the new root node.token - Id of new root node or null if there are no changes to persist.Exception - if an error occurspublic Id rebase(Id baseId, Id fromId, Id toId, RevisionStore.PutToken token) throws Exception
Exceptionpublic Id merge(StoredNode ourRoot, Id newBaseRevisionId, Id commonAncestorRevisionId, RevisionStore.PutToken token) throws Exception
ourRoot)
and their tree (identified by newBaseRevisionId),
using the common ancestor revision commonAncestorRevisionId as
base reference.
This instance will be initially reset to newBaseRevisionId, discarding
all currently staged changes.ourRoot - newBaseRevisionId - commonAncestorRevisionId - token - Id of new root nodeExceptionpublic void add(String parentNodePath, String nodeName, org.apache.jackrabbit.oak.commons.json.JsonObject nodeData) throws Exception
nodeName at parentNodePath.parentNodePath - parent node pathnodeName - name of new nodenodeData - JsonObject representation of the node to be addedNotFoundException - if there's no node at parentNodePathException - if a node named nodeName already exists at parentNodePath
or if another error occurspublic void remove(String nodePath) throws Exception
nodePath.nodePath - node pathExceptionpublic void setProperty(String nodePath, String propName, String propValue) throws Exception
propName of the specified node.
if propValue == null the specified property will be removed.nodePath - node pathpropName - property namepropValue - property valueNotFoundException - if there's no node at nodePathException - if another error occurspublic void move(String srcPath, String destPath) throws Exception
srcPath to destPath.srcPath - path of node to be moveddestPath - destination pathNotFoundException - if either the node at srcPath or the parent
node of destPath doesn't existException - if a node already exists at destPath,
if srcPath denotes an ancestor of destPath
or if another error occurspublic void copy(String srcPath, String destPath) throws Exception
srcPath to destPath.srcPath - path of node to be copieddestPath - destination pathNotFoundException - if either the node at srcPath or the parent
node of destPath doesn't existException - if a node already exists at destPath
or if another error occursCopyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.