vgritsenko 01/07/29 09:23:02
Modified: src/org/apache/cocoon/components/source SitemapSource.java
Log:
Fix bug in cocoon:// protocol processing in sub-sitemaps:
cocoon:// resources where incorrectly resolved relative to subsitemap,
but not root sitemap.
This happend because environment was popped too early.
Revision Changes Path
1.12 +37 -28
xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SitemapSource.java 2001/07/12 10:57:14 1.11
+++ SitemapSource.java 2001/07/29 16:23:02 1.12
@@ -50,7 +50,7 @@
* Description of a source which is defined by a pipeline.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.11 $ $Date: 2001/07/12 10:57:14 $
+ * @version CVS $Revision: 1.12 $ $Date: 2001/07/29 16:23:02 $
*/
public final class SitemapSource
@@ -131,11 +131,11 @@
requestURI = requestURI.substring(0, queryStringPos);
}
Request request=
(Request)env.getObjectModel().get(Constants.REQUEST_OBJECT);
+ boolean isDefaultPort = "http".equalsIgnoreCase(request.getScheme()) && 80
== request.getServerPort();
this.systemId = request.getScheme() + "://" +
request.getServerName() +
- (request.getServerPort() == 80 ? "" : ":" +
request.getServerPort()) +
+ (isDefaultPort ? "" : ":" + request.getServerPort()) +
request.getContextPath() + '/' + requestURI;
-
this.environment = new EnvironmentWrapper(env, requestURI, queryString);
queryStringPos = uri.indexOf('?');
if (queryStringPos != -1) {
@@ -248,31 +248,40 @@
} finally {
this.environment.popURI();
}
- String redirectURL = this.environment.getRedirectURL();
- if (redirectURL == null) {
- if (this.eventPipeline instanceof CacheableEventPipeline) {
- CacheableEventPipeline cep =
(CacheableEventPipeline)this.eventPipeline;
- PipelineCacheKey pck = cep.generateKey(this.environment);
- Map validity = null;
- if (pck != null) {
- validity = cep.generateValidity(this.environment);
- if (validity != null) {
- // the event pipeline is cacheable
- // now calculate a last modification date
- String hashKey = pck.toString() + validity.toString();
- this.lastModificationDate = HashUtil.hash(hashKey);
+ // Do push again as process() resets sourceHandler in environment
+ try {
+ this.environment.pushURI(this.prefix, this.uri);
+
+ String redirectURL = this.environment.getRedirectURL();
+ if (redirectURL == null) {
+ if (this.eventPipeline instanceof CacheableEventPipeline) {
+ CacheableEventPipeline cep =
(CacheableEventPipeline)this.eventPipeline;
+ PipelineCacheKey pck = cep.generateKey(this.environment);
+ Map validity = null;
+ if (pck != null) {
+ validity = cep.generateValidity(this.environment);
+ if (validity != null) {
+ // the event pipeline is cacheable
+ // now calculate a last modification date
+ String hashKey = pck.toString() +
validity.toString();
+ this.lastModificationDate = HashUtil.hash(hashKey);
+ }
}
}
- }
- } else {
- if (redirectURL.indexOf(":") == -1) {
- redirectURL = "cocoon:/" + redirectURL;
+ } else {
+ if (redirectURL.indexOf(":") == -1) {
+ redirectURL = "cocoon:/" + redirectURL;
+ }
+ this.redirectSource = this.environment.resolve(redirectURL);
+ this.lastModificationDate =
this.redirectSource.getLastModified();
}
- this.redirectSource = this.environment.resolve(redirectURL);
- this.lastModificationDate = this.redirectSource.getLastModified();
+ } finally {
+ this.environment.popURI();
}
} catch (Exception e) {
e.printStackTrace();
+ if (this.eventPipeline != null)
this.manager.release(this.eventPipeline);
+ if (this.pipeline != null) this.manager.release(this.pipeline);
this.eventPipeline = null;
this.pipeline = null;
this.redirectSource = null;
@@ -303,12 +312,12 @@
if (this.redirectSource != null) {
this.redirectSource.stream(consumer);
} else {
- try {
- this.environment.pushURI(this.prefix, this.uri);
- ((XMLProducer)eventPipeline).setConsumer(consumer);
- eventPipeline.process(this.environment);
- } finally {
- this.environment.popURI();
+ try {
+ this.environment.pushURI(this.prefix, this.uri);
+ ((XMLProducer)eventPipeline).setConsumer(consumer);
+ eventPipeline.process(this.environment);
+ } finally {
+ this.environment.popURI();
}
}
} catch (ComponentException cme) {
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]