cziegeler    01/07/10 00:44:34

  Modified:    .        changes.xml todo.xml
               src/org/apache/cocoon/components/source SitemapSource.java
               src/org/apache/cocoon/environment AbstractEnvironment.java
                        Environment.java
  Log:
  Finished the cocoon:// protocol
  
  Revision  Changes    Path
  1.18      +3 -2      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- changes.xml       2001/07/09 08:54:40     1.17
  +++ changes.xml       2001/07/10 07:44:20     1.18
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.17 2001/07/09 08:54:40 cziegeler Exp $
  +  $Id: changes.xml,v 1.18 2001/07/10 07:44:20 cziegeler Exp $
   -->
   
   <changes title="History of Changes">
  @@ -38,7 +38,8 @@
       and source factory components.
     </action>
     <action dev="CZ" type="add">
  -    Added the cocoon: protocol to access pipelines.
  +    Added the cocoon: protocol to access pipelines. cocoon:/ resolves
  +    to the current sitemap and cocoon:// to the root sitemap.
     </action>
     <action dev="VG" type="fix">
       Offline site generation now allows recursive links and
  
  
  
  1.4       +1 -5      xml-cocoon2/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/todo.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- todo.xml  2001/07/09 08:54:42     1.3
  +++ todo.xml  2001/07/10 07:44:22     1.4
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: todo.xml,v 1.3 2001/07/09 08:54:42 cziegeler Exp $
  +  $Id: todo.xml,v 1.4 2001/07/10 07:44:22 cziegeler Exp $
   -->
   
   
  @@ -34,10 +34,6 @@
      the servlet. A reloading of the Cocoon is not sufficient. This is not
      very convenient. Suggestion: When Cocoon is reloaded (a new cocoon instance
      is created then) the classpath is rebuild and used.
  -  </action>
  -
  -  <action context="code" assigned-to="open">
  -   Make the cocoon:/ protocol work which should resolve to the root sitemap.
     </action>
   
     <action context="code" assigned-to="open">
  
  
  
  1.8       +10 -7     
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SitemapSource.java        2001/07/09 13:20:00     1.7
  +++ SitemapSource.java        2001/07/10 07:44:26     1.8
  @@ -43,7 +43,7 @@
    * Description of a source which is defined by a pipeline.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/07/09 13:20:00 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/07/10 07:44:26 $
    */
   
   public final class SitemapSource
  @@ -70,6 +70,9 @@
       /** The environment */
       private Environment environment;
   
  +    /** The prefix for the processing */
  +    private String prefix;
  +
       /**
        * Construct a new object
        */
  @@ -91,16 +94,16 @@
           // does the uri point to this sitemap or to the root sitemap?
           if (uri.startsWith("//") == true) {
               uri = uri.substring(2);
  -            // FIXME (CZ) The root sitemap is not available
  -            // so resolve it to the current sitemap
               Processor processor = null;
               try {
                   processor = (Processor)this.manager.lookup(Processor.ROLE);
               } catch (ComponentException e) {
                   throw new ProcessingException("Cannot get Processor instance", e);
               }
  +            this.prefix = ""; // start at the root
               this.processor = processor;
           } else if (uri.startsWith("/") == true) {
  +            this.prefix = null;
               uri = uri.substring(1);
               this.processor = sitemap;
           }
  @@ -152,13 +155,13 @@
               pipeline.setEventPipeline(eventPipeline);
   
               try {
  -                this.environment.pushURI(this.uri);
  +                this.environment.pushURI(this.prefix, this.uri);
                   this.processor.process(this.environment, pipeline, eventPipeline);
               } finally {
                   this.environment.popURI();
               }
               try {
  -                this.environment.pushURI(this.uri);
  +                this.environment.pushURI(this.prefix, this.uri);
                   ((XMLProducer)eventPipeline).setConsumer(serializer);
                   eventPipeline.process(this.environment);
               } finally {
  @@ -236,13 +239,13 @@
               pipeline.setEventPipeline(eventPipeline);
   
               try {
  -                this.environment.pushURI(this.uri);
  +                this.environment.pushURI(this.prefix, this.uri);
                   this.processor.process(this.environment, pipeline, eventPipeline);
               } finally {
                   this.environment.popURI();
               }
               try {
  -                this.environment.pushURI(this.uri);
  +                this.environment.pushURI(this.prefix, this.uri);
                   ((XMLProducer)eventPipeline).setConsumer(consumer);
                   eventPipeline.process(this.environment);
               } finally {
  
  
  
  1.10      +42 -10    
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractEnvironment.java  2001/07/04 14:00:49     1.9
  +++ AbstractEnvironment.java  2001/07/10 07:44:30     1.10
  @@ -20,6 +20,13 @@
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  +/**
  + * Base class for any environment
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  + * @version CVS $Revision: 1.10 $ $Date: 2001/07/10 07:44:30 $
  + */
   public abstract class AbstractEnvironment extends AbstractLoggable implements 
Environment {
   
       /** The current uri in progress */
  @@ -37,6 +44,9 @@
        /** The Context path */
       protected URL context = null;
   
  +    /** The root context path */
  +    protected URL rootContext = null;
  +
       /** The servlet object model */
       protected HashMap objectModel = null;
   
  @@ -80,11 +90,12 @@
        */
       public AbstractEnvironment(String uri, String view, URL context, String action)
       throws MalformedURLException {
  -        this.pushURI(uri);
  +        this.pushURI(null, uri);
           this.view = view;
           this.context = context;
           this.action = action;
           this.objectModel = new HashMap();
  +        this.rootContext = context;
       }
   
       /**
  @@ -208,23 +219,39 @@
        */
       public Source resolve(String systemId)
       throws ProcessingException, SAXException, IOException {
  +        this.getLogger().debug("Resolving '"+systemId+"'");
           if (systemId == null) throw new SAXException("Invalid System ID");
   
  -        if (systemId.length() == 0)
  -            return this.sourceHandler.getSource(this, 
this.context.toExternalForm());
  -        if (systemId.indexOf(":") > 1)
  -            return this.sourceHandler.getSource(this, systemId);
  -        if (systemId.charAt(0) == '/')
  -            return this.sourceHandler.getSource(this, this.context.getProtocol() + 
":" + systemId);
  -        return this.sourceHandler.getSource(this, this.context, systemId);
  +        Source source;
  +        if (systemId.length() == 0) {
  +            source = this.sourceHandler.getSource(this, 
this.context.toExternalForm());
  +        } else if (systemId.indexOf(":") > 1) {
  +            source = this.sourceHandler.getSource(this, systemId);
  +        } else if (systemId.charAt(0) == '/') {
  +            source = this.sourceHandler.getSource(this, this.context.getProtocol() 
+ ":" + systemId);
  +        } else {
  +            source = this.sourceHandler.getSource(this, this.context, systemId);
  +        }
  +        this.getLogger().debug("Resolved to '"+source.getSystemId()+"'");
  +        return source;
       }
   
       /**
  -     * Push a new URI for processing
  +     * Push a new URI for processing. If the prefix is null the
  +     * new URI is inside the current context.
  +     * If the prefix is not null the context is changed to the root
  +     * context and the prefix is set.
        */
  -    public void pushURI(String uri) {
  +    public void pushURI(String prefix, String uri) {
  +        this.getLogger().debug("Push uri '"+uri+"' with prefix '"+prefix+"'");
           this.uris.add(this.sourceHandler);
  +        this.uris.add(this.prefix);
  +        this.uris.add(this.context);
           this.uris.add(uri);
  +        if (prefix != null) {
  +            this.context = this.rootContext;
  +            this.prefix = new StringBuffer(prefix);
  +        }
       }
   
       /**
  @@ -232,6 +259,11 @@
        */
       public String popURI() {
           String uri = (String)this.uris.get(this.uris.size()-1);
  +        this.getLogger().debug("Pop uri '"+uri+"'");
  +        this.uris.remove(this.uris.size()-1);
  +        this.context = (URL)this.uris.get(this.uris.size()-1);
  +        this.uris.remove(this.uris.size()-1);
  +        this.prefix = (StringBuffer)this.uris.get(this.uris.size()-1);
           this.uris.remove(this.uris.size()-1);
           this.sourceHandler = (SourceHandler)this.uris.get(this.uris.size()-1);
           this.uris.remove(this.uris.size()-1);
  
  
  
  1.5       +7 -3      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Environment.java  2001/07/04 14:00:50     1.4
  +++ Environment.java  2001/07/10 07:44:31     1.5
  @@ -19,7 +19,8 @@
    * Base interface for an environment abstraction
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/07/04 14:00:50 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  + * @version CVS $Revision: 1.5 $ $Date: 2001/07/10 07:44:31 $
    */
   
   public interface Environment extends SourceResolver {
  @@ -85,9 +86,12 @@
       Map getObjectModel();
   
       /**
  -     * Push a new URI for processing
  +     * Push a new URI for processing. If the prefix is null the
  +     * new URI is inside the current context.
  +     * If the prefix is not null the context is changed to the root
  +     * context and the prefix is set.
        */
  -    void pushURI(String uri);
  +    void pushURI(String prefix, String uri);
   
       /**
        * Pop last pushed URI
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to