com.caplin.keymaster.servlet
Class HTMLFormatter

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

public class HTMLFormatter
extends JavaScriptFormatter

This ResponseFormatter is specially designed to link in with SL4B. It wraps JavaScriptFormatter responses in HTML so it can be loaded in an embedded IFRAME.


Constructor Summary
HTMLFormatter()
           
 
Method Summary
 String formatErrorResponse(javax.servlet.http.HttpServletRequest request, String errorMessage)
           This method formats an error response into a proper format for JavaScript applications that use an HTML response.
 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

HTMLFormatter

public HTMLFormatter()
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. SL4B) expecting an HTML type response. 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
Overrides:
formatResponse in class JavaScriptFormatter
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. SL4B) expecting an HTML type response. 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
Overrides:
formatResponse in class JavaScriptFormatter
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 applications that use an HTML response.

Specified by:
formatErrorResponse in interface ResponseFormatter
Overrides:
formatErrorResponse in class JavaScriptFormatter
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