org.modeshape.connector.jcr
Class JcrRequestProcessor

java.lang.Object
  extended by org.modeshape.graph.request.processor.RequestProcessor
      extended by org.modeshape.connector.jcr.JcrRequestProcessor

@NotThreadSafe
public class JcrRequestProcessor
extends RequestProcessor

A RequestProcessor that processes Requests by operating against the JCR Repository.


Nested Class Summary
protected  class JcrRequestProcessor.Workspace
          An encapsulation of a remote JCR Session, with an ExecutionContext that contains a namespace registry which mirrors the session's registry, and with factories that convert the JCR-specific values, paths, and names into their graph-equivalents.
 
Nested classes/interfaces inherited from class org.modeshape.graph.request.processor.RequestProcessor
RequestProcessor.LocationWithDepth
 
Constructor Summary
JcrRequestProcessor(String sourceName, ExecutionContext context, Repository repository, Observer observer, Credentials credentials, CachePolicy defaultCachePolicy)
           
 
Method Summary
 void close()
          Close this processor, allowing it to clean up any open resources.
 void commit()
          Commit all changes to any sessions.
 void process(CloneBranchRequest request)
          Process a request to clone a branch into a new workspace.
 void process(CloneWorkspaceRequest request)
          Process a request to clone an existing workspace as a new workspace.
 void process(CopyBranchRequest request)
          Process a request to copy a branch into another location.
 void process(CreateNodeRequest request)
          Process a request to create a node at a specified location.
 void process(CreateWorkspaceRequest request)
          Process a request to create a new workspace.
 void process(DeleteBranchRequest request)
          Process a request to delete a branch at a specified location.
 void process(DestroyWorkspaceRequest request)
          Process a request to permanently destroy a workspace.
 void process(GetWorkspacesRequest request)
          Process a request to get the information about the available workspaces.
 void process(MoveBranchRequest request)
          Process a request to move a branch at a specified location into a different location.
 void process(ReadAllChildrenRequest request)
          Process a request to read all of the children of a node.
 void process(ReadAllPropertiesRequest request)
          Process a request to read the properties of a node at the supplied location.
 void process(ReadNodeRequest request)
          Process a request to read the properties and children of a node at the supplied location.
 void process(UpdatePropertiesRequest request)
          Process a request to remove the specified properties from a node.
 void process(VerifyWorkspaceRequest request)
          Process a request to verify a named workspace.
 void rollback()
          Rollback all changes made to any sessions.
protected  JcrRequestProcessor.Workspace workspace()
          Use the first workspace that's available, or if none is available establish one for the default workspace.
protected  boolean workspaceExistsNamed(String workspaceName)
          Determine if there is an existing workspace with the supplied name.
protected  JcrRequestProcessor.Workspace workspaceFor(String workspaceName)
          Obtain the JCR session for the named workspace in the current repository using the credentials given to this processor during instantiation.
 
Methods inherited from class org.modeshape.graph.request.processor.RequestProcessor
completeRequest, getChanges, getDefaultCachePolicy, getExecutionContext, getNowInUtc, getSourceName, notifyObserverOfChanges, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, process, processUnknownRequest, recordChange, setCacheableInfo, setCacheableInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrRequestProcessor

public JcrRequestProcessor(String sourceName,
                           ExecutionContext context,
                           Repository repository,
                           Observer observer,
                           Credentials credentials,
                           CachePolicy defaultCachePolicy)
Parameters:
sourceName -
context -
repository -
observer -
credentials -
defaultCachePolicy -
Method Detail

workspaceFor

protected JcrRequestProcessor.Workspace workspaceFor(String workspaceName)
                                              throws RepositoryException
Obtain the JCR session for the named workspace in the current repository using the credentials given to this processor during instantiation. If no workspace name is supplied, a session for the default workspace is obtained.

This method caches a single Session object for each named (or default) workspace, so multiple calls with the same workspace name will always result in the same Session object. These cached Session objects are released only when this processor is closed.

Parameters:
workspaceName - the name of the workspace for which a Session is to be found, or null if a session to the default workspace should be returned
Returns:
the Session to the workspace, or null if there was an error
Throws:
NoSuchWorkspaceException - if the named workspace does not exist
RepositoryException - if there is an error creating a Session

workspace

protected JcrRequestProcessor.Workspace workspace()
                                           throws RepositoryException
Use the first workspace that's available, or if none is available establish one for the default workspace.

Returns:
the workspace, or null if there was an error
Throws:
RepositoryException - if there is an error creating a Session

workspaceExistsNamed

protected boolean workspaceExistsNamed(String workspaceName)
                                throws RepositoryException
Determine if there is an existing workspace with the supplied name.

Parameters:
workspaceName - the name of the workspace
Returns:
true if the workspace with the supplied name does exist, or false if it does not
Throws:
RepositoryException - if there is an error working with the session

commit

public void commit()
            throws RepositoryException
Commit all changes to any sessions.

Throws:
RepositoryException - if there is a problem committing any changes

rollback

public void rollback()
              throws RepositoryException
Rollback all changes made to any sessions.

Throws:
RepositoryException - if there is a problem committing any changes

close

public void close()
Close this processor, allowing it to clean up any open resources.

Overrides:
close in class RequestProcessor
See Also:
RequestProcessor.close()

process

public void process(VerifyWorkspaceRequest request)
Process a request to verify a named workspace.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.VerifyWorkspaceRequest)

process

public void process(GetWorkspacesRequest request)
Process a request to get the information about the available workspaces.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.GetWorkspacesRequest)

process

public void process(CreateWorkspaceRequest request)
Process a request to create a new workspace.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.CreateWorkspaceRequest)

process

public void process(CloneWorkspaceRequest request)
Process a request to clone an existing workspace as a new workspace.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.CloneWorkspaceRequest)

process

public void process(DestroyWorkspaceRequest request)
Process a request to permanently destroy a workspace.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.DestroyWorkspaceRequest)

process

public void process(ReadNodeRequest request)
Process a request to read the properties and children of a node at the supplied location.

This method does nothing if the request is null. Unless overridden, this method converts the single request into a ReadAllChildrenRequest and a ReadAllPropertiesRequest.

Overrides:
process in class RequestProcessor
Parameters:
request - the read request
See Also:
RequestProcessor.process(org.modeshape.graph.request.ReadNodeRequest)

process

public void process(ReadAllChildrenRequest request)
Process a request to read all of the children of a node.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the read request
See Also:
RequestProcessor.process(org.modeshape.graph.request.ReadAllChildrenRequest)

process

public void process(ReadAllPropertiesRequest request)
Process a request to read the properties of a node at the supplied location.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the read request
See Also:
RequestProcessor.process(org.modeshape.graph.request.ReadAllPropertiesRequest)

process

public void process(CreateNodeRequest request)
Process a request to create a node at a specified location.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the create request
See Also:
RequestProcessor.process(org.modeshape.graph.request.CreateNodeRequest)

process

public void process(CloneBranchRequest request)
Process a request to clone a branch into a new workspace.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the request
See Also:
RequestProcessor.process(org.modeshape.graph.request.CloneBranchRequest)

process

public void process(CopyBranchRequest request)
Process a request to copy a branch into another location.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the copy request
See Also:
RequestProcessor.process(org.modeshape.graph.request.CopyBranchRequest)

process

public void process(DeleteBranchRequest request)
Process a request to delete a branch at a specified location.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the delete request
See Also:
RequestProcessor.process(org.modeshape.graph.request.DeleteBranchRequest)

process

public void process(MoveBranchRequest request)
Process a request to move a branch at a specified location into a different location.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the move request
See Also:
RequestProcessor.process(org.modeshape.graph.request.MoveBranchRequest)

process

public void process(UpdatePropertiesRequest request)
Process a request to remove the specified properties from a node.

This method does nothing if the request is null.

Specified by:
process in class RequestProcessor
Parameters:
request - the remove request
See Also:
RequestProcessor.process(org.modeshape.graph.request.UpdatePropertiesRequest)


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