Package org.apache.struts.config

Examples of org.apache.struts.config.ActionConfig


     * @param context A valid ActionContext
     * @return a <code>Command</code> to execute, or null if none is specified
     *         or if the specified command cannot be found.
     */
    protected Command getCommand(ActionContext context) {
        ActionConfig actionConfig = context.getActionConfig();

        String commandName = actionConfig.getCommand();

        if (commandName == null) {
            return null;
        }

        String catalogName = actionConfig.getCatalog();

        return getCommand(commandName, catalogName);
    }
View Full Code Here


     * @throws Exception if authorization fails
     */
    public boolean execute(ActionContext actionCtx)
        throws Exception {
        // Retrieve ActionConfig
        ActionConfig actionConfig = actionCtx.getActionConfig();

        // Is this action protected by role requirements?
        if (!isAuthorizationRequired(actionConfig)) {
            return (false);
        }

        boolean throwEx;

        try {
            throwEx =
                !(isAuthorized(actionCtx, actionConfig.getRoleNames(),
                    actionConfig));
        } catch (Exception ex) {
            throwEx = true;
            LOG.error("Unable to complete authorization process", ex);
        }
View Full Code Here

        if (actionForm == null) {
            return false;
        }

        // Is validation disabled on this request?
        ActionConfig actionConfig = actionCtx.getActionConfig();

        if (!actionConfig.getValidate()) {
            return false;
        }

        // Was this request cancelled?
        if (isCancelled(actionCtx, actionConfig)) {
View Full Code Here

        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()) {
View Full Code Here

            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());
View Full Code Here

        // Identify the matching path for this request
        String path = getPath(actionCtx);

        // Cache the corresponding ActonConfig instance
        ModuleConfig moduleConfig = actionCtx.getModuleConfig();
        ActionConfig actionConfig = moduleConfig.findActionConfig(path);

        if (actionConfig == null) {
            // NOTE Shouldn't this be the responsibility of ModuleConfig?
            // Locate the mapping for unknown paths (if any)
            ActionConfig[] configs = moduleConfig.findActionConfigs();
View Full Code Here

        // Look up the application module configuration information we need
        ModuleConfig moduleConfig = lookupModuleConfig(context);

        // Look up the ActionConfig we are processing
        String action = getAction();
        ActionConfig actionConfig = moduleConfig.findActionConfig(action);
        if (actionConfig == null) {
            throw new IllegalArgumentException("Cannot find action '" +
                                               action + "' configuration");
        }

        // Does this ActionConfig specify a form bean?
        String name = actionConfig.getName();
        if (name == null) {
            return;
        }

        // Look up the FormBeanConfig we are processing
        FormBeanConfig fbConfig = moduleConfig.findFormBeanConfig(name);
        if (fbConfig == null) {
            throw new IllegalArgumentException("Cannot find form bean '" +
                                               name + "' configuration");
        }

        // Does a usable form bean attribute already exist?
        String attribute = actionConfig.getAttribute();
        String scope = actionConfig.getScope();
        ActionForm instance = null;
        if ("request".equals(scope)) {
            instance = (ActionForm)
                context.getExternalContext().getRequestMap().get(attribute);
        } else if ("session".equals(scope)) {
View Full Code Here

        ModuleConfig moduleConfig = factory.createModuleConfig(PACKAGE_NAME);
        assertNotNull(moduleConfig);
       
        assertEquals("/"+PACKAGE_NAME, moduleConfig.getPrefix());
       
        ActionConfig actionConfig = moduleConfig.findActionConfig("/action1");
        assertNotNull(actionConfig);
        assertEquals("/action1", actionConfig.getPath());
       
        ActionConfig[] actionConfigs = moduleConfig.findActionConfigs();
        assertNotNull(actionConfigs);
        assertEquals(2, actionConfigs.length);
       
View Full Code Here

        fpc.setType("java.lang.String");
        fpc.setInitial("test");
        barFBC.addFormPropertyConfig(fpc);
        moduleConfig.addFormBeanConfig(barFBC);

        ActionConfig testActionConfig = new ActionConfig();

        testActionConfig.setPath("/Test");
        testActionConfig.setName("foo");
        testActionConfig.setScope("request");
        moduleConfig.addActionConfig(testActionConfig);

        moduleConfig.freeze(); // otherwise, ActionConfigMatcher will be null and we'll get an NPE...
    }
View Full Code Here

    protected void tearDown() {
    }

    public void testAuthorizeOneRole()
        throws Exception {
        ActionConfig config = new ActionConfig();

        config.setPath("/testAuthorizeOneRole");
        config.setRoles("administrator");
        this.saContext.setActionConfig(config);

        boolean result = command.execute(saContext);

        assertFalse(result);
View Full Code Here

TOP

Related Classes of org.apache.struts.config.ActionConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.