use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class ExceptionHandler method handle.
// ------------------------------------------------------- Protected Methods
protected ForwardConfig handle(ActionContext context, Exception exception, ExceptionConfig exceptionConfig, ActionConfig actionConfig, ModuleConfig moduleConfig) throws Exception {
// Look up the remaining properties needed for this handler
ServletActionContext sacontext = (ServletActionContext) context;
ActionForm actionForm = (ActionForm) sacontext.getActionForm();
HttpServletRequest request = sacontext.getRequest();
HttpServletResponse response = sacontext.getResponse();
// Handle this exception
org.apache.struts.action.ExceptionHandler handler = (org.apache.struts.action.ExceptionHandler) ClassUtils.getApplicationInstance(exceptionConfig.getHandler());
return (handler.execute(exception, exceptionConfig, (ActionMapping) actionConfig, actionForm, request, response));
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class PerformForward method perform.
// ------------------------------------------------------- Protected Methods
/**
* <p>Perform the appropriate processing on the specified
* <code>ForwardConfig</code>.</p>
*
* @param context The context for this request
* @param forwardConfig The forward to be performed
*/
protected void perform(ActionContext context, ForwardConfig forwardConfig) throws Exception {
ServletActionContext sacontext = (ServletActionContext) context;
String uri = forwardConfig.getPath();
if (uri == null) {
ActionServlet servlet = sacontext.getActionServlet();
MessageResources resources = servlet.getInternal();
throw new IllegalArgumentException(resources.getMessage("forwardPathNull"));
}
HttpServletRequest request = sacontext.getRequest();
ServletContext servletContext = sacontext.getContext();
HttpServletResponse response = sacontext.getResponse();
// If the forward can be unaliased into an action, then use the path of the action
String actionIdPath = RequestUtils.actionIdURL(forwardConfig, sacontext.getRequest(), sacontext.getActionServlet());
if (actionIdPath != null) {
uri = actionIdPath;
ForwardConfig actionIdForwardConfig = new ForwardConfig(forwardConfig);
actionIdForwardConfig.setPath(actionIdPath);
forwardConfig = actionIdForwardConfig;
}
if (uri.startsWith("/")) {
uri = resolveModuleRelativePath(forwardConfig, servletContext, request);
}
if (response.isCommitted() && !forwardConfig.getRedirect()) {
handleAsInclude(uri, servletContext, request, response);
} else if (forwardConfig.getRedirect()) {
handleAsRedirect(uri, request, response);
} else {
handleAsForward(uri, servletContext, request, response);
}
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class FormBeanConfig method createActionForm.
/**
* <p>Create and return an <code>ActionForm</code> instance appropriate to
* the information in this <code>FormBeanConfig</code>.</p>
* <p><b>NOTE:</b> If the given <code>ActionContext</code> is not of type
* <code>ServletActionContext</code> (or a subclass), then the form which
* is returned will have a null <code>servlet</code> property. Some of
* the subclasses of <code>ActionForm</code> included in Struts will later
* throw a <code>NullPointerException</code> in this case. </p> <p>TODO:
* Find a way to control this direct dependency on the Servlet API.</p>
*
* @param context The ActionContext.
* @return ActionForm instance
* @throws IllegalAccessException if the Class or the appropriate
* constructor is not accessible
* @throws InstantiationException if this Class represents an abstract
* class, an array class, a primitive type,
* or void; or if instantiation fails for
* some other reason
*/
public ActionForm createActionForm(ActionContext context) throws IllegalAccessException, InstantiationException {
ActionServlet actionServlet = null;
if (context instanceof ServletActionContext) {
ServletActionContext saContext = (ServletActionContext) context;
actionServlet = saContext.getActionServlet();
}
return createActionForm(actionServlet);
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class PopulateActionForm method populate.
// ------------------------------------------------------- Protected Methods
protected void populate(ActionContext context, ActionConfig actionConfig, ActionForm actionForm) throws Exception {
ServletActionContext saContext = (ServletActionContext) context;
RequestUtils.populate(actionForm, actionConfig.getPrefix(), actionConfig.getSuffix(), saContext.getRequest());
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class PopulateActionForm method reset.
protected void reset(ActionContext context, ActionConfig actionConfig, ActionForm actionForm) {
ServletActionContext saContext = (ServletActionContext) context;
actionForm.reset((ActionMapping) actionConfig, saContext.getRequest());
// Set the multipart class
if (actionConfig.getMultipartClass() != null) {
saContext.getRequestScope().put(Globals.MULTIPART_KEY, actionConfig.getMultipartClass());
}
}
Aggregations