|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.dna.graph.session.GraphSession<Payload,PropertyPayload>
Payload
- the type of the payload object for each node, used to allow the nodes to hold additional cached informationPropertyPayload
- the type of payload object for each property, used to allow the nodes to hold additional cached
information@NotThreadSafe public class GraphSession<Payload,PropertyPayload>
This class represents an interactive session for working with the content within a graph. This session maintains a cache of
content read from the repository, as well as transient changes that have been made to the nodes within this session that are
then pushed to the graph when the session is saved
.
Like the other Graph APIs, the mutable objects in this session should not be held onto for very long periods of time. When the
session is saved
or {refreshed
(or when a node is saved
or
refreshed
), the session may unload
and discard some of its nodes. Using
nodes after they are discarded may result in assertion errors (assuming Java assertions are enabled).
Nested Class Summary | |
---|---|
static interface |
GraphSession.Authorizer
|
static class |
GraphSession.Node<Payload,PropertyPayload>
|
static class |
GraphSession.NodeId
An immutable identifier for a node, used within the GraphSession . |
static interface |
GraphSession.NodeIdFactory
|
static class |
GraphSession.NodeOperations<Payload,PropertyPayload>
A default implementation of GraphSession.Operations that provides all the basic functionality required by a graph
session. |
static class |
GraphSession.NodeVisitor<NodePayload,PropertyPayloadType>
The node visitor. |
static interface |
GraphSession.Operations<NodePayload,PropertyPayload>
|
static class |
GraphSession.PropertyInfo<PropertyPayload>
|
static class |
GraphSession.Status
|
static class |
GraphSession.StructureSnapshot<PropertyPayload>
A read-only visitor that walks the cache to obtain a snapshot of the cache structure. |
Constructor Summary | |
---|---|
GraphSession(Graph graph,
String workspaceName,
GraphSession.Operations<Payload,PropertyPayload> nodeOperations)
Create a session that uses the supplied graph and the supplied node operations. |
|
GraphSession(Graph graph,
String workspaceName,
GraphSession.Operations<Payload,PropertyPayload> nodeOperations,
GraphSession.Authorizer authorizer)
Create a session that uses the supplied graph and the supplied node operations. |
Method Summary | |
---|---|
void |
clearAllChangedNodes()
Remove any cached information that has been marked as a transient change. |
GraphSession.Node<Payload,PropertyPayload> |
findNodeRelativeTo(GraphSession.Node<Payload,PropertyPayload> startingPoint,
Path relativePath)
Find the node with the supplied path relative to another node. |
GraphSession.Node<Payload,PropertyPayload> |
findNodeWith(GraphSession.NodeId id)
Find in the session the node with the supplied identifier. |
GraphSession.Node<Payload,PropertyPayload> |
findNodeWith(GraphSession.NodeId id,
Path path)
Find the node with the supplied identifier or, if no such node is found, the node at the supplied path. |
GraphSession.Node<Payload,PropertyPayload> |
findNodeWith(Location location)
Find in the session the node with the supplied location. |
GraphSession.Node<Payload,PropertyPayload> |
findNodeWith(Path path)
Find the node with the supplied path. |
int |
getDepthForLoadingNodes()
Get the subgraph depth that is read when a node is loaded from the persistence store. |
PathFactory |
getPathFactory()
Get the path factory that should be used to adjust the path objects. |
GraphSession.Node<Payload,PropertyPayload> |
getRoot()
Get the root node. |
boolean |
hasPendingChanges()
Returns whether the session cache has any pending changes that need to be executed. |
void |
immediateClone(Path source,
String sourceWorkspace,
Path destination,
boolean removeExisting,
boolean destPathIncludesSegment)
Clone the supplied source branch and place into the destination location, optionally removing any existing copy that already exists in the destination location, doing so immediately without enqueuing the operation within the session's operations. |
void |
immediateCopy(Path source,
Path destination)
Copy the node at the supplied source path in the named workspace, and place the copy at the supplied location within the current workspace, doing so immediately without enqueuing the operation within the session's operations. |
void |
immediateCopy(Path source,
String sourceWorkspace,
Path destination)
Copy the node at the supplied source path in the named workspace, and place the copy at the supplied location within the current workspace, doing so immediately without enqueuing the operation within the session's operations. |
void |
immediateMove(Path nodeToMove,
Path destination)
Move this node from its current location so that is is a child of the supplied parent, doing so immediately without enqueuing the operation within the session's operations. |
void |
refresh(boolean keepChanges)
Refreshes (removes the cached state) for all cached nodes. |
void |
refresh(GraphSession.Node<Payload,PropertyPayload> node,
boolean keepChanges)
Refreshes (removes the cached state) for the given node and its descendants. |
void |
save()
Save any changes that have been accumulated by this session. |
void |
save(GraphSession.Node<Payload,PropertyPayload> node)
Save any changes to the identified node or its descendants. |
void |
setDepthForLoadingNodes(int depth)
Set the loading depth parameter, which controls how deep a subgraph should be read when a node is loaded from the persistence store. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphSession(Graph graph, String workspaceName, GraphSession.Operations<Payload,PropertyPayload> nodeOperations)
graph
- the graph that this session is to useworkspaceName
- the name of the workspace that is to be used, or null if the current workspace should be usednodeOperations
- the operations that are to be performed during various stages in the lifecycle of a node, or null if
there are no special operations that should be performedpublic GraphSession(Graph graph, String workspaceName, GraphSession.Operations<Payload,PropertyPayload> nodeOperations, GraphSession.Authorizer authorizer)
graph
- the graph that this session is to useworkspaceName
- the name of the workspace that is to be used, or null if the current workspace should be usednodeOperations
- the operations that are to be performed during various stages in the lifecycle of a node, or null if
there are no special operations that should be performedauthorizer
- the authorizing component, or null if no special authorization is to be performed
IllegalArgumentException
- if the graph reference is null
IllegalArgumentException
- if the depth is not positiveMethod Detail |
---|
public int getDepthForLoadingNodes()
public void setDepthForLoadingNodes(int depth)
depth
- the depth that should be read whenever a single node is loaded
IllegalArgumentException
- if the depth is not positivepublic GraphSession.Node<Payload,PropertyPayload> getRoot()
public PathFactory getPathFactory()
public GraphSession.Node<Payload,PropertyPayload> findNodeWith(Location location) throws PathNotFoundException, AccessControlException
location
- the location of the node
PathNotFoundException
- if the node at the supplied location does not exist
AccessControlException
- if the user does not have permission to read the node given by the supplied location
IllegalArgumentException
- if the location is nullpublic GraphSession.Node<Payload,PropertyPayload> findNodeWith(GraphSession.NodeId id)
id
- the identifier of the node
IllegalArgumentException
- if the identifier is nullpublic GraphSession.Node<Payload,PropertyPayload> findNodeWith(GraphSession.NodeId id, Path path) throws PathNotFoundException, AccessControlException
id
- the identifier to the node; may be null if the node is to be found by pathpath
- the path that should be used to find the node only when the cache doesn't contain a node with the identifier
IllegalArgumentException
- if the identifier and path are both node
PathNotFoundException
- if the node at the supplied path does not exist
AccessControlException
- if the user does not have permission to read the nodes given by the supplied pathpublic GraphSession.Node<Payload,PropertyPayload> findNodeWith(Path path) throws PathNotFoundException, AccessControlException
path
- the path to the node
PathNotFoundException
- if the node at the supplied path does not exist
AccessControlException
- if the user does not have permission to read the nodes given by the supplied pathpublic GraphSession.Node<Payload,PropertyPayload> findNodeRelativeTo(GraphSession.Node<Payload,PropertyPayload> startingPoint, Path relativePath) throws PathNotFoundException, AccessControlException
startingPoint
- the node from which the path is relativerelativePath
- the relative path from the designated starting point to the desired node; may not be null and may not
be an absolute
path
PathNotFoundException
- if the node at the supplied path does not exist
AccessControlException
- if the user does not have permission to read the nodes given by the supplied pathpublic boolean hasPendingChanges()
public void clearAllChangedNodes()
public void immediateMove(Path nodeToMove, Path destination) throws AccessControlException, RepositorySourceException
nodeToMove
- the path to the node that is to be moved; may not be nulldestination
- the desired new path; may not be null
IllegalArgumentException
- if the node being moved is the root node
AccessControlException
- if the caller does not have the permission to perform the operation
RepositorySourceException
- if any error resulting while performing the operationpublic void immediateCopy(Path source, Path destination) throws AccessControlException, RepositorySourceException
Note that the destination path should not include a same-name-sibling index, since this will be ignored and will always be recomputed (as the copy will be appended to any children already in the destination's parent).
source
- the path to the node that is to be copied; may not be nulldestination
- the path where the copy is to be placed; may not be null
IllegalArgumentException
- either path is null or invalid
AccessControlException
- if the caller does not have the permission to perform the operation
RepositorySourceException
- if any error resulting while performing the operationpublic void immediateCopy(Path source, String sourceWorkspace, Path destination) throws InvalidWorkspaceException, AccessControlException, PathNotFoundException, RepositorySourceException
Note that the destination path should not include a same-name-sibling index, since this will be ignored and will always be recomputed (as the copy will be appended to any children already in the destination's parent).
source
- the path to the node that is to be copied; may not be nullsourceWorkspace
- the name of the workspace where the source node is to be found, or null if the current workspace
should be useddestination
- the path where the copy is to be placed; may not be null
IllegalArgumentException
- either path is null or invalid
PathNotFoundException
- if the node being copied or the parent of the destination path do not exist
InvalidWorkspaceException
- if the source workspace name is invalid or does not exist
AccessControlException
- if the caller does not have the permission to perform the operation
RepositorySourceException
- if any error resulting while performing the operationpublic void immediateClone(Path source, String sourceWorkspace, Path destination, boolean removeExisting, boolean destPathIncludesSegment) throws InvalidWorkspaceException, AccessControlException, UuidAlreadyExistsException, PathNotFoundException, RepositorySourceException
source
- the path to the node that is to be cloned; may not be nullsourceWorkspace
- the name of the workspace where the source node is to be found, or null if the current workspace
should be useddestination
- the path for the new cloned copy; may not be null indexremoveExisting
- true if the original should be removed, or false if the original should be leftdestPathIncludesSegment
- true if the destination path includes the segment that should be used
IllegalArgumentException
- either path is null or invalid
InvalidWorkspaceException
- if the source workspace name is invalid or does not exist
UuidAlreadyExistsException
- if copy could not be completed because the current workspace already includes at least
one of the nodes at or below the source
branch in the source workspace
PathNotFoundException
- if the node being clone or the destination node do not exist
AccessControlException
- if the caller does not have the permission to perform the operation
RepositorySourceException
- if any error resulting while performing the operationpublic void refresh(boolean keepChanges) throws InvalidStateException, RepositorySourceException
If keepChanges == true
, modified nodes will not have their state refreshed, while all others will either be
unloaded or changed to reflect the current state of the persistent store.
keepChanges
- indicates whether changed nodes should be kept or refreshed from the repository.
InvalidStateException
- if any error resulting while reading information from the repository
RepositorySourceException
- if any error resulting while reading information from the repositorypublic void refresh(GraphSession.Node<Payload,PropertyPayload> node, boolean keepChanges) throws InvalidStateException, RepositorySourceException
If keepChanges == true
, modified nodes will not have their state refreshed, while all others will either be
unloaded or changed to reflect the current state of the persistent store.
node
- the node that is to be refreshed; may not be nullkeepChanges
- indicates whether changed nodes should be kept or refreshed from the repository.
InvalidStateException
- if any error resulting while reading information from the repository
RepositorySourceException
- if any error resulting while reading information from the repositorypublic void save() throws PathNotFoundException, ValidationException, InvalidStateException
PathNotFoundException
- if the state of this session is invalid and is attempting to change a node that doesn't exist
ValidationException
- if any of the changes being made result in an invalid node state
InvalidStateException
- if the supplied node is no longer a node within this cache (because it was unloaded)public void save(GraphSession.Node<Payload,PropertyPayload> node) throws PathNotFoundException, ValidationException, InvalidStateException
node
- the node being saved; may not be null
PathNotFoundException
- if the state of this session is invalid and is attempting to change a node that doesn't exist
ValidationException
- if any of the changes being made result in an invalid node state
InvalidStateException
- if the supplied node is no longer a node within this cache (because it was unloaded)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |