Extends Unknown Handler to allowed check if method is allowed
Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/45659934 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/45659934 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/45659934 Branch: refs/heads/master Commit: 4565993463f660e9be90b9fe9c3597ce54b58917 Parents: fb0c4a5 Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Mon Aug 31 14:43:21 2015 +0200 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Mon Aug 31 14:43:21 2015 +0200 ---------------------------------------------------------------------- .../opensymphony/xwork2/DefaultUnknownHandlerManager.java | 10 ++++++++++ .../main/java/com/opensymphony/xwork2/UnknownHandler.java | 10 ++++++++++ .../com/opensymphony/xwork2/UnknownHandlerManager.java | 3 +++ 3 files changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/45659934/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java b/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java index 5cafe9a..04ac430 100644 --- a/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java +++ b/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java @@ -145,4 +145,14 @@ public class DefaultUnknownHandlerManager implements UnknownHandlerManager { public List<UnknownHandler> getUnknownHandlers() { return unknownHandlers; } + + @Override + public boolean isAllowedMethod(String allowedMethod, ActionConfig config) { + for (UnknownHandler unknownHandler : unknownHandlers) { + if (unknownHandler.isAllowedMethod(allowedMethod, config)) { + return true; + } + } + return false; + } } http://git-wip-us.apache.org/repos/asf/struts/blob/45659934/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java b/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java index 51556d6..1e6f5aa 100644 --- a/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java +++ b/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java @@ -60,4 +60,14 @@ public interface UnknownHandler { */ Object handleUnknownActionMethod(Object action, String methodName); + /** + * Handles the case when an action method is unknown and cannot be validated if it is allowed to be executed. + * + * @since 2.5 + * @param allowedMethod The method's name + * @param actionConfig The config of actions + * @return true if allowedMethod can be executed, false otherwise + */ + boolean isAllowedMethod(String allowedMethod, ActionConfig actionConfig); + } http://git-wip-us.apache.org/repos/asf/struts/blob/45659934/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java b/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java index f5e2542..caf63b3 100644 --- a/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java +++ b/core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java @@ -43,4 +43,7 @@ public interface UnknownHandlerManager { boolean hasUnknownHandlers(); List<UnknownHandler> getUnknownHandlers(); + + boolean isAllowedMethod(String allowedMethod, ActionConfig actionConfig); + }