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 2003/10/30 12:30:12 UTC
cvs commit: cocoon-2.2/src/java/org/apache/cocoon/environment EnvironmentHelper.java
cziegeler 2003/10/30 03:30:12
Modified: src/java/org/apache/cocoon/components/treeprocessor
TreeProcessor.java
src/java/org/apache/cocoon/components/treeprocessor/sitemap
MountNode.java
src/java/org/apache/cocoon/environment
EnvironmentHelper.java
Log:
Change environment context when entering a sub sitemap
Revision Changes Path
1.21 +7 -4 cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
Index: TreeProcessor.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TreeProcessor.java 29 Oct 2003 18:58:06 -0000 1.20
+++ TreeProcessor.java 30 Oct 2003 11:30:12 -0000 1.21
@@ -59,8 +59,6 @@
import org.apache.avalon.excalibur.component.RoleManageable;
import org.apache.avalon.excalibur.component.RoleManager;
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.Recomposable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -78,7 +76,6 @@
import org.apache.cocoon.Constants;
import org.apache.cocoon.Processor;
import org.apache.cocoon.components.ChainedConfiguration;
-import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.components.ExtendedComponentSelector;
import org.apache.cocoon.components.LifecycleHelper;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
@@ -614,4 +611,10 @@
return this.environmentHelper;
}
+ /**
+ * Return the environment helper
+ */
+ public EnvironmentHelper getEnvironmentHelper() {
+ return this.environmentHelper;
+ }
}
1.9 +3 -4 cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
Index: MountNode.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MountNode.java 20 Oct 2003 08:15:27 -0000 1.8
+++ MountNode.java 30 Oct 2003 11:30:12 -0000 1.9
@@ -114,9 +114,8 @@
String oldPrefix = env.getURIPrefix();
String oldURI = env.getURI();
- String oldContext = env.getContext();
try {
- env.changeContext(resolvedPrefix, resolvedSource);
+ processor.getEnvironmentHelper().changeContext(env);
if (context.isBuildingPipelineOnly()) {
// Propagate pipelines
@@ -133,7 +132,7 @@
}
} finally {
// Restore context
- env.setContext(oldPrefix, oldURI, oldContext);
+ env.setURI(oldPrefix, oldURI);
// Recompose pipelines which may have been recomposed by subsitemap
context.recompose(this.manager);
1.7 +14 -11 cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java
Index: EnvironmentHelper.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EnvironmentHelper.java 29 Oct 2003 18:58:06 -0000 1.6
+++ EnvironmentHelper.java 30 Oct 2003 11:30:12 -0000 1.7
@@ -87,7 +87,7 @@
/** The service manager */
protected ServiceManager manager;
- /** The current prefix to strip off from the request uri */
+ /** The complete prefix */
protected String prefix;
/** The Context path */
@@ -96,8 +96,11 @@
/** The root context path */
protected String rootContext;
+ /** The last prefix, which is stripped off from the request uri */
+ protected String lastPrefix;
+
/** The environment information */
- private static InheritableThreadLocal environmentStack = new CloningInheritableThreadLocal();
+ protected static InheritableThreadLocal environmentStack = new CloningInheritableThreadLocal();
/**
* Constructor
@@ -188,19 +191,17 @@
public void changeContext(Environment env)
throws ProcessingException {
- if ( this.prefix != null ) {
- String uris = env.getURIPrefix() + '/' + env.getURI();
- if (!uris.startsWith(this.prefix)) {
+ if ( this.lastPrefix != null ) {
+ String uris = env.getURI();
+ if (!uris.startsWith(this.lastPrefix)) {
String message = "The current URI (" + uris +
- ") doesn't start with given prefix (" + prefix + ")";
- getLogger().error(message);
+ ") doesn't start with given prefix (" + this.lastPrefix + ")";
throw new ProcessingException(message);
}
// we don't need to check for slash at the beginning
// of uris - the prefix always ends with a slash!
- final int l = this.prefix.length();
- uris = uris.substring(l);
- env.setURI(this.prefix, uris);
+ final int l = this.lastPrefix.length();
+ env.setURI(this.prefix, uris.substring(l));
}
}
@@ -216,6 +217,7 @@
}
int l = newPrefix.length();
if (l >= 1) {
+ this.lastPrefix = newPrefix;
if ( this.prefix == null ) {
this.prefix = "";
}
@@ -224,6 +226,7 @@
// check for a slash at the beginning to avoid problems with subsitemaps
if ( buffer.charAt(buffer.length()-1) != '/') {
buffer.append('/');
+ this.lastPrefix = this.lastPrefix + '/';
}
this.prefix = buffer.toString();
}