stephan 2003/01/29 06:56:47 Modified: src/java/org/apache/cocoon/components/source SourceUtil.java src/java/org/apache/cocoon/xml/dom DOMBuilder.java Log: Prevent to throw a NullPointerException in DOMBuilder, instead throwing a PressingException in SourceUtil. Revision Changes Path 1.14 +29 -21 xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java Index: SourceUtil.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- SourceUtil.java 29 Jan 2003 10:55:16 -0000 1.13 +++ SourceUtil.java 29 Jan 2003 14:56:47 -0000 1.14 @@ -9,7 +9,7 @@ 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, + 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, @@ -17,12 +17,12 @@ 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 + 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 + 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] @@ -33,7 +33,7 @@ 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 + 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 @@ -174,7 +174,7 @@ /** * Generates a DOM from the given source * @param source The data - * @param manager Component manager. + * @param manager Component manager. * * @return Created DOM document. * @@ -189,7 +189,15 @@ DOMBuilder builder = new DOMBuilder(); toSAX(source, builder, manager); - return builder.getDocument(); + + Document document = builder.getDocument(); + + if (document==null) { + throw new ProcessingException("Could not build DOM for '"+ + source.getSystemId()+"'"); + } + + return document; } /** @@ -254,7 +262,7 @@ * Get a <code>Source</code> object * * @param uri Uri of the source. - * @param typeParameters + * @param typeParameters * @param resourceParameters Parameters of the source. * @param resolver Resolver for the source. * @@ -351,7 +359,7 @@ * the move. */ static public void move(Source source, - Source destination) throws SourceException { + Source destination) throws SourceException { if (source instanceof WriteableSource) { copy(source, destination); ((WriteableSource) source).delete(); @@ -371,7 +379,7 @@ * the copy. */ static public void copy(Source source, - Source destination) throws SourceException { + Source destination) throws SourceException { if ((source instanceof MoveableSource) && (source.getClass().equals(destination.getClass()))) { ((MoveableSource) source).copy(destination); @@ -410,13 +418,13 @@ * If not, the source is invoked with an additional parameter named * "content" containing the XML. * - * @param location + * @param location * @param typeParameters - * @param parameters - * @param frag - * @param resolver + * @param parameters + * @param frag + * @param resolver * @param serializerName - * @param manager + * @param manager * * @throws ProcessingException */ @@ -536,11 +544,11 @@ /** * Read a DOM Fragment from a source * - * @param location + * @param location * @param typeParameters - * @param parameters - * @param resolver - * @param manager + * @param parameters + * @param resolver + * @param manager * * @return * 1.10 +4 -2 xml-cocoon2/src/java/org/apache/cocoon/xml/dom/DOMBuilder.java Index: DOMBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/xml/dom/DOMBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DOMBuilder.java 17 Jan 2003 23:47:19 -0000 1.9 +++ DOMBuilder.java 29 Jan 2003 14:56:47 -0000 1.10 @@ -176,7 +176,9 @@ * Return the newly built Document. */ public Document getDocument() { - if (this.result.getNode().getNodeType() == Node.DOCUMENT_NODE) { + if ((this.result == null) || (this.result.getNode()==null)) { + return null; + } else if (this.result.getNode().getNodeType() == Node.DOCUMENT_NODE) { return ( (Document)this.result.getNode() ); } else { return ( this.result.getNode().getOwnerDocument() );
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]