vgritsenko    02/01/11 09:07:06

  Modified:    src/java/org/apache/cocoon/matching
                        RegexpTargetHostMatcher.java
                        RegexpTargetHostMatcherFactory.java
                        RequestParamMatcher.java
                        WildcardParameterValueMatcher.java
                        WildcardParameterValueMatcherFactory.java
               src/java/org/apache/cocoon/selection RequestSelector.java
                        RequestSelectorFactory.java
               src/webapp sitemap.xmap
  Added:       src/java/org/apache/cocoon/matching RegexpHostMatcher.java
                        RequestParameterMatcher.java
                        WildcardRequestParameterMatcher.java
               src/java/org/apache/cocoon/selection
                        RequestParameterSelector.java
  Log:
  Rename some matchers/selectors:
  > RequestSelector               -> RequestParameterSelector
  > RequestParamMatcher           -> RequestParameterMatcher
  > WildcardParameterValueMatcher -> WildcardRequestParameterMatcher
  > RegexpTargetHostMatcher       -> RegexpHostMatcher
  to be more consistent...
  
  Revision  Changes    Path
  1.2       +7 -14     
xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcher.java
  
  Index: RegexpTargetHostMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegexpTargetHostMatcher.java      3 Jan 2002 12:31:17 -0000       1.1
  +++ RegexpTargetHostMatcher.java      11 Jan 2002 17:07:05 -0000      1.2
  @@ -7,24 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import java.util.Map;
  -
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * Matches the target host ("Host" request header) against a regular expression.
    *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Russell</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:05 $
  + * @deprecated Renamed to RegexpHostMatcher
    */
  +public class RegexpTargetHostMatcher extends RegexpHostMatcher implements 
Initializable {
   
  -public class RegexpTargetHostMatcher extends AbstractRegexpMatcher {
  -
  -    protected String getMatchString(Map objectModel, Parameters parameters) {
  -        return ObjectModelHelper.getRequest(objectModel).getHeader("Host");
  +    public void initialize() {
  +        getLogger().warn("RegexpTargetHostMatcher is deprecated. Please use 
RegexpHostMatcher");
       }
   }
  
  
  
  1.2       +3 -4      
xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java
  
  Index: RegexpTargetHostMatcherFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegexpTargetHostMatcherFactory.java       3 Jan 2002 12:31:17 -0000       1.1
  +++ RegexpTargetHostMatcherFactory.java       11 Jan 2002 17:07:05 -0000      1.2
  @@ -10,14 +10,13 @@
   import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $
  - * @deprecated replaced by RegexpTargetHostMatcher - code factories should no 
longer be used
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:05 $
  + * @deprecated replaced by RegexpHostMatcher - code factories should no longer be 
used
    */
   
   public class RegexpTargetHostMatcherFactory extends RegexpTargetHostMatcher 
implements Initializable {
       
       public void initialize() {
  -        getLogger().warn("RegexpTargetHostMatcherFactory is deprecated. Please use 
RegexpTargetHostMatcher");
  +        getLogger().warn("RegexpTargetHostMatcherFactory is deprecated. Please use 
RegexpHostMatcher");
       }
  -
   }
  
  
  
  1.2       +8 -48     
xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParamMatcher.java
  
  Index: RequestParamMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParamMatcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestParamMatcher.java  3 Jan 2002 12:31:17 -0000       1.1
  +++ RequestParamMatcher.java  11 Jan 2002 17:07:05 -0000      1.2
  @@ -5,59 +5,19 @@
    * version 1.1, a copy of which has been included  with this distribution in *
    * the LICENSE file.                                                         *
    *****************************************************************************/
  -
  -/*
  - * Package definition
  - */
   package org.apache.cocoon.matching;
   
  -/*
  - * Standard imports
  - */
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.cocoon.Constants;
  -import org.apache.cocoon.environment.Request;
  -
  -import java.util.HashMap;
  -import java.util.Map;
  +import org.apache.avalon.framework.logger.Loggable;
  +import org.apache.log.Logger;
   
   /**
  - * This class allows for matching based on a request parameter.
  - * If the specified request parameter exists, its value is retrieved for later
  - * xpath substitution.
  - *
  - * <p><b>Example:</b></p>
  - * <pre>
  - * &lt;map:match type="request" pattern="dest"&gt;
  - *     &lt;map:redirect-to uri="{1}"/&gt;
  - * &lt;/map:match&gt;
  - * </pre>
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Marcus Crafter</a>
  - * @version CVS $Revision: 1.1 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
  + * @deprecated Renamed to RequestParameterMatcher
  + * @version CVS $Revision: 1.2 $
    */
  -public class RequestParamMatcher implements Matcher, ThreadSafe {
  -    /**
  -      * Match method to see if the request parameter exists. If it does
  -      * have a value the parameter is added to the array list for later
  -      * substitution with a xpath attribute.
  -      *
  -      * @param pattern name of request parameter to find
  -      * @param objectModel environment passed through via cocoon
  -      * @returns null or map containing value of request parameter 'pattern'
  -      */
  -    public Map match(String pattern, Map objectModel, Parameters parameters) {
  -        Request request =
  -          (Request) objectModel.get(Constants.REQUEST_OBJECT);
  -        String param = request.getParameter(pattern);
  +public class RequestParamMatcher extends RequestParameterMatcher implements 
Loggable {
   
  -        if (param == null)
  -            return null; // no parameter defined
  -        else {
  -            Map map = new HashMap();
  -            map.put(Integer.toString(1), param);
  -            return map; // parameter defined, return map
  -        }
  +    public void setLogger(Logger logger) {
  +        logger.warn("RequestParamMatcher is deprecated. Please use 
RequestParameterMatcher");
       }
   }
  
  
  
  1.2       +8 -42     
xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcher.java
  
  Index: WildcardParameterValueMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WildcardParameterValueMatcher.java        3 Jan 2002 12:31:17 -0000       1.1
  +++ WildcardParameterValueMatcher.java        11 Jan 2002 17:07:06 -0000      1.2
  @@ -7,50 +7,16 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.parameters.Parameters;
  -
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -
  -import java.util.Map;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * Matches a request parameter against a wildcard expression.
  - *
  - * <p><b>Global and local configuration</b></p>
  - * <table border="1">
  - * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to
  - * match against</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Christian Haul</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
  + * @deprecated Renamed to WildcardRequestParameterMatcher
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $
    */
  -
  -public class WildcardParameterValueMatcher extends AbstractWildcardMatcher 
implements Configurable {
  -
  -    private String defaultParam;
  -
  -    public void configure(Configuration config) throws ConfigurationException {
  -        this.defaultParam = config.getChild("parameter-name").getValue(null);
  -    }
  -
  -    protected String getMatchString(Map objectModel, Parameters parameters) {
  -        
  -        String paramName = parameters.getParameter("parameter-name", 
this.defaultParam);
  -        if (paramName == null) {
  -            getLogger().warn("No parameter name given. FAILING");
  -            return null;
  -        }
  -        
  -        String result = 
ObjectModelHelper.getRequest(objectModel).getParameter(paramName);
  -        if (result == null) {
  -            getLogger().debug("Parameter '" + paramName + "' not set.");
  -        }
  -        
  -        return result;
  +public class WildcardParameterValueMatcher extends WildcardRequestParameterMatcher 
implements Initializable {
  +    
  +    public void initialize() {
  +        getLogger().warn("WildcardParameterValueMatcher is deprecated. Please use 
WildcardRequestParameterMatcher");
       }
   }
  
  
  
  1.2       +3 -4      
xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java
  
  Index: WildcardParameterValueMatcherFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WildcardParameterValueMatcherFactory.java 3 Jan 2002 12:31:17 -0000       1.1
  +++ WildcardParameterValueMatcherFactory.java 11 Jan 2002 17:07:06 -0000      1.2
  @@ -10,14 +10,13 @@
   import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $
  - * @deprecated replaced by WildcardParameterValueMatcher - code factories should no 
longer be used
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $
  + * @deprecated replaced by WildcardRequestParameterMatcher - code factories should 
no longer be used
    */
   
   public class WildcardParameterValueMatcherFactory extends 
WildcardParameterValueMatcher implements Initializable {
       
       public void initialize() {
  -        getLogger().warn("WildcardParameterValueMatcherFactory is deprecated. 
Please use WildcardParameterValueMatcher");
  +        getLogger().warn("WildcardParameterValueMatcherFactory is deprecated. 
Please use WildcardRequestParameterMatcher");
       }
  -
   }
  
  
  
  1.1                  
xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpHostMatcher.java
  
  Index: RegexpHostMatcher.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import java.util.Map;
  
  /**
   * Matches the target host ("Host" request header) against a regular expression.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Russell</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/01/11 17:07:05 $
   */
  public class RegexpHostMatcher extends AbstractRegexpMatcher {
  
      protected String getMatchString(Map objectModel, Parameters parameters) {
          return ObjectModelHelper.getRequest(objectModel).getHeader("Host");
      }
  }
  
  
  
  1.1                  
xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParameterMatcher.java
  
  Index: RequestParameterMatcher.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Request;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * This class allows for matching based on a request parameter.
   * If the specified request parameter exists, its value is retrieved for later
   * xpath substitution.
   *
   * <p><b>Example:</b></p>
   * <pre>
   * &lt;map:match type="request" pattern="dest"&gt;
   *     &lt;map:redirect-to uri="{1}"/&gt;
   * &lt;/map:match&gt;
   * </pre>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Marcus Crafter</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
   * @version CVS $Revision: 1.1 $
   */
  public class RequestParameterMatcher implements Matcher, ThreadSafe {
  
      /**
       * Match method to see if the request parameter exists. If it does
       * have a value the parameter is added to the array list for later
       * substitution with a xpath attribute.
       *
       * @param pattern name of request parameter to find
       * @param objectModel environment passed through via cocoon
       * @returns null or map containing value of request parameter 'pattern'
       */
      public Map match(String pattern, Map objectModel, Parameters parameters) {
          Request request = ObjectModelHelper.getRequest(objectModel);
  
          String parameter = request.getParameter(pattern);
          if (parameter == null) {
              return null; // no parameter defined
          } else {
              Map map = new HashMap();
              map.put("1", parameter);
              return map; // parameter defined, return map
          }
      }
  }
  
  
  
  1.1                  
xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java
  
  Index: WildcardRequestParameterMatcher.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.environment.ObjectModelHelper;
  
  import java.util.Map;
  
  /**
   * Matches a request parameter against a wildcard expression.
   *
   * <p><b>Global and local configuration</b></p>
   * <table border="1">
   * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to
   * match against</td></tr>
   * </table>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christian Haul</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/01/11 17:07:06 $
   */
  public class WildcardRequestParameterMatcher extends AbstractWildcardMatcher 
implements Configurable {
  
      private String defaultParam;
  
      public void configure(Configuration config) throws ConfigurationException {
          this.defaultParam = config.getChild("parameter-name").getValue(null);
      }
  
      protected String getMatchString(Map objectModel, Parameters parameters) {
          
          String paramName = parameters.getParameter("parameter-name", 
this.defaultParam);
          if (paramName == null) {
              getLogger().warn("No parameter name given. FAILING");
              return null;
          }
          
          String result = 
ObjectModelHelper.getRequest(objectModel).getParameter(paramName);
          if (result == null) {
              getLogger().debug("Parameter '" + paramName + "' not set.");
          }
          
          return result;
      }
  }
  
  
  
  1.2       +7 -45     
xml-cocoon2/src/java/org/apache/cocoon/selection/RequestSelector.java
  
  Index: RequestSelector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/RequestSelector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestSelector.java      3 Jan 2002 12:31:19 -0000       1.1
  +++ RequestSelector.java      11 Jan 2002 17:07:06 -0000      1.2
  @@ -7,54 +7,16 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.thread.ThreadSafe;
  -
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.environment.Request;
  -
  -import java.util.Map;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * A <code>Selector</code> that matches a string against a configurable request 
parameter's value.
  - *
  - * <p><b>Global and local configuration</b></p>
  - * <table border="1">
  - * <tr><td><code>parameter-name</code></td><td>Name of the request
  - * parameter whose value to match against</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Christian Haul</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $
  + * @deprecated Renamed to RequestParameterSelector
    */
  -public class RequestSelector extends AbstractLoggable
  -  implements Configurable, ThreadSafe, Selector {
  -
  -    protected String defaultName;
  -    
  -    public void configure(Configuration config) throws ConfigurationException {
  -        this.defaultName = config.getChild("parameter-name").getValue(null);
  -    }
  +public class RequestSelector extends RequestParameterSelector implements 
Initializable {
   
  -    public boolean select(String expression, Map objectModel, Parameters 
parameters) {
  -        String name = parameters.getParameter("parameter-name", this.defaultName);
  -        
  -        if (name == null) {
  -            getLogger().warn("No parameter name given -- failing.");
  -            return false;
  -        }
  -        
  -        String value = ObjectModelHelper.getRequest(objectModel).getParameter(name);
  -        if (value == null) {
  -            getLogger().debug("Request parameter '" + name + "' not set -- 
failing.");
  -            return false;
  -        }
  -        
  -        return value.equals(expression);
  +    public void initialize() {
  +        getLogger().warn("RequestSelector is deprecated. Please use 
RequestParameterSelector");
       }
   }
  
  
  
  1.2       +3 -4      
xml-cocoon2/src/java/org/apache/cocoon/selection/RequestSelectorFactory.java
  
  Index: RequestSelectorFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/RequestSelectorFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestSelectorFactory.java       3 Jan 2002 12:31:19 -0000       1.1
  +++ RequestSelectorFactory.java       11 Jan 2002 17:07:06 -0000      1.2
  @@ -10,14 +10,13 @@
   import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $
  - * @deprecated replaced by RequestSelector - code factories should no longer be used
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $
  + * @deprecated Replaced by RequestParameterSelector - code factories should no 
longer be used
    */
   
   public class RequestSelectorFactory extends RequestSelector implements 
Initializable {
   
       public void initialize() {
  -        getLogger().warn("RequestSelectorFactory is deprecated. Please use 
RequestSelector");
  +        getLogger().warn("RequestSelectorFactory is deprecated. Please use 
RequestParameterSelector");
       }
  -
   }
  
  
  
  1.1                  
xml-cocoon2/src/java/org/apache/cocoon/selection/RequestParameterSelector.java
  
  Index: RequestParameterSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.selection;
  
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.AbstractLoggable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Request;
  
  import java.util.Map;
  
  /**
   * A <code>Selector</code> that matches a string against a configurable request 
parameter's value.
   *
   * <p><b>Global and local configuration</b></p>
   * <table border="1">
   * <tr><td><code>parameter-name</code></td><td>Name of the request
   * parameter whose value to match against</td></tr>
   * </table>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christian Haul</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/01/11 17:07:06 $
   */
  public class RequestParameterSelector extends AbstractLoggable
    implements Configurable, ThreadSafe, Selector {
  
      protected String defaultName;
      
      public void configure(Configuration config) throws ConfigurationException {
          this.defaultName = config.getChild("parameter-name").getValue(null);
      }
  
      public boolean select(String expression, Map objectModel, Parameters parameters) 
{
          String name = parameters.getParameter("parameter-name", this.defaultName);
          
          if (name == null) {
              getLogger().warn("No parameter name given -- failing.");
              return false;
          }
          
          String value = ObjectModelHelper.getRequest(objectModel).getParameter(name);
          if (value == null) {
              getLogger().debug("Request parameter '" + name + "' not set -- 
failing.");
              return false;
          }
          
          return value.equals(expression);
      }
  }
  
  
  
  1.9       +12 -4     xml-cocoon2/src/webapp/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/sitemap.xmap,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- sitemap.xmap      11 Jan 2002 14:39:12 -0000      1.8
  +++ sitemap.xmap      11 Jan 2002 17:07:06 -0000      1.9
  @@ -226,8 +226,8 @@
      <map:matcher name="regexp"        logger="sitemap.matcher.regexp"
                   src="org.apache.cocoon.matching.RegexpURIMatcher"/>
   
  -   <map:matcher name="request"       logger="sitemap.matcher.request"
  -                src="org.apache.cocoon.matching.RequestParamMatcher"/>
  +   <map:matcher name="request-parameter" logger="sitemap.matcher.request-parameter"
  +                src="org.apache.cocoon.matching.RequestParameterMatcher"/>
   
      <map:matcher name="sessionstate"  logger="sitemap.matcher.sessionstate"
                   src="org.apache.cocoon.matching.WildcardSessionAttributeMatcher">
  @@ -235,7 +235,7 @@
      </map:matcher>
   
      <map:matcher name="next-page"     logger="sitemap.matcher.next-page"
  -                src="org.apache.cocoon.matching.WildcardParameterValueMatcher">
  +                src="org.apache.cocoon.matching.WildcardRequestParameterMatcher">
         <parameter-name>next-state</parameter-name>
      </map:matcher>
   
  @@ -282,6 +282,14 @@
   
      <map:selector name="parameter" logger="sitemap.selector.parameter"
                    src="org.apache.cocoon.selection.ParameterSelector"/>
  +
  +   <map:selector name="request-parameter" 
logger="sitemap.selector.request-parameter"
  +                 src="org.apache.cocoon.selection.RequestParameterSelector">
  +    <!-- Define now which request parameter to use; or do it later,
  +         when using this selector, via "parameter-name" parameter.
  +    <parameter-name>myparam</parameter-name> 
  +    -->
  +   <map:selector>
     </map:selectors>
   
   <!--
  @@ -1168,7 +1176,7 @@
   
      <!-- ========================= XML:DB ================================ -->
      <map:match pattern="xmldb/**">
  -    <map:match type="request" pattern="xpath">
  +    <map:match type="request-parameter" pattern="xpath">
        <map:generate src="xmldb:dbxml://localhost:4080/{../1}#{1}"/>
        <map:serialize type="xml"/>
       </map:match>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to