You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/03/11 15:48:30 UTC
cvs commit: cocoon-2.2/src/java/org/apache/cocoon/components/pipeline AbstractProcessingPipeline.java
cziegeler 2004/03/11 06:48:30
Modified: src/java/org/apache/cocoon/components/cprocessor/variables
VariableResolver.java
src/java/org/apache/cocoon Constants.java
src/java/org/apache/cocoon/environment/wrapper
EnvironmentWrapper.java RequestParameters.java
RequestWrapper.java
src/java/org/apache/cocoon/matching
AbstractRegexpMatcher.java
AbstractWildcardMatcher.java
src/java/org/apache/cocoon/components/cprocessor
TreeProcessor.java AbstractProcessingNode.java
src/java/org/apache/cocoon/components/pipeline
AbstractProcessingPipeline.java
Added: src/java/org/apache/cocoon/sitemap SitemapParameters.java
Log:
Changing internal redirect to a forward
Add new sitemap parameter handling
Revision Changes Path
1.3 +14 -4 cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/variables/VariableResolver.java
Index: VariableResolver.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/variables/VariableResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- VariableResolver.java 8 Mar 2004 13:57:37 -0000 1.2
+++ VariableResolver.java 11 Mar 2004 14:48:29 -0000 1.3
@@ -15,9 +15,11 @@
*/
package org.apache.cocoon.components.cprocessor.variables;
+import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.components.cprocessor.InvokeContext;
import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.sitemap.SitemapParameters;
import java.util.Collections;
import java.util.HashMap;
@@ -88,8 +90,10 @@
return Parameters.EMPTY_PARAMETERS;
}
- Parameters result = new Parameters();
-
+ SitemapParameters result = new SitemapParameters();
+ if ( expressions instanceof SitemapParameters.ExtendedHashMap ) {
+ result.setStatementLocation(((SitemapParameters.ExtendedHashMap)expressions).getLocation());
+ }
Iterator iter = expressions.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
@@ -114,7 +118,13 @@
return EMPTY_MAP;
}
- Map result = new HashMap(size);
+ Map result;
+ if ( expressions instanceof SitemapParameters.ExtendedHashMap ) {
+ Configuration config = ((SitemapParameters.ExtendedHashMap)expressions).getConfiguration();
+ result = new SitemapParameters.ExtendedHashMap(config, size );
+ } else {
+ result = new HashMap(size);
+ }
Iterator iter = expressions.entrySet().iterator();
while (iter.hasNext()) {
1.14 +4 -19 cocoon-2.2/src/java/org/apache/cocoon/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Constants.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Constants.java 8 Mar 2004 13:57:35 -0000 1.13
+++ Constants.java 11 Mar 2004 14:48:29 -0000 1.14
@@ -262,6 +262,9 @@
*/
public static final String CONTEXT_CONFIG_URL = "config-url";
+ /** Application <code>Context</code> Key for the default encoding */
+ public static final String CONTEXT_DEFAULT_ENCODING = "default-encoding";
+
/** Application root directory @since 2.2 */
public static final String CONTEXT_ROOT_URL = "root-url";
@@ -272,23 +275,5 @@
*/
public static final boolean DESCRIPTOR_RELOADABLE_DEFAULT = true;
- /**
- * The special parameter passed to each sitemap component (matchers, generators, etc) that
- * contains the location of the sitemap statement where this component is used.
- */
- public static final String SITEMAP_PARAMETERS_LOCATION = "org.apache.cocoon.sitemap/Location";
}
-
-
-
-
-
-
-
-
-
-
-
-
-
1.1 cocoon-2.2/src/java/org/apache/cocoon/sitemap/SitemapParameters.java
Index: SitemapParameters.java
===================================================================
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.sitemap;
import java.util.HashMap;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.parameters.Parameters;
/**
* Extension to the Avalon Parameters
*
* @version CVS $Id: SitemapParameters.java,v 1.1 2004/03/11 14:48:29 cziegeler Exp $
*/
public class SitemapParameters extends Parameters {
protected String statementLocation;
/**
public String getParameterLocation(String name) {
return null;
}
*/
public String getStatementLocation() {
return this.statementLocation;
}
public void setStatementLocation(String value) {
this.statementLocation = value;
}
/**
* Return the location - if available
*/
public static String getStatementLocation(Parameters param) {
String value = null;
if ( param instanceof SitemapParameters ) {
value = ((SitemapParameters)param).getStatementLocation();
}
if ( value == null ) {
value = "[unknown location]";
}
return value;
}
public static class ExtendedHashMap extends HashMap {
protected Configuration configuration;
public ExtendedHashMap(Configuration conf) {
super();
this.configuration = conf;
}
public ExtendedHashMap(Configuration conf, int capacity) {
super(capacity);
this.configuration = conf;
}
public String getLocation() {
if ( this.configuration != null ) {
return this.configuration.getLocation();
}
return null;
}
public Configuration getConfiguration() {
return this.configuration;
}
}
}
1.19 +14 -5 cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
Index: EnvironmentWrapper.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- EnvironmentWrapper.java 8 Mar 2004 14:02:46 -0000 1.18
+++ EnvironmentWrapper.java 11 Mar 2004 14:48:29 -0000 1.19
@@ -59,7 +59,11 @@
/** The stream to output to */
protected OutputStream outputStream;
+
+ protected String contentType;
+ protected boolean external = false;
+
/**
* Constructs an EnvironmentWrapper object from a Request
* and Response objects
@@ -228,15 +232,14 @@
* Set the ContentType
*/
public void setContentType(String contentType) {
- // ignore this
+ this.contentType = contentType;
}
/**
* Get the ContentType
*/
public String getContentType() {
- // ignore this
- return null;
+ return this.contentType;
}
/**
@@ -278,7 +281,13 @@
* Always return <code>false</code>.
*/
public boolean isExternal() {
- return false;
+ return this.external;
}
+ public void setExternal(boolean flag) {
+ this.external = flag;
+ if ( flag ) {
+ ((RequestWrapper)this.request).setRequestURI(this.prefix, this.uri);
+ }
+ }
}
1.5 +7 -2 cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/RequestParameters.java
Index: RequestParameters.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/RequestParameters.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RequestParameters.java 8 Mar 2004 14:02:47 -0000 1.4
+++ RequestParameters.java 11 Mar 2004 14:48:29 -0000 1.5
@@ -16,7 +16,12 @@
package org.apache.cocoon.environment.wrapper;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
/**
* This class is used by the <code>RequestWrapper</code>. It parses
1.6 +22 -5 cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
Index: RequestWrapper.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RequestWrapper.java 8 Mar 2004 14:02:47 -0000 1.5
+++ RequestWrapper.java 11 Mar 2004 14:48:29 -0000 1.6
@@ -15,14 +15,19 @@
*/
package org.apache.cocoon.environment.wrapper;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
-import java.security.Principal;
-import java.util.*;
-
/**
* This is a wrapper class for the <code>Request</code> object.
@@ -49,6 +54,9 @@
/** raw mode? **/
private final boolean rawMode;
+ /** The request uri */
+ private String requestURI;
+
/**
* Constructor
*/
@@ -78,6 +86,7 @@
else
this.queryString += '&' + this.req.getQueryString();
}
+ this.requestURI = this.req.getRequestURI();
}
public Object get(String name) {
@@ -262,7 +271,7 @@
}
public String getRequestURI() {
- return this.req.getRequestURI();
+ return this.requestURI;
}
public String getSitemapURI() {
@@ -308,4 +317,12 @@
public String getAuthType() {
return this.req.getAuthType();
}
+
+ public void setRequestURI(String prefix, String uri) {
+ StringBuffer buffer = new StringBuffer(this.getContextPath());
+ buffer.append('/');
+ buffer.append(prefix);
+ buffer.append(uri);
+ this.requestURI = buffer.toString();
+ }
}
1.6 +3 -4 cocoon-2.2/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java
Index: AbstractRegexpMatcher.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractRegexpMatcher.java 8 Mar 2004 14:02:41 -0000 1.5
+++ AbstractRegexpMatcher.java 11 Mar 2004 14:48:30 -0000 1.6
@@ -19,8 +19,8 @@
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.Constants;
import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.sitemap.SitemapParameters;
import org.apache.regexp.RE;
import org.apache.regexp.RECompiler;
import org.apache.regexp.REProgram;
@@ -73,8 +73,7 @@
public Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters) throws PatternException {
if(preparedPattern == null) {
- throw new PatternException("A pattern is needed at " +
- parameters.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "unknown location"));
+ throw new PatternException("A pattern is needed at " + SitemapParameters.getStatementLocation(parameters));
}
RE re = new RE((REProgram)preparedPattern);
1.6 +3 -3 cocoon-2.2/src/java/org/apache/cocoon/matching/AbstractWildcardMatcher.java
Index: AbstractWildcardMatcher.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/matching/AbstractWildcardMatcher.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractWildcardMatcher.java 8 Mar 2004 14:02:41 -0000 1.5
+++ AbstractWildcardMatcher.java 11 Mar 2004 14:48:30 -0000 1.6
@@ -19,9 +19,9 @@
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.Constants;
import org.apache.cocoon.matching.helpers.WildcardHelper;
import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.sitemap.SitemapParameters;
/**
* Base class for wildcard matchers
@@ -47,7 +47,7 @@
if(preparedPattern == null) {
throw new PatternException("A pattern is needed at " +
- parameters.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "unknown location"));
+ SitemapParameters.getStatementLocation(parameters));
}
String match = getMatchString(objectModel, parameters);
1.22 +1 -0 cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java
Index: TreeProcessor.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TreeProcessor.java 8 Mar 2004 13:57:39 -0000 1.21
+++ TreeProcessor.java 11 Mar 2004 14:48:30 -0000 1.22
@@ -391,6 +391,7 @@
}
Environment newEnv = new ForwardEnvironmentWrapper(environment, m_manager, uri, getLogger());
+ ((ForwardEnvironmentWrapper)newEnv).setExternal(true);
if (facade != null) {
// Change the facade delegate
1.6 +5 -3 cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/AbstractProcessingNode.java
Index: AbstractProcessingNode.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/AbstractProcessingNode.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractProcessingNode.java 8 Mar 2004 13:57:39 -0000 1.5
+++ AbstractProcessingNode.java 11 Mar 2004 14:48:30 -0000 1.6
@@ -15,7 +15,6 @@
*/
package org.apache.cocoon.components.cprocessor;
-import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configurable;
@@ -23,6 +22,7 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.components.cprocessor.variables.VariableResolverFactory;
import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.sitemap.SitemapParameters;
/**
*
@@ -68,9 +68,11 @@
private final void setParameters(Configuration config) throws ConfigurationException {
final Configuration[] children = config.getChildren(PARAMETER_ELEMENT);
if (children.length == 0) {
+ // TODO Optimize this
+ m_parameters = new SitemapParameters.ExtendedHashMap(config);
return;
}
- m_parameters = new HashMap();
+ m_parameters = new SitemapParameters.ExtendedHashMap(config, children.length+1);
for (int i = 0; i < children.length; i++) {
Configuration child = children[i];
String name = child.getAttribute(PARAMETER_NAME_ATTR);
1.35 +11 -4 cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- AbstractProcessingPipeline.java 8 Mar 2004 14:01:57 -0000 1.34
+++ AbstractProcessingPipeline.java 11 Mar 2004 14:48:30 -0000 1.35
@@ -32,7 +32,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.ConnectionResetException;
-import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Processor;
import org.apache.cocoon.environment.Environment;
@@ -43,6 +42,7 @@
import org.apache.cocoon.reading.Reader;
import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.sitemap.SitemapModelComponent;
+import org.apache.cocoon.sitemap.SitemapParameters;
import org.apache.cocoon.transformation.Transformer;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
@@ -728,8 +728,15 @@
public String getKeyForEventPipeline() {
return null;
}
-
+
protected String getLocation(Parameters param) {
- return param.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "[unknown location]");
+ String value = null;
+ if ( param instanceof SitemapParameters ) {
+ value = ((SitemapParameters)param).getStatementLocation();
+ }
+ if ( value == null ) {
+ value = "[unknown location]";
+ }
+ return value;
}
}