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 2001/07/04 15:59:40 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/environment AbstractEnvironment.java Environment.java

cziegeler    01/07/04 06:59:40

  Modified:    src/org/apache/cocoon/components/source Tag:
                        cocoon_20_branch SitemapSource.java
               src/org/apache/cocoon/environment Tag: cocoon_20_branch
                        AbstractEnvironment.java Environment.java
  Log:
  - fixed uri-prefix handling (leading / was not removed)
  - systemId for cocoon: urls is now build by using the http request
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +7 -8      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.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SitemapSource.java	2001/07/04 09:19:32	1.1.2.2
  +++ SitemapSource.java	2001/07/04 13:59:34	1.1.2.3
  @@ -21,12 +21,14 @@
   import java.net.URLConnection;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Roles;
   import org.apache.cocoon.components.parser.Parser;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.sitemap.Sitemap;
  @@ -40,7 +42,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.2 $ $Date: 2001/07/04 09:19:32 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/07/04 13:59:34 $
    */
   
   public final class SitemapSource
  @@ -86,20 +88,17 @@
           if (uri.startsWith("//") == true) {
               uri = uri.substring(2);
               // FIXME (CZ) The root sitemap is not available
  +            // so resolve it to the current sitemap
           } else if (uri.startsWith("/") == true) {
               uri = uri.substring(1);
           }
   
  -        // FIXME (CZ) We should change the systemId from cocoon:
  -        // to http://server/context/...
  -/*        Request request= (Request)env.getObjectModel().get(Constants.REQUEST_OBJECT);
  +        Request request= (Request)env.getObjectModel().get(Constants.REQUEST_OBJECT);
           this.systemId = request.getScheme() + "://" +
  -                        request.getServerName() + ":" +
  -                        request.getServerPort() +
  -                        request.getContextPath() + '/' + uri;
  -*/
  +                        request.getServerName() +
  +                        (request.getServerPort() == 80 ? "" : ":" + request.getServerPort()) +
  +                        request.getContextPath() + '/' + env.getURIPrefix() + uri;
           this.uri = uri;
  -        this.systemId = uri;
           this.contentLength = -1;
           this.lastModificationDate = 0;
           this.manager = manager;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.3   +13 -0     xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java,v
  retrieving revision 1.6.2.2
  retrieving revision 1.6.2.3
  diff -u -r1.6.2.2 -r1.6.2.3
  --- AbstractEnvironment.java	2001/07/04 07:26:42	1.6.2.2
  +++ AbstractEnvironment.java	2001/07/04 13:59:36	1.6.2.3
  @@ -104,6 +104,13 @@
       }
   
       /**
  +     * Get the prefix of the URI in progress
  +     */
  +    public String getURIPrefix() {
  +        return this.prefix.toString();
  +    }
  +
  +    /**
        * Adds an prefix to the overall stripped off prefix from the request uri
        */
       public void changeContext(String prefix, String context)
  @@ -116,6 +123,12 @@
               if (uri.startsWith(prefix)) {
                   this.prefix.append(prefix);
                   uri = uri.substring(prefix.length());
  +
  +                // check for a slash at the beginning to avoid problems with subsitemaps
  +                if (uri.startsWith("/") == true) {
  +                    uri = uri.substring(1);
  +                    this.prefix.append('/');
  +                }
   
                   //if the resource is zipped into a war file (e.g. Weblogic temp deployment)
                   if (this.context.getProtocol().equals("zip")) {
  
  
  
  1.2.2.2   +6 -1      xml-cocoon2/src/org/apache/cocoon/environment/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Environment.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- Environment.java	2001/07/04 07:26:43	1.2.2.1
  +++ Environment.java	2001/07/04 13:59:37	1.2.2.2
  @@ -19,7 +19,7 @@
    * Base interface for an environment abstraction
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.2.2.1 $ $Date: 2001/07/04 07:26:43 $
  + * @version CVS $Revision: 1.2.2.2 $ $Date: 2001/07/04 13:59:37 $
    */
   
   public interface Environment extends SourceResolver {
  @@ -30,9 +30,14 @@
       void setSourceHandler(SourceHandler sourceHandler);
   
       /**
  -     * Get the URI to process
  +     * Get the URI to process. The prefix is stripped off.
        */
       String getURI();
  +
  +    /**
  +     * Get the prefix of the URI in progress.
  +     */
  +    String getURIPrefix();
   
       /**
        * Get the view to process
  
  
  

----------------------------------------------------------------------
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