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/selection HeaderSelectorFactory.java
Date Tue, 18 Sep 2001 14:58:40 GMT
haul        01/09/18 07:58:40

  Modified:    src/org/apache/cocoon/selection Tag: cocoon_20_branch
                        HeaderSelectorFactory.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   +31 -8     xml-cocoon2/src/org/apache/cocoon/selection/HeaderSelectorFactory.java
  
  Index: HeaderSelectorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/HeaderSelectorFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- HeaderSelectorFactory.java	2001/08/20 14:07:32	1.1.2.3
  +++ HeaderSelectorFactory.java	2001/09/18 14:58: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:58:40 $
    */
   public class HeaderSelectorFactory extends ParameterSelectorFactory {
   
  @@ -45,13 +45,36 @@
           }
   
           StringBuffer sb = new StringBuffer();
  -	sb.append("String compareToString = null;")
  -	  .append("if (param == null) {")
  -          .append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel,
\""+parameterName+"\");")
  -          .append("} else { ")
  -          .append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel,
param.getParameter(\"state-key\",\""+parameterName+"\"));")
  -	  .append("}")
  -	  .append("return compareToString != null && compareToString.equals (pattern);");
  +	sb
  +	    .append("String compareToString = null;")
  +	    .append("if (param.getNames().length == 0) {");
  +	if ( parameterName == null ) {
  +	    sb
  +		.append("   getLogger().warn(\"No request header name and no default name given. FAILING\");")
  +		.append("} else { ")
  +		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request header name and no default name given. FAILING\");")
  +		.append("  } else {")
  +		.append("     compareToString = (String) XSPRequestHelper.getHeader(objectModel, parameterName);")
  +		.append("  }");
  +	} else {
  +	    sb
  +		.append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel, \""+parameterName+"\");")
  +		.append("} else { ")
  +		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request header name given, will use default\");")
  +		.append("     parameterName = \""+parameterName+"\";")
  +		.append("  }")
  +		.append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel, parameterName);");
  +	}
  +	sb
  +	    .append("}")
  +	    .append("if ( compareToString == null ) {")
  +	    .append("   getLogger().debug(\"request header not set\");")
  +	    .append("}")
  +	    .append("return compareToString != null && compareToString.equals (pattern);");
           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