cziegeler 2003/10/30 23:22:36
Modified: src/java/org/apache/cocoon/components/source/impl
SitemapSource.java
src/java/org/apache/cocoon/environment/wrapper
EnvironmentWrapper.java
MutableEnvironmentFacade.java
src/java/org/apache/cocoon/environment
EnvironmentHelper.java
Log:
Updating environment handling
Revision Changes Path
1.17 +3 -3
cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SitemapSource.java 29 Oct 2003 18:58:05 -0000 1.16
+++ SitemapSource.java 31 Oct 2003 07:22:35 -0000 1.17
@@ -380,8 +380,8 @@
try {
this.processKey =
EnvironmentHelper.startProcessing(this.environment);
this.processingPipeline =
this.processor.buildPipeline(this.environment);
- this.pipelineProcessor =
EnvironmentHelper.getLastProcessor(this.environment);
- this.environment.changeToLastContext();
+ this.pipelineProcessor =
EnvironmentHelper.getLastProcessor(this.environment);
+
this.pipelineProcessor.getEnvironmentHelper().setContext(this.environment);
String redirectURL = this.environment.getRedirectURL();
if (redirectURL == null) {
1.15 +1 -25
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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- EnvironmentWrapper.java 30 Oct 2003 12:31:05 -0000 1.14
+++ EnvironmentWrapper.java 31 Oct 2003 07:22:35 -0000 1.15
@@ -92,12 +92,6 @@
/** The request object */
protected Request request;
- /** The last uri */
- protected String lastURI;
-
- /** The last prefix */
- protected String lastPrefix;
-
/** The stream to output to */
protected OutputStream outputStream;
@@ -381,15 +375,6 @@
}
/**
- * Change the current context to the last one set by changeContext()
- * and return last processor
- */
- public void changeToLastContext() {
- this.uris = this.lastURI;
- this.prefix = this.lastPrefix;
- }
-
- /**
* Lookup an attribute in this instance, and if not found search it
* in the wrapped environment.
*
@@ -422,15 +407,6 @@
*/
public boolean isExternal() {
return false;
- }
-
- /* (non-Javadoc)
- * @see
org.apache.cocoon.environment.Environment#setURI(java.lang.String)
- */
- public void setURI(String prefix, String value) {
- super.setURI(prefix, value);
- this.lastURI = this.uris;
- this.lastPrefix = this.prefix;
}
}
1.9 +5 -22
cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
Index: MutableEnvironmentFacade.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MutableEnvironmentFacade.java 30 Oct 2003 12:56:48 -0000 1.8
+++ MutableEnvironmentFacade.java 31 Oct 2003 07:22:35 -0000 1.9
@@ -75,10 +75,6 @@
private EnvironmentWrapper env;
- // Track the first values set for prefix and uri
- private String prefix;
- private String uri;
-
public MutableEnvironmentFacade(EnvironmentWrapper env) {
this.env = env;
}
@@ -91,36 +87,19 @@
this.env = env;
}
- //----------------------------------
- // EnvironmentWrapper-specific method (SW:still have to understand why
SitemapSource needs them)
public void setURI(String prefix, String uri) {
this.env.setURI(prefix, uri);
-
- // keep the values to restore them on the wrapped
- // enviromnent in reset()
- this.prefix = prefix;
- this.uri = uri;
}
public void setOutputStream(OutputStream os) {
this.env.setOutputStream(os);
}
- public void changeToLastContext() {
- this.env.changeToLastContext();
- }
-
// Move this to the Environment interface ?
public String getRedirectURL() {
return this.env.getRedirectURL();
}
- public void reset() {
- this.env.reset();
- this.env.setURI(this.uri, this.prefix);
- }
- //----------------------------------
-
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Environment#getURI()
*/
@@ -275,5 +254,9 @@
*/
public boolean isExternal() {
return env.isExternal();
+ }
+
+ public void reset() {
+ this.env.reset();
}
}
1.11 +17 -1
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- EnvironmentHelper.java 30 Oct 2003 12:38:26 -0000 1.10
+++ EnvironmentHelper.java 31 Oct 2003 07:22:36 -0000 1.11
@@ -212,6 +212,22 @@
}
}
+ public void setContext(Environment env)
+ throws ProcessingException {
+ if ( this.prefix != null ) {
+ String uris = env.getURI();
+ if (!uris.startsWith(this.prefix)) {
+ String message = "The current URI (" + uris +
+ ") doesn't start with given prefix (" +
this.prefix + ")";
+ 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();
+ env.setURI(this.prefix, uris.substring(l));
+ }
+ }
+
/**
* Adds an prefix to the overall stripped off prefix from the request uri
*/