com.acsinet_solutions.cetia4.controller.rest
Class AbstractServletRequestContext

java.lang.Object
  extended by com.acsinet_solutions.cetia4.controller.rest.AbstractServletRequestContext
All Implemented Interfaces:
ActionContext, AttributeKeys, ControllerConstants, MultipartContext, ParameterAccessor, RenderContext, RequestContext, ServletRequestContext
Direct Known Subclasses:
WebServiceServletRequestContext, WebServletRequestContext

public abstract class AbstractServletRequestContext
extends java.lang.Object
implements ServletRequestContext, ControllerConstants

Web implementation of a servlet request context. Provides the common methods for both web and web service request contexts.

Author:
Santiago Arriaga

Field Summary
 
Fields inherited from interface com.acsinet_solutions.cetia4.controller.ControllerConstants
_METHOD_PARAM, _PAGE_PARAM, _ROOT_PARAM, DEFAULT_VIEW, ERROR_URL, ERROR_VIEW, LOAD_CANCEL, LOAD_CURRENT, LOAD_DEFAULT, LOAD_ERROR, LOAD_PREVIOUS
 
Fields inherited from interface com.acsinet_solutions.cetia4.controller.AttributeKeys
_BUNDLE_KEY, _CONFIGURATION_KEY, _DEFAULT_CONTROLLER_KEY, _FORM_ACTION_KEY, _FORM_ATTRIBUTE_KEY, _LOCALE_KEY, _MESSAGE_KEY, _NAVIGATION_FLOW_KEY, _PORTAL_PATH_KEY, _RENDER_PARAMETERS_KEY, _SERVICE_LOCATOR_KEY, _SESSION_KEY, _SYSTEM_EXCEPTION_KEY, _VALIDATION_EXCEPTION_KEY
 
Constructor Summary
protected AbstractServletRequestContext(java.lang.String requestType, javax.servlet.ServletConfig config, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Configuration configuration)
          Protected constructor, for use by implementations.
 
Method Summary
 void display(java.lang.String view)
          This implementation sets headers to prevent caching of dynamic responses, and performs a forward to the provided view.
 java.lang.Object getAttribute(Scope scope, java.lang.String key)
          Get an attribute from the given scope.
 Configuration getConfiguration()
          Get a reference to the not-null configuration of the current module
 java.lang.Object getContextAttribute(java.lang.String key)
          Get an application attribute
 java.lang.String getContextPath()
          Convenience method for obtaining the context path.
 java.util.List<org.apache.commons.fileupload.FileItem> getItems()
          This method throws an exception if called on a not-multipart request.
 java.lang.String getMethod()
          Get the not null String method to be executed by the current call.
 Link getNavigationLink()
          Obtain a link to the current render request, including all paramters provided.
 java.lang.String getParameter(java.lang.String param)
          Get a parameter for the given source
 java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
          Obtain the parameter map associated to a parameter request.
 java.util.List<java.lang.String> getPathInfo()
          Get the path info as a list of Strings.
 java.lang.Object getRequestAttribute(java.lang.String key)
          Get a request attribute
 java.lang.String getRequestedController()
          Get the requested controller with path info, not containing context path nor query String.
 java.lang.String getRequestedPage()
          Get the requested page, containing all request string with path info and query string.
 java.lang.String getRequestedURI()
          Get the requested page, containing all request string with path info but no query string.
 java.lang.String getRequestType()
          Get the request type; it may be any constant of the RequestType interface or a custom request type ( although extensibility mechanisms are still not provided in this version ).
 SecurityContext getSecurityContext()
          Get the security context associated to the current request.
 javax.servlet.ServletConfig getServletConfig()
          Get a reference to the servlet config
 javax.servlet.ServletContext getServletContext()
          Get a reference to the servlet context
 javax.servlet.http.HttpServletRequest getServletRequest()
          Get a reference to the servlet request.
 javax.servlet.http.HttpServletResponse getServletResponse()
          Get a reference to the servlet response.
 javax.servlet.http.HttpSession getServletSession()
          Get a reference to the servlet session
 void invalidateSession()
          Invalidate the current session.
 boolean isMultipart()
          Check if the current request is multipart or not.
 void redirectTo(java.lang.String url)
          Perform a redirection.
 void removeAttribute(Scope scope, java.lang.String key)
          Remove an attribute on the given scope.
 void removeContextAttribute(java.lang.String key)
          Remove an application attribute
 void removeRequestAttribute(java.lang.String key)
          Remove a request attribute
 boolean sessionExists()
          Check if the session exists or not.
 void setAttribute(Scope scope, java.lang.String key, java.lang.Object value)
          Set an attribute on the given scope.
 void setContextAttribute(java.lang.String key, java.lang.Object attribute)
          Set an application attribute
 void setFormAttribute(java.lang.Object bean)
          Sets the FORM_ATTRIBUTE object.
 void setMessage(java.lang.String message)
          Set a message in portlet or session level.
 void setRenderParameter(java.lang.String name, java.lang.Object value)
          Set a render parameter.
 void setRequestAttribute(java.lang.String key, java.lang.Object attribute)
          Set a request attribute
 void setSystemException(java.lang.Exception exception)
          Set a system exception in portlet or session level.
 void setValidationException(java.lang.Exception exception)
          Set a validation exception in portlet or session level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.acsinet_solutions.cetia4.controller.RenderContext
isNewForm
 

Constructor Detail

AbstractServletRequestContext

protected AbstractServletRequestContext(java.lang.String requestType,
                                        javax.servlet.ServletConfig config,
                                        javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        Configuration configuration)
Protected constructor, for use by implementations.

Method Detail

getConfiguration

public Configuration getConfiguration()
Description copied from interface: RequestContext
Get a reference to the not-null configuration of the current module

Specified by:
getConfiguration in interface RequestContext

getRequestType

public java.lang.String getRequestType()
Description copied from interface: RequestContext
Get the request type; it may be any constant of the RequestType interface or a custom request type ( although extensibility mechanisms are still not provided in this version ).

Specified by:
getRequestType in interface RequestContext
See Also:
RequestType

getPathInfo

public final java.util.List<java.lang.String> getPathInfo()
Description copied from interface: RequestContext
Get the path info as a list of Strings.

Specified by:
getPathInfo in interface RequestContext

getRequestedPage

public final java.lang.String getRequestedPage()
Description copied from interface: RequestContext
Get the requested page, containing all request string with path info and query string.

Specified by:
getRequestedPage in interface RequestContext
See Also:
ControllerTools.getRequestedPage(HttpServletRequest)

getRequestedURI

public final java.lang.String getRequestedURI()
Description copied from interface: RequestContext
Get the requested page, containing all request string with path info but no query string.

Specified by:
getRequestedURI in interface RequestContext
See Also:
HttpServletRequest.getRequestURI()

getRequestedController

public final java.lang.String getRequestedController()
Description copied from interface: RequestContext
Get the requested controller with path info, not containing context path nor query String.

Specified by:
getRequestedController in interface RequestContext
See Also:
ControllerTools.getRequestedController(HttpServletRequest)

getContextPath

public final java.lang.String getContextPath()
Description copied from interface: RequestContext
Convenience method for obtaining the context path.

Specified by:
getContextPath in interface RequestContext

setContextAttribute

public final void setContextAttribute(java.lang.String key,
                                      java.lang.Object attribute)
Description copied from interface: RequestContext
Set an application attribute

Specified by:
setContextAttribute in interface RequestContext

setRequestAttribute

public void setRequestAttribute(java.lang.String key,
                                java.lang.Object attribute)
Description copied from interface: RequestContext
Set a request attribute

Specified by:
setRequestAttribute in interface RequestContext

removeContextAttribute

public final void removeContextAttribute(java.lang.String key)
Description copied from interface: RequestContext
Remove an application attribute

Specified by:
removeContextAttribute in interface RequestContext

removeRequestAttribute

public final void removeRequestAttribute(java.lang.String key)
Description copied from interface: RequestContext
Remove a request attribute

Specified by:
removeRequestAttribute in interface RequestContext

getContextAttribute

public final java.lang.Object getContextAttribute(java.lang.String key)
Description copied from interface: RequestContext
Get an application attribute

Specified by:
getContextAttribute in interface RequestContext

getRequestAttribute

public final java.lang.Object getRequestAttribute(java.lang.String key)
Description copied from interface: RequestContext
Get a request attribute

Specified by:
getRequestAttribute in interface RequestContext

setSystemException

public final void setSystemException(java.lang.Exception exception)
Description copied from interface: RequestContext
Set a system exception in portlet or session level.

Specified by:
setSystemException in interface RequestContext
See Also:
AttributeKeys._SYSTEM_EXCEPTION_KEY

setValidationException

public final void setValidationException(java.lang.Exception exception)
Description copied from interface: RequestContext
Set a validation exception in portlet or session level. The provided exception should preferably be a ValidationException or a ValidationRuntimeException

Specified by:
setValidationException in interface RequestContext
See Also:
AttributeKeys._VALIDATION_EXCEPTION_KEY

setMessage

public final void setMessage(java.lang.String message)
Description copied from interface: RequestContext
Set a message in portlet or session level. Messages are stored not as strings but as a CompoundMessage, so this method may be called more than once to display different messages on a page.

Specified by:
setMessage in interface RequestContext
See Also:
AttributeKeys._MESSAGE_KEY, CompoundMessage

getParameter

public final java.lang.String getParameter(java.lang.String param)
Description copied from interface: ParameterAccessor
Get a parameter for the given source

Specified by:
getParameter in interface ParameterAccessor

getParameterMap

public final java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
Description copied from interface: ParameterAccessor
Obtain the parameter map associated to a parameter request. Values are arrays of string because in HTTP a single parameter name may appear multiple times in a query string.

Specified by:
getParameterMap in interface ParameterAccessor

setFormAttribute

public final void setFormAttribute(java.lang.Object bean)
Description copied from interface: RequestContext
Sets the FORM_ATTRIBUTE object. if the form attribute is not set at request level, this call will throw an IllegalStateException.

Specified by:
setFormAttribute in interface RequestContext
See Also:
AttributeKeys._FORM_ATTRIBUTE_KEY, FormAttribute

getAttribute

public final java.lang.Object getAttribute(Scope scope,
                                           java.lang.String key)
Description copied from interface: RequestContext
Get an attribute from the given scope.

Specified by:
getAttribute in interface RequestContext

setAttribute

public final void setAttribute(Scope scope,
                               java.lang.String key,
                               java.lang.Object value)
Description copied from interface: RequestContext
Set an attribute on the given scope.

Specified by:
setAttribute in interface RequestContext

removeAttribute

public final void removeAttribute(Scope scope,
                                  java.lang.String key)
Description copied from interface: RequestContext
Remove an attribute on the given scope.

Specified by:
removeAttribute in interface RequestContext

getMethod

public final java.lang.String getMethod()
Description copied from interface: RequestContext
Get the not null String method to be executed by the current call. May be an empty String for default methods. Action methods must always be not empty.

Specified by:
getMethod in interface RequestContext
See Also:
ControllerConstants._METHOD_PARAM, METHOD_PREFIX

redirectTo

public final void redirectTo(java.lang.String url)
                      throws java.io.IOException
Description copied from interface: RequestContext
Perform a redirection. This may throw an unchecked exception if called in portlets render phase where redirection is forbidden.

Specified by:
redirectTo in interface RequestContext
Throws:
java.io.IOException

sessionExists

public boolean sessionExists()
Description copied from interface: RequestContext
Check if the session exists or not. Obviously, it does not create a session object if it is not needed ( but other methods and facilities in and outside the framework may call getSession() indiscriminately ).

Specified by:
sessionExists in interface RequestContext

invalidateSession

public void invalidateSession()
Description copied from interface: RequestContext
Invalidate the current session.

Specified by:
invalidateSession in interface RequestContext

getSecurityContext

public final SecurityContext getSecurityContext()
Description copied from interface: RequestContext
Get the security context associated to the current request. If no security service is configured in the application service locator, a generic all-inclusive security context will be returned.

Specified by:
getSecurityContext in interface RequestContext

getNavigationLink

public final Link getNavigationLink()
Description copied from interface: RenderContext
Obtain a link to the current render request, including all paramters provided.

Specified by:
getNavigationLink in interface RenderContext
See Also:
NavigationStage

display

public final void display(java.lang.String view)
                   throws java.io.IOException,
                          SystemException
This implementation sets headers to prevent caching of dynamic responses, and performs a forward to the provided view.

Specified by:
display in interface RenderContext
Throws:
java.io.IOException
SystemException

setRenderParameter

public final void setRenderParameter(java.lang.String name,
                                     java.lang.Object value)
Description copied from interface: ActionContext
Set a render parameter. Although for convenience this method accepts objects, they are internally converted to Strings as they will form part of an HTTP request or other type of response.

Specified by:
setRenderParameter in interface ActionContext

isMultipart

public final boolean isMultipart()
Description copied from interface: ActionContext
Check if the current request is multipart or not.

Specified by:
isMultipart in interface ActionContext

getItems

public java.util.List<org.apache.commons.fileupload.FileItem> getItems()
This method throws an exception if called on a not-multipart request. Item files are lazily loaded and processed from request just once.

Specified by:
getItems in interface MultipartContext

getServletConfig

public final javax.servlet.ServletConfig getServletConfig()
Description copied from interface: ServletRequestContext
Get a reference to the servlet config

Specified by:
getServletConfig in interface ServletRequestContext

getServletContext

public final javax.servlet.ServletContext getServletContext()
Description copied from interface: ServletRequestContext
Get a reference to the servlet context

Specified by:
getServletContext in interface ServletRequestContext

getServletSession

public final javax.servlet.http.HttpSession getServletSession()
Description copied from interface: ServletRequestContext
Get a reference to the servlet session

Specified by:
getServletSession in interface ServletRequestContext

getServletRequest

public final javax.servlet.http.HttpServletRequest getServletRequest()
Description copied from interface: ServletRequestContext
Get a reference to the servlet request.

Specified by:
getServletRequest in interface ServletRequestContext

getServletResponse

public final javax.servlet.http.HttpServletResponse getServletResponse()
Description copied from interface: ServletRequestContext
Get a reference to the servlet response.

Specified by:
getServletResponse in interface ServletRequestContext