cziegeler    2003/03/12 01:35:39

  Modified:    src/blocks/mail/java/org/apache/cocoon/mail
                        MailContentHandlerDelegate.java
               src/java/org/apache/cocoon cocoon.roles
               src/blocks/fop/java/org/apache/cocoon/serialization
                        FOPSerializer.java
               src/blocks/xmldb/conf xmldb.xconf
               src/webapp/WEB-INF cocoon.xconf
               src/blocks/html/java/org/apache/cocoon/generation
                        HTMLGenerator.java
               src/documentation cocoon.xconf
               src/blocks/lucene/java/org/apache/cocoon/transformation
                        LuceneIndexTransformer.java
  Added:       src/deprecated/java/org/apache/cocoon/components/resolver
                        ResolverImpl.java
               src/java/org/apache/cocoon/components/resolver
                        DefaultResolver.java
               src/blocks/xmldb/java/org/apache/cocoon/components/source/impl
                        XMLDBSourceFactory.java XMLDBSource.java
               src/scratchpad/src/org/apache/cocoon/components/source/impl
                        blob.xconf
  Removed:     src/scratchpad/src/org/apache/cocoon/components/source
                        blob.xconf BlobSourceFactory.java BlobSource.java
               src/java/org/apache/cocoon/components/resolver
                        ResolverImpl.java
               src/blocks/xmldb/java/org/apache/cocoon/components/source
                        XMLDBSourceFactory.java XMLDBSource.java
  Log:
  Next step in removing dependencies to the deprecated stuff.
  As some components (e.g. FOPSerializer) used deprecated stuff, this
  might break some parts, we have to fix them one after the other.
  
  Revision  Changes    Path
  1.3       +7 -7      
cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java
  
  Index: MailContentHandlerDelegate.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MailContentHandlerDelegate.java   11 Mar 2003 19:04:58 -0000      1.2
  +++ MailContentHandlerDelegate.java   12 Mar 2003 09:35:36 -0000      1.3
  @@ -837,7 +837,7 @@
        [EMAIL PROTECTED]    CVS Version: $Id$
        */
       static class FolderXMLizer extends AbstractLogEnabled
  -             implements XMLizable, org.apache.cocoon.xml.XMLizable {
  +             implements XMLizable {
           //private Folder folder;
           private Folder[] folders;
   
  @@ -888,7 +888,7 @@
        [EMAIL PROTECTED]    CVS Version: $Id$
        */
       static class MessageEnvelopeXMLizer extends AbstractLogEnabled
  -             implements XMLizable, org.apache.cocoon.xml.XMLizable {
  +             implements XMLizable {
           private Message[] messages;
   
           private SimpleDateFormat sdf;
  @@ -964,7 +964,7 @@
        [EMAIL PROTECTED]    CVS Version: $Id$
        */
       static class MessageXMLizer extends AbstractLogEnabled
  -             implements XMLizable, org.apache.cocoon.xml.XMLizable {
  +             implements XMLizable {
           private Message message;
   
           private SimpleDateFormat sdf;
  
  
  
  1.3       +5 -4      cocoon-2.1/src/java/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cocoon.roles      10 Mar 2003 09:13:15 -0000      1.2
  +++ cocoon.roles      12 Mar 2003 09:35:36 -0000      1.3
  @@ -14,6 +14,11 @@
   
   <role-list>
   
  +  <!-- The entity resolver used by most parsers -->
  +  <role name="org.apache.excalibur.xml.EntityResolver"
  +        shorthand="entity-resolver"
  +        default-class="org.apache.cocoon.components.resolver.ResolverImpl"/>
  +
     <!-- Parser:
     
          Starting with Cocoon 2.1 we have a bunch of different parser:
  @@ -38,10 +43,6 @@
           shorthand="html-parser"
           default-class="org.apache.excalibur.xml.sax.JTidyHTMLParser"/>
   
  -  <!-- The entity resolver used by most parsers -->
  -  <role name="org.apache.excalibur.xml.EntityResolver"
  -        shorthand="entity-resolver"
  -        default-class="org.apache.cocoon.components.resolver.ResolverImpl"/>
   
     <!-- A Dom Serializer -->
     <role default-class="org.apache.excalibur.xml.dom.DefaultDOMSerializer" 
name="org.apache.excalibur.xml.dom.DOMSerializer" shorthand="dom-serializer"/>
  
  
  
  1.2       +14 -15    
cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java
  
  Index: FOPSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FOPSerializer.java        9 Mar 2003 00:03:50 -0000       1.1
  +++ FOPSerializer.java        12 Mar 2003 09:35:36 -0000      1.2
  @@ -60,10 +60,10 @@
   import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.renderer.ExtendableRendererFactory;
   import org.apache.cocoon.components.renderer.RendererFactory;
  -import org.apache.cocoon.components.url.URLFactory;
  +import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.util.ClassUtils;
  -import org.apache.cocoon.environment.URLFactorySourceResolver;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.apache.fop.apps.Driver;
  @@ -180,25 +180,24 @@
               // New syntax: Element user-config contains URL
               configUrl = conf.getChild("user-config").getValue(null);
           }
  -        if(configUrl != null) {
  -            URLFactory urlFactory = null;
  +        
  +        if (configUrl != null) {
               Source configSource = null;
  +            SourceResolver resolver = null;
               try {
  -                // FIXME: How to do without URLFactory but relative to context?
  -                urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
  -                URLFactorySourceResolver urlResolver = new 
URLFactorySourceResolver(urlFactory, manager);
  -                configSource = urlResolver.resolve(configUrl);
  +                resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
  +                configSource = resolver.resolveURI(configUrl);
                   if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Loading configuration from " + 
configSource.getSystemId());
  +                    getLogger().debug("Loading configuration from " + 
configSource.getURI());
                   }
  -                configSource.toSAX(new ConfigurationParser());
  +                SourceUtil.toSAX(configSource, new ConfigurationParser());
               } catch (Exception e) {
                   getLogger().warn("Cannot load configuration from " + configUrl);
                   throw new ConfigurationException("Cannot load configuration from " 
+ configUrl, e);
               } finally {
  -                manager.release(urlFactory);
  -                if (configSource != null) {
  -                    configSource.recycle();
  +                if ( null != resolver ) {
  +                    resolver.release(configSource);
  +                    manager.release(resolver);
                   }
               }
           }
  
  
  
  1.1                  
cocoon-2.1/src/deprecated/java/org/apache/cocoon/components/resolver/ResolverImpl.java
  
  Index: ResolverImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.resolver;
  
  import org.apache.excalibur.xml.EntityResolver;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.Constants;
  import org.apache.xml.resolver.CatalogManager;
  import org.apache.xml.resolver.tools.CatalogResolver;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import java.io.IOException;
  
  
  /**
   * A component that uses catalogs for resolving entities.
   * This implementation uses the XML Entity and URI Resolvers from
   * http://xml.apache.org/commons/
   * published by Norman Walsh. More information on the catalogs can be
   * found at
   * http://cocoon.apache.org/userdocs/concepts/catalog.html
   *
   * The catalog is by default loaded from "WEB-INF/entities/catalog".
   * This can be configured by the "catalog" parameter in the cocoon.xconf:
   * &lt;entity-resolver&gt;
   *   &lt;parameter name="catalog" value="mycatalog"/&gt;
   * &lt;/entity-resolver&gt;
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">David Crossley</a>
   * @version CVS $Id: ResolverImpl.java,v 1.1 2003/03/12 09:35:37 cziegeler Exp $
   * @since 2.0rc1
   */
  public class ResolverImpl extends AbstractLogEnabled
    implements EntityResolver,
               Resolver,
               Contextualizable,
               Composable,
               Parameterizable,
               ThreadSafe,
               Disposable {
  
      /** The catalog manager */
      protected CatalogManager catalogManager = new CatalogManager();
  
      /** The catalog resolver */
      protected CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
  
      /** The component manager */
      protected ComponentManager manager = null;
  
      /** The context */
      protected org.apache.cocoon.environment.Context context;
  
      /** Contextualize this class */
      public void contextualize(Context context)
              throws ContextException {
          this.context = (org.apache.cocoon.environment.Context)
                          context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
      }
  
  
      /**
       * Set the configuration. Load the system catalog and apply any
       * parameters that may have been specified in cocoon.xconf
       * @param params The configuration information
       * @exception ParameterException
       */
      public void parameterize(Parameters params) throws ParameterException {
  
          /* Over-ride debug level that is set by CatalogManager.properties */
          String verbosity = params.getParameter("verbosity", "");
          if (verbosity != "") {
              if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Setting Catalog resolver "
                  + "verbosity level to " + verbosity);
              }
              int verbosityLevel = 0;
              try {
                  verbosityLevel = Integer.parseInt(verbosity);
                  catalogManager.setVerbosity(verbosityLevel);
              } catch (NumberFormatException ce1) {
                  this.getLogger().warn("Trouble setting Catalog verbosity",
                                          ce1);
              }
          }
  
          /* Load the built-in catalog */
          String catalogFile = params.getParameter("catalog",
                                  "/WEB-INF/entities/catalog");
          try {
              String catalogURL = null;
              catalogURL = this.context.getRealPath(catalogFile);
              if (catalogURL == null) {
                  catalogURL =
                      this.context.getResource(catalogFile).toExternalForm();
              }
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("System OASIS Catalog URL is "
                      + catalogURL);
              }
              catalogResolver.getCatalog().parseCatalog(catalogURL);
          } catch (Exception e) {
              this.getLogger().warn("Could not get Catalog URL", e);
          }
  
          /* Load a single additional local catalog */
          String localCatalogFile = params.getParameter("local-catalog", null);
          if (localCatalogFile != null) {
              try {
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Additional Catalog is "
                          + localCatalogFile);
                  }
                  catalogResolver.getCatalog().parseCatalog(localCatalogFile);
              } catch (Exception e) {
                  this.getLogger().warn("Could not get local Catalog file", e);
              }
          }
      }
  
      /**
       * Set the global component manager.
       * @param manager The global component manager
       * @exception ComponentException
       */
      public void compose(ComponentManager manager) throws ComponentException {
          if ((this.manager == null) && (manager != null)) {
              this.manager = manager;
          }
      }
  
      /**
       * Allow the application to resolve external entities.
       *
       * <p>The Parser will call this method before opening any external
       * entity except the top-level document entity (including the
       * external DTD subset, external entities referenced within the
       * DTD, and external entities referenced within the document
       * element): the application may request that the parser resolve
       * the entity itself, that it use an alternative URI, or that it
       * use an entirely different input source.</p>
       *
       * <p>Application writers can use this method to redirect external
       * system identifiers to secure and/or local URIs, to look up
       * public identifiers in a catalogue, or to read an entity from a
       * database or other input source (including, for example, a dialog
       * box).</p>
       *
       * <p>If the system identifier is a URL, the SAX parser must
       * resolve it fully before reporting it to the application.</p>
       *
       * @param publicId The public identifier of the external entity
       *        being referenced, or null if none was supplied.
       * @param systemId The system identifier of the external entity
       *        being referenced.
       * @return An InputSource object describing the new input source,
       *         or null to request that the parser open a regular
       *         URI connection to the system identifier.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException A Java-specific IO exception,
       *            possibly the result of creating a new InputStream
       *            or Reader for the InputSource.
       * @see org.xml.sax.InputSource
       */
      public InputSource resolveEntity(String publicId, String systemId)
              throws SAXException, IOException {
  /*
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("CER resolution: publicId="
                  + publicId + " systemId=" + systemId);
          }
  */
          InputSource altInputSource = catalogResolver.resolveEntity(publicId,
                                          systemId);
          if (altInputSource != null) {
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("Resolved catalog entity: "
                      + publicId + " " + altInputSource.getSystemId());
              }
          }
  /*
          else {
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("CER: altInputSource is null");
              }
          }
  */
          return altInputSource;
      }
  
      /**
       * Dispose
       */
      public void dispose() {
      }
  }
  
  
  
  1.2       +5 -6      cocoon-2.1/src/blocks/xmldb/conf/xmldb.xconf
  
  Index: xmldb.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmldb/conf/xmldb.xconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- xmldb.xconf       9 Mar 2003 00:06:44 -0000       1.1
  +++ xmldb.xconf       12 Mar 2003 09:35:37 -0000      1.2
  @@ -3,12 +3,11 @@
   <xconf xpath="/cocoon/source-factories" unless="[EMAIL PROTECTED]'xmldb']">
   
       <!-- xmldb pseudo protocol -->
  -    <component-instance 
class="org.apache.cocoon.components.source.impl.SourceFactoryWrapper" name="xmldb">
  -        <source-factory 
class="org.apache.cocoon.components.source.XMLDBSourceFactory">
  -            <!-- Xindice driver -->
  -            <driver type="xindice" 
class="org.apache.xindice.client.xmldb.DatabaseImpl"/>
  -            <!-- Add here other XML:DB compliant databases drivers -->
  -        </source-factory>
  +    <component-instance 
class="org.apache.cocoon.components.source.impl.XMLDBSourceFactory" name="xmldb">
  +        <!-- Xindice driver -->
  +        <driver class="org.apache.xindice.client.xmldb.DatabaseImpl" 
type="xindice"/>
  +        <!-- Add here other XML:DB compliant databases drivers -->
       </component-instance>
  +
   
   </xconf>
  
  
  
  1.4       +1 -1      cocoon-2.1/src/webapp/WEB-INF/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/WEB-INF/cocoon.xconf,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- cocoon.xconf      11 Mar 2003 15:18:26 -0000      1.3
  +++ cocoon.xconf      12 Mar 2003 09:35:37 -0000      1.4
  @@ -278,7 +278,7 @@
         |
         |     <parameter name="verbosity" value="2"/>
         +-->
  -  <entity-resolver class="org.apache.cocoon.components.resolver.ResolverImpl" 
logger="core.resolver">
  +  <entity-resolver logger="core.resolver">
      <parameter name="catalog" value="/WEB-INF/entities/catalog"/>
      <parameter name="verbosity" value="1"/>
     </entity-resolver>
  
  
  
  1.2       +9 -12     
cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation/HTMLGenerator.java
  
  Index: HTMLGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation/HTMLGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HTMLGenerator.java        9 Mar 2003 00:04:01 -0000       1.1
  +++ HTMLGenerator.java        12 Mar 2003 09:35:38 -0000      1.2
  @@ -78,9 +78,7 @@
   import org.apache.cocoon.ResourceNotFoundException;
   import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.source.SourceUtil;
  -import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.environment.URLFactorySourceResolver;
   import org.apache.cocoon.environment.http.HttpEnvironment;
   import org.apache.cocoon.util.PostInputStream;
   import org.apache.cocoon.xml.XMLUtils;
  @@ -133,14 +131,13 @@
           String configUrl = config.getChild("jtidy-config").getValue(null);
   
           if(configUrl != null) {
  -            URLFactory urlFactory = null;
  -            org.apache.cocoon.environment.Source configSource = null;
  +            org.apache.excalibur.source.SourceResolver resolver = null;
  +            Source configSource = null;
               try {
  -                urlFactory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
  -                URLFactorySourceResolver urlResolver = new 
URLFactorySourceResolver(urlFactory, this.manager);
  -                configSource = urlResolver.resolve(configUrl);
  +                resolver = 
(org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
  +                configSource = resolver.resolveURI(configUrl);
                   if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Loading configuration from " + 
configSource.getSystemId());
  +                    getLogger().debug("Loading configuration from " + 
configSource.getURI());
                   }
                   
                   this.properties = new Properties();
  @@ -150,9 +147,9 @@
                   getLogger().warn("Cannot load configuration from " + configUrl);
                   throw new ConfigurationException("Cannot load configuration from " 
+ configUrl, e);
               } finally {
  -                this.manager.release(urlFactory);
  -                if (configSource != null) {
  -                    configSource.recycle();
  +                if ( null != resolver ) {
  +                    this.manager.release(resolver);
  +                    resolver.release(configSource);
                   }
               }
           }
  
  
  
  1.1                  
cocoon-2.1/src/java/org/apache/cocoon/components/resolver/DefaultResolver.java
  
  Index: DefaultResolver.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.resolver;
  
  import org.apache.excalibur.xml.DefaultEntityResolver;
  
  
  /**
   * A component that uses catalogs for resolving entities.
   * This component simply inherits from the excalibur implementation and
   * adds the context: protocol to each relative uri.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
   * @version CVS $Id: DefaultResolver.java,v 1.1 2003/03/12 09:35:38 cziegeler Exp $
   * @since 2.1
   */
  public class DefaultResolver
    extends DefaultEntityResolver {
  
      /**
       * Parse a catalog
       */
      protected void parseCatalog(String file) {
          // relative uri
          if (file.indexOf(":/") == -1) {
              file = "context://" + file;
          }
          super.parseCatalog( file );
      }
  }
  
  
  
  1.2       +1 -2      cocoon-2.1/src/documentation/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/documentation/cocoon.xconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- cocoon.xconf      9 Mar 2003 00:07:16 -0000       1.1
  +++ cocoon.xconf      12 Mar 2003 09:35:38 -0000      1.2
  @@ -91,8 +91,7 @@
     <classloader 
class="org.apache.cocoon.components.classloader.ClassLoaderManagerImpl" 
logger="core.classloader"/>
   
     <!-- Entity resolution catalogs -->
  -  <entity-resolver class="org.apache.cocoon.components.resolver.ResolverImpl"
  -                   logger="core.resolver">
  +  <entity-resolver logger="core.resolver">
       <parameter name="catalog" value="/WEB-INF/entities/catalog"/>
       <parameter name="verbosity" value="1"/>
     </entity-resolver>
  
  
  
  1.1                  
cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSourceFactory.java
  
  Index: XMLDBSourceFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source.impl;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.cocoon.components.source.helpers.SourceCredential;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceFactory;
  
  /**
   * This class implements the xmldb:// pseudo-protocol and allows to get XML
   * content from an XML:DB enabled XML database.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Gianugo Rabellino</a>
   * @version CVS $Id: XMLDBSourceFactory.java,v 1.1 2003/03/12 09:35:38 cziegeler Exp 
$
   */
  
  public final class XMLDBSourceFactory
          extends AbstractLogEnabled
          implements SourceFactory, Configurable, Composable {
  
      /** The driver implementation class */
      protected String driver;
  
      /** The authentication info */
      protected SourceCredential credential;
  
      /** The Component Manager class */
      protected ComponentManager m_manager;
  
      /** A Map containing the driver list */
      protected HashMap driverMap;
  
      /** A Map containing the authentication credentials */
      protected HashMap credentialMap;
  
      /**
       * Configure the instance.
       */
      public void configure(final Configuration conf)
              throws ConfigurationException {
  
          driverMap = new HashMap();
          credentialMap = new HashMap();
  
          Configuration[] xmldbConfigs = conf.getChildren("driver");
  
          for (int i = 0; i < xmldbConfigs.length; i++) {
              SourceCredential credential = new SourceCredential(null, null);
  
              driverMap.put(xmldbConfigs[i].getAttribute("type"),
                            xmldbConfigs[i].getAttribute("class"));
  
              credential.setPrincipal(xmldbConfigs[i].getAttribute("user", null));
              credential.setPassword(xmldbConfigs[i].getAttribute("password", null));
              credentialMap.put(xmldbConfigs[i].getAttribute("type"), credential);
          }
      }
  
      /**
       * Compose this Composable object. We need to pass on the
       * ComponentManager to the actual Source.
       */
  
      public void compose(ComponentManager cm) {
          this.m_manager = cm;
      }
  
      public Source getSource(String location, Map parameters)
      throws MalformedURLException, IOException {
          int start = location.indexOf(':') + 1;
          int end = location.indexOf(':', start);
  
          if (start == -1 || end == -1) {
              throw new MalformedURLException("Mispelled XML:DB URL. " +
                                              "The syntax is 
\"xmldb:databasetype://host/collection/resource\"");
          }
  
          String type = location.substring(start, end);
  
          driver = (String)driverMap.get(type);
          credential = (SourceCredential)credentialMap.get(type);
  
          if (driver == null) {
              throw new IOException("Unable to find a driver for the \"" +
                                            type + " \" database type, please check 
the configuration");
          }
  
          return new XMLDBSource(this.getLogger(),
                                 driver, credential, location, location.substring(0, 
start-1), 
                                 this.m_manager);
      }
  
      public void release(org.apache.excalibur.source.Source source) {
          // nothing to do here
          if (null != source ) {
              ((XMLDBSource)source).recycle();
          }
      }
  
  }
  
  
  
  1.1                  
cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSource.java
  
  Index: XMLDBSource.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source.impl;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.cocoon.CascadingIOException;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.ResourceNotFoundException;
  import org.apache.cocoon.components.source.helpers.SourceCredential;
  import org.apache.cocoon.serialization.Serializer;
  import org.apache.cocoon.xml.IncludeXMLConsumer;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceValidity;
  import org.apache.excalibur.xml.sax.XMLizable;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.AttributesImpl;
  import org.xmldb.api.DatabaseManager;
  import org.xmldb.api.base.Collection;
  import org.xmldb.api.base.Database;
  import org.xmldb.api.base.ResourceIterator;
  import org.xmldb.api.base.ResourceSet;
  import org.xmldb.api.base.XMLDBException;
  import org.xmldb.api.modules.XMLResource;
  import org.xmldb.api.modules.XPathQueryService;
  
  /**
   * This class implements the xmldb:// pseudo-protocol and allows to get XML
   * content from an XML:DB enabled XML database.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Gianugo Rabellino</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
   * @version CVS $Id: XMLDBSource.java,v 1.1 2003/03/12 09:35:39 cziegeler Exp $
   */
  public class XMLDBSource extends AbstractLogEnabled  
      implements Source, XMLizable {
  
      /** The driver implementation class */
      protected String driver;
  
      /** The connection status. */
      protected boolean connected = false;
  
      /** The requested URL */
      protected String url;
  
      /** The supplied user */
      protected String user = null;
  
      /** The supplied password */
      protected String password;
  
      /** The part of URL after # sign */
      protected String query = null;
  
      /** The System ID */
      protected String systemId;
  
      /** The scheme */
      protected String scheme;
      
      /** ComponentManager */
      protected ComponentManager manager;
      
      /** Static Strings used for XML Collection representation */
  
      protected static final String URI = "http://apache.org/cocoon/xmldb/1.0";;
      // FIXME (VG): Should not be this more generic? Say, "xmldb"?
      protected static final String PREFIX = "collection";
  
      /** Root element &lt;collections&gt; */
      protected static final String COLLECTIONS  = "collections";
      protected static final String QCOLLECTIONS  = PREFIX + ":" + COLLECTIONS;
      protected static final String RESOURCE_COUNT_ATTR = "resources";
      protected static final String COLLECTION_COUNT_ATTR  = "collections";
  //    protected static final String COLLECTION_BASE_ATTR  = "base";
  
      /** Element &lt;collection&gt; */
      protected static final String COLLECTION  = "collection";
      protected static final String QCOLLECTION  = PREFIX + ":" + COLLECTION;
  
      /** Element &lt;resource&gt; */
      protected static final String RESOURCE  = "resource";
      protected static final String QRESOURCE  = PREFIX + ":" + RESOURCE;
      protected static final String NAME_ATTR  = "name";
  
      /** Root element &lt;results&gt; */
      protected static final String RESULTSET = "results";
      protected static final String QRESULTSET = PREFIX + ":" + RESULTSET;
      protected static final String QUERY_ATTR = "query";
      protected static final String RESULTS_COUNT_ATTR = "resources";
  
      /** Element &lt;result&gt; */
      protected static final String RESULT = "result";
      protected static final String QRESULT = PREFIX + ":" + RESULT;
      protected static final String RESULT_DOCID_ATTR = "docid";
      protected static final String RESULT_ID_ATTR = "id";
  
      protected static final String CDATA  = "CDATA";
  
      /**
       * The constructor.
       *
       * @param environment the Cocoon Environment.
       * @param url the URL being queried.
       * @param driver the XML:DB driver class name.
       */
      public XMLDBSource(Logger logger,
                         String driver,
                         SourceCredential credential,
                         String url,
                         String scheme,
                         ComponentManager manager) {
          this.enableLogging(logger);
          this.manager = manager;
          int start;
  
          this.driver = driver;
          this.scheme = scheme;
          this.user = credential.getPrincipal();
          this.password = credential.getPassword();
  
          if ((start = url.indexOf('#')) != -1) {
              this.url = url.substring(0, start);
              this.query = url.substring(start + 1);
          } else {
              this.url = url;
          }
      }
  
      /**
       * Initialize the XML:DB connection.
       *
       */
      public void connect()
      throws ProcessingException {
  
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Initializing XML:DB connection, using driver " + 
driver);
          }
  
          try {
  
              Class c = Class.forName(driver);
              DatabaseManager.registerDatabase((Database)c.newInstance());
  
          } catch (XMLDBException xde) {
  
              String error = "Unable to connect to the XMLDB database. Error "
                      + xde.errorCode + ": " + xde.getMessage();
              this.getLogger().debug(error, xde);
              throw new ProcessingException(error, xde);
  
          } catch (Exception e) {
  
              throw new ProcessingException("Problem setting up the connection to 
XML:DB: "
                      + e.getMessage() + ". Make sure that your driver is available.", 
e);
  
          }
  
          this.connected = true;
      }
  
  
      /**
       * Stream SAX events to a given ContentHandler. If the requested
       * resource is a collection, build an XML view of it.
       *
       */
      public void toSAX(ContentHandler handler) throws SAXException {
  
          try {
              if (!connected) {
                  this.connect();
              }
              if (url.endsWith("/"))
                  this.collectionToSAX(handler);
              else
                  this.resourceToSAX(handler);
          } catch (ProcessingException pe) {
              throw new SAXException("ProcessingException", pe);
          }
  
      }
  
      private void resourceToSAX(ContentHandler handler) throws SAXException, 
ProcessingException {
  
          final String col = url.substring(0, url.lastIndexOf('/'));
          final String res = url.substring(url.lastIndexOf('/') + 1);
  
          try {
              Collection collection = DatabaseManager.getCollection(col, user, 
password);
              if (collection == null) {
                  throw new ResourceNotFoundException("Document " + url + " not 
found");
              }
  
              XMLResource xmlResource = (XMLResource) collection.getResource(res);
              if (xmlResource == null) {
                  throw new ResourceNotFoundException("Document " + url + " not 
found");
              }
  
              if (query != null) {
                  // Query resource
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Querying resource " + res + " from 
collection " + url + "; query= " + this.query);
                  }
  
                  queryToSAX(handler, collection, res);
              } else {
                  // Return entire resource
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Obtaining resource " + res + " from 
collection " + col);
                  }
  
                  xmlResource.getContentAsSAX(handler);
              }
  
              collection.close();
          } catch (XMLDBException xde) {
              String error = "Unable to fetch content. Error "
                       + xde.errorCode + ": " + xde.getMessage();
              throw new SAXException(error, xde);
          }
      }
  
      private void collectionToSAX(ContentHandler handler) throws SAXException, 
ProcessingException {
  
          AttributesImpl attributes = new AttributesImpl();
  
          try {
              Collection collection = DatabaseManager.getCollection(url, user, 
password);
              if (collection == null) {
                  throw new ResourceNotFoundException("Collection " + url +
                          " not found");
              }
  
              if (query != null) {
                  // Query collection
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Querying collection " + url + "; query= 
" + this.query);
                  }
  
                  queryToSAX(handler, collection, null);
              } else {
                  // List collection
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Listing collection " + url);
                  }
  
                  final String ncollections = 
Integer.toString(collection.getChildCollectionCount());
                  final String nresources = 
Integer.toString(collection.getResourceCount());
                  attributes.addAttribute("", RESOURCE_COUNT_ATTR,
                          RESOURCE_COUNT_ATTR, "CDATA", nresources);
                  attributes.addAttribute("", COLLECTION_COUNT_ATTR,
                          COLLECTION_COUNT_ATTR, "CDATA", ncollections);
  //                attributes.addAttribute("", COLLECTION_BASE_ATTR,
  //                        COLLECTION_BASE_ATTR, "CDATA", url);
  
                  handler.startDocument();
                  handler.startPrefixMapping(PREFIX, URI);
                  handler.startElement(URI, COLLECTIONS, QCOLLECTIONS, attributes);
  
                  // Print child collections
                  String[] collections = collection.listChildCollections();
                  for (int i = 0; i < collections.length; i++) {
                      attributes.clear();
                      attributes.addAttribute("", NAME_ATTR, NAME_ATTR, CDATA, 
collections[i]);
                      handler.startElement(URI, COLLECTION,
                              QCOLLECTION, attributes);
                      handler.endElement(URI, COLLECTION, COLLECTION);
                  }
  
                  // Print child resources
                  String[] resources = collection.listResources();
                  for (int i = 0; i < resources.length; i++) {
                      attributes.clear();
                      attributes.addAttribute("", NAME_ATTR, NAME_ATTR, CDATA, 
resources[i]);
                      handler.startElement(URI, RESOURCE,
                              QRESOURCE, attributes);
                      handler.endElement(URI, RESOURCE, RESOURCE);
                  }
  
                  handler.endElement(URI, COLLECTIONS, QCOLLECTIONS);
                  handler.endPrefixMapping(PREFIX);
                  handler.endDocument();
              }
  
              collection.close();
          } catch (XMLDBException xde) {
              String error = "Collection listing failed. Error " + xde.errorCode + ": 
" + xde.getMessage();
              throw new SAXException(error, xde);
          }
      }
  
      private void queryToSAX(ContentHandler handler, Collection collection, String 
resource) throws SAXException {
  
          AttributesImpl attributes = new AttributesImpl();
  
          try {
              XPathQueryService service =
                  (XPathQueryService) collection.getService("XPathQueryService", 
"1.0");
              ResourceSet resultSet = (resource == null) ?
                      service.query(query) : service.queryResource(resource, query);
  
              attributes.addAttribute("", QUERY_ATTR, QUERY_ATTR, "CDATA", query);
              attributes.addAttribute("", RESULTS_COUNT_ATTR,
                      RESULTS_COUNT_ATTR, "CDATA", Long.toString(resultSet.getSize()));
  
              handler.startDocument();
              handler.startPrefixMapping(PREFIX, URI);
              handler.startElement(URI, RESULTSET, QRESULTSET, attributes);
  
              IncludeXMLConsumer includeHandler = new IncludeXMLConsumer(handler);
  
              // Print search results
              ResourceIterator results = resultSet.getIterator();
              while (results.hasMoreResources()) {
                  XMLResource result = (XMLResource)results.nextResource();
  
                  final String id = result.getId();
                  final String documentId = result.getDocumentId();
  
                  attributes.clear();
                  if (id != null) {
                      attributes.addAttribute("", RESULT_ID_ATTR, RESULT_ID_ATTR,
                          CDATA, id);
                  }
                  if (documentId != null) {
                      attributes.addAttribute("", RESULT_DOCID_ATTR, RESULT_DOCID_ATTR,
                          CDATA, documentId);
                  }
                  handler.startElement(URI, RESULT, QRESULT, attributes);
  
                  result.getContentAsSAX(includeHandler);
  
                  handler.endElement(URI, RESULT, RESULT);
              }
  
              handler.endElement(URI, RESULTSET, QRESULTSET);
              handler.endPrefixMapping(PREFIX);
              handler.endDocument();
          } catch (XMLDBException xde) {
              String error = "Query failed. Error " + xde.errorCode + ": " + 
xde.getMessage();
              throw new SAXException(error, xde);
          }
      }
  
      public void recycle() {
          this.driver = null;
          this.url = null;
          this.query = null;
      }
  
      public String getURI() {
          return url;
      }
      
      public long getContentLength() {
        return -1;
      }
  
      public long getLastModified() {
        return 0;
      }
  
      public boolean exists() {
          // FIXME
          return true;
      }
  
      public String getMimeType() {
          return null;
      }
  
      public String getScheme() {
          return this.getScheme();
      }
  
      public SourceValidity getValidity() {
          return null;
      }
  
      public void refresh() {
      }
  
      /**
       * Get an InputSource for the given URL. Shamelessly stolen
       * from SitemapSource.
       *
       */
      public InputStream getInputStream()
      throws IOException {
  
          ComponentSelector serializerSelector = null;
          Serializer serializer = null;
          try {
  
              serializerSelector = (ComponentSelector) 
this.manager.lookup(Serializer.ROLE + "Selector");
              serializer = (Serializer)serializerSelector.select("xml");
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              serializer.setOutputStream(os);
  
              this.toSAX(serializer);
  
              return new ByteArrayInputStream(os.toByteArray());
          } catch (ComponentException cme) {
              throw new CascadingIOException("could not lookup pipeline components", 
cme);
          } catch (Exception e) {
              throw new CascadingIOException("Exception during processing of " + 
this.getURI(), e);
          } finally {
              if (serializer != null) serializerSelector.release(serializer);
              if (serializerSelector != null) this.manager.release(serializerSelector);
          }
      }
  
  
  }
  
  
  
  1.3       +11 -10    
cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/transformation/LuceneIndexTransformer.java
  
  Index: LuceneIndexTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/transformation/LuceneIndexTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LuceneIndexTransformer.java       11 Mar 2003 17:44:23 -0000      1.2
  +++ LuceneIndexTransformer.java       12 Mar 2003 09:35:39 -0000      1.3
  @@ -52,6 +52,7 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.io.Serializable;
   import java.util.Map;
   import java.util.Stack;
   
  @@ -70,12 +71,12 @@
   
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.search.LuceneCocoonHelper;
   import org.apache.cocoon.components.search.LuceneXMLIndexer;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   
   import org.apache.lucene.analysis.Analyzer;
   import org.apache.lucene.document.Document;
  @@ -94,7 +95,7 @@
    * @version CVS $Id$
    */
   public class LuceneIndexTransformer extends AbstractTransformer
  -    implements Disposable, Cacheable, Recyclable, Configurable, Contextualizable {
  +    implements Disposable, CacheableProcessingComponent, Recyclable, Configurable, 
Contextualizable {
   
       public static final String ANALYZER_CLASSNAME_CONFIG = "analyzer-classname";
       public static final String ANALYZER_CLASSNAME_PARAMETER = "analyzer-classname";
  @@ -196,10 +197,10 @@
        * Generate the unique key.
        * This key must be unique inside the space of this component.
        *
  -     * @return The generated key hashes the src
  +     * @return The generated key
        */
  -    public long generateKey() {
  -        return 1;
  +    public Serializable generateKey() {
  +        return "1";
       }
   
       /**
  @@ -208,8 +209,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
   
  
  
  
  1.1                  
cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/source/impl/blob.xconf
  
  Index: blob.xconf
  ===================================================================
  <?xml version="1.0"?>
  
  <xconf xpath="/cocoon/source-factories" unless="[EMAIL PROTECTED]'blob']">
  
      <!-- blob pseudo protocol -->
      <protocol name="blob" 
class="org.apache.cocoon.components.source.impl.BlobSourceFactory"/>
  
  </xconf>
  
  
  

Reply via email to