org.modeshape.graph.connector.path
Class AbstractWritablePathWorkspace

java.lang.Object
  extended by org.modeshape.graph.connector.path.AbstractWritablePathWorkspace
All Implemented Interfaces:
PathWorkspace, WritablePathWorkspace

public abstract class AbstractWritablePathWorkspace
extends Object
implements WritablePathWorkspace

Implementation of some methods from WritablePathWorkspace to assist in the development of path-based connectors. Subclasses of this class should be made thread-safe.


Field Summary
protected  UUID rootNodeUuid
           
 
Constructor Summary
AbstractWritablePathWorkspace(String name, UUID rootNodeUuid)
           
 
Method Summary
 PathNode copyNode(ExecutionContext context, PathNode original, PathWorkspace originalWorkspace, PathNode newParent, Name desiredName, boolean recursive)
          This should copy the subgraph rooted at the original node and place the new copy under the supplied new parent.
 PathNode createNode(ExecutionContext context, String pathToNewNode, Map<Name,Property> properties, NodeConflictBehavior conflictBehavior)
          Create a node at the supplied path.
 String getName()
          Returns the name of the workspace.
 void lockNode(PathNode node, LockBranchRequest.LockScope lockScope, long lockTimeoutInMillis)
          Attempts to lock the given node with the given timeout.
 PathNode moveNode(ExecutionContext context, PathNode node, Name desiredNewName, WritablePathWorkspace originalWorkspace, PathNode newParent, PathNode beforeNode)
          Move the supplied node to the new parent within this workspace.
 QueryResults query(ExecutionContext context, AccessQueryRequest accessQuery)
          Perform a query of this workspace.
 PathNode removeProperties(ExecutionContext context, Path nodePath, Iterable<Name> propertyNames)
          Removes the properties with the given names
 QueryResults search(ExecutionContext context, String fullTextSearchExpression)
          Perform a full-text search of this workspace.
 void unlockNode(PathNode node)
          Attempts to unlock the given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.modeshape.graph.connector.path.WritablePathWorkspace
createNode, removeNode, setProperties
 
Methods inherited from interface org.modeshape.graph.connector.path.PathWorkspace
getLowestExistingPath, getNode
 

Field Detail

rootNodeUuid

protected final UUID rootNodeUuid
Constructor Detail

AbstractWritablePathWorkspace

public AbstractWritablePathWorkspace(String name,
                                     UUID rootNodeUuid)
Method Detail

copyNode

public PathNode copyNode(ExecutionContext context,
                         PathNode original,
                         PathWorkspace originalWorkspace,
                         PathNode newParent,
                         Name desiredName,
                         boolean recursive)
This should copy the subgraph rooted at the original node and place the new copy under the supplied new parent. Note that internal references between nodes within the original subgraph must be reflected as internal nodes within the new subgraph.

Specified by:
copyNode in interface WritablePathWorkspace
Parameters:
context - the context; may not be null
original - the node to be copied; may not be null
originalWorkspace - the workspace containing the original node; may not be null
newParent - the parent where the copy is to be placed; may not be null
desiredName - the desired name for the node; if null, the name will be obtained from the original node
recursive - true if the copy should be recursive
Returns:
the new node, which is the top of the new subgraph

createNode

public PathNode createNode(ExecutionContext context,
                           String pathToNewNode,
                           Map<Name,Property> properties,
                           NodeConflictBehavior conflictBehavior)
Description copied from interface: WritablePathWorkspace
Create a node at the supplied path. The parent of the new node must already exist.

Specified by:
createNode in interface WritablePathWorkspace
Parameters:
context - the environment; may not be null
pathToNewNode - the path to the new node; may not be null
properties - the properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists at the location
Returns:
the new node (or root if the path specified the root)

moveNode

public PathNode moveNode(ExecutionContext context,
                         PathNode node,
                         Name desiredNewName,
                         WritablePathWorkspace originalWorkspace,
                         PathNode newParent,
                         PathNode beforeNode)
Description copied from interface: WritablePathWorkspace
Move the supplied node to the new parent within this workspace. This method automatically removes the node from its existing parent, and also correctly adjusts the index to be correct in the new parent.

Specified by:
moveNode in interface WritablePathWorkspace
node - the node to be moved; may not be the workspace root node
desiredNewName - the new name for the node, if it is to be changed; may be null
originalWorkspace - the workspace containing the node to be moved
newParent - the new parent; may not be the workspace root node
beforeNode - the node before which this new node should be placed
Returns:
a new copy of node that reflects the new location

removeProperties

public PathNode removeProperties(ExecutionContext context,
                                 Path nodePath,
                                 Iterable<Name> propertyNames)
Description copied from interface: WritablePathWorkspace
Removes the properties with the given names

Specified by:
removeProperties in interface WritablePathWorkspace
Parameters:
context - the context; may not be null
nodePath - the path to the node from which the properties should be removed
propertyNames - the name of the properties to remove
Returns:
this map node

query

public QueryResults query(ExecutionContext context,
                          AccessQueryRequest accessQuery)
Description copied from interface: PathWorkspace
Perform a query of this workspace.

Specified by:
query in interface PathWorkspace
Parameters:
context - the context in which the query is to be executed; may not be null
accessQuery - the access query; may not be null
Returns:
the query results, or null if the query is not supported

search

public QueryResults search(ExecutionContext context,
                           String fullTextSearchExpression)
Description copied from interface: PathWorkspace
Perform a full-text search of this workspace.

Specified by:
search in interface PathWorkspace
Parameters:
context - the context in which the query is to be executed; may not be null
fullTextSearchExpression - the full-text search expression; may not be null
Returns:
the query results, or null if the query is not supported

getName

public String getName()
Description copied from interface: PathWorkspace
Returns the name of the workspace. There can only be one workspace with a given name per repository.

Specified by:
getName in interface PathWorkspace
Returns:
the name of the workspace

lockNode

public void lockNode(PathNode node,
                     LockBranchRequest.LockScope lockScope,
                     long lockTimeoutInMillis)
              throws LockFailedException
Description copied from interface: PathWorkspace
Attempts to lock the given node with the given timeout. If the lock attempt fails, a LockFailedException will be thrown.

Specified by:
lockNode in interface PathWorkspace
Parameters:
node - the node to be locked; may not be null
lockScope - the scope of the lock (i.e., whether descendants of node should be included in the lock
lockTimeoutInMillis - the maximum lifetime of the lock in milliseconds; zero (0) indicates that the connector default should be used
Throws:
LockFailedException - if the implementing connector supports locking but the lock could not be acquired.

unlockNode

public void unlockNode(PathNode node)
Description copied from interface: PathWorkspace
Attempts to unlock the given node.

Specified by:
unlockNode in interface PathWorkspace
Parameters:
node - the node to be unlocked; may not be null


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