You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2011/12/05 09:31:40 UTC

svn commit: r1210360 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/impl/ core/src/main/resources/org/apache/struts2/ xwork-core/src/main/java/com/opensymphony/xwork2/

Author: lukaszlenart
Date: Mon Dec  5 08:31:39 2011
New Revision: 1210360

URL: http://svn.apache.org/viewvc?rev=1210360&view=rev
Log:
WW-3687 adds Context Path to the error message

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
    struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionProxy.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java?rev=1210360&r1=1210359&r2=1210360&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java Mon Dec  5 08:31:39 2011
@@ -26,8 +26,10 @@ package org.apache.struts2.impl;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.DefaultActionProxy;
+import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import org.apache.struts2.ServletActionContext;
 
-import java.util.Map;
+import java.util.Locale;
 
 public class StrutsActionProxy extends DefaultActionProxy {
 
@@ -48,7 +50,7 @@ public class StrutsActionProxy extends D
 //                    return invocation.invoke();
 //                }
 //            });
-            
+
             return invocation.invoke();
         } finally {
             if (cleanupContext)
@@ -61,4 +63,18 @@ public class StrutsActionProxy extends D
         super.prepare();
     }
 
+    @Override
+    protected String getErrorMessage() {
+        if ((namespace != null) && (namespace.trim().length() > 0)) {
+            String contextPath = ServletActionContext.getRequest().getContextPath();
+            return LocalizedTextUtil.findDefaultText(
+                    "struts.exception.missing-package-action.with-context",
+                    Locale.getDefault(),
+                    new String[]{namespace, actionName, contextPath}
+            );
+        } else {
+            return super.getErrorMessage();
+        }
+    }
+
 }

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties?rev=1210360&r1=1210359&r2=1210360&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties Mon Dec  5 08:31:39 2011
@@ -32,3 +32,5 @@ struts.messages.error.content.type.not.a
 struts.messages.error.file.extension.not.allowed=File extension not allowed: {0} "{1}" "{2}" {3}
 
 devmode.notification=Developer Notification (set struts.devMode to false to disable this message):\n{0}
+
+struts.exception.missing-package-action.with-context = There is no Action mapped for namespace [{0}] and action name [{1}] associated with context path [{2}].

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionProxy.java?rev=1210360&r1=1210359&r2=1210360&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionProxy.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionProxy.java Mon Dec  5 08:31:39 2011
@@ -41,15 +41,14 @@ import java.util.Locale;
  * @author Rainer Hermanns
  * @author Revised by <a href="mailto:hu_pengfei@yahoo.com.cn">Henry Hu</a>
  * @author tmjee
- * 
  * @version $Date$ $Id$
  * @since 2005-8-6
  */
 public class DefaultActionProxy implements ActionProxy, Serializable {
-	
-	private static final long serialVersionUID = 3293074152487468527L;
 
-	private static final Logger LOG = LoggerFactory.getLogger(DefaultActionProxy.class);
+    private static final long serialVersionUID = 3293074152487468527L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultActionProxy.class);
 
     protected Configuration configuration;
     protected ActionConfig config;
@@ -65,7 +64,7 @@ public class DefaultActionProxy implemen
 
     protected ActionEventListener actionEventListener;
 
-    private boolean methodSpecified=true;
+    private boolean methodSpecified = true;
 
     /**
      * This constructor is private so the builder methods (create*) should be used to create an DefaultActionProxy.
@@ -74,35 +73,35 @@ public class DefaultActionProxy implemen
      * (like a RMIActionProxy).
      */
     protected DefaultActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) {
-        
+
         this.invocation = inv;
-		this.cleanupContext = cleanupContext;
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("Creating an DefaultActionProxy for namespace " + namespace + " and action name " + actionName);
-		}
+        this.cleanupContext = cleanupContext;
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Creating an DefaultActionProxy for namespace " + namespace + " and action name " + actionName);
+        }
 
         this.actionName = StringEscapeUtils.escapeHtml(actionName);
         this.namespace = namespace;
         this.executeResult = executeResult;
         this.method = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(methodName));
     }
-    
+
     @Inject
     public void setObjectFactory(ObjectFactory factory) {
         this.objectFactory = factory;
     }
-    
+
     @Inject
     public void setConfiguration(Configuration config) {
         this.configuration = config;
     }
-    
+
     @Inject
     public void setUnknownHandler(UnknownHandlerManager unknownHandlerManager) {
         this.unknownHandlerManager = unknownHandlerManager;
     }
-    
-    @Inject(required=false) 
+
+    @Inject(required = false)
     public void setActionEventListener(ActionEventListener listener) {
         this.actionEventListener = listener;
     }
@@ -118,7 +117,7 @@ public class DefaultActionProxy implemen
     public ActionConfig getConfig() {
         return config;
     }
-    
+
     public void setExecuteResult(boolean executeResult) {
         this.executeResult = executeResult;
     }
@@ -143,8 +142,8 @@ public class DefaultActionProxy implemen
 
         String profileKey = "execute: ";
         try {
-        	UtilTimerStack.push(profileKey);
-        	
+            UtilTimerStack.push(profileKey);
+
             retCode = invocation.invoke();
         } finally {
             if (cleanupContext) {
@@ -169,38 +168,27 @@ public class DefaultActionProxy implemen
             if (StringUtils.isEmpty(this.method)) {
                 this.method = ActionConfig.DEFAULT_METHOD;
             }
-            methodSpecified=false;
+            methodSpecified = false;
         }
     }
 
-    protected void prepare()  {
+    protected void prepare() {
         String profileKey = "create DefaultActionProxy: ";
         try {
             UtilTimerStack.push(profileKey);
             config = configuration.getRuntimeConfiguration().getActionConfig(namespace, actionName);
-    
+
             if (config == null && unknownHandlerManager.hasUnknownHandlers()) {
                 config = unknownHandlerManager.handleUnknownAction(namespace, actionName);
             }
             if (config == null) {
-                String message;
-    
-                if ((namespace != null) && (namespace.trim().length() > 0)) {
-                    message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[]{
-                        namespace, actionName
-                    });
-                } else {
-                    message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[]{
-                        actionName
-                    });
-                }
-                throw new ConfigurationException(message);
+                throw new ConfigurationException(getErrorMessage());
             }
 
             resolveMethod();
-            
+
             if (!config.isAllowedMethod(method)) {
-                throw new ConfigurationException("Invalid method: "+method+" for action "+actionName);
+                throw new ConfigurationException("Invalid method: " + method + " for action " + actionName);
             }
 
             invocation.init(this);
@@ -210,6 +198,20 @@ public class DefaultActionProxy implemen
         }
     }
 
+    protected String getErrorMessage() {
+        if ((namespace != null) && (namespace.trim().length() > 0)) {
+            return LocalizedTextUtil.findDefaultText(
+                    XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION,
+                    Locale.getDefault(),
+                    new String[]{namespace, actionName});
+        } else {
+            return LocalizedTextUtil.findDefaultText(
+                    XWorkMessages.MISSING_ACTION_EXCEPTION,
+                    Locale.getDefault(),
+                    new String[]{actionName});
+        }
+    }
+
     public boolean isMethodSpecified() {
         return methodSpecified;
     }