org.jboss.dna.graph.request
Class RequestBuilder

java.lang.Object
  extended by org.jboss.dna.graph.request.RequestBuilder

public abstract class RequestBuilder
extends Object

A component that can be used to build requests while allowing different strategies for how requests are handled. Subclasses can simply override the process(Request) method to define what happens with each request.


Method Summary
 UpdateValuesRequest addValues(String workspaceName, Location on, Name property, List<Object> values)
          Add a request to add values to a property on an existing node
 CloneBranchRequest cloneBranch(Location from, String fromWorkspace, Location into, String intoWorkspace, Name nameForClone, Path.Segment exactSegmentForClone, boolean removeExisting)
          Add a request to clone a branch to another.
 CloneWorkspaceRequest cloneWorkspace(String nameOfWorkspaceToBeCloned, String desiredNameOfTargetWorkspace, CreateWorkspaceRequest.CreateConflictBehavior createConflictBehavior, CloneWorkspaceRequest.CloneConflictBehavior cloneConflictBehavior)
          Add a request to clone an existing workspace to create a new workspace, and specify the behavior should a workspace already exists with a name that matches the desired name for the new workspace.
 CopyBranchRequest copyBranch(Location from, String fromWorkspace, Location into, String intoWorkspace, Name nameForCopy, NodeConflictBehavior conflictBehavior)
          Add a request to copy a branch to another.
 CreateNodeRequest createNode(Location parentLocation, String workspaceName, Name childName, Iterator<Property> properties)
          Add a request to create a node with the given properties under the supplied location.
 CreateNodeRequest createNode(Location parentLocation, String workspaceName, Name childName, Iterator<Property> properties, NodeConflictBehavior conflictBehavior)
          Add a request to create a node with the given properties under the supplied location.
 CreateNodeRequest createNode(Location parentLocation, String workspaceName, Name childName, Property[] properties)
          Add a request to create a node with the given properties under the supplied location.
 CreateNodeRequest createNode(Location parentLocation, String workspaceName, Name childName, Property[] properties, NodeConflictBehavior conflictBehavior)
          Add a request to create a node with the given properties under the supplied location.
 CreateWorkspaceRequest createWorkspace(String desiredNameOfNewWorkspace, CreateWorkspaceRequest.CreateConflictBehavior createConflictBehavior)
          Add a request to create a new workspace, and specify the behavior should a workspace already exists with a name that matches the desired name for the new workspace.
 DeleteBranchRequest deleteBranch(Location at, String workspaceName)
          Add a request to delete a branch.
 DestroyWorkspaceRequest destroyWorkspace(String workspaceName)
          Add a request to destroy an existing workspace.
 GetWorkspacesRequest getWorkspaces()
          Add a request to obtain the information about the available workspaces.
 LockBranchRequest lockBranch(String workspaceName, Location target, LockBranchRequest.LockScope lockScope, long lockTimeoutInMillis)
          Create a request to lock a branch or node
 MoveBranchRequest moveBranch(Location from, Location into, Location before, String workspaceName, Name newNameForNode)
          Create a request to move a branch from one location into another before the given child node of the new location.
 MoveBranchRequest moveBranch(Location from, Location into, String workspaceName)
          Create a request to move a branch from one location into another.
 MoveBranchRequest moveBranch(Location from, Location into, String workspaceName, Name newNameForNode)
          Create a request to move a branch from one location into another.
 MoveBranchRequest moveBranch(Location from, Location into, String workspaceName, Name newNameForNode, NodeConflictBehavior conflictBehavior)
          Create a request to move a branch from one location into another.
 MoveBranchRequest moveBranch(Location from, Location into, String workspaceName, NodeConflictBehavior conflictBehavior)
          Create a request to move a branch from one location into another.
 ReadAllChildrenRequest readAllChildren(Location of, String workspaceName)
          Add a request to read the children of a node at the supplied location in the designated workspace.
 ReadAllPropertiesRequest readAllProperties(Location of, String workspaceName)
          Add a request to read the properties and number of children of a node at the supplied location.
 ReadBlockOfChildrenRequest readBlockOfChildren(Location of, String workspaceName, int startingIndex, int count)
          Add a request to read a block of the children of a node at the supplied location.
 ReadBranchRequest readBranch(Location at, String workspaceName)
          Add a request to read the branch at the supplied location, to a maximum depth of 2.
 ReadBranchRequest readBranch(Location at, String workspaceName, int maxDepth)
          Add a request to read the branch (of given depth) at the supplied location.
 ReadNextBlockOfChildrenRequest readNextBlockOfChildren(Location startingAfter, String workspaceName, int count)
          Add a request to read those children of a node that are immediately after a supplied sibling node.
 ReadNodeRequest readNode(Location at, String workspaceName)
          Add a request to read the properties and number of children of a node at the supplied location.
 ReadPropertyRequest readProperty(Location of, String workspaceName, Name propertyName)
          Add a request to read the properties and number of children of a node at the supplied location.
 Request removeProperties(Location on, String workspaceName, Name... propertyNames)
          Add a request to remove from the node the properties with the supplied names.
 RemovePropertyRequest removeProperty(Location on, String workspaceName, Name propertyName)
          Add a request to remove the property with the supplied name from the given node.
 UpdateValuesRequest removeValues(String workspaceName, Location on, Name property, List<Object> values)
          Add a request to remove values from a property on an existing node
 RenameNodeRequest renameNode(Location at, String workspaceName, Name newName)
          Add a request to rename the node at the supplied location.
 FullTextSearchRequest search(String workspaceName, String fullTextSearchExpression, int maxResults, int offset)
          Create a request to perform a full-text search of the workspace.
 Request setProperties(Location on, String workspaceName, Property... properties)
          Add a request to update the properties on the node at the supplied location.
 SetPropertyRequest setProperty(Location on, String workspaceName, Property property)
          Add a request to update the property on the node at the supplied location.
 UnlockBranchRequest unlockBranch(String workspaceName, Location target)
          Create a request to unlock a branch or node The lock on the node should be removed.
 VerifyNodeExistsRequest verifyNodeExists(Location at, String workspaceName)
          Add a request to verify the existance and location of a node at the supplied location.
 VerifyWorkspaceRequest verifyWorkspace(String workspaceName)
          Add a request to verify the existance of the named workspace.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWorkspaces

public GetWorkspacesRequest getWorkspaces()
Add a request to obtain the information about the available workspaces.

Returns:
the request; never null

verifyWorkspace

public VerifyWorkspaceRequest verifyWorkspace(String workspaceName)
Add a request to verify the existance of the named workspace.

Parameters:
workspaceName - the desired name of the workspace, or null if the source's default workspace should be used
Returns:
the request; never null

createWorkspace

public CreateWorkspaceRequest createWorkspace(String desiredNameOfNewWorkspace,
                                              CreateWorkspaceRequest.CreateConflictBehavior createConflictBehavior)
Add a request to create a new workspace, and specify the behavior should a workspace already exists with a name that matches the desired name for the new workspace.

Parameters:
desiredNameOfNewWorkspace - the desired name of the new workspace
createConflictBehavior - the behavior if a workspace already exists with the same name, or null if the default behavior should be used
Returns:
the request; never null

cloneWorkspace

public CloneWorkspaceRequest cloneWorkspace(String nameOfWorkspaceToBeCloned,
                                            String desiredNameOfTargetWorkspace,
                                            CreateWorkspaceRequest.CreateConflictBehavior createConflictBehavior,
                                            CloneWorkspaceRequest.CloneConflictBehavior cloneConflictBehavior)
Add a request to clone an existing workspace to create a new workspace, and specify the behavior should a workspace already exists with a name that matches the desired name for the new workspace.

Parameters:
nameOfWorkspaceToBeCloned - the name of the existing workspace that is to be cloned
desiredNameOfTargetWorkspace - the desired name of the target workspace
createConflictBehavior - the behavior if a workspace already exists with the same name
cloneConflictBehavior - the behavior if the workspace to be cloned does not exist
Returns:
the request; never null
Throws:
IllegalArgumentException - if the either workspace name is null

destroyWorkspace

public DestroyWorkspaceRequest destroyWorkspace(String workspaceName)
Add a request to destroy an existing workspace.

Parameters:
workspaceName - the name of the workspace that is to be destroyed
Returns:
the request; never null
Throws:
IllegalArgumentException - if the workspace name is null

verifyNodeExists

public VerifyNodeExistsRequest verifyNodeExists(Location at,
                                                String workspaceName)
Add a request to verify the existance and location of a node at the supplied location.

Parameters:
at - the location of the node to be verified
workspaceName - the name of the workspace containing the node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

readNode

public ReadNodeRequest readNode(Location at,
                                String workspaceName)
Add a request to read the properties and number of children of a node at the supplied location.

Parameters:
at - the location of the node to be read
workspaceName - the name of the workspace containing the node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

readAllChildren

public ReadAllChildrenRequest readAllChildren(Location of,
                                              String workspaceName)
Add a request to read the children of a node at the supplied location in the designated workspace.

Parameters:
of - the location of the node whose children are to be read
workspaceName - the name of the workspace
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

readAllProperties

public ReadAllPropertiesRequest readAllProperties(Location of,
                                                  String workspaceName)
Add a request to read the properties and number of children of a node at the supplied location.

Parameters:
of - the location of the node whose children are to be read
workspaceName - the name of the workspace
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

readProperty

public ReadPropertyRequest readProperty(Location of,
                                        String workspaceName,
                                        Name propertyName)
Add a request to read the properties and number of children of a node at the supplied location.

Parameters:
of - the location of the node whose children are to be read
workspaceName - the name of the workspace
propertyName - the name of the property to read
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

readBranch

public ReadBranchRequest readBranch(Location at,
                                    String workspaceName)
Add a request to read the branch at the supplied location, to a maximum depth of 2.

Parameters:
at - the location of the branch
workspaceName - the name of the workspace containing the branch
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if the maximum depth is not positive

readBranch

public ReadBranchRequest readBranch(Location at,
                                    String workspaceName,
                                    int maxDepth)
Add a request to read the branch (of given depth) at the supplied location.

Parameters:
at - the location of the branch
workspaceName - the name of the workspace containing the branch
maxDepth - the maximum depth to read
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if the maximum depth is not positive

readBlockOfChildren

public ReadBlockOfChildrenRequest readBlockOfChildren(Location of,
                                                      String workspaceName,
                                                      int startingIndex,
                                                      int count)
Add a request to read a block of the children of a node at the supplied location. The block is defined by the starting index of the first child and the number of children to include. Note that this index is not the same-name-sibiling index, but rather is the index of the child as if the children were in an array.

Parameters:
of - the location of the node whose children are to be read
workspaceName - the name of the workspace containing the parent
startingIndex - the zero-based index of the first child to be included in the block
count - the maximum number of children that should be included in the block
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null, if startingIndex is negative, or if count is less than 1.

readNextBlockOfChildren

public ReadNextBlockOfChildrenRequest readNextBlockOfChildren(Location startingAfter,
                                                              String workspaceName,
                                                              int count)
Add a request to read those children of a node that are immediately after a supplied sibling node.

Parameters:
startingAfter - the location of the previous sibling that was the last child of the previous block of children read
workspaceName - the name of the workspace containing the node
count - the maximum number of children that should be included in the block
Returns:
the request; never null
Throws:
IllegalArgumentException - if the workspace name or startingAfter location is null, or if count is less than 1.

createNode

public CreateNodeRequest createNode(Location parentLocation,
                                    String workspaceName,
                                    Name childName,
                                    Iterator<Property> properties)
Add a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

createNode

public CreateNodeRequest createNode(Location parentLocation,
                                    String workspaceName,
                                    Name childName,
                                    Iterator<Property> properties,
                                    NodeConflictBehavior conflictBehavior)
Add a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists under the into location
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

createNode

public CreateNodeRequest createNode(Location parentLocation,
                                    String workspaceName,
                                    Name childName,
                                    Property[] properties)
Add a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

createNode

public CreateNodeRequest createNode(Location parentLocation,
                                    String workspaceName,
                                    Name childName,
                                    Property[] properties,
                                    NodeConflictBehavior conflictBehavior)
Add a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists under the into location
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

setProperty

public SetPropertyRequest setProperty(Location on,
                                      String workspaceName,
                                      Property property)
Add a request to update the property on the node at the supplied location. This request will create the property if it does not yet exist.

Parameters:
on - the location of the node to be read
workspaceName - the name of the workspace containing the node
property - the new property on the node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if there are no properties to update

setProperties

public Request setProperties(Location on,
                             String workspaceName,
                             Property... properties)
Add a request to update the properties on the node at the supplied location.

Parameters:
on - the location of the node to be read
workspaceName - the name of the workspace containing the node
properties - the new properties on the node
Returns:
the SetPropertyRequest or UpdatePropertiesRequest request, depending upon the number of properties being set; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if there are no properties to update

removeProperty

public RemovePropertyRequest removeProperty(Location on,
                                            String workspaceName,
                                            Name propertyName)
Add a request to remove the property with the supplied name from the given node. Supplying a name for a property that does not exist will not cause an error.

Parameters:
on - the location of the node to be read
workspaceName - the name of the workspace containing the node
propertyName - the name of the property that is to be removed
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if there are no properties to remove

removeProperties

public Request removeProperties(Location on,
                                String workspaceName,
                                Name... propertyNames)
Add a request to remove from the node the properties with the supplied names. Supplying a name for a property that does not exist will not cause an error.

Parameters:
on - the location of the node to be read
workspaceName - the name of the workspace containing the node
propertyNames - the names of the properties that are to be removed
Returns:
the RemovePropertyRequest or UpdatePropertiesRequest request, depending upon the number of properties being removed; never null
Throws:
IllegalArgumentException - if the location or workspace name is null or if there are no properties to remove

renameNode

public RenameNodeRequest renameNode(Location at,
                                    String workspaceName,
                                    Name newName)
Add a request to rename the node at the supplied location.

Parameters:
at - the location of the node to be read
workspaceName - the name of the workspace containing the node
newName - the new name for the node
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

copyBranch

public CopyBranchRequest copyBranch(Location from,
                                    String fromWorkspace,
                                    Location into,
                                    String intoWorkspace,
                                    Name nameForCopy,
                                    NodeConflictBehavior conflictBehavior)
Add a request to copy a branch to another.

Parameters:
from - the location of the top node in the existing branch that is to be copied
fromWorkspace - the name of the workspace where the from node exists
into - the location of the existing node into which the copy should be placed
intoWorkspace - the name of the workspace where the into node is to be copied
nameForCopy - the desired name for the node that results from the copy, or null if the name of the original should be used
conflictBehavior - the expected behavior if an equivalently-named child already exists at the into location, or null if the default conflict behavior should be used
Returns:
the request; never null
Throws:
IllegalArgumentException - if either of the locations or workspace names are null

cloneBranch

public CloneBranchRequest cloneBranch(Location from,
                                      String fromWorkspace,
                                      Location into,
                                      String intoWorkspace,
                                      Name nameForClone,
                                      Path.Segment exactSegmentForClone,
                                      boolean removeExisting)
Add a request to clone a branch to another.

Parameters:
from - the location of the top node in the existing branch that is to be cloned
fromWorkspace - the name of the workspace where the from node exists
into - the location of the existing node into which the clone should be placed
intoWorkspace - the name of the workspace where the into node is to be cloned
nameForClone - the desired name for the node that results from the clone, or null if the name of the original should be used
exactSegmentForClone - the exact segment at which the cloned tree should be rooted.
removeExisting - whether any nodes in the intoWorkspace with the same UUIDs as a node in the source branch should be removed (if true) or a UuidAlreadyExistsException should be thrown.
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null except for nameForClone or exactSegmentForClone. Exactly one of nameForClone and exactSegmentForClone must be null.

moveBranch

public MoveBranchRequest moveBranch(Location from,
                                    Location into,
                                    String workspaceName)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

moveBranch

public MoveBranchRequest moveBranch(Location from,
                                    Location into,
                                    String workspaceName,
                                    Name newNameForNode)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
newNameForNode - the new name for the node being moved, or null if the name of the original should be used
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

moveBranch

public MoveBranchRequest moveBranch(Location from,
                                    Location into,
                                    Location before,
                                    String workspaceName,
                                    Name newNameForNode)
Create a request to move a branch from one location into another before the given child node of the new location.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
before - the location of the node before which the branch should be moved; may be null
workspaceName - the name of the workspace
newNameForNode - the new name for the node being moved, or null if the name of the original should be used
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

moveBranch

public MoveBranchRequest moveBranch(Location from,
                                    Location into,
                                    String workspaceName,
                                    Name newNameForNode,
                                    NodeConflictBehavior conflictBehavior)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
newNameForNode - the new name for the node being moved, or null if the name of the original should be used
conflictBehavior - the expected behavior if an equivalently-named child already exists at the into location
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

moveBranch

public MoveBranchRequest moveBranch(Location from,
                                    Location into,
                                    String workspaceName,
                                    NodeConflictBehavior conflictBehavior)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
conflictBehavior - the expected behavior if an equivalently-named child already exists at the into location
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

deleteBranch

public DeleteBranchRequest deleteBranch(Location at,
                                        String workspaceName)
Add a request to delete a branch.

Parameters:
at - the location of the top node in the existing branch that is to be deleted
workspaceName - the name of the workspace containing the parent
Returns:
the request; never null
Throws:
IllegalArgumentException - if the location or workspace name is null

addValues

public UpdateValuesRequest addValues(String workspaceName,
                                     Location on,
                                     Name property,
                                     List<Object> values)
Add a request to add values to a property on an existing node

Parameters:
workspaceName - the name of the workspace containing the node; may not be null
on - the location of the node; may not be null
property - the name of the property; may not be null
values - the new values to add; may not be null
Returns:
the request; never null

removeValues

public UpdateValuesRequest removeValues(String workspaceName,
                                        Location on,
                                        Name property,
                                        List<Object> values)
Add a request to remove values from a property on an existing node

Parameters:
workspaceName - the name of the workspace containing the node; may not be null
on - the location of the node; may not be null
property - the name of the property; may not be null
values - the new values to remove; may not be null
Returns:
the request; never null

lockBranch

public LockBranchRequest lockBranch(String workspaceName,
                                    Location target,
                                    LockBranchRequest.LockScope lockScope,
                                    long lockTimeoutInMillis)
Create a request to lock a branch or node

Parameters:
workspaceName - the name of the workspace containing the node; may not be null
target - the location of the top node in the existing branch that is to be locked
lockScope - the LockBranchRequest.lockScope() scope of the lock
lockTimeoutInMillis - the number of milliseconds that the lock should last before the lock times out; zero (0) indicates that the connector default should be used
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

unlockBranch

public UnlockBranchRequest unlockBranch(String workspaceName,
                                        Location target)
Create a request to unlock a branch or node

The lock on the node should be removed. If the lock was deep (i.e., locked the entire branch under the node, then all of the descendants of the node affected by the lock should also be unlocked after this request is processed.

Parameters:
workspaceName - the name of the workspace containing the node; may not be null
target - the location of the top node in the existing branch that is to be unlocked
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null

search

public FullTextSearchRequest search(String workspaceName,
                                    String fullTextSearchExpression,
                                    int maxResults,
                                    int offset)
Create a request to perform a full-text search of the workspace.

Parameters:
workspaceName - the name of the workspace containing the node
fullTextSearchExpression - the full-text search expression
maxResults - the maximum number of results that are to be returned; always positive
offset - the number of initial results to skip, or 0 if the first results are to be returned
Returns:
the request; never null
Throws:
IllegalArgumentException - if any of the parameters are null or if the expression is empty


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.