You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ha...@apache.org on 2001/07/23 18:31:20 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/acting HttpHeaderAction.java

haul        01/07/23 09:31:20

  Modified:    src/org/apache/cocoon/acting Tag: cocoon_20_branch
                        HttpHeaderAction.java
  Log:
  moved configure method code to AbstractConfigurabeAction (sic!), subclassed it with
    ConfigurableComposableAction, moved some actions that used that configuration scheme
    to appropriate superclasses.
  
  extended actions that do take parameters but didn't support configuration of default
    values to use this scheme
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +31 -7     xml-cocoon2/src/org/apache/cocoon/acting/HttpHeaderAction.java
  
  Index: HttpHeaderAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/HttpHeaderAction.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- HttpHeaderAction.java	2001/06/14 11:13:00	1.1.2.1
  +++ HttpHeaderAction.java	2001/07/23 16:31:19	1.1.2.2
  @@ -10,8 +10,9 @@
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.Map;
  -import java.util.Iterator;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Response;
  @@ -23,17 +24,40 @@
    * @author <a href="mailto:balld@apache.org">Donald Ball</a>
    * @version CVS $Revision:
    */
  -public class HttpHeaderAction extends AbstractAction {
  +public class HttpHeaderAction extends AbstractConfigurableAction {
   
  +    private static Object[] defaults = {};
  +    
  +    public void configure(Configuration conf) throws ConfigurationException {
  +        if (conf != null) {
  +	    String[] names = {};
  +	    super.configure(conf);
  +	    defaults=(settings.keySet()).toArray();
  +	};
  +    }
  +
       public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
           Map results = new HashMap();
  +	HashMap isDone = new HashMap();
  +	Integer dummy = new Integer(1);
  +
           Response response = (Response)objectModel.get(Constants.RESPONSE_OBJECT);
  -        Iterator iterator = parameters.getParameterNames();
  -        while (iterator.hasNext()) {
  -            String name = (String)iterator.next();
  -            response.setHeader(name,parameters.getParameter(name));
  -            results.put(name,parameters.getParameter(name));
  +        String[] names = parameters.getNames();
  +
  +	// parameters
  +        for (int i=0; i<names.length; i++) {
  +	    isDone.put(names[i], dummy);
  +            response.setHeader(names[i],parameters.getParameter(names[i]));
  +            results.put(names[i],parameters.getParameter(names[i]));
           }
  +	// defaults, that are not overridden
  +        for (int i=0; i<defaults.length; i++) {
  +	    if (! isDone.containsKey(defaults[i])) {
  +		response.setHeader((String) defaults[i], (String) settings.get(defaults[i]));
  +		results.put((String) defaults[i],(String) settings.get(defaults[i]));
  +	    }
  +        }
  +
           return Collections.unmodifiableMap(results);
       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org