cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap LinkResolver.java LinkTranslator.java GenericProcessor.java Sitemap.java SitemapPartition.java
Date Sun, 27 Feb 2000 14:57:28 GMT
pier        00/02/27 06:57:28

  Modified:    src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        GenericProcessor.java Sitemap.java
                        SitemapPartition.java
  Added:       src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        LinkResolver.java LinkTranslator.java
  Log:
  [Cocoon 2.0] Added link resolution and translation.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +20 -5     xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java
  
  Index: GenericProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- GenericProcessor.java	2000/02/27 12:56:19	1.1.2.5
  +++ GenericProcessor.java	2000/02/27 14:57:26	1.1.2.6
  @@ -35,9 +35,10 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/27 12:56:19 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/02/27 14:57:26 $
    */
  -public class GenericProcessor implements Composer, Configurable, Processor {
  +public class GenericProcessor
  +implements Composer, Configurable, Processor, LinkResolver {
   
       /** The component manager instance */
       private ComponentManager manager=null;
  @@ -85,7 +86,7 @@
       public void setConfiguration(Configuration conf)
       throws ConfigurationException {
           String uri=conf.getAttribute("uri");
  -        if ((uri.length()==0)||(uri.charAt(0)!='/')) uri='/'+uri;
  +        //if ((uri.length()==0)||(uri.charAt(0)!='/')) uri='/'+uri;
           String source=conf.getAttribute("source",null);
           try {
               if(source==null) {
  @@ -115,6 +116,7 @@
           while (e.hasMoreElements()) {
               Configuration f=(Configuration)e.nextElement();
               this.filters.addElement("filter:"+c.getAttribute("name"));
  +            this.filtersParam.addElement(Parameters.fromConfiguration(c));
           }
       }
   
  @@ -134,11 +136,13 @@
           Serializer s=(Serializer)this.manager.getComponent(this.serializer);
           s.setup(req,res,src,this.serializerParam);
           s.setOutputStream(out);
  -        XMLConsumer current=s;
  +        LinkTranslator t=new LinkTranslator(this,req.getUri());
  +        t.setConsumer(s);
  +        XMLConsumer current=t;
           for (int x=0; x<this.filters.size(); x++) {
               String k=(String)this.filters.elementAt(x);
               Filter f=(Filter)this.manager.getComponent(k);
  -            f.setup(req,res,src,null);
  +            f.setup(req,res,src,(Parameters)this.filtersParam.elementAt(x));
               f.setConsumer(current);
               current=f;
           }
  @@ -148,5 +152,16 @@
           g.setup(req,res,src,this.generatorParam);
           g.generate();
           return(true);
  +    }
  +    
  +    /**
  +     * Resolve a link against a source into the target URI space.
  +     */
  +    public String resolve(String source, String partition) {
  +        if ((partition==null)||(this.partition.name.equals(partition))) {
  +            String translated=this.sourceTranslator.translate(source);
  +            if (translated!=null) return(translated);
  +        }
  +        return(this.partition.resolve(source,partition,this));
       }
   }
  
  
  
  1.1.4.4   +18 -5     xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java
  
  Index: Sitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java,v
  retrieving revision 1.1.4.3
  retrieving revision 1.1.4.4
  diff -u -r1.1.4.3 -r1.1.4.4
  --- Sitemap.java	2000/02/27 12:56:19	1.1.4.3
  +++ Sitemap.java	2000/02/27 14:57:26	1.1.4.4
  @@ -27,7 +27,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 12:56:19 $
  + * @version CVS $Revision: 1.1.4.4 $ $Date: 2000/02/27 14:57:26 $
    */
   public class Sitemap implements Composer, Configurable, Processor {
       
  @@ -82,9 +82,6 @@
                                       "of the partition named \""+name+"\"",co);
               }
           }
  -        if (this.partition==null)
  -            throw new ConfigurationException("No default partition configured",
  -                                             conf);
       }
   
       /**
  @@ -93,7 +90,8 @@
        */
       public boolean process(Request req, Response res, OutputStream out)
       throws SAXException, IOException, ProcessingException {
  -        if(this.partition.process(req,res,out)) return(true);
  +        if(this.partition!=null)
  +            if(this.partition.process(req,res,out)) return(true);
   
           Enumeration e=partitions.elements();
           while (e.hasMoreElements()) {
  @@ -101,5 +99,20 @@
               if (p.process(req,res,out)) return(true);
           }
           return(false);
  +    }
  +
  +    public String resolve(String source, String part, SitemapPartition caller) {
  +        if ((part==null)||("default".equals(part))) {
  +            if (caller!=this.partition)
  +                return(this.partition.resolve(source,part,null));
  +            return(null);
  +        }
  +        
  +        SitemapPartition p=(SitemapPartition)this.partitions.get(part);
  +        if ((p!=null)&&(p!=caller)) {
  +            return(p.resolve(source,part,null));
  +        }
  +
  +        return(null);
       }
   }
  
  
  
  1.1.2.4   +18 -1     xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapPartition.java
  
  Index: SitemapPartition.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapPartition.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- SitemapPartition.java	2000/02/27 12:56:19	1.1.2.3
  +++ SitemapPartition.java	2000/02/27 14:57:26	1.1.2.4
  @@ -27,7 +27,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 12:56:19 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 14:57:26 $
    */
   public class SitemapPartition implements Composer, Configurable, Processor {
   
  @@ -102,4 +102,21 @@
           }
           return(false);
       }
  +
  +    /**
  +     * Resolve a link against a source into the target URI space.
  +     */
  +    public String resolve(String source, String partition, LinkResolver orig) {
  +        if ((partition==null)||(this.name.equals(partition))) {
  +            Enumeration e=this.processors.elements();
  +            while (e.hasMoreElements()) {
  +                LinkResolver r=(LinkResolver)e.nextElement();
  +                if (orig==r) continue;
  +                String translated=r.resolve(source,partition);
  +                if (translated!=null) return(translated);
  +            }
  +        }
  +        return(this.sitemap.resolve(source,partition,this));
  +    }
  +
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.1   +26 -0     xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkResolver.java
  
  
  
  
  1.1.2.1   +281 -0    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkTranslator.java
  
  
  
  

Mime
View raw message