svn commit: r425552 - /struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java

2006-07-25 Thread hrabago
Author: hrabago
Date: Tue Jul 25 16:14:19 2006
New Revision: 425552

URL: http://svn.apache.org/viewvc?rev=425552&view=rev
Log:
Let the user know if an action mapping isn't going anywhere.

Modified:

struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java

Modified: 
struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java?rev=425552&r1=425551&r2=425552&view=diff
==
--- 
struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java
 (original)
+++ 
struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/commands/AbstractCreateAction.java
 Tue Jul 25 16:14:19 2006
@@ -73,7 +73,12 @@
 String type = actionConfig.getType();
 
 if (type == null) {
-LOG.trace("no type for " + actionConfig.getPath());
+if ((actionConfig.getForward() == null)
+&& (actionConfig.getInclude() == null)) {
+LOG.error("no type for " + actionConfig.getPath());
+} else {
+LOG.trace("no type for " + actionConfig.getPath());
+}
 
 return (false);
 }




svn commit: r425554 - /struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java

2006-07-25 Thread hrabago
Author: hrabago
Date: Tue Jul 25 16:15:36 2006
New Revision: 425554

URL: http://svn.apache.org/viewvc?rev=425554&view=rev
Log:
Copy the set of arbitrary properties when copying a ForwardConfig.

Modified:

struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java

Modified: 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java?rev=425554&r1=425553&r2=425554&view=diff
==
--- 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java
 (original)
+++ 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionRedirect.java
 Tue Jul 25 16:15:36 2006
@@ -119,7 +119,7 @@
 
 /**
  * Construct a new instance with a [EMAIL PROTECTED] ForwardConfig} 
object to copy
- * name, path, and contextRelative values from.
+ * name, path, contextRelative, and arbitrary property values from.
  *
  * @param baseConfig the [EMAIL PROTECTED] ForwardConfig} to copy 
configuration
  *   values from
@@ -129,6 +129,7 @@
 setPath(baseConfig.getPath());
 setModule(baseConfig.getModule());
 setRedirect(baseConfig.getRedirect());
+inheritProperties(baseConfig);
 initializeParameters();
 }
 




svn commit: r425569 - /struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java

2006-07-25 Thread hrabago
Author: hrabago
Date: Tue Jul 25 17:35:35 2006
New Revision: 425569

URL: http://svn.apache.org/viewvc?rev=425569&view=rev
Log:
Test ActionRedirect's handling of a ForwardConfig's arbitrary properties.

Modified:

struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java

Modified: 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java?rev=425569&r1=425568&r2=425569&view=diff
==
--- 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java
 (original)
+++ 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionRedirect.java
 Tue Jul 25 17:35:35 2006
@@ -106,6 +106,7 @@
 public void testActionRedirectFromExistingForward() {
 ActionForward forward = new ActionForward("/path.do?param=param1");
 forward.setRedirect(false);
+forward.setProperty("key","value");
 
 ActionRedirect ar = new ActionRedirect(forward);
 
@@ -117,6 +118,8 @@
 assertHasParameter(ar.parameterValues, "object1", "someString");
 assertEquals("Incorrect original path.", forward.getPath(),
 ar.getOriginalPath());
+assertEquals("Incorrect or missing property", "value",
+ar.getProperty("key"));
 assertTrue("Original had redirect to false", !ar.getRedirect());
 }
 




svn commit: r425573 - in /struts/struts1/trunk/core/src: main/java/org/apache/struts/action/ActionServlet.java test/java/org/apache/struts/action/TestActionServlet.java

2006-07-25 Thread hrabago
Author: hrabago
Date: Tue Jul 25 17:41:36 2006
New Revision: 425573

URL: http://svn.apache.org/viewvc?rev=425573&view=rev
Log:
STR-2917
Fix bug that prevents action-mapping-level forwards and exception handlers from 
inheriting onfig data from global forwards and exception handlers.

Modified:

struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java

struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java

Modified: 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java?rev=425573&r1=425572&r2=425573&view=diff
==
--- 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java
 (original)
+++ 
struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java
 Tue Jul 25 17:41:36 2006
@@ -1061,7 +1061,7 @@
 for (int i = 0; i < forwards.length; i++) {
 ForwardConfig forward = forwards[i];
 
-processForwardExtension(forward, config);
+processForwardExtension(forward, config, null);
 }
 
 for (int i = 0; i < forwards.length; i++) {
@@ -1076,14 +1076,18 @@
 }
 
 /**
- * Extend the forward's configuration as necessary.
+ * Extend the forward's configuration as necessary.  If actionConfig is 
+ * provided, then this method will process the forwardConfig as part
+ * of that actionConfig.  If actionConfig is null, the forwardConfig
+ * will be processed as a global forward.
  *
  * @param forwardConfig the configuration to process.
  * @param moduleConfig  the module configuration for this module.
+ * @param actionConfig  If applicable, the config for the current action.
  * @throws ServletException if initialization cannot be performed.
  */
 protected void processForwardExtension(ForwardConfig forwardConfig,
-ModuleConfig moduleConfig)
+ModuleConfig moduleConfig, ActionConfig actionConfig)
 throws ServletException {
 try {
 if (!forwardConfig.isExtensionProcessed()) {
@@ -1093,9 +1097,10 @@
 }
 
 forwardConfig =
-processForwardConfigClass(forwardConfig, moduleConfig);
+processForwardConfigClass(forwardConfig, moduleConfig,
+actionConfig);
 
-forwardConfig.processExtends(moduleConfig, null);
+forwardConfig.processExtends(moduleConfig, actionConfig);
 }
 } catch (ServletException e) {
 throw e;
@@ -1107,10 +1112,14 @@
 
 /**
  * Checks if the current forwardConfig is using the correct class based
- * on the class of its configuration ancestor.
+ * on the class of its configuration ancestor.  If actionConfig is 
+ * provided, then this method will process the forwardConfig as part
+ * of that actionConfig.  If actionConfig is null, the forwardConfig
+ * will be processed as a global forward.
  *
  * @param forwardConfig The forward to check.
  * @param moduleConfig  The config for the current module.
+ * @param actionConfig  If applicable, the config for the current action.
  * @return The forward config using the correct class as determined by the
  * config's ancestor and its own overridden value.
  * @throws UnavailableException if an instance of the forward config class
@@ -1118,7 +1127,8 @@
  * @throws ServletException on class creation error
  */
 protected ForwardConfig processForwardConfigClass(
-ForwardConfig forwardConfig, ModuleConfig moduleConfig)
+ForwardConfig forwardConfig, ModuleConfig moduleConfig,
+ActionConfig actionConfig)
 throws ServletException {
 String ancestor = forwardConfig.getExtends();
 
@@ -1128,7 +1138,17 @@
 }
 
 // Make sure that this config is of the right class
-ForwardConfig baseConfig = moduleConfig.findForwardConfig(ancestor);
+ForwardConfig baseConfig = null;
+if (actionConfig != null) {
+// Look for this in the actionConfig
+baseConfig = actionConfig.findForwardConfig(ancestor);
+} 
+
+if (baseConfig == null) {
+// Either this is a forwardConfig that inherits a global config,
+//  or actionConfig is null
+baseConfig = moduleConfig.findForwardConfig(ancestor);
+}
 
 if (baseConfig == null) {
 throw new UnavailableException("Unable to find " + "forward '"
@@ -1145,7 +1165,8 @@
 
 try {
 newForwardConfig =
-(Forwar

svn commit: r425585 - /struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java

2006-07-25 Thread hrabago
Author: hrabago
Date: Tue Jul 25 18:44:13 2006
New Revision: 425585

URL: http://svn.apache.org/viewvc?rev=425585&view=rev
Log:
STR-2917
Additional tests for action-level config objects inheriting from global config 
objects.

Modified:

struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java

Modified: 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java?rev=425585&r1=425584&r2=425585&view=diff
==
--- 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java
 (original)
+++ 
struts/struts1/trunk/core/src/test/java/org/apache/struts/action/TestActionServlet.java
 Tue Jul 25 18:44:13 2006
@@ -862,6 +862,48 @@
 }
 
 /**
+ * Test that an ActionConfig's ForwardConfig can inherit from a 
+ * global ForwardConfig.
+ */
+public void testProcessActionExtensionWithForwardConfig()
+throws ServletException {
+ForwardConfig forwardConfig = new ForwardConfig();
+forwardConfig.setName("sub");
+forwardConfig.setExtends("success");
+baseAction.addForwardConfig(forwardConfig);
+
+moduleConfig.addActionConfig(baseAction);
+moduleConfig.addForwardConfig(baseForward);
+actionServlet.processActionConfigExtension(baseAction, moduleConfig);
+
+forwardConfig = baseAction.findForwardConfig("sub");
+
+assertEquals("'sub' forward's inheritance was not processed.",
+baseForward.getPath(), forwardConfig.getPath());
+}
+
+/**
+ * Test that an ActionConfig's ExceptionConfig can inherit from a 
+ * global ExceptionConfig.
+ */
+public void testProcessActionExtensionWithExceptionConfig()
+throws ServletException {
+ExceptionConfig exceptionConfig = new ExceptionConfig();
+exceptionConfig.setType("SomeException");
+exceptionConfig.setExtends("java.lang.NullPointerException");
+baseAction.addExceptionConfig(exceptionConfig);
+
+moduleConfig.addActionConfig(baseAction);
+moduleConfig.addExceptionConfig(baseException);
+actionServlet.processActionConfigExtension(baseAction, moduleConfig);
+
+exceptionConfig = baseAction.findExceptionConfig("SomeException");
+
+assertEquals("SomeException's inheritance was not processed.",
+baseException.getKey(), exceptionConfig.getKey());
+}
+
+/**
  * Make sure processActionConfigClass() returns an instance of the correct
  * class if the base config is using a custom class.
  */