uk.org.ogsadai.client.toolkit.wsrf
Class WSRFDataService

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.wsrf.WSRFDataService
All Implemented Interfaces:
DAIService, DataService, DataTransport, Properties, Service
Direct Known Subclasses:
ConfigurableWSRFDataService

public class WSRFDataService
extends java.lang.Object
implements DataService

Author:
The OGSA-DAI Team. WSRF implementation of a DataService.

Field Summary
protected  ResourceID mResource
           
 
Constructor Summary
WSRFDataService(java.lang.String handle)
           
WSRFDataService(java.lang.String handle, ResourceID resourceID)
           
 
Method Summary
 void close()
          Used to terminate a clients use of a Data Service.
 ActivityMetaData getActivityMetaData(java.lang.String activityName)
          Retrieves meta data for the specified activity from the data service.
 java.lang.Object getBlock()
          Gets one block from the complete data set from the DT output stream.
 ConnectionProperty getConnectionProperty(javax.xml.namespace.QName name)
          Obtain a connection property with the specified name.
 DataResourceInfo getDataResourceInfo()
          Retrieves the data resource information from the data service.
 java.net.URL getDataTransportURL()
          Obtain the URL of the data service implementing the data transport interface
 java.lang.Object getFully()
          Gets the entire data set from the Data Transport output stream in one operation.
 java.lang.Object getNBlocks(int numberOfBlocks)
          Gets a number of blocks from the complete data set from the DT output stream as a single block.
 javax.xml.namespace.QName[] getPortTypes()
          Returns the port types that this service implements
 Property[] getProperties(javax.xml.namespace.QName[] names)
          Obtain multiple properties from a service in one request
 Property getProperty(javax.xml.namespace.QName name)
          Obtain a property of the service or the resource
 javax.xml.namespace.QName[] getPropertyNames()
          Obtain the names of the available properties
 ResourceID getResourceID()
          Get the ID of the resource this service communicates with
 ResourceID[] getResourceIDs()
          Obtain the resource IDs of the resources that are associated with this service
 RequestStatus getStatus()
          Gets the status of the current request.
 java.lang.String getStreamID()
          Obtain the stream ID of the input or output stream
 java.lang.String[] getSupportedActivities()
          Retrieves the names of the supported activities from the service.
 java.net.URL getURL()
          Obtain the URL of the service
 DAIVersion getVersion()
           
 Response perform(Request request)
          Sends the request document to a data service.
 Response perform(RequestComponent component)
          Sends a single activity request to the data service.
 void ping()
          Contacts the service to check it is running.
 void pollUntilRequestCompleted(int pollInterval)
          Polls the data service for the request status and blocks until the status is 'COMPLETED'.
 void pollUntilRequestCompleted(int pollInterval, int timeoutPeriod)
          Polls the data service for the request status and blocks until the status is 'COMPLETED'.
 boolean putBlock(java.lang.Object data)
          Puts one block from a larger data set in to the DT input stream.
 boolean putClosingBlock()
          Signals to the DT input stream that all blocks have been sent, so processing at the data service can be completed.
 boolean putFully(java.lang.Object data)
          Puts the entire data set in to the DT input stream in one operation.
 void setConnectionProperty(ConnectionProperty property)
          Configure the connection with a property.
 void setResourceID(ResourceID id)
          Set the ID of the resource this service communicates with
 void setStreamID(java.lang.String streamID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mResource

protected ResourceID mResource
Constructor Detail

WSRFDataService

public WSRFDataService(java.lang.String handle)
                throws java.net.MalformedURLException
Parameters:
handle -

WSRFDataService

public WSRFDataService(java.lang.String handle,
                       ResourceID resourceID)
                throws ServiceCommsException,
                       java.net.MalformedURLException
Parameters:
handle -
Method Detail

perform

public Response perform(Request request)
                 throws PerformException,
                        UnsupportedActivityException,
                        AuthorisationException,
                        ActivityException,
                        ResourceException,
                        ServiceCommsException,
                        ServerException
Description copied from interface: DataService
Sends the request document to a data service. The service will attempt to process the request and send a response.

Specified by:
perform in interface DataService
Parameters:
request - Request specifying the work to be performed at the data service.
Returns:
Response from the data service containing the status of the request and any output results.
Throws:
ServiceCommsException - If there was an error communicating with the service.
PerformException
ActivityException - If an activity produces an error when executed at the service, causing the request to fail.
UnsupportedActivityException
AuthorisationException
ResourceException
ServerException

perform

public Response perform(RequestComponent component)
                 throws PerformException,
                        UnsupportedActivityException,
                        AuthorisationException,
                        ActivityException,
                        ResourceException,
                        ServiceCommsException,
                        ServerException
Description copied from interface: DataService
Sends a single activity request to the data service. The data service will attempt to process the request and send a response.

This is a shortcut when the request consists of only one activity. It is functionally equivalent to:
perform( new ActivityRequest( new Activity[] { activity } ) )

Specified by:
perform in interface DataService
Parameters:
component - Activity to be performed.
Returns:
Response from the data service containing the status of the request and any output results.
Throws:
ServiceCommsException - If there was an error communicating with the service.
PerformException
ActivityException - If an activity produces an error when executed at the service, causing the request to fail.
UnsupportedActivityException
AuthorisationException
ResourceException
ServerException

getStatus

public RequestStatus getStatus()
                        throws ServiceCommsException,
                               ResourceException
Description copied from interface: DataService
Gets the status of the current request.

Specified by:
getStatus in interface DataService
Returns:
The status of the current request.
Throws:
ServiceCommsException - If there was an error communicating with the service.
ResourceException

pollUntilRequestCompleted

public void pollUntilRequestCompleted(int pollInterval)
                               throws RequestStatusException,
                                      ResourceException,
                                      ServiceCommsException,
                                      java.lang.IllegalArgumentException
Description copied from interface: DataService
Polls the data service for the request status and blocks until the status is 'COMPLETED'. If at any time the status indicates that the request is not progressing smoothly a RequestStatusException is thrown.

Specified by:
pollUntilRequestCompleted in interface DataService
Parameters:
pollInterval - time (in milliseconds) between polls
Throws:
java.lang.IllegalArgumentException - If the poll internal less than or equal to 0.
RequestStatusException - If the status shows that the requent is not progressing smoothly.
ServiceCommsException - If there was an error communicating with the service.
ResourceException

pollUntilRequestCompleted

public void pollUntilRequestCompleted(int pollInterval,
                                      int timeoutPeriod)
                               throws RequestStatusException,
                                      ResourceException,
                                      ServiceCommsException,
                                      java.lang.IllegalArgumentException
Description copied from interface: DataService
Polls the data service for the request status and 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 status has not reached COMPLETED within the specififed timeout period a RequestStatusException is thrown.

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

Specified by:
pollUntilRequestCompleted in interface DataService
Parameters:
pollInterval - time (in milliseconds) between polls
timeoutPeriod - time (in millisconds) to wait before giving up
Throws:
java.lang.IllegalArgumentException - If the poll internal is less than or equal to 0.
RequestStatusException - If the status shows that the requent is not progressing smoothly.
ServiceCommsException - If there was an error communicating with the service.
ResourceException

getDataResourceInfo

public DataResourceInfo getDataResourceInfo()
                                     throws ServiceCommsException,
                                            ResourceException
Description copied from interface: DataService
Retrieves the data resource information from the data service.

Specified by:
getDataResourceInfo in interface DataService
Returns:
information on the data resource
Throws:
ServiceCommsException - If there was an error communicating with the service.
ResourceException

getSupportedActivities

public java.lang.String[] getSupportedActivities()
                                          throws ResourceException,
                                                 ServiceCommsException
Description copied from interface: DataService
Retrieves the names of the supported activities from the service.

Specified by:
getSupportedActivities in interface DataService
Returns:
all supported activities
Throws:
ServiceCommsException - If there was an error communicating with the service.
ResourceException

getActivityMetaData

public ActivityMetaData getActivityMetaData(java.lang.String activityName)
                                     throws ResourceException,
                                            ServiceCommsException
Description copied from interface: DataService
Retrieves meta data for the specified activity from the data service.

Specified by:
getActivityMetaData in interface DataService
Parameters:
activityName - the name of a supported activity
Returns:
meta data
ResourceException
ServiceCommsException

getVersion

public DAIVersion getVersion()
                      throws ServiceCommsException,
                             ServerException
Specified by:
getVersion in interface DAIService
ServiceCommsException
ServerException

getFully

public java.lang.Object getFully()
                          throws AuthorisationException,
                                 ResourceException,
                                 ServiceCommsException,
                                 ServerException
Description copied from interface: DataTransport
Gets the entire data set from the Data Transport output stream in one operation. Uses the DT getFully operation.

Specified by:
getFully in interface DataTransport
Returns:
The entire data set
Throws:
ServiceCommsException - If there is a problem communicating with the data service
ServerException
AuthorisationException
ResourceException

getNBlocks

public java.lang.Object getNBlocks(int numberOfBlocks)
                            throws DataFormatException,
                                   ServiceCommsException
Description copied from interface: DataTransport
Gets a number of blocks from the complete data set from the DT output stream as a single block. Uses the DT getNBlocks operation. Returns null if there are no more blocks to retrieve.

Specified by:
getNBlocks in interface DataTransport
Parameters:
numberOfBlocks - The number of blocks to fetch from the DT output stream at once. These blocks will be amalgamated into a single block
Returns:
The block of data retrieved from the DT output stream, null if there are no more blocks to retrieve
Throws:
ServiceCommsException - If there is a problem communicating with the service.
DataFormatException - If there is a problem with the data.

getBlock

public java.lang.Object getBlock()
                          throws AuthorisationException,
                                 ResourceException,
                                 ServiceCommsException,
                                 ServerException
Description copied from interface: DataTransport
Gets one block from the complete data set from the DT output stream. Uses the DT getBlock operation. Returns null if there are no more blocks to retrieve.

Specified by:
getBlock in interface DataTransport
Returns:
The block of data retrieved from the DT output stream, null if there are no more blocks to retrieve
Throws:
ServerException - If there is a problem at the server
AuthorisationException
ServiceCommsException - If there is a problem communicating with the service.
ResourceException

putFully

public boolean putFully(java.lang.Object data)
                 throws AuthorisationException,
                        ResourceException,
                        DataFormatException,
                        ServiceCommsException,
                        ServerException
Description copied from interface: DataTransport
Puts the entire data set in to the DT input stream in one operation. Uses the DT putFully operation.

Specified by:
putFully in interface DataTransport
Parameters:
data - The data set to put in to the DataTransport input stream
Returns:
true if the data was successfully put, false otherwise.
Throws:
ResourceException
DataFormatException - If there is a problem with the data.
AuthorisationException
ServiceCommsException - If there is a problem communicating with the DataTransport input stream
ServerException

putBlock

public boolean putBlock(java.lang.Object data)
                 throws DataFormatException,
                        AuthorisationException,
                        ResourceException,
                        ServiceCommsException,
                        ServerException
Description copied from interface: DataTransport
Puts one block from a larger data set in to the DT input stream. Uses the DT putBlock operation. Once all blocks have been submitted using this method, the putClosingBlock method should be called to signal to the data service that all the data has been sent.

Specified by:
putBlock in interface DataTransport
Parameters:
data - The block to put in to the DataTransport input stream
Returns:
true if the data was successfully put, false otherwise.
Throws:
DataFormatException - If there is a problem with the data, or the putClosingBlock method has already been called.
ResourceException
AuthorisationException
ServiceCommsException - If there is a problem communicating with the DataTransport input stream
ServerException

putClosingBlock

public boolean putClosingBlock()
                        throws AuthorisationException,
                               ResourceException,
                               ServiceCommsException,
                               ServerException
Description copied from interface: DataTransport
Signals to the DT input stream that all blocks have been sent, so processing at the data service can be completed. After putClosingBlock has been called, the putBlock method should no longer be used.

Specified by:
putClosingBlock in interface DataTransport
Returns:
true if the closing block was successfully put, false otherwise.
Throws:
ServiceCommsException - If there is a problem communicating with the DataTransport input stream
ServerException
AuthorisationException
ResourceException

getURL

public java.net.URL getURL()
Description copied from interface: Service
Obtain the URL of the service

Specified by:
getURL in interface Service
Returns:
the URL

getResourceIDs

public ResourceID[] getResourceIDs()
                            throws ServiceCommsException,
                                   ServerException
Description copied from interface: Service
Obtain the resource IDs of the resources that are associated with this service

Specified by:
getResourceIDs in interface Service
Returns:
an array of resource IDs
Throws:
ServerException
ServiceCommsException

getPortTypes

public javax.xml.namespace.QName[] getPortTypes()
Description copied from interface: Service
Returns the port types that this service implements

Specified by:
getPortTypes in interface Service
Returns:
an array of port type names

setConnectionProperty

public void setConnectionProperty(ConnectionProperty property)
Description copied from interface: Service
Configure the connection with a property.

Specified by:
setConnectionProperty in interface Service
Parameters:
property - a connection property

getConnectionProperty

public ConnectionProperty getConnectionProperty(javax.xml.namespace.QName name)
Description copied from interface: Service
Obtain a connection property with the specified name.

Specified by:
getConnectionProperty in interface Service
Parameters:
name - property name
Returns:
the connection property object

getProperty

public Property getProperty(javax.xml.namespace.QName name)
                     throws ServiceCommsException,
                            DataFormatException,
                            InvalidPropertyNameException,
                            ResourceException
Description copied from interface: Properties
Obtain a property of the service or the resource

Specified by:
getProperty in interface Properties
Parameters:
name - qualified name of the property
Returns:
property
Throws:
ServiceCommsException - if there was a problem communicating with the service
InvalidPropertyNameException - if the property name was invalid
DataFormatException - if the response returned by the service did not have the expected format
ResourceException - if the resource could not be found or the ID was invalid

getProperties

public Property[] getProperties(javax.xml.namespace.QName[] names)
                         throws ServiceCommsException,
                                DataFormatException,
                                ResourceException,
                                InvalidPropertyNameException
Description copied from interface: Properties
Obtain multiple properties from a service in one request

Specified by:
getProperties in interface Properties
Parameters:
names - an array of qualified names
Returns:
array of properties
Throws:
ServiceCommsException - if there was a problem communicating with the service
InvalidPropertyNameException - if one of the property names was invalid
DataFormatException - if the response did not have the expected format
ResourceException - if the resource could not be found or the ID was valid

getPropertyNames

public javax.xml.namespace.QName[] getPropertyNames()
                                             throws ServiceCommsException
Description copied from interface: Properties
Obtain the names of the available properties

Specified by:
getPropertyNames in interface Properties
Returns:
array of qualified names
Throws:
ServiceCommsException - if there was a problem communicating with the service

getResourceID

public ResourceID getResourceID()
Get the ID of the resource this service communicates with

Specified by:
getResourceID in interface DataTransport
Returns:
resource ID

setResourceID

public void setResourceID(ResourceID id)
Set the ID of the resource this service communicates with

Specified by:
setResourceID in interface Service
Parameters:
id - resource ID

getStreamID

public java.lang.String getStreamID()
Description copied from interface: DataTransport
Obtain the stream ID of the input or output stream

Specified by:
getStreamID in interface DataTransport
Returns:
stream ID

setStreamID

public void setStreamID(java.lang.String streamID)

getDataTransportURL

public java.net.URL getDataTransportURL()
Description copied from interface: DataTransport
Obtain the URL of the data service implementing the data transport interface

Specified by:
getDataTransportURL in interface DataTransport
Returns:
URL

ping

public void ping()
          throws ServiceCommsException
Description copied from interface: Service
Contacts the service to check it is running.

Specified by:
ping in interface Service
Throws:
ServiceCommsException - If the service cannot be contacted.

close

public void close()
           throws ServiceCommsException,
                  ServiceTerminationException
Description copied from interface: DataService
Used to terminate a clients use of a Data Service.

The method will destroy an OGSI (GT3) Data Service. It will do nothing on other platforms.

Specified by:
close in interface DataService
Throws:
ServiceTerminationException - If there was a problem when trying to terminate the service
ServiceCommsException - If there was a problem accessing the service