Search in sources :

Example 31 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.

the class ActionServlet method processActionConfigExtension.

/**
     * <p>Extend the action's configuration as necessary.</p>
     *
     * @param actionConfig the configuration to process.
     * @param moduleConfig the module configuration for this module.
     * @throws ServletException if initialization cannot be performed.
     */
protected void processActionConfigExtension(ActionConfig actionConfig, ModuleConfig moduleConfig) throws ServletException {
    try {
        if (!actionConfig.isExtensionProcessed()) {
            if (log.isDebugEnabled()) {
                log.debug("Processing extensions for '" + actionConfig.getPath() + "'");
            }
            actionConfig = processActionConfigClass(actionConfig, moduleConfig);
            actionConfig.processExtends(moduleConfig);
        }
        // Process forwards extensions.
        ForwardConfig[] forwards = actionConfig.findForwardConfigs();
        for (int i = 0; i < forwards.length; i++) {
            ForwardConfig forward = forwards[i];
            processForwardExtension(forward, moduleConfig, actionConfig);
        }
        // Process exception extensions.
        ExceptionConfig[] exceptions = actionConfig.findExceptionConfigs();
        for (int i = 0; i < exceptions.length; i++) {
            ExceptionConfig exception = exceptions[i];
            processExceptionExtension(exception, moduleConfig, actionConfig);
        }
    } catch (ServletException e) {
        throw e;
    } catch (Exception e) {
        handleGeneralExtensionException("Action", actionConfig.getPath(), e);
    }
}
Also used : ServletException(javax.servlet.ServletException) ExceptionConfig(org.apache.struts.config.ExceptionConfig) ForwardConfig(org.apache.struts.config.ForwardConfig) ServletException(javax.servlet.ServletException) MissingResourceException(java.util.MissingResourceException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 32 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.

the class ActionMapping method findForwards.

/**
     * <p>Return the logical names of all locally defined forwards for this
     * mapping. If there are no such forwards, a zero-length array is
     * returned.</p>
     *
     * @return The forward names for this action mapping.
     */
public String[] findForwards() {
    ArrayList results = new ArrayList();
    ForwardConfig[] fcs = findForwardConfigs();
    for (int i = 0; i < fcs.length; i++) {
        results.add(fcs[i].getName());
    }
    return ((String[]) results.toArray(new String[results.size()]));
}
Also used : ArrayList(java.util.ArrayList) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 33 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.

the class AbstractSelectInput method execute.

// ---------------------------------------------------------- Public Methods
/**
     * <p>Select and cache a <code>ForwardConfig</code> for the input page for
     * the current request.</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 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();
    // Cache an ForwardConfig back to our input page
    ForwardConfig forwardConfig;
    String input = actionConfig.getInput();
    if (moduleConfig.getControllerConfig().getInputForward()) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Finding ForwardConfig for '" + input + "'");
        }
        forwardConfig = actionConfig.findForwardConfig(input);
        if (forwardConfig == null) {
            forwardConfig = moduleConfig.findForwardConfig(input);
        }
    } else {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Delegating to forward() for '" + input + "'");
        }
        forwardConfig = forward(actionCtx, moduleConfig, input);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Forwarding back to " + forwardConfig);
    }
    actionCtx.setForwardConfig(forwardConfig);
    return (false);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ModuleConfig(org.apache.struts.config.ModuleConfig) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 34 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonarqube 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);
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ExceptionConfig(org.apache.struts.config.ExceptionConfig) ModuleConfig(org.apache.struts.config.ModuleConfig) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 35 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonarqube by SonarSource.

the class ModuleConfigImpl method freeze.

/**
     * <p> Freeze the configuration of this module.  After this method
     * returns, any attempt to modify the configuration will return an
     * IllegalStateException. </p>
     */
public void freeze() {
    super.freeze();
    ActionConfig[] aconfigs = findActionConfigs();
    for (int i = 0; i < aconfigs.length; i++) {
        aconfigs[i].freeze();
    }
    matcher = new ActionConfigMatcher(aconfigs);
    getControllerConfig().freeze();
    ExceptionConfig[] econfigs = findExceptionConfigs();
    for (int i = 0; i < econfigs.length; i++) {
        econfigs[i].freeze();
    }
    FormBeanConfig[] fbconfigs = findFormBeanConfigs();
    for (int i = 0; i < fbconfigs.length; i++) {
        fbconfigs[i].freeze();
    }
    ForwardConfig[] fconfigs = findForwardConfigs();
    for (int i = 0; i < fconfigs.length; i++) {
        fconfigs[i].freeze();
    }
    MessageResourcesConfig[] mrconfigs = findMessageResourcesConfigs();
    for (int i = 0; i < mrconfigs.length; i++) {
        mrconfigs[i].freeze();
    }
    PlugInConfig[] piconfigs = findPlugInConfigs();
    for (int i = 0; i < piconfigs.length; i++) {
        piconfigs[i].freeze();
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ExceptionConfig(org.apache.struts.config.ExceptionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) PlugInConfig(org.apache.struts.config.PlugInConfig) ForwardConfig(org.apache.struts.config.ForwardConfig) ActionConfigMatcher(org.apache.struts.config.ActionConfigMatcher) MessageResourcesConfig(org.apache.struts.config.MessageResourcesConfig)

Aggregations

ForwardConfig (org.apache.struts.config.ForwardConfig)63 ActionConfig (org.apache.struts.config.ActionConfig)14 UnavailableException (javax.servlet.UnavailableException)12 ServletException (javax.servlet.ServletException)10 ExceptionConfig (org.apache.struts.config.ExceptionConfig)10 MalformedURLException (java.net.MalformedURLException)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 IOException (java.io.IOException)6 MissingResourceException (java.util.MissingResourceException)6 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)6 SAXException (org.xml.sax.SAXException)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 ActionFormBean (org.apache.struts.action.ActionFormBean)4 ActionForward (org.apache.struts.action.ActionForward)4 ActionMapping (org.apache.struts.action.ActionMapping)4 ActionServlet (org.apache.struts.action.ActionServlet)4 FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)4 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)3 ArrayList (java.util.ArrayList)2