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/org/apache/cocoon/matching WildcardHeaderMatcherFactory.java
Date Tue, 18 Sep 2001 14:56:41 GMT
haul        01/09/18 07:56:41

  Modified:    src/org/apache/cocoon/matching Tag: cocoon_20_branch
                        WildcardHeaderMatcherFactory.java
  Log:
  - changed *SessionState(Matcher|Selector)* to more general *SessionAttribute(Matcher|Selector)*
    updated docs + samples accordingly
  - make some SourceFactories fail in a friendlier way when parameters are missing
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +41 -13    xml-cocoon2/src/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java
  
  Index: WildcardHeaderMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- WildcardHeaderMatcherFactory.java	2001/08/20 14:07:32	1.1.2.3
  +++ WildcardHeaderMatcherFactory.java	2001/09/18 14:56:40	1.1.2.4
  @@ -22,7 +22,7 @@
    * </table>
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/08/20 14:07:32 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/09/18 14:56:40 $
    */
   
   public class WildcardHeaderMatcherFactory extends WildcardURIMatcherFactory {
  @@ -48,18 +48,46 @@
               }
           }
   
  -    return "HashMap map = new HashMap(1);" +
  -	    "String theParameter = null;" +
  -	    "if (parameters == null) {"+
  -	    "  theParameter = XSPRequestHelper.getHeader(objectModel, \""+parameterName+"\");"
+
  -	    " } else { " +
  -	    "  theParameter = XSPRequestHelper.getHeader(objectModel, parameters.getParameter(\"parameter-name\",
\""+parameterName+"\"));" +
  -	    " }; " +
  -	    "if (theParameter != null && org.apache.cocoon.matching.helpers.WildcardURIMatcher.match
(map, theParameter, pattern)) {" +
  -	    "map.put(\""+parameterName+"\", theParameter);"+
  -	    "return map;" +
  -	    "} else {" +
  -	    "return null;}";
  +        StringBuffer sb = new StringBuffer();
  +	sb
  +	    .append("HashMap map = new HashMap(1);")
  +	    .append("String parameterName = null;")
  +	    .append("String parameterValue = null;")
  +	    .append("if (parameters.getNames().length == 0) {");
  +	if ( parameterName == null ) {
  +	    sb
  +		.append("   getLogger().warn(\"No request header name and no default name given. FAILING\");")
  +		.append("} else { ")
  +		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request header name and no default name given. FAILING\");")
  +		.append("  } else {")
  +		.append("     parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName);
")
  +		.append("  }");
  +	} else {
  +	    sb
  +		.append("  parameterName = \""+parameterName+"\";")
  +		.append("  parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName);")
  +		.append("} else { ")
  +		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request header name given, will use default\");")
  +		.append("     parameterName = \""+parameterName+"\";")
  +		.append("  }")
  +		.append("  parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName); ");
  +	}
  +	sb
  +	    .append("}")
  +	    .append("if ( parameterValue == null ) {")
  +	    .append("   getLogger().debug(\"Request header not set\");")
  +	    .append("} else {")
  +	    .append("   if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map,
parameterValue, pattern)) {")
  +	    .append("      map.put(parameterName, parameterValue ); ")   
  +	    .append("      return map;")
  +	    .append("   }")
  +	    .append("}")
  +	    .append("return null;");
  +        return sb.toString();
       }
   
   }
  
  
  

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