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 2001/08/15 05:54:20 UTC
cvs commit: xml-cocoon2/src/org/apache/cocoon/components/source SitemapSource.java
vgritsenko 01/08/14 20:54:20
Modified: src/org/apache/cocoon/components/source SitemapSource.java
Log:
exception handling
Revision Changes Path
1.13 +34 -35 xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SitemapSource.java 2001/07/29 16:23:02 1.12
+++ SitemapSource.java 2001/08/15 03:54:20 1.13
@@ -50,7 +50,7 @@
* Description of a source which is defined by a pipeline.
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.12 $ $Date: 2001/07/29 16:23:02 $
+ * @version CVS $Revision: 1.13 $ $Date: 2001/08/15 03:54:20 $
*/
public final class SitemapSource
@@ -87,6 +87,9 @@
/** The redirect <code>Source</code> */
private Source redirectSource;
+ /** The <code>ProcessingException</code> if unable to get resource */
+ private ProcessingException exception;
+
/**
* Construct a new object
*/
@@ -166,8 +169,9 @@
*/
public InputStream getInputStream()
throws ProcessingException, IOException {
- if ((this.eventPipeline == null || this.pipeline == null) && this.redirectSource == null) {
- throw new ProcessingException("could not lookup pipeline components.");
+ // VG: Why exception is not thrown in constructor?
+ if (this.exception != null) {
+ throw this.exception;
}
SitemapComponentSelector serializerSelector = null;
Serializer serializer = null;
@@ -183,18 +187,14 @@
return new ByteArrayInputStream(os.toByteArray());
} catch (ComponentException cme) {
throw new ProcessingException("could not lookup pipeline components", cme);
+ } catch (ProcessingException e) {
+ throw e;
} catch (Exception e) {
- throw new ProcessingException("Exception during processing of "+this.systemId, e);
+ throw new ProcessingException("Exception during processing of " + this.systemId, e);
} finally {
if (serializer != null) serializerSelector.release(serializer);
if (serializerSelector != null) this.manager.release(serializerSelector);
- if (this.eventPipeline != null) this.manager.release(this.eventPipeline);
- if (this.pipeline != null) this.manager.release(this.pipeline);
- this.eventPipeline = null;
- this.pipeline = null;
- this.lastModificationDate = 0;
- this.environment.reset();
- this.redirectSource = null;
+ reset();
}
}
@@ -226,13 +226,7 @@
* and content length.
*/
public void refresh() {
- if (eventPipeline != null) this.manager.release(eventPipeline);
- if (pipeline != null) this.manager.release(pipeline);
- this.lastModificationDate = 0;
- this.eventPipeline = null;
- this.pipeline = null;
- this.environment.reset();
- redirectSource = null;
+ reset();
try {
// initialize the pipelines
this.eventPipeline = (EventPipeline)this.manager.lookup(EventPipeline.ROLE);
@@ -278,14 +272,12 @@
} finally {
this.environment.popURI();
}
+ } catch (ProcessingException e) {
+ reset();
+ this.exception = e;
} catch (Exception e) {
- e.printStackTrace();
- if (this.eventPipeline != null) this.manager.release(this.eventPipeline);
- if (this.pipeline != null) this.manager.release(this.pipeline);
- this.eventPipeline = null;
- this.pipeline = null;
- this.redirectSource = null;
- this.environment.reset();
+ reset();
+ this.exception = new ProcessingException("Could not get sitemap source " + this.systemId, e);
}
}
@@ -304,8 +296,8 @@
*/
public void stream(XMLConsumer consumer)
throws ProcessingException, SAXException, IOException {
- if ((this.eventPipeline == null || this.pipeline == null) && this.redirectSource == null) {
- throw new ProcessingException("could not lookup pipeline components.");
+ if (this.exception != null) {
+ throw this.exception;
}
try {
@@ -322,16 +314,12 @@
}
} catch (ComponentException cme) {
throw new ProcessingException("could not lookup pipeline components", cme);
+ } catch (ProcessingException e) {
+ throw e;
} catch (Exception e) {
- throw new ProcessingException("Exception during processing of "+this.systemId, e);
+ throw new ProcessingException("Exception during processing of " + this.systemId, e);
} finally {
- if (this.eventPipeline != null) this.manager.release(this.eventPipeline);
- if (this.pipeline != null) this.manager.release(this.pipeline);
- this.eventPipeline = null;
- this.pipeline = null;
- this.lastModificationDate = 0;
- this.environment.reset();
- this.redirectSource = null;
+ reset();
}
}
@@ -341,6 +329,17 @@
public void stream(ContentHandler contentHandler)
throws ProcessingException, SAXException, IOException {
this.stream(new ContentHandlerWrapper(contentHandler));
+ }
+
+ private void reset() {
+ if (this.eventPipeline != null) this.manager.release(this.eventPipeline);
+ if (this.pipeline != null) this.manager.release(this.pipeline);
+ this.eventPipeline = null;
+ this.pipeline = null;
+ this.lastModificationDate = 0;
+ this.environment.reset();
+ this.redirectSource = null;
+ this.exception = null;
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org