com.caplin.keymaster.servlet
Class JavaScriptFormatter

java.lang.Object
  extended by com.caplin.keymaster.servlet.JavaScriptFormatter
All Implemented Interfaces:
AdvancedResponseFormatter, ResponseFormatter
Direct Known Subclasses:
HTMLFormatter

public class JavaScriptFormatter
extends Object
implements AdvancedResponseFormatter

This ResponseFormatter is specially designed to link in with RTSL, RTML and WebSheet. It will produce one of two messages if no major errors occur. The two messages are:

Major errors include the request object being null or missing parameters.

Author:
David Shorten

Constructor Summary
JavaScriptFormatter()
           
 
Method Summary
 String formatErrorResponse(javax.servlet.http.HttpServletRequest request, String errorMessage)
           This method formats an error response into a proper format for JavaScript.
 String formatResponse(javax.servlet.http.HttpServletRequest request, String token)
           This method will encode a response suitable for JavaScript type applications (e.g.
 String formatResponse(javax.servlet.http.HttpServletRequest request, String token, UserCredentialsProvider provider)
           This method will encode a response suitable for JavaScript type applications (e.g.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptFormatter

public JavaScriptFormatter()
Method Detail

formatResponse

public String formatResponse(javax.servlet.http.HttpServletRequest request,
                             String token)

This method will encode a response suitable for JavaScript type applications (e.g. RTSL). Token will have a password that the calling application can use to access a Caplin Liberator source. The HttpServletRequest object must contain both a username and a sourceid parameter.

Specified by:
formatResponse in interface ResponseFormatter
Parameters:
request - the request object that has been sent to the servlet calling class. This should contain all the required parameters
token - the token used to access a Liberator source.
Returns:
a message containing a response (encodeOkResponse/encodeErrorResponse) or an error message.

formatResponse

public String formatResponse(javax.servlet.http.HttpServletRequest request,
                             String token,
                             UserCredentialsProvider provider)

This method will encode a response suitable for JavaScript type applications (e.g. RTSL). Token will have a password that the calling application can use to access a Caplin Liberator source. The HttpServletRequest object must contain both a username and a sourceid parameter, unless httpUserOverride is set to true, in which case the username parameter will be ignored.

Specified by:
formatResponse in interface AdvancedResponseFormatter
Parameters:
request - the request object that has been sent to the servlet calling class. This should contain all the required parameters
token - the token used to access a Liberator source.
httpUserOverride - allow the standard HTTP remote user to override any parameter username value. Should the call to HttpServletRequest.getRemoteUser() return null, then an error response will be sent regardless of whether username has been specified as part of the URL request parameters.
Returns:
a message containing a response (encodeOkResponse/encodeErrorResponse) or an error message.

formatErrorResponse

public String formatErrorResponse(javax.servlet.http.HttpServletRequest request,
                                  String errorMessage)

This method formats an error response into a proper format for JavaScript.

Specified by:
formatErrorResponse in interface ResponseFormatter
Parameters:
request - needs to contain the source id or else a source id of 0000 will be returned in the formatted response.
errorMessage - contains the cause of the error.
Returns:
a properly formatter string for a Caplin JavaScript application.
See Also:
ResponseFormatter.formatErrorResponse(javax.servlet.http.HttpServletRequest, java.lang.String)


Please send bug reports and comments to Caplin support