uk.org.ogsadai.client.toolkit.resource
Class SimpleRequestResource

java.lang.Object
  extended by uk.org.ogsadai.client.toolkit.resource.ResourceWrapper
      extended by uk.org.ogsadai.client.toolkit.resource.SimpleRequestResource
All Implemented Interfaces:
RequestResource, Resource

public class SimpleRequestResource
extends ResourceWrapper
implements RequestResource

Simple implementation of a request resource.

Author:
The OGSA-DAI Project Team

Constructor Summary
SimpleRequestResource(Resource resource)
          Constructor.
 
Method Summary
protected  RequestExecutionStatus fetchExecutionStatus()
          Gets the request execution status from the server.
protected  RequestStatus fetchRequestStatus()
          Gets the request status from the server.
 ActivitiesMetaData getActivityDetails()
          Gets details of the activities that can be targeted at this resource.
 RequestStatus getLocalRequestStatus()
          Gets the status of the request as stored locally.
 RequestExecutionStatus getRequestExecutionStatus()
          Gets the execution status of the request.
 RequestStatus getRequestStatus()
          Gets the status of the request.
 SessionResource getSessionResource()
          Gets the session resource associated with this request.
 boolean hasSession()
          Gets whether or not this request has an associated session.
 void pollUntilRequestCompleted(int pollInterval)
          Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is completed.
 void pollUntilRequestCompleted(int pollInterval, int timeoutPeriod)
          Polls a request resource to obtain the latest execution status is blocks until the status is COMPLETED.
 void pollUntilRequestStarted(int pollInterval)
          Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is started.
 void pollUntilRequestStarted(int pollInterval, int timeoutPeriod)
          Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is started.
 void setRequestStatus(RequestStatus requestStatus)
          Sets the requests status for the request resource.
 void setRequestWorkflow(Workflow requestWorkflow)
          Sets the request workflow.
 void setSessionResource(SessionResource sessionResource)
          Sets the session resource associated with the request.
 
Methods inherited from class uk.org.ogsadai.client.toolkit.resource.ResourceWrapper
addServerCommsProperty, destroy, getCurrentTime, getMultipleResourceProperties, getResource, getResourceID, getResourceProperty, getResourceType, getTerminationTime, setTerminationTime, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.org.ogsadai.client.toolkit.Resource
addServerCommsProperty, destroy, getCurrentTime, getMultipleResourceProperties, getResourceID, getResourceProperty, getResourceType, getTerminationTime, setTerminationTime, setTimeout
 

Constructor Detail

SimpleRequestResource

public SimpleRequestResource(Resource resource)
Constructor.

Parameters:
resource - class implementing the base resource operations
Method Detail

getRequestExecutionStatus

public RequestExecutionStatus getRequestExecutionStatus()
                                                 throws ServerCommsException,
                                                        ServerException,
                                                        ResourceUnknownException,
                                                        ClientServerCompatibilityException,
                                                        ClientToolkitException
Description copied from interface: RequestResource
Gets the execution status of the request. If the final request execution status has not yet been obtained from the server then the latest request execution status will be obtained and returned. If the final request execution status has already been obtained and is stored locally it will be returned and no call will be made to the server.

Specified by:
getRequestExecutionStatus in interface RequestResource
Returns:
the request execution status
Throws:
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if there are incompatibility issues between the client and the server.
ClientToolkitException - if an internal client toolkit error occurs.

hasSession

public boolean hasSession()
Description copied from interface: RequestResource
Gets whether or not this request has an associated session.

Specified by:
hasSession in interface RequestResource
Returns:
true if the request has an associated session, or false otherwise.

getSessionResource

public SessionResource getSessionResource()
Description copied from interface: RequestResource
Gets the session resource associated with this request.

Specified by:
getSessionResource in interface RequestResource
Returns:
session resource associated with the request, or null if there is none.

setSessionResource

public void setSessionResource(SessionResource sessionResource)
Description copied from interface: RequestResource
Sets the session resource associated with the request.

Specified by:
setSessionResource in interface RequestResource
Parameters:
sessionResource - session resource or null if there is no session associated with this request.

setRequestWorkflow

public void setRequestWorkflow(Workflow requestWorkflow)
Description copied from interface: RequestResource
Sets the request workflow.

Specified by:
setRequestWorkflow in interface RequestResource
Parameters:
requestWorkflow - the request workflow.

setRequestStatus

public void setRequestStatus(RequestStatus requestStatus)
Description copied from interface: RequestResource
Sets the requests status for the request resource.

Specified by:
setRequestStatus in interface RequestResource
Parameters:
requestStatus - requests status.

getRequestStatus

public RequestStatus getRequestStatus()
                               throws ServerCommsException,
                                      ServerException,
                                      ResourceUnknownException,
                                      ClientServerCompatibilityException,
                                      ClientToolkitException
Description copied from interface: RequestResource
Gets the status of the request. If the final request status has not yet been obtained from the server then the latest request status will be obtained and returned. If the final request status has already been obtained and is stored locally it will be returned and no call will be made to the server.

Specified by:
getRequestStatus in interface RequestResource
Returns:
the request status
Throws:
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if the data received from the server is cannot be handled by the client toolkit.
ClientToolkitException - if an internal client toolkit error occurs.

getLocalRequestStatus

public RequestStatus getLocalRequestStatus()
                                    throws ClientToolkitException
Description copied from interface: RequestResource
Gets the status of the request as stored locally. This method call will not contact the server but will instead return the locally stored request status. This status will be either the one recieved when the request was sent to the server or the last one received via a call to getRequestStatus.

Specified by:
getLocalRequestStatus in interface RequestResource
Returns:
the local request status
Throws:
ClientToolkitException - if an internal client toolkit error occurs.

getActivityDetails

public ActivitiesMetaData getActivityDetails()
                                      throws ServerCommsException,
                                             ServerException,
                                             ResourceUnknownException,
                                             ClientServerCompatibilityException,
                                             ClientToolkitException
Description copied from interface: Resource
Gets details of the activities that can be targeted at this resource.

Specified by:
getActivityDetails in interface Resource
Overrides:
getActivityDetails in class ResourceWrapper
Returns:
details of the activities that can target this resource.
Throws:
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

pollUntilRequestStarted

public void pollUntilRequestStarted(int pollInterval)
                             throws RequestErrorException,
                                    ServerCommsException,
                                    ServerException,
                                    ResourceUnknownException,
                                    ClientServerCompatibilityException,
                                    ClientToolkitException
Description copied from interface: RequestResource
Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is started.

If the status shows an error has occurred before starting then a RequestErrorException is thrown.

This method does not timeout. It will only terminate when the status shows the request has completed or in error, or when an error occurs contacting the service.

Specified by:
pollUntilRequestStarted in interface RequestResource
Parameters:
pollInterval - Time (in milliseconds) between polls.
Throws:
RequestErrorException - if the request failed to start due to an error.
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

pollUntilRequestStarted

public void pollUntilRequestStarted(int pollInterval,
                                    int timeoutPeriod)
                             throws RequestErrorException,
                                    TimeoutException,
                                    ServerCommsException,
                                    ServerException,
                                    ResourceUnknownException,
                                    ClientServerCompatibilityException,
                                    ClientToolkitException
Description copied from interface: RequestResource
Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is started.

If the status shows an error has occured before starting then a RequestErrorException is thrown.

This method does not timeout. It will only terminate when the status shows the request has completed or in error, or when an error occurs contacting the service.

Specified by:
pollUntilRequestStarted in interface RequestResource
Parameters:
pollInterval - Time (in milliseconds) between polls.
timeoutPeriod - Time (in milliseconds) before timeout.
Throws:
RequestErrorException - if the request failed to start due to an error
TimeoutException - if the method times out before the request has finished.
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

pollUntilRequestCompleted

public void pollUntilRequestCompleted(int pollInterval)
                               throws RequestExecutionException,
                                      ServerCommsException,
                                      ServerException,
                                      ResourceUnknownException,
                                      ClientServerCompatibilityException,
                                      ClientToolkitException
Description copied from interface: RequestResource
Polls a request resource to obtain the latest execution status and blocks until the status indicates that processing is completed.

If the final status shows that the request has not completed successfully a RequestExecutionException is thrown.

This method does not timeout. It will only terminate when the status shows the request has completed or in error, or when an error occurs contacting the service.

Specified by:
pollUntilRequestCompleted in interface RequestResource
Parameters:
pollInterval - Time (in milliseconds) between polls.
Throws:
RequestExecutionException - if the request failed to run to completion or completes with an error.
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

pollUntilRequestCompleted

public void pollUntilRequestCompleted(int pollInterval,
                                      int timeoutPeriod)
                               throws RequestExecutionException,
                                      TimeoutException,
                                      ServerCommsException,
                                      ServerException,
                                      ResourceUnknownException,
                                      ClientServerCompatibilityException,
                                      ClientToolkitException
Description copied from interface: RequestResource
Polls a request resource to obtain the latest execution status is blocks until the status is COMPLETED.

If at any time the status indicates that the request is not progressing smoothly a RequestStatusException is thrown.

If the execution status has not reached COMPLETED within the specififed timeout period a RequestStatusException is thrown.

Specified by:
pollUntilRequestCompleted in interface RequestResource
Parameters:
pollInterval - Time (in milliseconds) between polls.
timeoutPeriod - Time (in milliseconds) before timeout.
Throws:
RequestExecutionException - if the request failed to run to completion due to an error, termination.
TimeoutException - if the method times out before the request has finished.
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server or is the wrong type.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

fetchRequestStatus

protected RequestStatus fetchRequestStatus()
                                    throws ServerCommsException,
                                           ServerException,
                                           ResourceUnknownException,
                                           ClientServerCompatibilityException,
                                           ClientToolkitException
Gets the request status from the server.

Returns:
the request status.
Throws:
ServerCommsException - if an error occurs communicating with the server.
ServerException - if an internal error occurs at the server.
ResourceUnknownException - if the resource is unknown to the server.
ClientServerCompatibilityException - if the server does not behave as expected.
ClientToolkitException - if an internal client toolkit error occurs.

fetchExecutionStatus

protected RequestExecutionStatus fetchExecutionStatus()
                                               throws ServerCommsException,
                                                      ServerException,
                                                      ResourceUnknownException,
                                                      ClientServerCompatibilityException,
                                                      ClientToolkitException
Gets the request execution status from the server.

Returns:
the request execution status.
Throws:
ServerException - if an internal error occurs at the server.
ClientServerCompatibilityException - if the server does not behave as expected.
ResourceUnknownException - if the resource is unknown to the server.
ClientToolkitException - if an internal client toolkit error occurs.
ServerCommsException - if an error occurs communicating with the server.