Package org.sakaiproject.cheftool
Class ToolServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.sakaiproject.vm.ComponentServlet
-
- org.sakaiproject.vm.VmServlet
-
- org.sakaiproject.cheftool.VmServlet
-
- org.sakaiproject.cheftool.ToolServlet
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
VelocityPortletPaneledAction
public abstract class ToolServlet extends VmServlet
ToolServlet is a Servlet that support CHEF tools.
Extending VmServlet provides support for component location and use of the Velocity Template Engine.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringALERT_ATTRThe state attribute name used to store the Alert.protected static StringALERT_STATE_INITEDThe state attribute name used to store the marker of have been initialized.protected static StringHELPER_IDToolSession attribute name holding the helper id, if we are in helper mode.protected StringMAIN_PANELThe special panel name for the main.protected static StringMENU_ATTRThe state attribute name used to store the Menu.protected static StringPARAM_ACTIONThe request parameter name whose value is the action.protected static StringPARAM_ACTION_COMBOThe request parameter name root that has the action name following.protected StringTITLE_PANELThe special panel name for the title.protected StringTOOL_MODE_ATTRThe mode attribute name base - postfix with the portlet mode.protected StringTOOL_MODE_DEFAULTThe mode value when no mode has been set.-
Fields inherited from class org.sakaiproject.cheftool.VmServlet
m_validator
-
Fields inherited from class org.sakaiproject.vm.ComponentServlet
ATTR_PARAMS
-
-
Constructor Summary
Constructors Constructor Description ToolServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactionDispatch(String methodBase, String methodExt, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Dispatch to a "processAction" method based on reflection.protected voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Respond to a request by dispatching to a portlet like "do" method based on the portlet mode and tool modeprotected voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Respond to a request by dispatching to a portlet like "do" method based on the portlet mode and tool modeprotected org.sakaiproject.cheftool.api.AlertgetAlert(javax.servlet.http.HttpServletRequest req)Access the Alert for the current request.protected org.sakaiproject.cheftool.api.AlertgetAlert(org.sakaiproject.event.api.SessionState state)Access the Alert in this state - will create one if needed.protected org.sakaiproject.cheftool.api.MenugetMenu(javax.servlet.http.HttpServletRequest req)Access the Menu for the current request.protected StringgetPid(javax.servlet.http.HttpServletRequest req)Access the "pid" - portlet window id, tool id, from the requestprotected org.sakaiproject.event.api.SessionStategetState(javax.servlet.http.HttpServletRequest req)Access the SessionState for the current request.protected StringgetToolMode(javax.servlet.http.HttpServletRequest req)Access the tool mode for the current Portlet mode.protected voidinitState(org.sakaiproject.event.api.SessionState state, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Initialize for the first time the session state for this session.protected voidprepState(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Prepare state, either for first time or updateprotected voidprocessAction(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Process a Portlet action.protected booleansendToHelper(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String target)protected voidsetToolMode(String toolMode, javax.servlet.http.HttpServletRequest req)Set the tool mode.protected voidsetVmStdRef(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Add some standard references to the vm context.protected voidstartHelper(javax.servlet.http.HttpServletRequest req, String helperId)Setup for a helper tool - all subsequent requests will be directed there, till the tool is done.protected voidstartHelper(javax.servlet.http.HttpServletRequest req, String helperId, String panel)Setup for a helper tool - all subsequent requests will be directed there, till the tool is done.protected voidtoolModeDispatch(String methodBase, String methodExt, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Dispatch to a "do" method based on reflection.protected voidupdateState(org.sakaiproject.event.api.SessionState state, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Update for this request processing the session state.-
Methods inherited from class org.sakaiproject.vm.VmServlet
getActionURL, getVmReference, includeVm, setVmReference
-
Methods inherited from class org.sakaiproject.vm.ComponentServlet
sendParentRedirect, service, setNoCacheHeaders
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
HELPER_ID
protected static final String HELPER_ID
ToolSession attribute name holding the helper id, if we are in helper mode. NOTE: promote to Tool -ggolden- See Also:
- Constant Field Values
-
TOOL_MODE_DEFAULT
protected final String TOOL_MODE_DEFAULT
The mode value when no mode has been set.- See Also:
- Constant Field Values
-
TOOL_MODE_ATTR
protected final String TOOL_MODE_ATTR
The mode attribute name base - postfix with the portlet mode.- See Also:
- Constant Field Values
-
TITLE_PANEL
protected final String TITLE_PANEL
The special panel name for the title.- See Also:
- Constant Field Values
-
MAIN_PANEL
protected final String MAIN_PANEL
The special panel name for the main.- See Also:
- Constant Field Values
-
PARAM_ACTION_COMBO
protected static final String PARAM_ACTION_COMBO
The request parameter name root that has the action name following.- See Also:
- Constant Field Values
-
PARAM_ACTION
protected static final String PARAM_ACTION
The request parameter name whose value is the action.- See Also:
- Constant Field Values
-
ALERT_STATE_INITED
protected static final String ALERT_STATE_INITED
The state attribute name used to store the marker of have been initialized.- See Also:
- Constant Field Values
-
ALERT_ATTR
protected static final String ALERT_ATTR
The state attribute name used to store the Alert.- See Also:
- Constant Field Values
-
MENU_ATTR
protected static final String MENU_ATTR
The state attribute name used to store the Menu.- See Also:
- Constant Field Values
-
-
Method Detail
-
setVmStdRef
protected void setVmStdRef(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Add some standard references to the vm context.- Overrides:
setVmStdRefin classVmServlet- Parameters:
request- The render request.response- The render response.
-
setToolMode
protected void setToolMode(String toolMode, javax.servlet.http.HttpServletRequest req)
Set the tool mode.- Parameters:
toolMode- The new tool mode.req- The portlet request.
-
getToolMode
protected String getToolMode(javax.servlet.http.HttpServletRequest req)
Access the tool mode for the current Portlet mode.- Parameters:
req- The portlet request.- Returns:
- the tool mode for the current Portlet mode.
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletExceptionRespond to a request by dispatching to a portlet like "do" method based on the portlet mode and tool mode- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletExceptionRespond to a request by dispatching to a portlet like "do" method based on the portlet mode and tool mode- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletException
-
startHelper
protected void startHelper(javax.servlet.http.HttpServletRequest req, String helperId, String panel)Setup for a helper tool - all subsequent requests will be directed there, till the tool is done.- Parameters:
helperId- The helper tool id.
-
startHelper
protected void startHelper(javax.servlet.http.HttpServletRequest req, String helperId)Setup for a helper tool - all subsequent requests will be directed there, till the tool is done.- Parameters:
helperId- The helper tool id.
-
toolModeDispatch
protected void toolModeDispatch(String methodBase, String methodExt, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws org.sakaiproject.tool.api.ToolException
Dispatch to a "do" method based on reflection.- Parameters:
methodBase- The base name of the method to call.methodExt- The end name of the method to call.req- The HttpServletRequest.res- The HttpServletResponse- Throws:
org.sakaiproject.tool.api.ToolException
-
processAction
protected void processAction(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Process a Portlet action.
-
actionDispatch
protected void actionDispatch(String methodBase, String methodExt, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
Dispatch to a "processAction" method based on reflection.- Parameters:
methodBase- The base name of the method to call.methodExt- The end name of the method to call.req- The ActionRequest.res- The ActionResponse
-
getPid
protected String getPid(javax.servlet.http.HttpServletRequest req)
Access the "pid" - portlet window id, tool id, from the request- Parameters:
req- The current request.- Returns:
- the "pid" - portlet window id, tool id, from the request
-
getState
protected org.sakaiproject.event.api.SessionState getState(javax.servlet.http.HttpServletRequest req)
Access the SessionState for the current request. Note: this is scoped only for the current request.- Parameters:
req- The current portlet request.- Returns:
- The SessionState objet for the current request.
-
prepState
protected void prepState(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Prepare state, either for first time or update- Parameters:
req- The current portlet request.res- The current response.
-
initState
protected void initState(org.sakaiproject.event.api.SessionState state, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Initialize for the first time the session state for this session. If overridden in a sub-class, make sure to call super.- Parameters:
state- The session state.req- The current request.res- The current response.
-
updateState
protected void updateState(org.sakaiproject.event.api.SessionState state, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Update for this request processing the session state. If overridden in a sub-class, make sure to call super.- Parameters:
state- The session state.req- The current request.res- The current response.
-
getAlert
protected org.sakaiproject.cheftool.api.Alert getAlert(javax.servlet.http.HttpServletRequest req)
Access the Alert for the current request.- Parameters:
req- The current portlet request.- Returns:
- The Alert objet for the current request.
-
getAlert
protected org.sakaiproject.cheftool.api.Alert getAlert(org.sakaiproject.event.api.SessionState state)
Access the Alert in this state - will create one if needed.- Parameters:
state- The state in which to find the alert.- Returns:
- The Alert objet.
-
getMenu
protected org.sakaiproject.cheftool.api.Menu getMenu(javax.servlet.http.HttpServletRequest req)
Access the Menu for the current request.- Parameters:
req- The current portlet request.- Returns:
- The Menu objet for the current request.
-
sendToHelper
protected boolean sendToHelper(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String target) throws org.sakaiproject.tool.api.ToolException- Parameters:
req-res-target-- Returns:
- Throws:
org.sakaiproject.tool.api.ToolException
-
-