struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Huber (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4596) Strict DMI causes This method: for action is not allowed!
Date Wed, 03 Feb 2016 15:40:40 GMT

    [ https://issues.apache.org/jira/browse/WW-4596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15130570#comment-15130570
] 

Greg Huber edited comment on WW-4596 at 2/3/16 3:39 PM:
--------------------------------------------------------

XmlConfigurationProvider.addAction is where it adds the {1} stuff.

Possible solution is to remove it at the load stage, using AllowedMethods.build(..) logic.
{noformat}
This works for method="{1}" but from the docs is suggests : method="do{2}" which I have not
used before.

Thought {1} was the value after the bang ie myView!cancelWithSearch action=myView, method=cancelWithSearch.

{noformat}

So not sure this will work for other configs.

{code:java}
        .......
        Set<String> allowedMethods = buildAllowedMethods(actionElement, packageContext);
        
        // remove any wild card methods {x}
        if (methodName != null && packageContext.isStrictMethodInvocation()) {
            int len = methodName.length();
            char c;
            for (int x = 0; x < len; x++) {
                c = methodName.charAt(x);
                if (x < len - 2 && c == '{' && '}' == methodName.charAt(x
+ 2)) {
                    methodName = null;
                    break;
                }
            }
        }
        
        ActionConfig actionConfig = new ActionConfig.Builder(packageContext.getName(), name,
className)
                .methodName(methodName)
                .addResultConfigs(results)
                .addInterceptors(interceptorList)
                .addExceptionMappings(exceptionMappings)
                .addParams(XmlHelper.getParams(actionElement))
                .addAllowedMethod(allowedMethods)
                .location(location)
                .build();
        packageContext.addActionConfig(name, actionConfig);
        .......
{code}


was (Author: gregh99):
XmlConfigurationProvider.addAction is where it adds the {1} stuff.

Possible solution is to remove it at the load stage, using AllowedMethods.build(..) logic.
This works for method="{1}" but from the docs is suggests : method="do{2}" which I have not
used before.

Thought {1} was the value after the bang ie myView!cancelWithSearch action=myView, method=cancelWithSearch.

So not sure this will work for other configs.

{code:java}
        .......
        Set<String> allowedMethods = buildAllowedMethods(actionElement, packageContext);
        
        // remove any wild card methods {x}
        if (methodName != null && packageContext.isStrictMethodInvocation()) {
            int len = methodName.length();
            char c;
            for (int x = 0; x < len; x++) {
                c = methodName.charAt(x);
                if (x < len - 2 && c == '{' && '}' == methodName.charAt(x
+ 2)) {
                    methodName = null;
                    break;
                }
            }
        }
        
        ActionConfig actionConfig = new ActionConfig.Builder(packageContext.getName(), name,
className)
                .methodName(methodName)
                .addResultConfigs(results)
                .addInterceptors(interceptorList)
                .addExceptionMappings(exceptionMappings)
                .addParams(XmlHelper.getParams(actionElement))
                .addAllowedMethod(allowedMethods)
                .location(location)
                .build();
        packageContext.addActionConfig(name, actionConfig);
        .......
{code}

> Strict DMI causes This method: for action is not allowed!  
> -----------------------------------------------------------
>
>                 Key: WW-4596
>                 URL: https://issues.apache.org/jira/browse/WW-4596
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.5
>            Reporter: Greg Huber
>             Fix For: 2.5
>
>
> I have tried adding
> {code:xml}
> <global-allowed-methods>execute,input,cancel</global-allowed-methods>
> {code}
> and get
> {noformat}
> This method: cancel for action eventAdd is not allowed! - [unknown location]
> {noformat}
> {code:xml}
> <action name="eventAdd!*" method="{1}"
>                 class="ui.struts2.editor.EventAdd">
>             <result name="input" type="tiles">.EventAdd</result>
>             <result name="success" type="chain">eventEdit</result>
>             <result name="cancel" type="redirectAction">
>                 <param name="actionName">memberEvents</param>
>                 <param name="pgn">${bean.pageNum}</param>
>                 <param name="suppressEmptyParameters">true</param>
>             </result>
>         </action>
> {code}
> checking ActionConfig:
> {code:java}
> public boolean isAllowedMethod(String method) {
>         return method.equals(methodName != null ? methodName : DEFAULT_METHOD) || allowedMethods.isAllowed(method);
>     }
> {code}
> Debugging  I get a calls to isAllowedMethod with :
> {noformat}
> 1 methodName = {1}​ and method = execute
> 2 methodName = execute and method = cancel
> {noformat}
> ​Only #1 has the required cancel
> #2 there is only a {{\[LiteralAllowedMethod\{allowedMethod='execute'\}\]}}
> On further investigation {{com.opensymphony.xwork2.config.implActionConfigMatcher}} seems
to create a new ActionConfig but then only uses the default allowed names:
> {code:java}
> return new ActionConfig.Builder(pkgName, orig.getName(), className)
>                 .methodName(methodName)
>                 .addParams(params)
>                 .addResultConfigs(results)
>                 .addInterceptors(orig.getInterceptors())
>                 .addExceptionMappings(exs)
>                 .location(orig.getLocation())
>                 .build();
> {code}
> Could use the original by appending .addAllowedMethod(orig.getAllowedMethods()), but
I guess it should come from the ActionConfig stored in the packageContext or wherever the
orig object gets its allowedMethods from.
> Cheers Greg



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message