uk.org.ogsadai.activity
Class ActivityContext

java.lang.Object
  |
  +--uk.org.ogsadai.activity.ActivityContext

public class ActivityContext
extends java.lang.Object

The ActivityContext provides a view of the context of a request suitable for activity implementations. Various get methods are provided for accessing objects such as the inputs and output block readers and block writers, as well as the connection manager. Along with the RequestContext class, this class provides an extension point for users wishing to store additional objects within the request context.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement.
private static DAILogger LOG
          Logger object for logging in this class.
private  RequestContext mContext
          Holds the basic request context.
private  EngineConfiguration mEngineConfiguration
          Engine configuration
private  java.util.Map mInternalPipes
          Holds internal pipes used for transporting data between activities
 
Constructor Summary
ActivityContext(EngineConfiguration engineConfiguration, RequestContext context)
          Constructs an internal request context.
 
Method Summary
(package private)  void addPipe(java.lang.String name, Pipe pipe)
          Adds a Pipe to the request context.
(package private)  ActivityRequest getActivityRequest()
          Gets the activity request containing the activity.
 AttachmentManager getAttachmentManager()
          Gets the attachment manager through which attachments can be added to the response document.
 AccessAuthorizer getAuthorizer()
          Gets the authorizer which authorizes access to resources and activities.
(package private)  java.lang.Throwable getCauseOfError()
          If there is an error during the processing of a request, return the exception.
 DataResourceAccessor getDataResourceAccessor()
          Gets the DataResourceAccessor providing access to the underlying data resource associated with the data service resource.
 DataServiceResourceFactory getDataResourceFactory()
          Gets the data service resource factory through which new data service resources can be created.
 BlockReader getInput(java.lang.String name)
          Gets the BlockReader for an internal input to the activity.
 BlockWriter getOutput(java.lang.String name)
          Gets the BlockWriter for an internal output from the activity.
 java.lang.String getResourceID()
          Returns the resource ID associated with the request
 SecurityContext getSecurityContext()
          Gets the security context associated with the request.
 java.lang.String getURL()
          Returns the local path to the data service within its enclosing web application.
(package private)  boolean hasError()
          Indicates whether or not there has been an error while the request has been processing.
(package private)  boolean hasPipe(java.lang.String name)
          Checks whether the context contains a pipe with the given name.
(package private)  void setError(java.lang.Throwable cause)
          Sets a reference to the first error raised by an activity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement.

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class.


mContext

private final RequestContext mContext
Holds the basic request context.


mInternalPipes

private final java.util.Map mInternalPipes
Holds internal pipes used for transporting data between activities


mEngineConfiguration

private final EngineConfiguration mEngineConfiguration
Engine configuration

Constructor Detail

ActivityContext

public ActivityContext(EngineConfiguration engineConfiguration,
                       RequestContext context)
Constructs an internal request context.

Parameters:
engineConfiguration - Engine configuration which provides access to data resource accessors.
context - Request context containing the security settings.
Method Detail

addPipe

final void addPipe(java.lang.String name,
                   Pipe pipe)
            throws DuplicatePipeException
Adds a Pipe to the request context.

Parameters:
name - The name of the pipe to add.
pipe - The Pipe to add.
Throws:
DuplicatePipeException - If a pipe with the same name has already been added to the context.

hasPipe

final boolean hasPipe(java.lang.String name)
Checks whether the context contains a pipe with the given name.

Parameters:
name - The name of the pipe.
Returns:
true if it does, else false.

getDataResourceAccessor

public final DataResourceAccessor getDataResourceAccessor()
Gets the DataResourceAccessor providing access to the underlying data resource associated with the data service resource.

Returns:
DataResourceAccessor, the concrete type of which depends on the data service resource configuration.

getDataResourceFactory

public final DataServiceResourceFactory getDataResourceFactory()
Gets the data service resource factory through which new data service resources can be created.

Returns:
data service resource factory.

getInput

public final BlockReader getInput(java.lang.String name)
                           throws ActivityStreamNotFoundException
Gets the BlockReader for an internal input to the activity.

Parameters:
name - The name of the input.
Returns:
a BlockReader from which the input data can be read.
Throws:
ActivityStreamNotFoundException - If the specified input is not contained in the context.

getOutput

public final BlockWriter getOutput(java.lang.String name)
                            throws ActivityStreamNotFoundException
Gets the BlockWriter for an internal output from the activity.

Parameters:
name - The name of the output.
Returns:
a BlockWriter to which the output data can be written.
Throws:
ActivityStreamNotFoundException - If the specified output is not contained in the context.

getSecurityContext

public final SecurityContext getSecurityContext()
Gets the security context associated with the request.

Returns:
a SecurityContext instance

getURL

public java.lang.String getURL()
Returns the local path to the data service within its enclosing web application.

Returns:
a String object or null if the request is running outwith a web service.

getResourceID

public java.lang.String getResourceID()
Returns the resource ID associated with the request

Returns:
resource ID.

getAttachmentManager

public AttachmentManager getAttachmentManager()
Gets the attachment manager through which attachments can be added to the response document.

Returns:
The attachment manager, or null is there is not one.

getAuthorizer

public AccessAuthorizer getAuthorizer()
Gets the authorizer which authorizes access to resources and activities.

Returns:
access authorizer

setError

final void setError(java.lang.Throwable cause)
Sets a reference to the first error raised by an activity.

Parameters:
cause - Error raised by an activity.

hasError

final boolean hasError()
Indicates whether or not there has been an error while the request has been processing.

Returns:
true if there has been an error, otherwise false

getCauseOfError

final java.lang.Throwable getCauseOfError()
If there is an error during the processing of a request, return the exception.

Returns:
an exception if there has been an error processing the request or otherwise null

getActivityRequest

final ActivityRequest getActivityRequest()
Gets the activity request containing the activity.

Returns:
an ActivityRequest object