Search in sources :

Example 46 with ActionConfig

use of org.apache.struts.config.ActionConfig 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)

Example 47 with ActionConfig

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

the class ModuleConfigImpl method addActionConfig.

/**
     * </p> Ad   d a new <code>ActionConfig</code> instance to the set
     * associated with this module. </p>
     *
     * @param config The new configuration instance to be added
     * @throws IllegalStateException if this module configuration has been
     *                               frozen
     */
public void addActionConfig(ActionConfig config) {
    throwIfConfigured();
    config.setModuleConfig(this);
    String path = config.getPath();
    if (actionConfigs.containsKey(path)) {
        log.warn("Overriding ActionConfig of path " + path);
    }
    String actionId = config.getActionId();
    if ((actionId != null) && !actionId.equals("")) {
        if (actionConfigIds.containsKey(actionId)) {
            if (log.isWarnEnabled()) {
                ActionConfig otherConfig = (ActionConfig) actionConfigIds.get(actionId);
                StringBuffer msg = new StringBuffer("Overriding actionId[");
                msg.append(actionId);
                msg.append("] for path[");
                msg.append(otherConfig.getPath());
                msg.append("] with path[");
                msg.append(path);
                msg.append("]");
                log.warn(msg);
            }
        }
        actionConfigIds.put(actionId, config);
    }
    actionConfigs.put(path, config);
    actionConfigList.add(config);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 48 with ActionConfig

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

the class TestActionServlet method testProcessActionConfigClassOverriddenSubConfigClass.

/**
     * Test the case where the subconfig has already specified its own config
     * class.  If the code still attempts to create a new instance, an error
     * will be thrown.
     */
public void testProcessActionConfigClassOverriddenSubConfigClass() throws Exception {
    moduleConfig.addActionConfig(baseAction);
    ActionConfig customSub = new CustomActionConfigArg("/sub");
    customSub.setExtends("/index");
    moduleConfig.addActionConfig(customSub);
    try {
        actionServlet.processActionConfigClass(customSub, moduleConfig);
    } catch (Exception e) {
        fail("Exception should not be thrown");
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException)

Example 49 with ActionConfig

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

the class TestAuthorizeAction method testNotAuthorizedOneOfManyRoles.

public void testNotAuthorizedOneOfManyRoles() throws Exception {
    ActionConfig config = new ActionConfig();
    config.setPath("/testNotAuthorizedOneOfManyRoles");
    config.setRoles("roustabout,memory");
    this.saContext.setActionConfig(config);
    try {
        boolean result = command.execute(saContext);
    } catch (UnauthorizedActionException ex) {
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) UnauthorizedActionException(org.apache.struts.chain.commands.UnauthorizedActionException)

Example 50 with ActionConfig

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

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean5.

// use servlet mapping (path mapping)
//  -- with params
public void testString_getActionMappingURL_String_String_PageContext_boolean5() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "/myapp/*");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/mycontext", "/baz?foo=bar", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo?foo=bar", pageContext), "/mycontext/myapp/foo?foo=bar");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Aggregations

ActionConfig (org.apache.struts.config.ActionConfig)76 ForwardConfig (org.apache.struts.config.ForwardConfig)14 UnavailableException (javax.servlet.UnavailableException)8 ActionForm (org.apache.struts.action.ActionForm)8 ExceptionConfig (org.apache.struts.config.ExceptionConfig)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 ServletException (javax.servlet.ServletException)6 MalformedURLException (java.net.MalformedURLException)4 Map (java.util.Map)4 Action (org.apache.struts.action.Action)4 UnauthorizedActionException (org.apache.struts.chain.commands.UnauthorizedActionException)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MissingResourceException (java.util.MissingResourceException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 ActionErrors (org.apache.struts.action.ActionErrors)2 MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)2