use of org.apache.struts.config.ModuleConfig in project sonar-java by SonarSource.
the class AbstractExceptionHandler method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Invoke the appropriate <code>Action</code> for this request, and
* cache the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> if a <code>ForwardConfig</code> is returned,
* else <code>true</code> to complete processing
* @throws Exception if thrown by the Action class and not declared by an
* Exception Handler
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Look up the exception that was thrown
Exception exception = actionCtx.getException();
if (exception == null) {
LOG.warn("No Exception found in ActionContext");
return (true);
}
// Look up the local or global exception handler configuration
ExceptionConfig exceptionConfig = null;
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
if (actionConfig != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("See if actionConfig " + actionConfig + " has an exceptionConfig for " + exception.getClass().getName());
}
exceptionConfig = actionConfig.findException(exception.getClass());
} else if (moduleConfig != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No action yet, see if moduleConfig " + moduleConfig + " has an exceptionConfig " + exception.getClass().getName());
}
exceptionConfig = moduleConfig.findException(exception.getClass());
}
// Handle the exception in the configured manner
if (exceptionConfig == null) {
LOG.warn("Unhandled exception", exception);
throw exception;
}
ForwardConfig forwardConfig = handle(actionCtx, exception, exceptionConfig, actionConfig, moduleConfig);
if (forwardConfig != null) {
actionCtx.setForwardConfig(forwardConfig);
return (false);
} else {
return (true);
}
}
use of org.apache.struts.config.ModuleConfig in project sonar-java by SonarSource.
the class AbstractSelectForward method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Select and cache the <code>ActionForward</code> for this
* <code>ActionConfig</code> if specified.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
if ((valid == null) || !valid.booleanValue()) {
return (false);
}
// Acquire configuration objects that we need
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
ForwardConfig forwardConfig = null;
String forward = actionConfig.getForward();
if (forward != null) {
forwardConfig = forward(actionCtx, moduleConfig, forward);
if (LOG.isDebugEnabled()) {
LOG.debug("Forwarding to " + forwardConfig);
}
actionCtx.setForwardConfig(forwardConfig);
}
return (false);
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class RequestUtils method actionIdURL.
/**
* <p>Returns the true path of the destination action if the specified forward
* is an action-aliased URL. This method version forms the URL based on
* the current request; selecting the current module if the forward does not
* explicitly contain a module path.</p>
*
* @param forward the forward config
* @param request the current request
* @param servlet the servlet handling the current request
* @return the context-relative URL of the action if the forward has an action identifier; otherwise <code>null</code>.
* @since Struts 1.3.6
*/
public static String actionIdURL(ForwardConfig forward, HttpServletRequest request, ActionServlet servlet) {
ModuleConfig moduleConfig = null;
if (forward.getModule() != null) {
String prefix = forward.getModule();
moduleConfig = ModuleUtils.getInstance().getModuleConfig(prefix, servlet.getServletContext());
} else {
moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);
}
return actionIdURL(forward.getPath(), moduleConfig, servlet);
}
Aggregations