[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-cocoon-dev
Subject:    cvs commit: xml-cocoon2/src/org/apache/cocoon/components/source SitemapSource.java
From:       vgritsenko () apache ! org
Date:       2001-07-29 16:25:01
[Download RAW message or body]

vgritsenko    01/07/29 09:25:01

  Modified:    src/org/apache/cocoon/components/source Tag:
                        cocoon_20_branch 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.
  - Release components when finished
  - 80 is default port only for http
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.11  +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.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- SitemapSource.java	2001/07/12 10:53:07	1.1.2.10
  +++ SitemapSource.java	2001/07/29 16:25:01	1.1.2.11
  @@ -50,7 +50,7 @@
    * Description of a source which is defined by a pipeline.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/07/12 10:53:07 $
  + * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/07/29 16:25:01 $
    */
   
   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:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic