You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2001/02/15 01:59:09 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap Handler.java Manager.java

giacomo     01/02/14 16:59:09

  Modified:    src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: xml-cocoon2 sitemap.xsl
               src/org/apache/cocoon/environment Tag: xml-cocoon2
                        AbstractEnvironment.java Environment.java
               src/org/apache/cocoon/environment/commandline Tag:
                        xml-cocoon2 FileSavingEnvironment.java
                        LinkSamplingEnvironment.java
               src/org/apache/cocoon/environment/http Tag: xml-cocoon2
                        HttpEnvironment.java
               src/org/apache/cocoon/generation Tag: xml-cocoon2
                        FileGenerator.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2 Handler.java
                        Manager.java
  Log:
  Made mounting of sub sitemaps working again
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.76  +3 -18     xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
  retrieving revision 1.1.2.75
  retrieving revision 1.1.2.76
  diff -u -r1.1.2.75 -r1.1.2.76
  --- sitemap.xsl	2001/02/14 11:39:39	1.1.2.75
  +++ sitemap.xsl	2001/02/15 00:58:59	1.1.2.76
  @@ -95,7 +95,7 @@
        *
        * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
        * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  -     * @version CVS $Id: sitemap.xsl,v 1.1.2.75 2001/02/14 11:39:39 giacomo Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.1.2.76 2001/02/15 00:58:59 giacomo Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
         static final String LOCATION = "<xsl:value-of select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -193,6 +193,7 @@
         public void configure(Configuration conf) throws ConfigurationException {
           super.configure(conf);
           this.sitemapManager = new Manager(super.sitemapComponentManager);
  +        this.sitemapManager.setLogger(getLogger());
           this.sitemapManager.compose(this.manager);
           this.sitemapManager.configure(conf);
           try {
  @@ -837,23 +838,7 @@
       </xsl:variable>
   
       <!-- generate the code to invoke the sitemapManager which handles delegation of control to sub sitemaps -->
  -    <!-- here we make sure the uri-prefix ends with a slash -->
  -    <xsl:choose>
  -      <xsl:when test="substring(@uri-prefix,string-length(@uri-prefix))='/'">
  -        if(true)return sitemapManager.invoke (environment, substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"), substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
  -      </xsl:when>
  -      <xsl:when test="substring(@uri-prefix,string-length(@uri-prefix))='}'">
  -        String uri_prefix<xsl:value-of select="count(.)"/>=substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>");
  -        if (uri_prefix<xsl:value-of select="count(.)"/>.charAt(uri_prefix<xsl:value-of select="count(.)"/>.length()-1)=='/'){
  -          if(true)return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>, substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
  -        } else {
  -          return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>+"/", substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
  -        }
  -      </xsl:when>
  -      <xsl:otherwise>
  -        if(true)return sitemapManager.invoke (environment, substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>/"), substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
  -      </xsl:otherwise>
  -    </xsl:choose>
  +    if(true)return sitemapManager.invoke (environment, substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"), substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
     </xsl:template> <!-- match="map:mount" -->
   
     <!-- generate the code to redirect a request -->
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +18 -14    xml-cocoon/src/org/apache/cocoon/environment/Attic/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/Attic/AbstractEnvironment.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- AbstractEnvironment.java	2001/01/22 21:56:40	1.1.2.8
  +++ AbstractEnvironment.java	2001/02/15 00:59:00	1.1.2.9
  @@ -22,16 +22,13 @@
   
   import org.apache.cocoon.environment.Environment;
   
  -import org.apache.log.Logger;
  -import org.apache.avalon.Loggable;
  +import org.apache.avalon.AbstractLoggable;
   
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  -public abstract class AbstractEnvironment implements Environment, Loggable {
  +public abstract class AbstractEnvironment extends AbstractLoggable implements Environment {
   
  -    protected Logger log;
  -
       /** The current uri in progress */
       protected String uri = null;
   
  @@ -86,12 +83,6 @@
           this.objectModel = new HashMap();
       }
   
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
  -    }
  -
       // Sitemap methods
   
       /**
  @@ -106,17 +97,29 @@
        */
       public void changeContext(String prefix, String context)
       throws MalformedURLException {
  +        getLogger().debug("Changing Cocoon context(" + context + ") to prefix(" + prefix + ")");
  +        getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
  +        getLogger().debug("\tat URI " + uri);
           if (uri.startsWith(prefix)) {
               this.prefix.append(prefix);
               uri = uri.substring(prefix.length());
  -            File f = new File(context);
  +
  +            // if we got a absolute context or one with a protocol resolve it
  +            if (context.charAt(0) == '/') {
  +                this.context = new URL("file:" + context);
  +            }else if (context.indexOf(':') > 1) {
  +                this.context = new URL(context);
  +            }else {
  +                this.context = new URL(this.context, context);
  +            }
  +            File f = new File(this.context.getFile());
               if (f.isFile()) {
                   this.context = f.getParentFile().toURL();
               } else {
                   this.context = f.toURL();
               }
           } else {
  -            log.error("The current URI ("
  +            getLogger().error("The current URI ("
                   + uri + ") doesn't start with given prefix ("
                   + prefix + ")"
               );
  @@ -125,6 +128,7 @@
                   + prefix + ")"
               );
           }
  +        getLogger().debug("New context is " + this.context.toExternalForm());
       }
   
       /**
  @@ -176,7 +180,7 @@
   
           if (systemId.length() == 0)
               return new InputSource(this.context.toExternalForm());
  -        if (systemId.indexOf(":/") > 0)
  +        if (systemId.indexOf(":") > 1)
               return new InputSource(systemId);
           if (systemId.charAt(0) == '/')
               return new InputSource(this.context.getProtocol() + ":" + systemId);
  
  
  
  1.1.2.14  +2 -2      xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- Environment.java	2000/12/30 21:33:10	1.1.2.13
  +++ Environment.java	2001/02/15 00:59:01	1.1.2.14
  @@ -20,7 +20,7 @@
    * Base interface for an environment abstraction
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.13 $ $Date: 2000/12/30 21:33:10 $
  + * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/02/15 00:59:01 $
    */
   
   public interface Environment extends EntityResolver {
  @@ -43,7 +43,7 @@
       /**
        * Change the context from uriprefix to context
        */
  -    void changeContext(String uriprefix, String context) throws MalformedURLException;
  +    void changeContext(String uriprefix, String context) throws Exception;
   
       /**
        * Redirect to the given URL
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.10  +3 -14     xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/FileSavingEnvironment.java
  
  Index: FileSavingEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/FileSavingEnvironment.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- FileSavingEnvironment.java	2001/01/22 21:56:41	1.1.2.9
  +++ FileSavingEnvironment.java	2001/02/15 00:59:03	1.1.2.10
  @@ -20,34 +20,23 @@
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.environment.AbstractEnvironment;
   
  -import org.apache.log.Logger;
  -import org.apache.avalon.Loggable;
  -
   /**
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/01/22 21:56:41 $
  + * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/02/15 00:59:03 $
    */
  -
  -public class FileSavingEnvironment extends AbstractCommandLineEnvironment implements Loggable {
   
  -    private Logger log;
  +public class FileSavingEnvironment extends AbstractCommandLineEnvironment {
   
       public FileSavingEnvironment(String uri, File context, Map attributes, Map parameters, Map links, OutputStream stream)
       throws MalformedURLException {
           super(uri, null, context, stream);
  -        log.debug("FileSavingEnvironment: uri=" + uri);
  +        getLogger().debug("FileSavingEnvironment: uri=" + uri);
           this.objectModel.put(Cocoon.LINK_OBJECT, links);
           this.objectModel.put(Cocoon.REQUEST_OBJECT, new CommandLineRequest(null, uri, null, attributes, parameters));
           this.objectModel.put(Cocoon.RESPONSE_OBJECT, new CommandLineResponse());
       }
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
  -    }
  -
   }
   
   
  
  
  
  1.1.2.10  +3 -14     xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/LinkSamplingEnvironment.java
  
  Index: LinkSamplingEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/LinkSamplingEnvironment.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- LinkSamplingEnvironment.java	2001/01/22 21:56:42	1.1.2.9
  +++ LinkSamplingEnvironment.java	2001/02/15 00:59:03	1.1.2.10
  @@ -29,35 +29,24 @@
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.environment.AbstractEnvironment;
   
  -import org.apache.log.Logger;
  -import org.apache.avalon.Loggable;
   
  -
   /**
    * This environment is sample the links of the resource.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/01/22 21:56:42 $
  + * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/02/15 00:59:03 $
    */
  -
  -public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment implements Loggable {
   
  -    private Logger log;
  +public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment {
   
       private boolean skip = false;
   
       public LinkSamplingEnvironment(String uri, File contextFile, Map attributes, Map parameters)
       throws MalformedURLException, IOException {
           super(uri, Cocoon.LINK_VIEW, contextFile, new ByteArrayOutputStream());
  -        log.debug("LinkSamplingEnvironment: uri=" + uri);
  +        getLogger().debug("LinkSamplingEnvironment: uri=" + uri);
           this.objectModel.put(Cocoon.REQUEST_OBJECT, new CommandLineRequest(null, uri, null, attributes, parameters));
           this.objectModel.put(Cocoon.RESPONSE_OBJECT, new CommandLineResponse());
  -    }
  -
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.19  +3 -1      xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- HttpEnvironment.java	2000/12/30 21:33:11	1.1.2.18
  +++ HttpEnvironment.java	2001/02/15 00:59:05	1.1.2.19
  @@ -19,6 +19,8 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   
  +import org.apache.avalon.ComponentManager;
  +
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.environment.AbstractEnvironment;
   
  @@ -71,7 +73,7 @@
           if (qs != null)
               redirect = redirect + "?" + qs;
   
  -        log.debug("Sending redirect to '" + redirect + "'");
  +        getLogger().debug("Sending redirect to '" + redirect + "'");
           this.response.sendRedirect (redirect);
       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.17  +8 -6      xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- FileGenerator.java	2001/02/12 14:17:33	1.1.2.16
  +++ FileGenerator.java	2001/02/15 00:59:06	1.1.2.17
  @@ -57,7 +57,7 @@
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:cziegeler@sundn.de">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/02/12 14:17:33 $
  + * @version CVS $Revision: 1.1.2.17 $ $Date: 2001/02/15 00:59:06 $
    */
   public class FileGenerator extends ComposerGenerator implements Poolable, Configurable {
   
  @@ -85,7 +85,7 @@
       }
   
       /**
  -     * Configure this transformer.
  +     * Configure this generator.
        */
       public void configure(Configuration conf)
       throws ConfigurationException {
  @@ -113,19 +113,21 @@
               // Only local files are checked for modification
               // External files are never stored
               // Using the entity resolver we get the filename of the current file:
  -            // The systemID if such a resource starts with file:/.
  +            // The systemID of such a resource starts with file:.
  +            getLogger().debug("processing file " + super.source);
               InputSource src = super.resolver.resolveEntity(null, super.source);
               String      systemID = src.getSystemId();
  +            getLogger().debug("file resolved to " + systemID);
               byte[]      cxml = null;
   
               if (this.useStore == true)
               {
                   // Is this a local file
  -                if (systemID.startsWith("file:/") == true) {
  +                if (systemID.startsWith("file:") == true) {
                       // Stored is an array of the compiled xml and the caching time
                       if (store.containsKey(systemID) == true) {
                           Object[] cxmlAndTime = (Object[])store.get(systemID);
  -                        File xmlFile = new File(systemID.substring(6));
  +                        File xmlFile = new File(systemID.substring("file:".length()));
                           long storedTime = ((Long)cxmlAndTime[1]).longValue();
                           if (storedTime >= xmlFile.lastModified()) {
                               cxml = (byte[])cxmlAndTime[0];
  @@ -137,7 +139,7 @@
               if(cxml == null)
               {
                   // use the xmlcompiler for local files if storing is on
  -                if (this.useStore == true && systemID.startsWith("file:/") == true)
  +                if (this.useStore == true && systemID.startsWith("file:") == true)
                   {
                       ByteArrayOutputStream baos = new ByteArrayOutputStream();
                       XMLCompiler compiler = new XMLCompiler();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.14  +33 -19    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Handler.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- Handler.java	2001/02/14 11:39:14	1.1.2.13
  +++ Handler.java	2001/02/15 00:59:07	1.1.2.14
  @@ -19,6 +19,7 @@
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.language.generator.ProgramGenerator;
  +import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.Roles;
   
  @@ -35,7 +36,7 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/02/14 11:39:14 $
  + * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/02/15 00:59:07 $
    */
   public class Handler extends AbstractLoggable implements Runnable, Configurable, Composer, Processor {
   
  @@ -49,8 +50,12 @@
       private ComponentManager parentSitemapComponentManager;
   
       /** the source of this sitemap */
  +    private String source;
       private File sourceFile;
   
  +    /** the URLFactory */
  +    private URLFactory urlFactory;
  +
       /** the last error */
       private Exception exception;
   
  @@ -69,6 +74,11 @@
   
       public void compose (ComponentManager manager) {
           this.manager = manager;
  +        try {
  +            urlFactory = (URLFactory) manager.lookup(Roles.URL_FACTORY);
  +        } catch (Exception e) {
  +            getLogger().error ("cannot obtain URLFactory", e);
  +        }
       }
   
       public void configure (Configuration conf) {
  @@ -79,19 +89,7 @@
       throws FileNotFoundException {
           this.parentSitemapComponentManager = sitemapComponentManager;
           this.check_reload = check_reload;
  -        String s = null;
  -        if (source.charAt(source.length() - 1) == File.separatorChar) {
  -            s = source + "sitemap.xmap";
  -            this.sourceFile = new File (s);
  -        } else {
  -            this.sourceFile = new File (source);
  -            if (!this.sourceFile.isFile()) {
  -                this.sourceFile = new File (this.sourceFile, "sitemap.xmap");
  -            }
  -        }
  -        if (!this.sourceFile.canRead()) {
  -            throw new FileNotFoundException ("file " + this.sourceFile.toString() + " not found or cannot be opened for reading");
  -        }
  +        this.source = source;
       }
   
       protected boolean available () {
  @@ -114,6 +112,22 @@
   
       protected synchronized void regenerateAsynchronously (Environment environment)
       throws Exception {
  +        String s;
  +        if (this.source.charAt(this.source.length() - 1) == '/') {
  +            s = this.source + "sitemap.xmap";
  +        } else {
  +            s = this.source;
  +        }
  +        this.sourceFile = new File (
  +                urlFactory.getURL(
  +                        environment.resolveEntity(
  +                                null, s
  +                        ).getSystemId()
  +                ).getFile()
  +        );
  +        if (!this.sourceFile.canRead()) {
  +            throw new FileNotFoundException ("file " + this.sourceFile.toString() + " not found or cannot be opened for reading");
  +        }
           if (!this.isRegenerationRunning) {
               isRegenerationRunning = true;
               regeneration = new Thread (this);
  @@ -147,18 +161,18 @@
       /** Generate the Sitemap class */
       public void run() {
           Sitemap smap;
  -        InputSource inputSource = new InputSource (sourceFile.getPath());
  -        String systemId = inputSource.getSystemId();
  +        //InputSource inputSource = new InputSource (sourceFile.getPath());
  +        //String systemId = inputSource.getSystemId();
   
  -        File file = new File(systemId);
  +        //File file = new File(systemId);
   
           String markupLanguage = "sitemap";
           String programmingLanguage = "java";
   
           try {
               ProgramGenerator programGenerator = (ProgramGenerator) this.manager.lookup(Roles.PROGRAM_GENERATOR);
  -            smap = (Sitemap) programGenerator.load(file, markupLanguage, programmingLanguage, environment);
  -            if (smap instanceof Loggable) ((Loggable) smap).setLogger(getLogger());
  +            smap = (Sitemap) programGenerator.load(this.sourceFile, markupLanguage, programmingLanguage, environment);
  +            if (smap instanceof Loggable) ((Loggable)smap).setLogger(getLogger());
               if (smap instanceof Composer) smap.compose(this.manager);
               smap.setParentSitemapComponentManager (this.parentSitemapComponentManager);
               if (smap instanceof Configurable) smap.configure(this.conf);
  
  
  
  1.1.2.6   +12 -12    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Manager.java
  
  Index: Manager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Manager.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Manager.java	2001/01/22 21:56:49	1.1.2.5
  +++ Manager.java	2001/02/15 00:59:08	1.1.2.6
  @@ -20,7 +20,8 @@
   import org.apache.avalon.Configurable;
   import org.apache.avalon.Configuration;
   import org.apache.avalon.Loggable;
  -import org.apache.log.Logger;
  +import org.apache.avalon.AbstractLoggable;
  +//import org.apache.log.Logger;
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.environment.Environment;
  @@ -34,10 +35,9 @@
    * checking regeneration of the sub <code>Sitemap</code>
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/22 21:56:49 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/02/15 00:59:08 $
    */
  -public class Manager implements Configurable, Composer, Loggable {
  -    private Logger log;
  +public class Manager extends AbstractLoggable implements Configurable, Composer {
   
       /** The vectors of sub sitemaps */
       private HashMap sitemaps = new HashMap();
  @@ -55,12 +55,6 @@
           this.parentSitemapComponentManager = sitemapComponentManager;
       }
   
  -    public void setLogger (Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
  -    }
  -
       public void configure (Configuration conf) {
           this.conf = conf;
       }
  @@ -72,6 +66,12 @@
       public boolean invoke (Environment environment, String uri_prefix,
                              String source, boolean check_reload)
       throws Exception {
  +        // make sure the uri_prefix ends with a slash
  +        String prefix;
  +        if (uri_prefix.length() > 0)
  +            prefix = (uri_prefix.charAt(uri_prefix.length() - 1) == '/' ? uri_prefix : uri_prefix + "/");
  +        else
  +            prefix = uri_prefix;
           Handler sitemapHandler = (Handler) sitemaps.get(source);
   
           if (sitemapHandler != null) {
  @@ -86,11 +86,11 @@
               }
           } else {
               sitemapHandler = new Handler(parentSitemapComponentManager, source, check_reload);
  -            sitemapHandler.setLogger(this.log);
  +            sitemapHandler.setLogger(getLogger());
               sitemapHandler.compose(this.manager);
               sitemapHandler.configure(this.conf);
  -            sitemaps.put(source, sitemapHandler);
               sitemapHandler.regenerate(environment);
  +            sitemaps.put(source, sitemapHandler);
           }
   
           environment.changeContext(uri_prefix, source);