com.cafesoft.cams.agent.http
Class AbstractCamsHttpAgentResponse

java.lang.Object
  |
  +--com.cafesoft.cams.agent.http.AbstractCamsHttpAgentResponse
All Implemented Interfaces:
CamsHttpAgentResponse

public class AbstractCamsHttpAgentResponse
extends Object
implements CamsHttpAgentResponse

Abstract implementation of CamsHttpAgentResponse.


Constructor Summary
AbstractCamsHttpAgentResponse()
          Creates a new AAbstractCamsHttpAgentResponse.
AbstractCamsHttpAgentResponse(javax.servlet.http.HttpServletResponse response, CamsHttpAgentRequest request)
          Creates a new AbstractCamsHttpAgentResponse with the specified response and request.
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response.
 void addHeader(String name, String value)
          Adds a response header with the given name and value.
 boolean containsHeader(String name)
          Returns a boolean indicating whether the named response header has already been set.
 void destroy()
          Destroy the CamsHttpAgentResponse.
 String getMessage()
          Get a context sensitive response message.
 OutputStream getOutputStream()
          Returns an output stream.
 RemoteSession getSession()
          Returns the Cams session.
 String getSessionId()
          Returns the Cams Session ID.
 CamsHttpAgentStatusCode getStatus()
          Returns the status code for this response.
 void initialize(Config config)
          Initializes this request.
 boolean isCommitted()
          Return true if this response has been committed.
 void recycle()
          Recycle the CamsHttpAgentResponse for reuse.
 void redirectToLoginPage(String camsLoginUrl, Map queryParameters)
          Redirects the user to the Cams login page.
 void sendRedirect(String location)
          Sends a temporary redirect response to the client using the specified redirect location URL.
 void setAccessDenied(String message)
          Set an access denied response status and a context-sensitive message.
 void setContentType(String contentType)
          Sets the content type of this response.
 void setError(String message)
          Set an error response status and a context-sensitive error message.
 void setHeader(String name, String value)
          Sets a response header with the given name and value.
 void setRequest(CamsHttpAgentRequest request)
          Sets a new CamsHttpAgentRequest.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets a new Catalina response.
 void setSession(RemoteSession session)
          Sets the Cams session.
 void setSessionId(String sessionId)
          Sets the Cams Session identifier.
 void setStatus(CamsHttpAgentStatusCode status)
          Sets the status code for this response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCamsHttpAgentResponse

public AbstractCamsHttpAgentResponse()
Creates a new AAbstractCamsHttpAgentResponse.


AbstractCamsHttpAgentResponse

public AbstractCamsHttpAgentResponse(javax.servlet.http.HttpServletResponse response,
                                     CamsHttpAgentRequest request)
Creates a new AbstractCamsHttpAgentResponse with the specified response and request.

Parameters:
response - the Http response
request - the Cams Http agent specific request
Throws:
NullPointerException - thrown if either the response or request are null
Method Detail

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Sets a new Catalina response.

Parameters:
response - the Http response

setRequest

public void setRequest(CamsHttpAgentRequest request)
Sets a new CamsHttpAgentRequest.

Parameters:
request - contains Http data needed by the Cams CamsHttpAgent

initialize

public void initialize(Config config)
Initializes this request.

Parameters:
config - contains configuration data

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Specified by:
addCookie in interface CamsHttpAgentResponse
Parameters:
cookie - the Cookie to return to the client

containsHeader

public boolean containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.

Parameters:
name - the header name
Returns:
true if the named response header has already been set, else false

sendRedirect

public void sendRedirect(String location)
Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the HTTP container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Specified by:
sendRedirect in interface CamsHttpAgentResponse
Parameters:
location - the redirect location URL

setHeader

public void setHeader(String name,
                      String value)
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Parameters:
name - the name of the header
value - the header value
See Also:
containsHeader(java.lang.String), addHeader(java.lang.String, java.lang.String)

addHeader

public void addHeader(String name,
                      String value)
Adds a response header with the given name and value. This method allows response headers to have multiple values.

Parameters:
name - the name of the header
value - the additional header value
See Also:
setHeader(java.lang.String, java.lang.String)

setStatus

public void setStatus(CamsHttpAgentStatusCode status)
Sets the status code for this response.

Specified by:
setStatus in interface CamsHttpAgentResponse
Parameters:
status - the new status code

getStatus

public CamsHttpAgentStatusCode getStatus()
Returns the status code for this response.

Specified by:
getStatus in interface CamsHttpAgentResponse
Returns:
the status code

setError

public void setError(String message)
Set an error response status and a context-sensitive error message.

Specified by:
setError in interface CamsHttpAgentResponse
Parameters:
message - the error message.

setAccessDenied

public void setAccessDenied(String message)
Set an access denied response status and a context-sensitive message.

Specified by:
setAccessDenied in interface CamsHttpAgentResponse
Parameters:
message - the access denied message.

getMessage

public String getMessage()
Get a context sensitive response message.

Specified by:
getMessage in interface CamsHttpAgentResponse
Returns:
the context-sensitive error or access denied message or null if no message.

setSessionId

public void setSessionId(String sessionId)
Sets the Cams Session identifier.

Parameters:
sessionId - the Cams Session ID associated with the HTTP client.

getSessionId

public String getSessionId()
Returns the Cams Session ID.

Returns:
the Cams Session ID associated with the HTTP client or null if no session is currently established. (This session ID should be returned to the client as a Cookie).

setSession

public void setSession(RemoteSession session)
Sets the Cams session.

Specified by:
setSession in interface CamsHttpAgentResponse
Parameters:
session - Contains information about a user that has logged into Cams

getSession

public RemoteSession getSession()
Returns the Cams session.

Specified by:
getSession in interface CamsHttpAgentResponse
Returns:
the session associated with the authenticated user

isCommitted

public boolean isCommitted()
Return true if this response has been committed.


getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns an output stream.

Returns:
an output stream for writing to this response
IOException

setContentType

public void setContentType(String contentType)
Sets the content type of this response.

Specified by:
setContentType in interface CamsHttpAgentResponse
Parameters:
contentType - the content type of this response

recycle

public void recycle()
Description copied from interface: CamsHttpAgentResponse
Recycle the CamsHttpAgentResponse for reuse.

This method will return the CamsHttpAgentResponse object back to it's original creation state. That means any underlying collections should be cleared and not destroyed.

Specified by:
recycle in interface CamsHttpAgentResponse

destroy

public void destroy()
Destroy the CamsHttpAgentResponse.

This method will destroy the CamsHttpAgentResponse object. This method should be used when the CamsHttpAgentResponse will no longer be used. This method should destroy everything including underlying collections.

Specified by:
destroy in interface CamsHttpAgentResponse

redirectToLoginPage

public void redirectToLoginPage(String camsLoginUrl,
                                Map queryParameters)
Redirects the user to the Cams login page.

Specified by:
redirectToLoginPage in interface CamsHttpAgentResponse
Parameters:
camsLoginUrl - the Url of the Cams login page
queryParameters - a Map of query parameters to be appended to the camsLoginUrl.


Generated on 5:16:42 PM May 12, 2008, © 1996-2005 Cafésoft LLC. All rights reserved.