cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 54548 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/acting
Date Mon, 11 Oct 2004 10:32:40 GMT
Author: cziegeler
Date: Mon Oct 11 03:32:37 2004
New Revision: 54548

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java
Log:
Fix bug 29996

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java
Mon Oct 11 03:32:37 2004
@@ -15,8 +15,10 @@
  */
 package org.apache.cocoon.acting;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -44,15 +46,40 @@
  * </pre>
  *
  * @author <a href="mailto:Martin.Man@seznam.cz">Martin Man</a>
- * @version CVS $Id: SessionPropagatorAction.java,v 1.2 2004/03/05 13:02:43 bdelacretaz Exp
$
+ * @version CVS $Id$
  */
 public class SessionPropagatorAction extends AbstractConfigurableAction implements ThreadSafe
{
 
-    private Object[] defaults = {};
+    /**
+     * A private helper holding default parameter entries.
+     * 
+     */
+    private static class Entry {
+        public String key = null;
+        public String value = null;
+
+        public Entry(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+    }
+    
+    private List defaults;
 
     public void configure(Configuration conf) throws ConfigurationException {
         super.configure(conf);
-        this.defaults = super.settings.keySet().toArray();
+        Configuration[] dflts = conf.getChildren();
+        if (dflts != null) {
+            this.defaults = new ArrayList(dflts.length);
+            for (int i = 0; i < dflts.length; i++) {
+                this.defaults.add(
+                    new Entry(
+                        dflts[i].getName(),
+                        dflts[i].getValue()));
+            }
+        } else {
+            this.defaults = new ArrayList(0);
+        }
     }
 
     /**
@@ -90,18 +117,17 @@
             }
 
             // defaults, that are not overridden
-            for (int i = 0; i < defaults.length; i++) {
-                if (!actionMap.containsKey(defaults[i])) {
-                    String sessionParamName = (String) defaults[i];
-                    String value = parameters.getParameter(sessionParamName);
+            for (int i = 0; i < defaults.size(); i++) {
+                final Entry entry = (Entry)defaults.get(i);
+                if (!actionMap.containsKey(entry.key)) {
                     if (getLogger().isDebugEnabled()) {
                         getLogger().debug("Propagating value "
-                                          + value
+                                          + entry.value
                                           + " to session attribute "
-                                          + sessionParamName);
+                                          + entry.key);
                     }  
-                    session.setAttribute(sessionParamName, value);
-                    actionMap.put(sessionParamName, value);
+                    session.setAttribute(entry.key, entry.value);
+                    actionMap.put(entry.key, entry.value);
                 }
             }
             if (getLogger().isDebugEnabled()) {

Mime
View raw message