com.sage.orion.sdata.servlet
Class BaseServiceOperation

java.lang.Object
  extended by com.sage.orion.sdata.servlet.BaseServiceOperation
All Implemented Interfaces:
ServiceOperation
Direct Known Subclasses:
BaseService, ChangePasswordOperation, CloseSessionOperation, GetLoginTokenOperation, OpenSessionOperation, PingOperation

public abstract class BaseServiceOperation
extends java.lang.Object
implements ServiceOperation

An abstract class that provides an adapter for the ServiceOperation interface.

Each subclass must implement the following abstract methods:

The subclass will probably also wish to override the following methods:


Nested Class Summary
protected static class BaseServiceOperation.FieldData
          The set of field data complete with methods to retrieve it based upon FieldNames
protected static class BaseServiceOperation.FieldNames
          The pair of field name and description.
 
Constructor Summary
BaseServiceOperation()
           
 
Method Summary
protected abstract  java.util.List<ServiceField> createRequestFields(SDataRequest request)
          Create a list of input fields for Request.
protected abstract  java.util.List<ServiceField> createResponseFields(SDataRequest request)
          Create a list of output fields for Response.
protected abstract  java.util.List<ServiceField> createTemplateFields(SDataRequest request)
          Create a list of fields for Template.
protected abstract  java.util.List<ServiceField> execute(SDataResourceElement payload, SDataRequest request, AsyncStatusListener listener)
          Execute this service operation and then set the value for the response fields, if any.
 java.lang.String getDescription()
          Get a description of the service operation, for use in service lists
protected abstract  java.lang.String getOperationName()
          Get the short name of this service operation, i.e.
protected abstract  java.lang.String getPath()
          Get the URL to this service operation.
protected  java.util.List<ServiceField> getResponseFields(SDataRequest request, java.lang.String... values)
          Creates the list of response fields populated with the data provided.
 SDataSchema getSchema(SDataRequest request)
          Returns the schema of the operation, based upon its properties
 ResourceResponse handleRequest(SDataRequest request, AsyncStatusListener listener)
          Handle the request
 void shutdown()
          Release any resources allocated for this service operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sage.orion.sdata.servlet.ServiceOperation
getName
 

Constructor Detail

BaseServiceOperation

public BaseServiceOperation()
Method Detail

getDescription

public java.lang.String getDescription()
Description copied from interface: ServiceOperation
Get a description of the service operation, for use in service lists

It defaults to the full name of this service operation, i.e. the operation name prefixed with resource name(s)

The description should be in the language required by the user

Specified by:
getDescription in interface ServiceOperation
Returns:
a non-null String containing the description of the service operation

handleRequest

public ResourceResponse handleRequest(SDataRequest request,
                                      AsyncStatusListener listener)
Description copied from interface: ServiceOperation
Handle the request

Specified by:
handleRequest in interface ServiceOperation
Parameters:
request - the SDataRequest
listener - the asynchronous status listener that will listen for events and status from the service operation
Returns:
the resource response.

shutdown

public void shutdown()
Description copied from interface: ServiceOperation
Release any resources allocated for this service operation.

Specified by:
shutdown in interface ServiceOperation

getOperationName

protected abstract java.lang.String getOperationName()
Get the short name of this service operation, i.e. the operation name which is not prefixed with resource name(s)

Returns:
service operation name

getPath

protected abstract java.lang.String getPath()
Get the URL to this service operation.

Returns:
the URL to this service operation

createRequestFields

protected abstract java.util.List<ServiceField> createRequestFields(SDataRequest request)
Create a list of input fields for Request.

Note that value for each field may not be initialized.

Parameters:
request - the SDataRequest, or null
Returns:
a list of service fields for Request, or return null or an empty list if no input fields are required.

createResponseFields

protected abstract java.util.List<ServiceField> createResponseFields(SDataRequest request)
Create a list of output fields for Response.

Note that value for each field may not be initialized.

Parameters:
request - the SDataRequest, or null
Returns:
a list of service fields for Response, or return null or an empty list if there are no output fields.

createTemplateFields

protected abstract java.util.List<ServiceField> createTemplateFields(SDataRequest request)
Create a list of fields for Template.

The list must be the same as (or a subset of) request fields and each field has been initialized with default value

Parameters:
request - the SDataRequest
Returns:
a list of service fields for Template, or return null or an empty list if there are no such fields.

execute

protected abstract java.util.List<ServiceField> execute(SDataResourceElement payload,
                                                        SDataRequest request,
                                                        AsyncStatusListener listener)
Execute this service operation and then set the value for the response fields, if any.

Parameters:
payload - the request (input) portion of the payload from the original SData request
request - the SDataRequest
listener - the AsyncStatusListener
Returns:
a list of service fields for response, or return null or an empty list if there are no output fields.

getResponseFields

protected final java.util.List<ServiceField> getResponseFields(SDataRequest request,
                                                               java.lang.String... values)
Creates the list of response fields populated with the data provided. This is a utility for the subclass to help it build the response to the execute method.

Parameters:
request - the SDataRequest
values - the list of values to add to the list, in the order they are specified in the createResponseFields(SDataRequest) list.
Returns:
the populated list

getSchema

public SDataSchema getSchema(SDataRequest request)
Returns the schema of the operation, based upon its properties

Parameters:
request - the SDataRequest, or null
Returns:
the SDataSchema object


Copyright © 2011 Sage Software, Inc. All rights reserved.