You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/12/18 22:09:47 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/source SourceUtil.java

vgritsenko    2003/12/18 13:09:47

  Modified:    src/blocks/jsp/java/org/apache/cocoon/generation
                        JspGenerator.java
               src/java/org/apache/cocoon/components/source SourceUtil.java
  Log:
  Unwrap exception in the SourceUtil.toSAX()
  Add FIXME to JspGenerator
  
  Revision  Changes    Path
  1.11      +2 -1      cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java
  
  Index: JspGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JspGenerator.java	20 Nov 2003 12:46:52 -0000	1.10
  +++ JspGenerator.java	18 Dec 2003 21:09:47 -0000	1.11
  @@ -128,6 +128,7 @@
           } catch (ServletException e) {
               throw new ProcessingException("ServletException in JspGenerator.generate()", e.getRootCause());
           } catch (SAXException e) {
  +            // FIXME: e.getException can be null
               throw new ProcessingException("SAXException JspGenerator.generate()", e.getException());
           } catch (IOException e) {
               throw new ProcessingException("IOException JspGenerator.generate()", e);
  
  
  
  1.11      +23 -5     cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java
  
  Index: SourceUtil.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SourceUtil.java	15 Nov 2003 04:21:28 -0000	1.10
  +++ SourceUtil.java	18 Dec 2003 21:09:47 -0000	1.11
  @@ -155,12 +155,30 @@
        * @deprecated Use the {@link #toSAX(ServiceManager, Source, String, ContentHandler)}
        *             method instead.
        */
  -    static public void toSAX( ComponentManager manager, Source source,
  -                                String mimeTypeHint,
  -                                ContentHandler handler)
  +    static public void toSAX(ComponentManager manager, Source source,
  +                             String mimeTypeHint,
  +                             ContentHandler handler)
       throws SAXException, IOException, ProcessingException {
           if ( source instanceof XMLizable ) {
  -            ((XMLizable)source).toSAX( handler );
  +            try {
  +                ((XMLizable)source).toSAX( handler );
  +            } catch (SAXException e) {
  +                // Unwrap ProcessingException, IOException, and extreme cases of SAXExceptions.
  +                // See also FileGenerator.generate()
  +                final Exception cause = e.getException();
  +                if (cause != null) {
  +                    if (cause instanceof ProcessingException) {
  +                        throw (ProcessingException)cause;
  +                    }
  +                    if (cause instanceof IOException) {
  +                        throw (IOException)cause;
  +                    }
  +                    if (cause instanceof SAXException) {
  +                        throw (SAXException)cause;
  +                    }
  +                }
  +                throw e;
  +            }
           } else {
               String mimeType = source.getMimeType();
               if ( null == mimeType) mimeType = mimeTypeHint;