cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/modules/input RawRequestParameterModule.java DigestMetaModule.java AbstractJXPathModule.java ChainMetaModule.java DateInputModule.java DateMetaInputModule.java HeaderAttributeModule.java JXPathMetaModule.java MapMetaModule.java RandomNumberModule.java RequestAttributeModule.java RequestParameterModule.java RequestURIModule.java SessionAttributeModule.java XMLFileModule.java XMLFormInput.java XMLMetaModule.java
Date Fri, 31 Jan 2003 16:19:01 GMT
haul        2003/01/31 08:19:01

  Modified:    src/java/org/apache/cocoon/components/modules/input
                        DigestMetaModule.java AbstractJXPathModule.java
                        ChainMetaModule.java DateInputModule.java
                        DateMetaInputModule.java HeaderAttributeModule.java
                        JXPathMetaModule.java MapMetaModule.java
                        RandomNumberModule.java RequestAttributeModule.java
                        RequestParameterModule.java RequestURIModule.java
                        SessionAttributeModule.java XMLFileModule.java
                        XMLFormInput.java XMLMetaModule.java
  Added:       src/java/org/apache/cocoon/components/modules/input
                        RawRequestParameterModule.java
  Log:
  added module to access untranslated request parameters (request.get())
  to be used e.g. in conjunction with file uploads.
  
  run-time configure modules through nested elements instead of (well, in addition to) using
attributes for this -> run-time and declaration-time configuration is identical now.
  
  Revision  Changes    Path
  1.15      +29 -10    xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DigestMetaModule.java
  
  Index: DigestMetaModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DigestMetaModule.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DigestMetaModule.java	30 Jan 2003 05:00:12 -0000	1.14
  +++ DigestMetaModule.java	31 Jan 2003 16:18:59 -0000	1.15
  @@ -68,12 +68,11 @@
    * message digest of value. Very useful for storing and checking
    * passwords. Input module configured through nested element
    * "input-module", message digest algorithm, security provider, salt,
  - * and URL encoded output configurable through attributes "algorithm",
  - * "provider", "salt", "encode" of configuration root
  - * element. Defaults are "sha", null, "salt", and "false". Available
  - * value for encode are "none" (returns byte[]), "string" (return hash
  - * as string), "url" (returns url encoded string), "hex" (returns
  - * string of hex values).
  + * and URL encoded output configurable through elements "algorithm",
  + * "provider", "salt", "encode". Defaults are "sha", null, "salt", and
  + * "false". Available value for encode are "none" (returns byte[]),
  + * "string" (return hash as string), "url" (returns url encoded
  + * string), "hex" (returns string of hex values).
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
    * @version CVS $Id$
  @@ -114,10 +113,18 @@
   
           this.inputConf = config.getChild("input-module");
           this.defaultInput = this.inputConf.getAttribute("name", this.defaultInput);
  +
           this.defaultAlgorithm = this.inputConf.getAttribute("algorithm",this.defaultAlgorithm);
           this.defaultProvider = this.inputConf.getAttribute("provider",this.defaultProvider);
           this.defaultSalt = this.inputConf.getAttribute("salt",this.defaultSalt);
           this.defaultEncode = this.inputConf.getAttribute("encode","false");
  +
  +        // preferred
  +        this.defaultAlgorithm = config.getChild("algorithm").getValue(this.defaultAlgorithm);
  +        this.defaultProvider = config.getChild("provider").getValue(this.defaultProvider);
  +        this.defaultSalt = config.getChild("salt").getValue(this.defaultSalt);
  +        this.defaultEncode = config.getChild("encode").getValue(this.defaultEncode);
  +
           if (encodingNames.get(this.defaultEncode) == null) {
               if (getLogger().isErrorEnabled())
                   getLogger().error("Requested encoding is unknown: "+this.defaultEncode);
  @@ -153,9 +160,15 @@
               }
               // read necessary parameters
               algorithm = modeConf.getAttribute("algorithm", algorithm);
  -            provider  = modeConf.getAttribute("provider" , provider );
  -            salt  = modeConf.getAttribute("salt" , salt );
  -            encode = ((Integer) encodingNames.get(modeConf.getAttribute("encode" , this.defaultEncode))).intValue();
  +            provider  = modeConf.getAttribute("provider", provider);
  +            salt  = modeConf.getAttribute("salt", salt);
  +            encode = ((Integer) encodingNames.get(modeConf.getAttribute("encode", this.defaultEncode))).intValue();
  +
  +            // preferred
  +            algorithm = modeConf.getChild("algorithm").getValue(algorithm);
  +            provider  = modeConf.getChild("provider").getValue(provider);
  +            salt  = modeConf.getChild("salt").getValue(salt);
  +            encode = ((Integer) encodingNames.get(modeConf.getChild("encode").getValue(this.defaultEncode))).intValue();
           }
   
   
  @@ -247,6 +260,12 @@
               provider  = modeConf.getAttribute("provider" , provider );
               salt  = modeConf.getAttribute("salt" , salt );
               encode = ((Integer) encodingNames.get(modeConf.getAttribute("encode" , this.defaultEncode))).intValue();
  +
  +            // preferred
  +            algorithm = modeConf.getChild("algorithm").getValue(algorithm);
  +            provider  = modeConf.getChild("provider").getValue(provider);
  +            salt  = modeConf.getChild("salt").getValue(salt);
  +            encode = ((Integer) encodingNames.get(modeConf.getChild("encode").getValue(this.defaultEncode))).intValue();
           }
   
           Object[] values = getValues(name, objectModel, 
  
  
  
  1.10      +12 -1     xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java
  
  Index: AbstractJXPathModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractJXPathModule.java	25 Jan 2003 02:53:40 -0000	1.9
  +++ AbstractJXPathModule.java	31 Jan 2003 16:18:59 -0000	1.10
  @@ -74,6 +74,9 @@
    * <td>When set to true, non-existing attributes return null, when set to false,
    *     an exception is thrown. Default is true.</td> 
    *</tr>
  + * <tr><td><code>&lt;parameter&gt;foo&lt;/parameter&gt;</td>
  + * <td>When set overrides attribute name passed to module.</td> 
  + *</tr>
    * <tr><td><code>&lt;function name="java.lang.String" prefix="str"/&gt;</td>
    * <td>Imports the class "String" as extension class to the JXPathContext using 
    * the prefix "str". Thus "str:length(xpath)" would apply the method "length" to 
  @@ -105,6 +108,8 @@
        */
       protected boolean lenient = true;
   
  +    /** override attribute name */
  +    protected String parameter = null;
   
       /**
        * Configure component. Preprocess list of packages and functions
  @@ -220,6 +225,9 @@
   
           Object contextObj = getContextObject(modeConf, objectModel);
           if (contextObj == null) return null;
  +        if (modeConf != null) { 
  +            name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter
: name); 
  +        }
           try {
               JXPathContext jxContext = JXPathContext.newContext(contextObj);
               setupExtensions(jxContext, modeConf);
  @@ -263,6 +271,9 @@
   
           Object contextObj = getContextObject(modeConf, objectModel);
           if (contextObj == null) return null;
  +        if (modeConf != null) { 
  +            name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter
: name); 
  +        }
           try {
               JXPathContext jxContext = JXPathContext.newContext(contextObj);
               List values = new LinkedList();
  
  
  
  1.8       +3 -3      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/ChainMetaModule.java
  
  Index: ChainMetaModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/ChainMetaModule.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ChainMetaModule.java	25 Jan 2003 02:53:40 -0000	1.7
  +++ ChainMetaModule.java	31 Jan 2003 16:18:59 -0000	1.8
  @@ -190,7 +190,7 @@
           boolean allValues = this.allValues;
           boolean emptyAsNull = this.emptyAsNull;
           if (modeConf!=null) {
  -            inputConfigs = modeConf.getChildren("input-modules");
  +            inputConfigs = modeConf.getChildren("input-module");
               emptyAsNull = modeConf.getChild("empty-as-null").getValueAsBoolean(emptyAsNull);
               allValues = modeConf.getChild("all-values").getValueAsBoolean(allValues);
               if (inputConfigs.length == 0) inputConfigs = null;
  @@ -254,7 +254,7 @@
           boolean emptyAsNull = this.emptyAsNull;
           boolean allNames = this.allNames;
           if (modeConf!=null) {
  -            inputConfigs = modeConf.getChildren("input-modules");
  +            inputConfigs = modeConf.getChildren("input-module");
               emptyAsNull = modeConf.getChild("empty-as-null").getValueAsBoolean(emptyAsNull);
               allNames = modeConf.getChild("all-names").getValueAsBoolean(allNames);
               if (inputConfigs.length == 0) inputConfigs = null;
  
  
  
  1.7       +7 -5      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DateInputModule.java
  
  Index: DateInputModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DateInputModule.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DateInputModule.java	5 Dec 2002 10:01:04 -0000	1.6
  +++ DateInputModule.java	31 Jan 2003 16:18:59 -0000	1.7
  @@ -78,10 +78,12 @@
   
       public Object getAttribute( String name, Configuration modeConf, Map objectModel )
throws ConfigurationException {
           
  -        String format = (modeConf != null? 
  -                         modeConf.getAttribute("format", (String) this.settings.get("format",null))

  -                         : 
  -                         (String) this.settings.get("format",null));
  +        String format = null;
  +        if (modeConf != null) {
  +            format = modeConf.getAttribute("format", (String) this.settings.get("format",null));
  +            // this is preferred:
  +            format = modeConf.getChild("format").getAttribute(format);
  +        }
   
           if (format==null) {
               return new Date();
  
  
  
  1.6       +7 -5      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DateMetaInputModule.java
  
  Index: DateMetaInputModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/DateMetaInputModule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DateMetaInputModule.java	17 Dec 2002 14:53:16 -0000	1.5
  +++ DateMetaInputModule.java	31 Jan 2003 16:18:59 -0000	1.6
  @@ -62,10 +62,9 @@
   
   /**
    * Parses a date string according to a given format and returns a date
  - * object. Configuration options: child element "input-module" holds
  - * InputModule to obtain the string from, attribute "format" to
  - * "input-module" that holds ajava.text.SimpleDateFormat format
  - * string.
  + * object. Configuration options: element "format" to hold a {@link
  + * java.text.SimpleDateFormat} format string, child element
  + * "input-module" holds InputModule to obtain the string from.
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
    * @version CVS $Id$
  @@ -110,6 +109,9 @@
               inputName   = modeConf.getChild("input-module").getAttribute("name",null);
               parameter   = modeConf.getAttribute("parameter",parameter);
               format      = modeConf.getAttribute("format",this.defaultFormat);
  +            // preferred:
  +            parameter   = modeConf.getChild("parameter").getAttribute(parameter);
  +            format      = modeConf.getChild("format").getAttribute(format);
           }
           if (this.defaultFormat.equals(format)) {
               formatter = this.defaultFormatter;
  
  
  
  1.5       +5 -1      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/HeaderAttributeModule.java
  
  Index: HeaderAttributeModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/HeaderAttributeModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HeaderAttributeModule.java	5 Dec 2002 10:01:04 -0000	1.4
  +++ HeaderAttributeModule.java	31 Jan 2003 16:18:59 -0000	1.5
  @@ -80,6 +80,8 @@
           String pname = name;
           if ( modeConf != null ) {
               pname = modeConf.getAttribute( "parameter", pname );
  +            // preferred
  +            pname = modeConf.getChild("parameter").getValue(pname);
           }
           return ObjectModelHelper.getRequest(objectModel).getHeader( pname );
       }
  @@ -99,6 +101,8 @@
           String wildcard = name;
           if ( modeConf != null ) {
               wildcard = modeConf.getAttribute( "parameter", wildcard );
  +            // preferred
  +            wildcard = modeConf.getChild("parameter").getValue(wildcard);
           }
           int wildcardIndex = wildcard.indexOf( "*" );
           if ( wildcardIndex != -1 ) {
  
  
  
  1.8       +23 -6     xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java
  
  Index: JXPathMetaModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JXPathMetaModule.java	25 Jan 2003 02:53:40 -0000	1.7
  +++ JXPathMetaModule.java	31 Jan 2003 16:18:59 -0000	1.8
  @@ -76,8 +76,14 @@
    * <td>When set to true, non-existing attributes return null, when set to false,
    *     an exception is thrown. Default is true.</td> 
    *</tr>
  - * <tr><td><code>&lt;input-module name="request-attr" parameter="foo"/&gt;</td>
  - * <td>Uses the "request-attr" input module to obtain parameter named "foo" and 
  + * <tr><td><code>&lt;parameter&gt;false&lt;/lenient&gt;</td>
  + * <td>Attribute name to be used instead of passed attribute name.</td> 
  + *</tr>
  + * <tr><td><code>&lt;from-parameter&gt;false&lt;/lenient&gt;</td>
  + * <td>Attribute name to pass to configured input module</td> 
  + *</tr>
  + * <tr><td><code>&lt;input-module name="request-attr"/&gt;</td>
  + * <td>Uses the "request-attr" input module to obtain a value and 
    *     applies the given JXPath expression to it.</td> 
    *</tr>
    * <tr><td><code>&lt;function name="java.lang.String" prefix="str"/&gt;</td>
  @@ -92,6 +98,10 @@
    * new java.util.Date object.</td> 
    * </tr></table>
    *
  + * <p>In addition, it accepts the attributes "parameter" to override
  + * the attribute name and "from-parameter" to pass as attribute name
  + * to the configured input module.</p>
  + *
    * @author <a href="mailto:kpiroumian@apache.org">Konstantin Piroumian</a>
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
    * @version $Id$
  @@ -131,7 +141,7 @@
   
           this.inputConf = config.getChild("input-module");
           this.defaultInput = this.inputConf.getAttribute("name",this.defaultInput);
  -        this.parameter = this.inputConf.getAttribute("parameter", this.parameter);
  +        this.parameter = config.getChild("parameter").getValue(this.parameter);
   
           // start verbatim copy of AbstractJXPathModule
           // please keep both in sync.
  @@ -239,6 +249,9 @@
   
           Object contextObj = getContextObject(modeConf, objectModel);
           if (contextObj == null) return null;
  +        if (modeConf != null) {
  +            name = modeConf.getChild("parameter").getValue(name);
  +        }
           try {
               JXPathContext jxContext = JXPathContext.newContext(contextObj);
               setupExtensions(jxContext, modeConf);
  @@ -284,12 +297,16 @@
   
           Object contextObj = getContextObject(modeConf, objectModel);
           if (contextObj == null) return null;
  +        if (modeConf != null) {
  +            name = modeConf.getChild("parameter").getValue(name);
  +        }
           try {
               JXPathContext jxContext = JXPathContext.newContext(contextObj);
  -            List values = new LinkedList();
  +            List values = null;
               setupExtensions(jxContext, modeConf);
               if (this.lenient) jxContext.setLenient(true); // return null insted of exception
on non existing property
               Iterator i = jxContext.iterate(name);
  +            if (i.hasNext()) { values = new LinkedList(); } 
               while (i.hasNext()) {
                   values.add(i.next());
               }
  @@ -327,7 +344,7 @@
           if (modeConf!=null) {
               mConf   = modeConf.getChild("input-module");
               inputName   = mConf.getAttribute("name",null);
  -            parameter   = modeConf.getAttribute("parameter",parameter);
  +            parameter   = modeConf.getChild("from-parameter").getValue(parameter);
           }
   
           if (getLogger().isDebugEnabled())
  
  
  
  1.10      +13 -1     xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/MapMetaModule.java
  
  Index: MapMetaModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/MapMetaModule.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MapMetaModule.java	25 Jan 2003 02:53:40 -0000	1.9
  +++ MapMetaModule.java	31 Jan 2003 16:18:59 -0000	1.10
  @@ -62,6 +62,7 @@
    * that this Object implements the java.util.Map interface, and gives
    * access to the map contents. Possible use is to propagate data from
    * flow through request attributes to database actions.
  + * The same can be achieved by using the {@link JXPathMetaModule}.
    *
    * <p>Configuration: "input-module", "object", "parameter"</p>
    *
  @@ -80,6 +81,10 @@
           this.defaultInput = this.inputConf.getAttribute("name", this.defaultInput);
           this.objectName = this.inputConf.getAttribute("object",this.objectName);
           this.parameter = this.inputConf.getAttribute("parameter",this.parameter);
  +
  +        // preferred
  +        this.objectName = config.getChild("object").getValue(this.objectName);
  +        this.parameter = config.getChild("parameter").getValue(this.parameter);
       }
   
   
  @@ -104,6 +109,10 @@
               inputName  = modeConf.getChild("input-module").getAttribute("name",null);
               objectName = modeConf.getAttribute("object",objectName);
               parameter  = modeConf.getAttribute("parameter",parameter);
  +
  +            // preferred
  +            objectName = modeConf.getChild("object").getValue(objectName);
  +            parameter  = modeConf.getChild("parameter").getValue(parameter);
           }
           parameter = (parameter != null? parameter : name);
   
  @@ -139,6 +148,9 @@
           if (modeConf!=null) {
               inputName   = modeConf.getChild("input-module").getAttribute("name",null);
               objectName = modeConf.getAttribute("object",this.objectName);
  +
  +            // preferred
  +            objectName = modeConf.getChild("object").getValue(objectName);
               if (inputName != null) {
                   inputConfig = modeConf.getChild("input-module");
               }
  
  
  
  1.6       +6 -2      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java
  
  Index: RandomNumberModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RandomNumberModule.java	5 Dec 2002 10:01:04 -0000	1.5
  +++ RandomNumberModule.java	31 Jan 2003 16:18:59 -0000	1.6
  @@ -63,7 +63,7 @@
   
   /**
    * RandomNumberModule returns a random number as string.
  - * Configuration through attributes of root node: "min", "max" setting
  + * Configuration through child elements: "min", "max" setting
    * range of random number. Defaults to "0" and "9999999999"
    * respectively.
    *
  @@ -86,6 +86,10 @@
           if (modeConf != null) {
               min = Long.parseLong(modeConf.getAttribute("min","0"));
               max = Long.parseLong(modeConf.getAttribute("max",String.valueOf(max)));
  +            
  +            //preferred
  +            min = Long.parseLong(modeConf.getChild("min").getValue("0"));
  +            max = Long.parseLong(modeConf.getChild("max").getValue(String.valueOf(max)));
           }
           return Long.toString(java.lang.Math.round(java.lang.Math.random()*(max-min)));
   
  
  
  
  1.5       +5 -1      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java
  
  Index: RequestAttributeModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestAttributeModule.java	5 Dec 2002 10:01:04 -0000	1.4
  +++ RequestAttributeModule.java	31 Jan 2003 16:19:00 -0000	1.5
  @@ -81,6 +81,8 @@
           String pname = name;
           if ( modeConf != null ) {
               pname = modeConf.getAttribute( "parameter", pname );
  +            // preferred
  +            pname = modeConf.getChild("parameter").getValue(pname);
           }
           return ObjectModelHelper.getRequest(objectModel).getAttribute( pname );
       }
  @@ -100,6 +102,8 @@
           String wildcard = name;
           if ( modeConf != null ) {
               wildcard = modeConf.getAttribute( "parameter", wildcard );
  +            // preferred
  +            wildcard = modeConf.getChild("parameter").getValue(wildcard);
           }
           int wildcardIndex = wildcard.indexOf( "*" );
           if ( wildcardIndex != -1 ) {
  
  
  
  1.5       +5 -1      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestParameterModule.java
  
  Index: RequestParameterModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestParameterModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestParameterModule.java	5 Dec 2002 10:01:04 -0000	1.4
  +++ RequestParameterModule.java	31 Jan 2003 16:19:00 -0000	1.5
  @@ -82,6 +82,8 @@
           String pname = name;
           if ( modeConf != null ) {
               pname = modeConf.getAttribute( "parameter", pname );
  +            // preferred
  +            pname = modeConf.getChild("parameter").getValue(pname);
           }
           return ObjectModelHelper.getRequest(objectModel).getParameter( pname );
       }
  @@ -100,6 +102,8 @@
           String wildcard = name;
           if ( modeConf != null ) {
               wildcard = modeConf.getAttribute( "parameter", wildcard );
  +            // preferred
  +            wildcard = modeConf.getChild("parameter").getValue(wildcard);
           }
           int wildcardIndex = wildcard.indexOf( "*" );
           if ( wildcardIndex != -1 ) {
  
  
  
  1.5       +3 -2      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestURIModule.java
  
  Index: RequestURIModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RequestURIModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestURIModule.java	5 Dec 2002 10:01:05 -0000	1.4
  +++ RequestURIModule.java	31 Jan 2003 16:19:00 -0000	1.5
  @@ -63,7 +63,8 @@
   import java.util.Vector;
   
   /**
  - * RequestURIModule accesses the request URI. If the
  + * RequestURIModule accesses the request URI. The {@link
  + * RequestModule} provides similar functionality based on JXPath.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
    * @version CVS $Id$
  
  
  
  1.5       +5 -1      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/SessionAttributeModule.java
  
  Index: SessionAttributeModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/SessionAttributeModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SessionAttributeModule.java	5 Dec 2002 10:01:04 -0000	1.4
  +++ SessionAttributeModule.java	31 Jan 2003 16:19:00 -0000	1.5
  @@ -81,6 +81,8 @@
           String pname = name;
           if ( modeConf != null ) {
               pname = modeConf.getAttribute( "parameter", pname );
  +            // preferred
  +            pname = modeConf.getChild("parameter").getValue(pname);
           }
           return ObjectModelHelper.getRequest(objectModel).getSession().getAttribute( pname
);
       }
  @@ -100,6 +102,8 @@
           String wildcard = name;
           if ( modeConf != null ) {
               wildcard = modeConf.getAttribute( "parameter", wildcard );
  +            // preferred
  +            wildcard = modeConf.getChild("parameter").getValue(wildcard);
           }
           int wildcardIndex = wildcard.indexOf( "*" );
           if ( wildcardIndex != -1 ) {
  
  
  
  1.7       +4 -4      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
  
  Index: XMLFileModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLFileModule.java	25 Jan 2003 02:53:40 -0000	1.6
  +++ XMLFileModule.java	31 Jan 2003 16:19:00 -0000	1.7
  @@ -234,15 +234,15 @@
           boolean cache = this.cacheAll;
           
           if (modeConf != null) 
  -            src = modeConf.getAttribute("src",src);
  +            src = modeConf.getChild("file").getAttribute("src",src);
   
           if (this.documents == null) 
               this.documents = Collections.synchronizedMap(new HashMap());
   
           if (!this.documents.containsKey(src)) {
               if (modeConf != null) {
  -                reload = modeConf.getAttributeAsBoolean("reloadable",reload);
  -                cache = modeConf.getAttributeAsBoolean("cachable",cache);
  +                reload = modeConf.getChild("file").getAttributeAsBoolean("reloadable",reload);
  +                cache = modeConf.getChild("file").getAttributeAsBoolean("cachable",cache);
               }
               this.documents.put(src, new DocumentHelper(reload, cache, src));
           }
  
  
  
  1.3       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFormInput.java
  
  Index: XMLFormInput.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFormInput.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLFormInput.java	25 Jan 2003 02:53:40 -0000	1.2
  +++ XMLFormInput.java	31 Jan 2003 16:19:00 -0000	1.3
  @@ -99,7 +99,7 @@
       protected Object getContextObject(Configuration modeConf, Map objectModel) throws ConfigurationException
{
           String id = this.formId;
           if (modeConf != null) {
  -            id = modeConf.getAttribute("xmlform-id", this.formId);
  +            id = modeConf.getChild("xmlform-id").getValue(this.formId);
           }
           Form form = Form.lookup(objectModel,id);
           Object tmp = null;
  
  
  
  1.11      +23 -3     xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLMetaModule.java
  
  Index: XMLMetaModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLMetaModule.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLMetaModule.java	7 Jan 2003 23:56:11 -0000	1.10
  +++ XMLMetaModule.java	31 Jan 2003 16:19:00 -0000	1.11
  @@ -77,10 +77,18 @@
    * <p>Config</p>
    * <pre>
    *   &lt;!-- in cocoon.xconf --&gt;
  - *   &lt;input-module name="request" ignore="do-" strip="user."/&gt;
  + *   &lt;ignore&gt;do-&lt;/ignore&gt;
  + *   &lt;strip&gt;user.&lt;/strip&gt;
  + *   &lt;input-module name="request-param"/&gt;
    *
    *   &lt;!-- e.g. in database.xml --&gt;
  - *   &lt;mode type="all" name="xmlmeta" ignore="foo." use="foo" strip="f" root="my-root"/&gt;
  + *   &lt;mode type="all" name="xmlmeta"/&gt;
  + *      &lt;ignore&gt;foo.&lt;/ignore&gt;
  + *      &lt;strip&gt;f&lt;/strip&gt;
  + *      &lt;use&gt;foo&lt;/use&gt;
  + *      &lt;root&gt;my-root&lt;/root&gt;
  + *      &lt;input-module name="request-param"/&gt;
  + *   &lt;/mode&gt;
    * </pre>
    *
    * <p>If present, "ignore" gives a prefix of parameters to ignore,
  @@ -143,6 +151,12 @@
           this.use = this.inputConf.getAttribute("use",this.use);
           this.strip = this.inputConf.getAttribute("strip",this.strip);
           this.config = config;
  +
  +        // preferred
  +        this.rootName = config.getChild("root").getValue(this.rootName);
  +        this.ignore = config.getChild("ignore").getValue(this.ignore);
  +        this.use = config.getChild("use").getValue(this.use);
  +        this.strip = config.getChild("strip").getValue(this.strip);
       }
   
   
  @@ -175,6 +189,12 @@
               ignore  = modeConf.getAttribute("ignore" ,this.ignore );
               use  = modeConf.getAttribute("use" ,this.use );
               strip  = modeConf.getAttribute("strip" ,this.strip );
  +
  +            // preferred
  +            rootName = modeConf.getChild("root").getValue(rootName);
  +            ignore  = modeConf.getChild("ignore").getValue(ignore );
  +            use  = modeConf.getChild("use").getValue(use );
  +            strip  = modeConf.getChild("strip").getValue(strip );
               if (inputName != null) {
                   inputConfig = modeConf.getChild("input-module");
               }
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/RawRequestParameterModule.java
  
  Index: RawRequestParameterModule.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.components.modules.input;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.environment.ObjectModelHelper;
  
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Vector;
  
  /**
   * RawRequestParameterModule accesses request parameters without 
   * decoding or casting. It uses the get() method instead of the getParameter() 
   * method of the {@link org.apache.cocoon.environment.Request Request} This is useful
   *  for example in conjunction with uploads.
   * If get() returns a Vector, getAttribute() will return the first element, otherwise it
   * will return the same as get(). getAttributeValues() will either convert the Vector to
an array,
   * place the result in a new array, or return the array as is.
   *
   * @author <a href="mailto:haul@apache.org">Christian Haul</a>
   * @version CVS $Id: RawRequestParameterModule.java,v 1.1 2003/01/31 16:18:59 haul Exp $
   */
  public class RawRequestParameterModule extends AbstractInputModule implements ThreadSafe
{
  
      public Object getAttribute( String name, Configuration modeConf, Map objectModel ) throws
ConfigurationException {
  
          String pname = name;
          if ( modeConf != null ) {
              pname = modeConf.getAttribute( "parameter", pname );
              // preferred
              pname = modeConf.getChild("parameter").getValue(pname);
          }
          Object obj = ObjectModelHelper.getRequest(objectModel).get( pname );
          if (obj instanceof Vector) {
              return ((Vector) obj).firstElement();
          } else {
              return obj;
          }
          
      }
  
  
      public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws
ConfigurationException {
  
          return new IteratorHelper(ObjectModelHelper.getRequest(objectModel).getParameterNames());
      }
  
  
      public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel
)
          throws ConfigurationException {
          
          Object obj = getAttribute(name, modeConf, objectModel);
          if (obj instanceof Vector) {   
             return ((Vector)obj).toArray();
          } else if (obj.getClass().isArray()) {
              return (Object[]) obj;
          } else {
              Object[] tmp = new Object[1];
              tmp[0] = obj;
              return tmp;
          }
      }
  
  }
  
  
  

----------------------------------------------------------------------
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


Mime
View raw message