com.acsinet_solutions.cetia4.controller.rest
Class RestRequestHandlerBase

java.lang.Object
  extended by com.acsinet_solutions.cetia4.controller.rest.RestRequestHandlerBase
All Implemented Interfaces:
AttributeKeys, ControllerConstants, ServletRequestHandler

public abstract class RestRequestHandlerBase
extends java.lang.Object
implements ServletRequestHandler, ControllerConstants

Base convenience class for REST-based request handlers. This class is closely related to REST servlets, and works as a strategy-like helper class for that class. This base class provides useful methods for both render and action types.

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 RestRequestHandlerBase(AbstractRestServlet servlet)
          Package constructor
 
Method Summary
protected  java.lang.String format(RequestContext context, java.lang.String stub)
          Format an error message for typical request error messages.
protected  RestController getActionController(MultipartContext context)
          Get the action controller that corresponds to the given context.
protected  Configuration getConfiguration()
          Get the servlet configuration object
protected  com.acsinet_solutions.cetia4.controller.rest.ControllerManager getControllerManager()
          Get the render controller suitable for the current request.
protected  org.apache.commons.logging.Log getLogger()
          Get the logger for the current servlet.
protected  javax.servlet.ServletConfig getServletConfig()
          Get the servlet config
protected  javax.servlet.ServletContext getServletContext()
          Get the servlet context
protected  Link getSpecialRenderLink(WebServletRequestContext context, java.lang.String view)
          Get the render link for the special provided view.
protected  java.lang.String getViewPath(RestController controller, java.lang.String view, java.lang.String viewPath, java.lang.String extension)
          Get the path to a given view.
protected  void loadRenderView(WebServletRequestContext context, java.lang.String view)
          Redirect to te render view.
protected  java.lang.String performAction(RestController controller, MultipartContext context)
          Execute the action request.
protected  java.lang.String render(RenderContext context, RestController controller)
          A RenderController is executed in this method, and errors are handled.
 
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.ServletRequestHandler
getRequestContext, getRestController, handleRequest, handles
 

Constructor Detail

RestRequestHandlerBase

protected RestRequestHandlerBase(AbstractRestServlet servlet)
Package constructor

Method Detail

format

protected final java.lang.String format(RequestContext context,
                                        java.lang.String stub)
Format an error message for typical request error messages.

Utility method, this may be moved to a more suitable class if necessary


getControllerManager

protected final com.acsinet_solutions.cetia4.controller.rest.ControllerManager getControllerManager()
Get the render controller suitable for the current request.


getLogger

protected final org.apache.commons.logging.Log getLogger()
Get the logger for the current servlet. The advantage of this logger is that is related to the final class that extends this abstract class.


getServletContext

protected final javax.servlet.ServletContext getServletContext()
Get the servlet context


getServletConfig

protected final javax.servlet.ServletConfig getServletConfig()
Get the servlet config


getConfiguration

protected final Configuration getConfiguration()
Get the servlet configuration object


render

protected final java.lang.String render(RenderContext context,
                                        RestController controller)
                                 throws javax.servlet.ServletException
A RenderController is executed in this method, and errors are handled.

Throws:
javax.servlet.ServletException
See Also:
RestController.execute(RequestContext)

getActionController

protected final RestController getActionController(MultipartContext context)
Get the action controller that corresponds to the given context. This method may return a plain action context or a multipart context depending on the nature of the provided context ( may or not be multipart even if the implemented interface is MultipartContext ).


performAction

protected final java.lang.String performAction(RestController controller,
                                               MultipartContext context)
Execute the action request. Exceptions are handled here. Return the next view to load, or null if explicit response was performed within the method.

See Also:
RestController.execute(RequestContext)

getSpecialRenderLink

protected final Link getSpecialRenderLink(WebServletRequestContext context,
                                          java.lang.String view)
Get the render link for the special provided view.

See Also:
ControllerTools.getSpecialLink(NavigationFlow,String)

loadRenderView

protected final void loadRenderView(WebServletRequestContext context,
                                    java.lang.String view)
                             throws java.io.IOException
Redirect to te render view. Render parameters are added to the link, even in cases of special links.

Throws:
java.io.IOException - A redirection is performed here, and that may cause an IO Exception to be thrown.
See Also:
ActionContext.setRenderParameter(String,Object)

getViewPath

protected final java.lang.String getViewPath(RestController controller,
                                             java.lang.String view,
                                             java.lang.String viewPath,
                                             java.lang.String extension)
Get the path to a given view. This method is generic to accomodate both traditional web and web service requests.

Parameters:
controller - used to obtain the resource path to the view files in case of a relative view
view - the absolute or relative requested view. If absolute ( starts with / ), this string will be returned with no further modification
viewPath - The default view path for the current type of request. Default view path for web requests is /WEB-INF/html and for web services requests is /WEB-INF/xml
extension - The default extension for the current type of request. Default extension for web requests is .jsp, and for web service requests is .jspx. If the view param has already a .jsp or .jspx extension, this parameter will be ignored.