com.sage.orion.sdata.servlet
Class SDataRequestImpl

java.lang.Object
  extended by com.sage.orion.sdata.servlet.SDataRequestImpl
All Implemented Interfaces:
SDataRequest

public class SDataRequestImpl
extends java.lang.Object
implements SDataRequest

TODO: Fill in Javadoc for SDataRequestImpl.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sage.orion.sdata.servlet.SDataRequest
SDataRequest.SDataMethod
 
Constructor Summary
SDataRequestImpl(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context, SDataServletContext sDataContext, SDataDiagnoses sdataDiagnoses)
          Constructor.
 
Method Summary
 java.lang.String getAccpacSessionID()
          Gets the Sage 300 ERP (formerly Accpac) session ID for the current session.
 java.lang.String getApplicationName()
          Gets the application name from the request.
 java.lang.String getAuthorizationToken()
          gets the authorization token for the request.
 java.lang.String getConnectionID()
          TODO: javadoc
 java.lang.String getContractName()
          Gets the contract name in the SData Request.
 java.lang.String getDataSet()
          Get the dataset from the url request.
 SDataRequestEntry getEntryPayload()
          Gets the Entry payload.
 SDataRequestFeed getFeedPayload()
          Gets the Feed payload.
 java.lang.String getFullURL()
          returns the full URI of the Resources set
 javax.servlet.http.HttpSession getHttpSession()
          returns the HTTP Session
 java.util.Locale getHttpSessionLocale()
          returns the HTTP Session Locale
 java.lang.String getIfMatch()
          Gets the if-Match header value, or null if there is none.
 SDataRequest.SDataMethod getMethod()
          Gets the method for the SDataRequest.
 java.util.List<OrderByParameter> getOrderByParameters()
          Gets the list of order by parameters from the url.
 PagingControl getPagingControlRequest()
          return the paging request
 com.sage.swt.common.filter.QueryExpression getQueryFilter()
          Gets the QueryFilter for the SDataRequest.
 QueryPayloadControl getQueryPayloadControl()
          Gets the QueryPayloadControl for the SDataRequest.
 java.util.List<ResourceElement> getResourceElements()
          Gets a list of the Resource Elements.
 java.lang.String getResourceKindName()
          Gets the ResourceKindName for the SDataRequest.
 java.lang.String getResourceSetURL()
          Get the URL that defines the resource set.
 java.lang.String getResourcesURL()
          returns the full URI of the Resources set, as required for links
 SDataServletContext getsDataContext()
          Get the SDataServlet context for the request.
 SDataDiagnoses getSDataDiagnoses()
          Get the error stack for this request.
 int getSequenceNumber()
          Gets the sequence number of the request.
 SDataServer getServer()
          Gets the SData Server that is handling the request.
 int getSessionTimeout()
          Gets the Tomcat Session Timeout value in minutes.
 TrackingIDInfo getTrackingIDInfoRequest()
          Get the TrackingIDInfo object from either the Resource Element or from Query Parameter.
 java.lang.String getWebappURL()
          returns the URL of the Webapp
 java.lang.String getWhereClause()
          returns the where clause or null if there is none
 boolean hasApplication()
          Checks to see if the request has an application specified.
 boolean hasContract()
          Checks to see if the request has a contract specified.
 boolean hasDataset()
          Checks to see if the request has a dataset specified (including the hyphen signifying the default dataset).
 boolean hasDefaultDataset()
          returns whether the request specifies the default dataset as opposed to a named dataset
 boolean hasQueryFilter()
           
 boolean isAsyncRequest()
           
 boolean isBatchRequest()
          returns whether the request is for a batch
 boolean isCommitted()
          returns true if and only if the request is to be committed.
 boolean isConnectRequest()
          TODO - isConnectionRequest(), getConnectionID() and isStatelessRequest() are routines specific to Sage 300 ERP.
 boolean isForSingleResource()
          returns true if the request is for a single resource, i.e.
 boolean isSameRequest(SDataRequest other)
          is this request the same as the other one in all important aspects (e.g.
 boolean isSchemaRequest()
          returns whether the request is for a schema
 boolean isServiceListRequest()
          returns true if the request is a Service Request to get a list of services.
 boolean isServiceRequest()
          returns whether the request is for a service operation
 boolean isSpecialRequest()
          returns whether the request is a special (e.g.
 boolean isStatelessRequest()
          returns true if and only if the request is stateless.
 boolean isTemplateRequest()
          returns whether the request is for a template
 void setAuthorizationToken(java.lang.String token)
          sets the authorization token.
 boolean specifiesInlinedSchema()
          returns true if and only if the request specifies that an inlined schema should be included in the response
 boolean specifiesReturnDelta()
          returns true if and only if the request specified that the server should only include the properties that have been modified in the response
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SDataRequestImpl

public SDataRequestImpl(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.ServletContext context,
                        SDataServletContext sDataContext,
                        SDataDiagnoses sdataDiagnoses)
Constructor.

FIXME The request should only be used during the constructor; no reference to it should remain after the construction. At least, that is my view. But I guess it does not really matter.

Parameters:
request - the original HTTP request;
context - the servlet context in which this is happening
sDataContext - the SDataServletContext.
sdataDiagnoses - the error stack for this request
Method Detail

getContractName

public java.lang.String getContractName()
Description copied from interface: SDataRequest
Gets the contract name in the SData Request. If there is no contract the behaviour is not defined

Specified by:
getContractName in interface SDataRequest
Returns:
the contract
See Also:
SDataRequest.hasContract()

getDataSet

public java.lang.String getDataSet()
Get the dataset from the url request.

Specified by:
getDataSet in interface SDataRequest
Returns:
the dataset portion of the request.
See Also:
SDataRequest.hasDataset(), SDataRequest.hasDefaultDataset()

getResourceKindName

public java.lang.String getResourceKindName()
Description copied from interface: SDataRequest
Gets the ResourceKindName for the SDataRequest.

Specified by:
getResourceKindName in interface SDataRequest
Returns:
the resourceKindName

getMethod

public SDataRequest.SDataMethod getMethod()
Description copied from interface: SDataRequest
Gets the method for the SDataRequest.

Specified by:
getMethod in interface SDataRequest
Returns:
the method

getFeedPayload

public SDataRequestFeed getFeedPayload()
Description copied from interface: SDataRequest
Gets the Feed payload. This returns a null reference if the request is not compatible with having a feed payload

Specified by:
getFeedPayload in interface SDataRequest
Returns:
the feed payload, or a null reference if there is none.

getEntryPayload

public SDataRequestEntry getEntryPayload()
Description copied from interface: SDataRequest
Gets the Entry payload. This returns a null reference if the request is not compatible with having an entry payload

Specified by:
getEntryPayload in interface SDataRequest
Returns:
the entry payload, or a null reference if there is none.

getResourceElements

public java.util.List<ResourceElement> getResourceElements()
Description copied from interface: SDataRequest
Gets a list of the Resource Elements.

A Resource Element is a resource or property name along with its key or predicate, or one of the special names such as $schema.

e.g. http://someserver/sdata/app('abc')/contract/Orders('01')/Details('6')/DetailComments consists of 3 Resource Element objects: Orders, Details and DetailComments.

Specified by:
getResourceElements in interface SDataRequest
Returns:
a List of the resource elements

getPagingControlRequest

public PagingControl getPagingControlRequest()
Description copied from interface: SDataRequest
return the paging request

There must be a paging request (i.e. this function must return a non-null value), although the request may actually have no data in it

Specified by:
getPagingControlRequest in interface SDataRequest
Returns:
the paging request (and never null)

getTrackingIDInfoRequest

public TrackingIDInfo getTrackingIDInfoRequest()
Description copied from interface: SDataRequest
Get the TrackingIDInfo object from either the Resource Element or from Query Parameter. TrackingIDInfo object contains the TrackingID and also the Operation Name.

Specified by:
getTrackingIDInfoRequest in interface SDataRequest
Returns:
TrackingIDInfo

getResourcesURL

public java.lang.String getResourcesURL()
Description copied from interface: SDataRequest
returns the full URI of the Resources set, as required for links

Specified by:
getResourcesURL in interface SDataRequest
Returns:
the full URI of the Resources set, as required for links

getFullURL

public java.lang.String getFullURL()
Description copied from interface: SDataRequest
returns the full URI of the Resources set

Specified by:
getFullURL in interface SDataRequest
Returns:
the full URI of the Resources set

getResourceSetURL

public java.lang.String getResourceSetURL()
Description copied from interface: SDataRequest
Get the URL that defines the resource set. That is, the URL that includes the where & orderBy if they presents, but does not include paging info (StartKey, etc.)

Specified by:
getResourceSetURL in interface SDataRequest
Returns:
the URL for the resource set

getSDataDiagnoses

public SDataDiagnoses getSDataDiagnoses()
Description copied from interface: SDataRequest
Get the error stack for this request. This is initially an empty stack and provides a home to allow building up diagnostic messages while processing the request.

Specified by:
getSDataDiagnoses in interface SDataRequest
Returns:
SDataDiagnoses for the request.

isSpecialRequest

public boolean isSpecialRequest()
Description copied from interface: SDataRequest
returns whether the request is a special (e.g. $schema, $template)

Specified by:
isSpecialRequest in interface SDataRequest
Returns:
whether the request is a special (e.g. $schema, $template)

isSchemaRequest

public boolean isSchemaRequest()
Description copied from interface: SDataRequest
returns whether the request is for a schema

Specified by:
isSchemaRequest in interface SDataRequest
Returns:
whether the request is for a schema

isServiceRequest

public boolean isServiceRequest()
Description copied from interface: SDataRequest
returns whether the request is for a service operation

Specified by:
isServiceRequest in interface SDataRequest
Returns:
whether the request is for a service operation

isTemplateRequest

public boolean isTemplateRequest()
Description copied from interface: SDataRequest
returns whether the request is for a template

Specified by:
isTemplateRequest in interface SDataRequest
Returns:
whether the request is for a template

isBatchRequest

public boolean isBatchRequest()
Description copied from interface: SDataRequest
returns whether the request is for a batch

Specified by:
isBatchRequest in interface SDataRequest
Returns:
whether the request is for a batch

getWhereClause

public java.lang.String getWhereClause()
Description copied from interface: SDataRequest
returns the where clause or null if there is none

Specified by:
getWhereClause in interface SDataRequest
Returns:
the where clause or null if there is none

getQueryFilter

public com.sage.swt.common.filter.QueryExpression getQueryFilter()
Description copied from interface: SDataRequest
Gets the QueryFilter for the SDataRequest.

Specified by:
getQueryFilter in interface SDataRequest
Returns:
the QueryFilter for the SDataRequest. Returns null if there is no query filter.

hasQueryFilter

public boolean hasQueryFilter()
Specified by:
hasQueryFilter in interface SDataRequest
Returns:
true if the request includes a query filter.

getOrderByParameters

public java.util.List<OrderByParameter> getOrderByParameters()
Description copied from interface: SDataRequest
Gets the list of order by parameters from the url.

Specified by:
getOrderByParameters in interface SDataRequest
Returns:
list of order by parameters.

hasDataset

public boolean hasDataset()
Description copied from interface: SDataRequest
Checks to see if the request has a dataset specified (including the hyphen signifying the default dataset). This will be false if the request was an intermediate URL for the list of datasets, contracts or applications. Call SDataRequest.hasDefaultDataset() to see if the dataset specified is the default dataset or a named dataset. If it is a named dataset then call SDataRequest.getDataSet() to get the name of the dataset.

Specified by:
hasDataset in interface SDataRequest
Returns:
true if and only if the request specified a (possibly default) dataset.
See Also:
SDataRequest.hasDefaultDataset(), SDataRequest.getDataSet()

hasDefaultDataset

public boolean hasDefaultDataset()
Description copied from interface: SDataRequest
returns whether the request specifies the default dataset as opposed to a named dataset

Specified by:
hasDefaultDataset in interface SDataRequest
Returns:
true or false;

isAsyncRequest

public boolean isAsyncRequest()
Specified by:
isAsyncRequest in interface SDataRequest
Returns:
true if the request is asynchronous.

isForSingleResource

public boolean isForSingleResource()
Description copied from interface: SDataRequest
returns true if the request is for a single resource, i.e. if the last ResourceElement in the URL specifies a ResourceSelector

Specified by:
isForSingleResource in interface SDataRequest
Returns:
true if and only if the request is for a single resource rather than a feed

isSameRequest

public boolean isSameRequest(SDataRequest other)
Description copied from interface: SDataRequest
is this request the same as the other one in all important aspects (e.g. a repeated request or an echo)

Specified by:
isSameRequest in interface SDataRequest
Parameters:
other - The other SDataRequest to compare.
Returns:
true if and only if the two requests are equivalent

getApplicationName

public java.lang.String getApplicationName()
Description copied from interface: SDataRequest
Gets the application name from the request.

The application name returned consists only of ASCII characters and is returned in lower case.

Specified by:
getApplicationName in interface SDataRequest
Returns:
the application name or null if not found.
See Also:
SDataRequest.hasApplication()

isConnectRequest

public boolean isConnectRequest()
TODO - isConnectionRequest(), getConnectionID() and isStatelessRequest() are routines specific to Sage 300 ERP. Eventually they should be moved out of this package.

Specified by:
isConnectRequest in interface SDataRequest
Returns:
true if the request is for maintaining a connection
See Also:
SDataRequest.isStatelessRequest(), SDataRequest.getConnectionID(), SDataRequest.getSequenceNumber()

getConnectionID

public java.lang.String getConnectionID()
TODO: javadoc

Specified by:
getConnectionID in interface SDataRequest
Returns:
TODO: javadoc
See Also:
SDataRequest.getSequenceNumber(), SDataRequest.isStatelessRequest(), SDataRequest.isConnectRequest(), SDataRequest.isCommitted()

isStatelessRequest

public boolean isStatelessRequest()
Description copied from interface: SDataRequest
returns true if and only if the request is stateless.

If the request is not stateless (is stateful) then the request will typically be handled slightly differently from if it is stateless.

If the request is not stateless then call SDataRequest.getConnectionID() to find the connection ID.

The connection maintenance requests themselves (see SDataRequest.isConnectRequest()) are stateless.

This and the other methods about state are Sage 300 ERP extensions

Specified by:
isStatelessRequest in interface SDataRequest
Returns:
true if and only if the request is stateless.
See Also:
SDataRequest.isConnectRequest(), SDataRequest.getConnectionID(), SDataRequest.getSequenceNumber(), SDataRequest.isCommitted()

isServiceListRequest

public boolean isServiceListRequest()
Description copied from interface: SDataRequest
returns true if the request is a Service Request to get a list of services. For example ..\contract\resourceKind\$service\ but not ..\contract\resourceKind\$service\operationName\

Specified by:
isServiceListRequest in interface SDataRequest
Returns:
whether the request is to get a list of services

isCommitted

public boolean isCommitted()
Description copied from interface: SDataRequest
returns true if and only if the request is to be committed.

If the request is stateful then the request may be flagged as not to be committed. If the request is stateless then for convenience this function will return true rather than throwing an exception.

This and the other methods about state are Sage 300 ERP extensions

Specified by:
isCommitted in interface SDataRequest
Returns:
true if and only if the request is to be committed.
See Also:
SDataRequest.isStatelessRequest(), SDataRequest.isConnectRequest(), SDataRequest.getConnectionID()

specifiesInlinedSchema

public boolean specifiesInlinedSchema()
Description copied from interface: SDataRequest
returns true if and only if the request specifies that an inlined schema should be included in the response

Specified by:
specifiesInlinedSchema in interface SDataRequest
Returns:
whether the request specifies returning a schema with the response

getSequenceNumber

public int getSequenceNumber()
Description copied from interface: SDataRequest
Gets the sequence number of the request.

If the request has a connection ID (see SDataRequest.getConnectionID()) then it must also have a sequence number, which specifies the order in which the requests were generated, so that they can be handled in the same order.

This and the other methods about state are Sage 300 ERP extensions

Specified by:
getSequenceNumber in interface SDataRequest
Returns:
the sequence number of the request
See Also:
SDataRequest.getConnectionID(), SDataRequest.isStatelessRequest(), SDataRequest.isConnectRequest(), SDataRequest.isCommitted()

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Description copied from interface: SDataRequest
returns the HTTP Session

Specified by:
getHttpSession in interface SDataRequest
Returns:
the HTTP Session

getHttpSessionLocale

public java.util.Locale getHttpSessionLocale()
Description copied from interface: SDataRequest
returns the HTTP Session Locale

Specified by:
getHttpSessionLocale in interface SDataRequest
Returns:
the current locale of HTTP Session

getWebappURL

public java.lang.String getWebappURL()
Description copied from interface: SDataRequest
returns the URL of the Webapp

Specified by:
getWebappURL in interface SDataRequest
Returns:
the URL of the Webapp

hasApplication

public boolean hasApplication()
Description copied from interface: SDataRequest
Checks to see if the request has an application specified. This will be false if the request was an intermediate URL for the list of applications. Call SDataRequest.getApplicationName() to get the name of the application.

Specified by:
hasApplication in interface SDataRequest
Returns:
true if and only if the request specified an application name.
See Also:
SDataRequest.getApplicationName(), SDataRequest.hasContract()

hasContract

public boolean hasContract()
Description copied from interface: SDataRequest
Checks to see if the request has a contract specified. This will be false if the request was an intermediate URL for the list of applications or contracts. Call SDataRequest.getContractName() to get the name of the contract.

Specified by:
hasContract in interface SDataRequest
Returns:
true if and only if the request specified a contract
See Also:
SDataRequest.getContractName(), SDataRequest.hasDataset(), SDataRequest.hasApplication()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

specifiesReturnDelta

public boolean specifiesReturnDelta()
returns true if and only if the request specified that the server should only include the properties that have been modified in the response

Specified by:
specifiesReturnDelta in interface SDataRequest
Returns:
whether the request specified a delta return

getServer

public SDataServer getServer()
Gets the SData Server that is handling the request. This includes such information as the contract and dataset and is frequently used to generate links to other resources such as schemas etc.

Specified by:
getServer in interface SDataRequest
Returns:
an SDataServer representing the server that is handling the request

getQueryPayloadControl

public QueryPayloadControl getQueryPayloadControl()
Gets the QueryPayloadControl for the SDataRequest.

Specified by:
getQueryPayloadControl in interface SDataRequest
Returns:
a non-null QueryPayloadControl containing the various elements that control the response payload content

getIfMatch

public java.lang.String getIfMatch()
Gets the if-Match header value, or null if there is none.

Specified by:
getIfMatch in interface SDataRequest
Returns:
null if there is no ifMatch header and its value if there is one.

setAuthorizationToken

public void setAuthorizationToken(java.lang.String token)
sets the authorization token. Ideally this should actually happen during construction but that will have to wait.

The token should be set once and once only.

Parameters:
token - the token to set
See Also:
getAuthorizationToken()

getAuthorizationToken

public java.lang.String getAuthorizationToken()
gets the authorization token for the request. The format of the token varies between application

Specified by:
getAuthorizationToken in interface SDataRequest
Returns:
the authorization token

getAccpacSessionID

public java.lang.String getAccpacSessionID()
Description copied from interface: SDataRequest
Gets the Sage 300 ERP (formerly Accpac) session ID for the current session.

Specified by:
getAccpacSessionID in interface SDataRequest
Returns:
session id

getsDataContext

public SDataServletContext getsDataContext()
Get the SDataServlet context for the request.

Returns:
SDataServletContext

getSessionTimeout

public int getSessionTimeout()
Description copied from interface: SDataRequest
Gets the Tomcat Session Timeout value in minutes.

Specified by:
getSessionTimeout in interface SDataRequest


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