org.apache.jackrabbit.mk.model
Class StagedNodeTree

java.lang.Object
  extended by org.apache.jackrabbit.mk.model.StagedNodeTree

public class StagedNodeTree
extends Object

A 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 Summary
StagedNodeTree(RevisionStore store, Id baseRevisionId)
          Creates a new StagedNodeTree instance.
 
Method Summary
 void add(String parentNodePath, String nodeName, 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StagedNodeTree

public StagedNodeTree(RevisionStore store,
                      Id baseRevisionId)
Creates a new StagedNodeTree instance.

Parameters:
store - revision store used to read from and persist changes
baseRevisionId - id of revision the changes should be based upon
Method Detail

reset

public void reset(Id newBaseRevisionId)
Discards all staged changes and resets the base revision to the specified new revision id.

Parameters:
newBaseRevisionId - id of revision the changes should be based upon

isEmpty

public boolean isEmpty()
Returns true if there are no staged changes, otherwise returns false.

Returns:
true if there are no staged changes, otherwise returns false.

persist

public Id persist(RevisionStore.PutToken token)
           throws Exception
Persists the staged nodes and returns the Id of the new root node.

Parameters:
token -
Returns:
Id of new root node or null if there are no changes to persist.
Throws:
Exception - if an error occurs

merge

public Id merge(StoredNode ourRoot,
                Id newBaseRevisionId,
                Id commonAncestorRevisionId,
                RevisionStore.PutToken token)
         throws Exception
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.

This instance will be initially reset to newBaseRevisionId, discarding all currently staged changes.

Parameters:
ourRoot -
newBaseRevisionId -
commonAncestorRevisionId -
token -
Returns:
Id of new root node
Throws:
Exception

add

public void add(String parentNodePath,
                String nodeName,
                JsonObject nodeData)
         throws Exception
Creates a new node named nodeName at parentNodePath.

Parameters:
parentNodePath - parent node path
nodeName - name of new node
nodeData - JsonObject representation of the node to be added
Throws:
NotFoundException - if there's no node at parentNodePath
Exception - if a node named nodeName already exists at parentNodePath or if another error occurs

remove

public void remove(String nodePath)
            throws Exception
Removes the node at nodePath.

Parameters:
nodePath - node path
Throws:
Exception

setProperty

public void setProperty(String nodePath,
                        String propName,
                        String propValue)
                 throws Exception
Creates or updates the property named propName of the specified node.

if propValue == null the specified property will be removed.

Parameters:
nodePath - node path
propName - property name
propValue - property value
Throws:
NotFoundException - if there's no node at nodePath
Exception - if another error occurs

move

public void move(String srcPath,
                 String destPath)
          throws Exception
Moves the subtree rooted at srcPath to destPath.

Parameters:
srcPath - path of node to be moved
destPath - destination path
Throws:
NotFoundException - if either the node at srcPath or the parent node of destPath doesn't exist
Exception - if a node already exists at destPath, if srcPath denotes an ancestor of destPath or if another error occurs

copy

public void copy(String srcPath,
                 String destPath)
          throws Exception
Copies the subtree rooted at srcPath to destPath.

Parameters:
srcPath - path of node to be copied
destPath - destination path
Throws:
NotFoundException - if either the node at srcPath or the parent node of destPath doesn't exist
Exception - if a node already exists at destPath or if another error occurs


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.