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 GenericProcessor.java LinkTranslator.java Sitemap.java SitemapComponent.java SitemapPartition.java
Date Mon, 28 Feb 2000 18:43:22 GMT
pier        00/02/28 10:43:22

  Modified:    src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        GenericProcessor.java LinkTranslator.java
                        Sitemap.java SitemapComponent.java
                        SitemapPartition.java
  Log:
  [Cocoon 2.0] Fixed a bunch-o-bogus in the link translation codes.
               Now it works if you don't link to ../???? in your sources.
               We just need to normalize relative paths into absolutes.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.8   +14 -8     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.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- GenericProcessor.java	2000/02/27 17:49:41	1.1.2.7
  +++ GenericProcessor.java	2000/02/28 18:43:21	1.1.2.8
  @@ -35,7 +35,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/02/27 17:49:41 $
  + * @version CVS $Revision: 1.1.2.8 $ $Date: 2000/02/28 18:43:21 $
    */
   public class GenericProcessor
   implements Composer, Configurable, Processor, LinkResolver {
  @@ -136,8 +136,12 @@
           Serializer s=(Serializer)this.manager.getComponent(this.serializer);
           s.setup(req,res,src,this.serializerParam);
           s.setOutputStream(out);
  -        LinkTranslator t=new LinkTranslator(this,req.getUri());
  +
  +        LinkResolver resolver=this.partition.sitemap;
  +        String partname=this.partition.name;
  +        LinkTranslator t=new LinkTranslator(this,resolver,partname,src);
           t.setConsumer(s);
  +
           XMLConsumer current=t;
           for (int x=0; x<this.filters.size(); x++) {
               String k=(String)this.filters.elementAt(x);
  @@ -145,6 +149,10 @@
               f.setup(req,res,src,(Parameters)this.filtersParam.elementAt(x));
               f.setConsumer(current);
               current=f;
  +
  +            t=new LinkTranslator(this,resolver,partname,src);
  +            t.setConsumer(current);
  +            current=t;
           }
   
           Generator g=(Generator)this.manager.getComponent(this.generator);
  @@ -158,12 +166,10 @@
        * 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))) {
  -            //if (source!=null) {
  -                String translated=this.sourceTranslator.translate(source);
  -                if (translated!=null) return(translated);
  -            //}
  +        if (source==null) return(null);
  +        if (this.partition.name.equals(partition)) {
  +            return(this.sourceTranslator.translate(source));
           }
  -        return(this.partition.resolve(source,partition,this));
  +        return(null);
       }
   }
  
  
  
  1.1.2.3   +34 -13    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkTranslator.java
  
  Index: LinkTranslator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkTranslator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- LinkTranslator.java	2000/02/27 17:49:41	1.1.2.2
  +++ LinkTranslator.java	2000/02/28 18:43:21	1.1.2.3
  @@ -21,22 +21,38 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 17:49:41 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/28 18:43:21 $
    */
   public class LinkTranslator extends AbstractXMLProducer implements XMLConsumer {
   
  -    private LinkResolver linkResolver=null;
  -    private String prepath=null;
  +    private LinkResolver local=null;
  +    private LinkResolver global=null;
  +    private String partition=null;
  +    private String source=null;
  +    private String basepath=null;
  +    private String rootpath="";
   
  -    public LinkTranslator(LinkResolver resolver, String baseUri) {
  +    public LinkTranslator(LinkResolver local, LinkResolver global,
  +                          String partition, String source) {
           super();
  -        this.linkResolver=resolver;
  -
  -        String relative="";
  -        for (int k=0; k<baseUri.length(); k++)
  -            if (baseUri.charAt(k)=='/') relative=relative+"../";
  -        if (relative.length()==0) this.prepath="./";
  -        else this.prepath=relative;
  +        this.local=local;
  +        this.global=global;
  +        this.partition=partition;
  +        this.source=source;
  +        if (local==null) throw new IllegalArgumentException("loc");
  +        if (global==null) throw new IllegalArgumentException("global");
  +        if (partition==null) throw new IllegalArgumentException("partition");
  +        if (source==null) throw new IllegalArgumentException("loc");
  +        
  +        int pos=-1;
  +        for (int x=0; x<source.length(); x++) {
  +            if (source.charAt(x)=='/') {
  +                pos=x;
  +                this.rootpath=this.rootpath+"../";
  +            }
  +        }
  +        if (pos>0) this.basepath=source.substring(0,pos+1);
  +        else this.basepath="";
       }
       
   
  @@ -124,8 +140,13 @@
           if (tran!=null) {
               int x=a2.getIndex(tran);
               if (x>-1) {
  -                String resolved=this.linkResolver.resolve(a2.getValue(x),part);
  -                if (resolved!=null) a2.setValue(x,this.prepath+resolved);
  +                if (part==null) part=this.partition;
  +                String name=this.basepath+a2.getValue(x);
  +
  +                String resolved=this.local.resolve(name,part);
  +                if (resolved==null) resolved=this.global.resolve(name,part);
  +                
  +                if (resolved!=null) a2.setValue(x,rootpath+resolved);
               }
           }
           super.contentHandler.startElement(uri,loc,raw,a2);
  
  
  
  1.1.4.5   +8 -12     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.4
  retrieving revision 1.1.4.5
  diff -u -r1.1.4.4 -r1.1.4.5
  --- Sitemap.java	2000/02/27 14:57:26	1.1.4.4
  +++ Sitemap.java	2000/02/28 18:43:21	1.1.4.5
  @@ -27,9 +27,10 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.4 $ $Date: 2000/02/27 14:57:26 $
  + * @version CVS $Revision: 1.1.4.5 $ $Date: 2000/02/28 18:43:21 $
    */
  -public class Sitemap implements Composer, Configurable, Processor {
  +public class Sitemap
  +implements Composer, Configurable, Processor, LinkResolver {
       
       /** The default partition */
       private SitemapPartition partition=null;
  @@ -101,17 +102,12 @@
           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);
  -        }
  -        
  +    public String resolve(String source, String part) {
  +        if (part==null) return(null);
  +        if ("default".equals(part)) return(this.partition.resolve(source,part));
  +
           SitemapPartition p=(SitemapPartition)this.partitions.get(part);
  -        if ((p!=null)&&(p!=caller)) {
  -            return(p.resolve(source,part,null));
  -        }
  +        if (p!=null) return(p.resolve(source,part));
   
           return(null);
       }
  
  
  
  1.1.2.3   +6 -2      xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java
  
  Index: SitemapComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SitemapComponent.java	2000/02/27 01:33:09	1.1.2.2
  +++ SitemapComponent.java	2000/02/28 18:43:21	1.1.2.3
  @@ -7,16 +7,19 @@
    *****************************************************************************/
   package org.apache.cocoon.sitemap;
   
  +import java.io.IOException;
   import org.apache.arch.Component;
   import org.apache.cocoon.Parameters;
   import org.apache.cocoon.Request;
   import org.apache.cocoon.Response;
  +import org.apache.cocoon.ProcessingException;
  +import org.xml.sax.SAXException;
   
   /**
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:09 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/28 18:43:21 $
    */
   public interface SitemapComponent extends Component {
   
  @@ -24,5 +27,6 @@
        * Set the <code>Request</code>, <code>Response</code> and
sitemap
        * <code>Parameters</code> used to process the request.
        */
  -    public void setup(Request req, Response res, String src, Parameters par);
  +    public void setup(Request req, Response res, String src, Parameters par)
  +    throws ProcessingException, SAXException, IOException;
   }
  
  
  
  1.1.2.5   +8 -7      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.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SitemapPartition.java	2000/02/27 14:57:26	1.1.2.4
  +++ SitemapPartition.java	2000/02/28 18:43:21	1.1.2.5
  @@ -27,16 +27,17 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 14:57:26 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/28 18:43:21 $
    */
  -public class SitemapPartition implements Composer, Configurable, Processor {
  +public class SitemapPartition
  +implements Composer, Configurable, Processor, LinkResolver {
   
       /** The list of perocessors */
       private Vector processors=new Vector();
       /** The component manager instance */
       private ComponentManager manager=null;
       /** The sitemap */
  -    private Sitemap sitemap=null;
  +    protected Sitemap sitemap=null;
       /** This partition name */
       protected String name=null;
       
  @@ -106,17 +107,17 @@
       /**
        * 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))) {
  +    public String resolve(String source, String partition) {
  +        if (source==null) return(null);
  +        if (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));
  +        return(null);
       }
   
   }
  
  
  

Mime
View raw message