stephan     2002/06/29 14:04:12

  Modified:    src/scratchpad/src/org/apache/cocoon/components/source/impl
                        SourceInspectorManager.java
               src/scratchpad/src/org/apache/cocoon/generation
                        SourceDescriptionGenerator.java
  Added:       src/scratchpad/src/org/apache/cocoon/components/source/impl
                        GIFSourceInspector.java JPEGSourceInspector.java
                        sourceinspector.xconf
  Log:
  Add two implementations for source inspectors based on the
  ImageDirectoryGenerator.
  Add support for the source inspectors to the SourceDescriptionGenerator.
  
  Revision  Changes    Path
  1.2       +14 -4     
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SourceInspectorManager.java
  
  Index: SourceInspectorManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SourceInspectorManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceInspectorManager.java       29 Jun 2002 08:52:53 -0000      1.1
  +++ SourceInspectorManager.java       29 Jun 2002 21:04:11 -0000      1.2
  @@ -70,6 +70,9 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.LogEnabled;
  +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.excalibur.source.Source;
  @@ -88,7 +91,7 @@
    */
   public class SourceInspectorManager extends AbstractLogEnabled implements 
       SourceInspector, ThreadSafe, Contextualizable, Composable, Configurable, 
  -    Initializable, Recyclable, Disposable {
  +    Initializable, Disposable {
   
       private ArrayList inspectors = new ArrayList();
   
  @@ -137,6 +140,13 @@
               if (inspector instanceof Configurable) 
                   ((Configurable)inspector).configure(configurations[i]);
   
  +            try {
  +                if (inspector instanceof Parameterizable)
  +                    
((Parameterizable)inspector).parameterize(Parameters.fromConfiguration(configurations[i]));
  +            } catch (ParameterException pe) {
  +                throw new ConfigurationException("Could not parameterize 
inspector", pe);
  +            }
  +
               inspectors.add(inspector);
           }
       }
  @@ -174,7 +184,7 @@
        * threads, etc. What is categorised as "costly" resources is determined on
        * a case by case analysis.
        */
  -    public void recycle() {
  +    /*public void recycle() {
           SourceInspector inspector;
           for(int i=0; i<this.inspectors.size(); i++) {
               inspector = (SourceInspector)this.inspectors.get(i);
  @@ -182,7 +192,7 @@
               if (inspector instanceof Recyclable)
                   ((Recyclable)inspector).recycle();
           }
  -    }
  +    }*/
   
       /**
        * The dispose operation is called at the end of a components lifecycle.
  
  
  
  1.1                  
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/GIFSourceInspector.java
  
  Index: GIFSourceInspector.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 (INCLUDING, 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source.impl;
  
  import org.apache.avalon.excalibur.xml.Parser;
  import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
  
  import org.apache.avalon.framework.activity.Startable;
  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.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import org.apache.cocoon.components.source.SourceInspector;
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  
  import java.io.BufferedInputStream;
  import java.io.IOException;
  
  /**
   * This source inspector adds extra attributes for image files.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephan Michels</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Donald A. Ball Jr.</a>
   * @version $Id: GIFSourceInspector.java,v 1.1 2002/06/29 21:04:11 stephan Exp $
   */
  public class GIFSourceInspector extends AbstractLogEnabled implements 
      SourceInspector, ThreadSafe {
  
      private String PROPERTY_NS = "http://xml.apache.org/cocoon/GIFSourceInspector";;
      private static String IMAGE_WIDTH_PROPERTY_NAME = "width";
      private static String IMAGE_HEIGHT_PROPERTY_NAME = "height";
  
      public SourceProperty getSourceProperty(Source source, String namespace, String 
name) 
          throws SourceException {
  
          if ((namespace.equals(PROPERTY_NS)) && 
              ((name.equals(IMAGE_WIDTH_PROPERTY_NAME)) || 
(name.equals(IMAGE_HEIGHT_PROPERTY_NAME))) && 
              (source.getSystemId().endsWith(".gif")) && (isGIFFile(source))) {
  
              if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
                  return new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME, 
                                            String.valueOf(getGifSize(source)[0]));
              if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
                  return new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
                                            String.valueOf(getGifSize(source)[1]));
          }
          return null;  
      }
  
      public SourceProperty[] getSourceProperties(Source source) throws 
SourceException {
  
          if ((source.getSystemId().endsWith(".gif")) &&
              (isGIFFile(source))) {
              int[] size = getGifSize(source);
              return new SourceProperty[] {
                  new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME, 
String.valueOf(size[0])),
                  new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME, 
String.valueOf(size[1]))
              };
          }
          return null;
      }
  
      private boolean isGIFFile(Source source) throws SourceException {
          BufferedInputStream in = null;
          try {
              in = new BufferedInputStream(source.getInputStream());
              byte[] buf = new byte[3];
              int count = in.read(buf, 0, 3);
              if(count < 3) return false;
              if ((buf[0] == (byte)'G') &&
                  (buf[1] == (byte)'I') &&
                  (buf[2] == (byte)'F'))
                  return true;
          } catch (IOException ioe) {
              throw new SourceException("Could not read source", ioe);
          } finally {
              if (in != null) 
                  try { 
                      in.close(); 
                  } catch(Exception e) {}
          }
          return false;
      }
  
      /**
       * Returns width as first element, height as second
       */
      private int[] getGifSize(Source source) throws SourceException {
          BufferedInputStream in = null;
          try {
              in = new BufferedInputStream(source.getInputStream());
              byte[] buf = new byte[10];
              int count = in.read(buf, 0, 10);
              if(count < 10) throw new SourceException("Not a valid GIF file!");
              if((buf[0]) != (byte)'G'
              || (buf[1]) != (byte)'I'
              || (buf[2]) != (byte)'F' )
              throw new SourceException("Not a valid GIF file!");
  
              int w1 = ((int)buf[6] & 0xff) | (buf[6] & 0x80);
              int w2 = ((int)buf[7] & 0xff) | (buf[7] & 0x80);
              int h1 = ((int)buf[8] & 0xff) | (buf[8] & 0x80);
              int h2 = ((int)buf[9] & 0xff) | (buf[9] & 0x80);
  
              int width = w1 + (w2 << 8);
              int height = h1 + (h2 << 8);
  
              int[] dim = { width, height };
              return dim;
          } catch (IOException ioe) {
              throw new SourceException("Could not read source", ioe);
          } finally {
              if (in != null) 
                  try { 
                      in.close(); 
                  } catch (Exception e) {}
          }
      }
  }
  
  
  
  
  1.1                  
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/JPEGSourceInspector.java
  
  Index: JPEGSourceInspector.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 (INCLUDING, 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source.impl;
  
  import org.apache.avalon.excalibur.xml.Parser;
  import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
  
  import org.apache.avalon.framework.activity.Startable;
  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.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import org.apache.cocoon.components.source.SourceInspector;
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  
  import java.io.BufferedInputStream;
  import java.io.IOException;
  
  /**
   * This source inspector adds extra attributes for image files.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephan Michels</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Donald A. Ball Jr.</a>
   * @version $Id: JPEGSourceInspector.java,v 1.1 2002/06/29 21:04:11 stephan Exp $
   */
  public class JPEGSourceInspector extends AbstractLogEnabled implements 
      SourceInspector, ThreadSafe {
  
      private String PROPERTY_NS = "http://xml.apache.org/cocoon/JPEGSourceInspector";;
      private static String IMAGE_WIDTH_PROPERTY_NAME = "width";
      private static String IMAGE_HEIGHT_PROPERTY_NAME = "height";
  
      private String propertyname = "result";
      private String extension = null;
      private String xpath = null;
  
      private ComponentManager manager = null;
  
      public SourceProperty getSourceProperty(Source source, String namespace, String 
name) 
          throws SourceException {
  
          if ((namespace.equals(PROPERTY_NS)) && 
              ((name.equals(IMAGE_WIDTH_PROPERTY_NAME)) || 
(name.equals(IMAGE_HEIGHT_PROPERTY_NAME))) && 
              (source.getSystemId().endsWith(".jpg")) && (isJPEGFile(source))) {
  
              if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
                  return new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME, 
                                            String.valueOf(getJpegSize(source)[0]));
              if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
                  return new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
                                            String.valueOf(getJpegSize(source)[1]));
          }
          return null;  
      }
  
      public SourceProperty[] getSourceProperties(Source source) throws 
SourceException {
  
          if ((source.getSystemId().endsWith(".jpg")) &&
              (isJPEGFile(source))) {
              int[] size = getJpegSize(source);
              return new SourceProperty[] {
                  new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME, 
String.valueOf(size[0])),
                  new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME, 
String.valueOf(size[1]))
              };
          }
          return null;
      }
  
      private boolean isJPEGFile(Source source) throws SourceException {
          BufferedInputStream in = null;
          try {
              in = new BufferedInputStream(source.getInputStream());
              byte[] buf = new byte[2];
              int count = in.read(buf, 0, 2);
              if (count < 2) 
                  return false;
  
              if ((buf[0] == (byte)0xFF) &&
                  (buf[1] == (byte)0xD8))
                  return true;
          } catch (IOException ioe) {
              throw new SourceException("Could not read source", ioe);
          } finally {
              if (in != null) 
                  try { 
                      in.close(); 
                  } catch(Exception e) {}
          }
          return false;
      }
  
      /**
       * returns width as first element, height as second
       */
      private int[] getJpegSize(Source source) throws SourceException {
          BufferedInputStream in = null;
          try {
              in = new BufferedInputStream(source.getInputStream());
              // check for "magic" header
              byte[] buf = new byte[2];
              int count = in.read(buf, 0, 2);
              if (count < 2) throw new SourceException("Not a valid Jpeg file!");
              if((buf[0]) != (byte)0xFF
              || (buf[1]) != (byte)0xD8 )
              throw new SourceException("Not a valid Jpeg file!");
  
              int width = 0;
              int height = 0;
  
              boolean done = false;
              int ch = 0;
  
              try {
                  while(ch != 0xDA && !done) {
                      /* Find next marker (JPEG markers begin with 0xFF) */
                      while (ch != 0xFF) { ch = in.read(); }
                      /* JPEG markers can be padded with unlimited 0xFF's */
                      while (ch == 0xFF) { ch = in.read(); }
                      /* Now, ch contains the value of the marker. */
                      if(ch >= 0xC0 && ch <= 0xC3) {
                          // skip 3 bytes 
                          in.read();
                          in.read();
                          in.read();
                          height = 256 * in.read();
                          height += in.read();
                          width = 256 * in.read();
                          width += in.read();
                          done = true;
                      } else { 
                          /* We MUST skip variables, since FF's within variable names 
                             are NOT valid JPEG markers */
                          int length = 256 * in.read();
                          length += in.read();
                          if(length < 2) throw new RuntimeException("Erroneous JPEG 
marker length");
                          for(int foo = 0; foo<length-2; foo++)
                              in.read();
                      }
                  }
              } catch (Exception e) {
                  throw new SourceException("Not a valid Jpeg file!", e);
              }
  
              int[] dim = { width, height };
              return dim;
  
          } catch (IOException ioe) {
              throw new SourceException("Could not read source", ioe);
          } finally {
              if (in != null) 
                  try { 
                      in.close(); 
                  } catch (Exception e) {}
          }
      }
  
  }
  
  
  
  
  1.1                  
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/sourceinspector.xconf
  
  Index: sourceinspector.xconf
  ===================================================================
  <?xml version="1.0"?>
  <xconf xpath="/cocoon" 
unless="component[@role='org.apache.cocoon.components.source.SourceInspector']">
  
   <!-- Source inspectors:
     Each source inspectors helps to retrieve properties from sources
     -->
   <component role="org.apache.cocoon.components.source.SourceInspector" 
              class="org.apache.cocoon.components.source.impl.SourceInspectorManager"
              logger="core.source.sourceinspector">
  
    <sourceinspector 
class="org.apache.cocoon.components.source.impl.XPathSourceInspector">
     <parameter name="namespace" value="http://xml.apache.org/cocoon/xdoc/1.0"/>
     <parameter name="name"      value="title"/>
     <parameter name="extension" value=".xdoc"/>
     <parameter name="xpath"     value="/document/header/title"/>
    </sourceinspector>
  
    <sourceinspector 
class="org.apache.cocoon.components.source.impl.JPEGSourceInspector"/>
    <sourceinspector 
class="org.apache.cocoon.components.source.impl.GIFSourceInspector"/>
   </component>
  </xconf>
  
  
  
  1.5       +45 -11    
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java
  
  Index: SourceDescriptionGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SourceDescriptionGenerator.java   27 Jun 2002 16:53:38 -0000      1.4
  +++ SourceDescriptionGenerator.java   29 Jun 2002 21:04:12 -0000      1.5
  @@ -56,9 +56,9 @@
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   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.component.Composable;
  +//import org.apache.avalon.framework.component.ComponentManager;
  +//import org.apache.avalon.framework.component.ComponentSelector;
  +//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;
  @@ -69,6 +69,7 @@
   import org.apache.cocoon.components.source.InspectableSource;
   import org.apache.cocoon.components.source.LockableSource;
   import org.apache.cocoon.components.source.RestrictableSource;
  +import org.apache.cocoon.components.source.SourceInspector;
   import org.apache.cocoon.components.source.WriteableSource;
   import org.apache.cocoon.components.source.VersionableSource;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
  @@ -220,28 +221,34 @@
                                                
SOURCE_PREFIX+":"+CONTENTLENGTH_NODE_NAME, new AttributesImpl());
               
this.contentHandler.characters(String.valueOf(source.getContentLength()).toCharArray(),
 0,
                                              
String.valueOf(source.getContentLength()).length());
  -            this.contentHandler.endElement(SOURCE_NS, CONTENTLENGTH_NODE_NAME, 
SOURCE_PREFIX+":"+CONTENTLENGTH_NODE_NAME);
  +            this.contentHandler.endElement(SOURCE_NS, CONTENTLENGTH_NODE_NAME, 
  +                                           
SOURCE_PREFIX+":"+CONTENTLENGTH_NODE_NAME);
   
               this.contentHandler.startElement(SOURCE_NS, LASTMODIFIED_NODE_NAME, 
                                                
SOURCE_PREFIX+":"+LASTMODIFIED_NODE_NAME, new AttributesImpl());
               
this.contentHandler.characters(String.valueOf(source.getLastModified()).toCharArray(), 
0,
                                              
String.valueOf(source.getLastModified()).length());
  -            this.contentHandler.endElement(SOURCE_NS, LASTMODIFIED_NODE_NAME, 
SOURCE_PREFIX+":"+LASTMODIFIED_NODE_NAME);
  +            this.contentHandler.endElement(SOURCE_NS, LASTMODIFIED_NODE_NAME, 
  +                                           
SOURCE_PREFIX+":"+LASTMODIFIED_NODE_NAME);
   
               if (source instanceof VersionableSource) {
                   VersionableSource versionablesource = (VersionableSource)source;
                   if (versionablesource.isVersioned()) {
                       this.contentHandler.startElement(SOURCE_NS, REVISION_NODE_NAME, 
  -                                                     
SOURCE_PREFIX+":"+REVISION_NODE_NAME, new AttributesImpl());
  +                                                     
SOURCE_PREFIX+":"+REVISION_NODE_NAME, 
  +                                                     new AttributesImpl());
                       
this.contentHandler.characters(versionablesource.getSourceRevision().toCharArray(), 0,
                                                      
versionablesource.getSourceRevision().length());
  -                    this.contentHandler.endElement(SOURCE_NS, REVISION_NODE_NAME, 
SOURCE_PREFIX+":"+REVISION_NODE_NAME);
  +                    this.contentHandler.endElement(SOURCE_NS, REVISION_NODE_NAME, 
  +                                                   
SOURCE_PREFIX+":"+REVISION_NODE_NAME);
   
                       this.contentHandler.startElement(SOURCE_NS, 
REVISIONBRANCH_NODE_NAME,
  -                                                     
SOURCE_PREFIX+":"+REVISIONBRANCH_NODE_NAME, new AttributesImpl());
  +                                                     
SOURCE_PREFIX+":"+REVISIONBRANCH_NODE_NAME, 
  +                                                     new AttributesImpl());
                       
this.contentHandler.characters(versionablesource.getSourceRevisionBranch().toCharArray(),
 0,
                                                      
versionablesource.getSourceRevisionBranch().length());
  -                    this.contentHandler.endElement(SOURCE_NS, 
REVISIONBRANCH_NODE_NAME, SOURCE_PREFIX+":"+REVISIONBRANCH_NODE_NAME);
  +                    this.contentHandler.endElement(SOURCE_NS, 
REVISIONBRANCH_NODE_NAME, 
  +                                                   
SOURCE_PREFIX+":"+REVISIONBRANCH_NODE_NAME);
                   }
               }
   
  @@ -249,6 +256,32 @@
   
               if (source instanceof InspectableSource)
                   pushSourceProperties((InspectableSource)source);
  +
  +            SourceInspector inspector = null;
  +            try { 
  +                inspector = 
(SourceInspector)this.manager.lookup(SourceInspector.ROLE);
  +
  +                SourceProperty[] properties = inspector.getSourceProperties(source);
  +                for (int i=0; i<properties.length; i++) 
  +                    properties[i].toSAX(new EmbeddedXMLPipe(this.contentHandler));
  +            } catch (ComponentException ce) {
  +                getLogger().warn("Could not retrieve source inspector", ce);
  +            } finally {
  +                if (inspector!=null)
  +                    this.manager.release(inspector);
  +            }
  +
  +            /*this.contentHandler.startPrefixMapping("prop", 
property.getNamespace());
  +
  +            this.contentHandler.startElement(property.getNamespace(), 
property.getName(), 
  +                                             property.getName(), new 
AttributesImpl());
  +            
this.contentHandler.characters(property.getValue().toString().toCharArray(), 0,
  +                                           property.getValue().toString().length());
  +            this.contentHandler.endElement(property.getNamespace(), 
property.getName(), 
  +                                           property.getName());
  +
  +            this.contentHandler.endPrefixMapping("prop");*/
  +
               /*if (source instanceof RestrictableSource)
                   pushSourcePermissions((RestrictableSource)source);*/
               if (source instanceof LockableSource)
  @@ -304,7 +337,8 @@
   
                   this.contentHandler.endElement(RDF_NS, SEQUENCE_NODE_NAME,
                                                  RDF_PREFIX+':'+SEQUENCE_NODE_NAME);
  -                this.contentHandler.endElement(SOURCE_NS, CHILDREN_NODE_NAME, 
SOURCE_PREFIX+":"+CHILDREN_NODE_NAME);
  +                this.contentHandler.endElement(SOURCE_NS, CHILDREN_NODE_NAME, 
  +                                               
SOURCE_PREFIX+":"+CHILDREN_NODE_NAME);
   
                   this.contentHandler.endPrefixMapping(SOURCE_PREFIX);
               }
  
  
  

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

Reply via email to