1 16 package org.apache.cocoon.matching; 17 18 import org.apache.avalon.framework.configuration.Configurable; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.parameters.Parameters; 22 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 25 import java.util.Map ; 26 27 39 40 public class RegexpHeaderMatcher extends AbstractRegexpMatcher 41 implements Configurable 42 { 43 private String defaultParam; 44 45 public void configure(Configuration config) throws ConfigurationException { 46 47 this.defaultParam = config.getChild("header-name").getValue(null); 48 } 49 50 protected String getMatchString(Map objectModel, Parameters parameters) { 51 52 String paramName = parameters.getParameter("header-name", this.defaultParam); 53 if (paramName == null) { 54 getLogger().warn("No header name given. FAILING"); 55 return null; 56 } 57 58 String result = ObjectModelHelper.getRequest(objectModel).getHeader(paramName); 59 if (result == null) { 60 if (getLogger().isDebugEnabled()) { 61 getLogger().debug("Header '" + paramName + "' not set."); 62 } 63 } 64 65 return result; 66 } 67 } 68 | Popular Tags |