You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/10/09 18:28:35 UTC
svn commit: r703203 - in /cocoon/cocoon3/trunk:
cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/
cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/
cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline...
Author: reinhard
Date: Thu Oct 9 09:28:34 2008
New Revision: 703203
URL: http://svn.apache.org/viewvc?rev=703203&view=rev
Log:
Introduce an exception hierarchy for pipeline components (ProcessingException and SetupException extend both PipelineException).
Added:
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java (with props)
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java (with props)
Modified:
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/BetwixtBeanGenerator.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ProcessingException.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileGenerator.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileReaderComponent.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/StringGenerator.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XMLSerializer.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/URLConnectionUtils.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java
cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/TimestampGenerator.java
cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/component/RedirectorComponent.java
cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServiceConsumerGenerator.java
cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceGenerator.java
cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceSerializer.java
cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/component/ExceptionGenerator.java
Modified: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/BetwixtBeanGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/BetwixtBeanGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/BetwixtBeanGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/betwixt/BetwixtBeanGenerator.java Thu Oct 9 09:28:34 2008
@@ -19,6 +19,7 @@
import java.beans.IntrospectionException;
import java.io.IOException;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.sax.AbstractGenerator;
import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
import org.apache.cocoon.pipeline.util.StringRepresentation;
@@ -68,11 +69,11 @@
try {
this.saxBeanWriter.write(this.bean);
} catch (IOException e) {
- throw new RuntimeException("Fatal protocol violation", e);
+ throw new ProcessingException("Fatal protocol violation", e);
} catch (SAXException e) {
- throw new RuntimeException("Fatal XML error", e);
+ throw new ProcessingException("Fatal XML error", e);
} catch (IntrospectionException e) {
- throw new RuntimeException("Impossible to analyze input bean", e);
+ throw new ProcessingException("Impossible to analyze input bean", e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java Thu Oct 9 09:28:34 2008
@@ -98,7 +98,7 @@
if (this.cacheKey == null) {
return -1;
}
- return this.cacheKey.getLastModifed();
+ return this.cacheKey.getLastModified();
}
public CacheKey constructCacheKey() {
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java?rev=703203&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java Thu Oct 9 09:28:34 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline;
+
+public class PipelineException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public PipelineException() {
+ super();
+ }
+
+ public PipelineException(String message) {
+ super(message);
+ }
+
+ public PipelineException(Throwable cause) {
+ super(cause);
+ }
+
+ public PipelineException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/PipelineException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ProcessingException.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ProcessingException.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ProcessingException.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ProcessingException.java Thu Oct 9 09:28:34 2008
@@ -19,7 +19,7 @@
/**
* Exception that indicates that there was a problem while processing a pipeline.
*/
-public class ProcessingException extends RuntimeException {
+public class ProcessingException extends PipelineException {
private static final long serialVersionUID = 1L;
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java?rev=703203&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java Thu Oct 9 09:28:34 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline;
+
+/**
+ * Exception that indicates that there was a problem while processing a pipeline.
+ */
+public class SetupException extends PipelineException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SetupException() {
+ super();
+ }
+
+ public SetupException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SetupException(String message) {
+ super(message);
+ }
+
+ public SetupException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/SetupException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheKey.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheKey.java Thu Oct 9 09:28:34 2008
@@ -24,5 +24,5 @@
boolean isValid(CacheKey cacheKey);
- long getLastModifed();
+ long getLastModified();
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java Thu Oct 9 09:28:34 2008
@@ -118,10 +118,10 @@
return true;
}
- public long getLastModifed() {
+ public long getLastModified() {
long lastModified = 0;
for (CacheKey eachKey : this.cacheKeys) {
- long eachLastModified = eachKey.getLastModifed();
+ long eachLastModified = eachKey.getLastModified();
if (eachLastModified == -1) {
return -1;
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java Thu Oct 9 09:28:34 2008
@@ -68,7 +68,7 @@
return this.parameters.equals(other.parameters);
}
- public long getLastModifed() {
+ public long getLastModified() {
return -1;
}
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCacheKey.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCacheKey.java Thu Oct 9 09:28:34 2008
@@ -38,7 +38,7 @@
return true;
}
- public long getLastModifed() {
+ public long getLastModified() {
return 0;
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java Thu Oct 9 09:28:34 2008
@@ -51,7 +51,7 @@
return this.timestamp;
}
- public long getLastModifed() {
+ public long getLastModified() {
return this.getTimestamp();
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileGenerator.java Thu Oct 9 09:28:34 2008
@@ -23,6 +23,7 @@
import java.net.URLConnection;
import java.util.Map;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.caching.CacheKey;
import org.apache.cocoon.pipeline.caching.TimestampCacheKey;
import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
@@ -77,7 +78,7 @@
try {
URLConnectionUtils.toSax(this.source.openConnection(), this.getXMLConsumer());
} catch (IOException e) {
- throw new RuntimeException("Can't open connection to " + this.source, e);
+ throw new ProcessingException("Can't open connection to " + this.source, e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileReaderComponent.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileReaderComponent.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileReaderComponent.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/FileReaderComponent.java Thu Oct 9 09:28:34 2008
@@ -25,6 +25,7 @@
import java.net.URLConnection;
import java.util.Map;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.caching.CacheKey;
import org.apache.cocoon.pipeline.caching.TimestampCacheKey;
import org.apache.cocoon.pipeline.component.AbstractPipelineComponent;
@@ -98,7 +99,7 @@
} catch (IOException e) {
String message = "FileReader cannot read from '" + this.source + "'";
this.logger.error(message, e);
- throw new RuntimeException(message, e);
+ throw new ProcessingException(message, e);
} finally {
URLConnectionUtils.closeQuietly(connection);
}
@@ -119,7 +120,7 @@
connection = this.source.openConnection();
return connection.getContentType();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new ProcessingException(e);
} finally {
URLConnectionUtils.closeQuietly(connection);
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/StringGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/StringGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/StringGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/StringGenerator.java Thu Oct 9 09:28:34 2008
@@ -20,6 +20,8 @@
import java.io.ByteArrayInputStream;
+import org.apache.cocoon.pipeline.PipelineException;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.Starter;
import org.apache.cocoon.pipeline.util.StringRepresentation;
import org.apache.cocoon.pipeline.util.XMLUtils;
@@ -43,7 +45,13 @@
* @see org.apache.cocoon.pipeline.component.Starter#execute()
*/
public void execute() {
- XMLUtils.toSax(new ByteArrayInputStream(this.xmlString.getBytes()), this.getXMLConsumer());
+ try {
+ XMLUtils.toSax(new ByteArrayInputStream(this.xmlString.getBytes()), this.getXMLConsumer());
+ } catch (PipelineException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ProcessingException("Can't parse inputStream.", e);
+ }
}
@Override
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XMLSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XMLSerializer.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XMLSerializer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XMLSerializer.java Thu Oct 9 09:28:34 2008
@@ -28,7 +28,7 @@
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
-import org.apache.cocoon.pipeline.ProcessingException;
+import org.apache.cocoon.pipeline.SetupException;
import org.apache.cocoon.pipeline.caching.CacheKey;
import org.apache.cocoon.pipeline.caching.SimpleCacheKey;
import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
@@ -55,7 +55,7 @@
try {
this.transformerHandler = SAX_TRANSFORMER_FACTORY.newTransformerHandler();
} catch (TransformerConfigurationException e) {
- throw new ProcessingException("Can't setup transformer handler for the serializer.", e);
+ throw new SetupException("Can't setup transformer handler for the serializer.", e);
}
this.transformerHandler.getTransformer().setOutputProperties(this.format);
this.setContentHandler(this.transformerHandler);
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java Thu Oct 9 09:28:34 2008
@@ -28,6 +28,7 @@
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler;
+import org.apache.cocoon.pipeline.SetupException;
import org.apache.cocoon.pipeline.util.StringRepresentation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -79,7 +80,7 @@
try {
transformerHandler = this.createTransformerHandler();
} catch (Exception ex) {
- throw new RuntimeException("Could not initialize transformer handler.", ex);
+ throw new SetupException("Could not initialize transformer handler.", ex);
}
final Map<String, Object> map = this.getLogicSheetParameters();
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/URLConnectionUtils.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/URLConnectionUtils.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/URLConnectionUtils.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/URLConnectionUtils.java Thu Oct 9 09:28:34 2008
@@ -21,6 +21,8 @@
import java.io.OutputStream;
import java.net.URLConnection;
+import org.apache.cocoon.pipeline.PipelineException;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -34,8 +36,10 @@
InputStream inputStream = urlConnection.getInputStream();
XMLUtils.toSax(inputStream, xmlConsumer);
inputStream.close();
+ } catch (PipelineException e) {
+ throw e;
} catch (Exception e) {
- throw new RuntimeException("Can't parse url connection " + urlConnection.getURL(), e);
+ throw new ProcessingException("Can't parse url connection " + urlConnection.getURL(), e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java Thu Oct 9 09:28:34 2008
@@ -17,6 +17,7 @@
package org.apache.cocoon.pipeline.util;
import java.io.BufferedInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
@@ -26,8 +27,10 @@
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
@@ -36,23 +39,25 @@
private static final SAXTransformerFactory SAX_TRANSFORMER_FACTORY = (SAXTransformerFactory) TransformerFactory
.newInstance();
- public static void toSax(InputStream inputStream, XMLConsumer xmlConsumer) {
+ public static void toSax(final InputStream inputStream, final XMLConsumer xmlConsumer) throws IOException,
+ SAXException {
+ XMLReader xmlReader;
+
try {
- XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(xmlConsumer);
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", xmlConsumer);
-
- inputStream = new BufferedInputStream(inputStream);
- xmlReader.parse(new InputSource(inputStream));
- } catch (Exception e) {
+ } catch (SAXException e) {
// FIXME We have to do something with exception handling. Throwing
// plain RuntimeExceptions makes it difficult to react on different
// error conditions in your code.
- throw new RuntimeException("Can't parse inputStream.", e);
+ throw new ProcessingException("Cannot create and prepare an XMLReader.", e);
}
+
+ xmlReader.parse(new InputSource(new BufferedInputStream(inputStream)));
}
- public static void toOutputStream(OutputStream outputStream, SaxBuffer saxBuffer) {
+ public static void toOutputStream(final OutputStream outputStream, final SaxBuffer saxBuffer) {
try {
TransformerHandler transformerHandler = SAX_TRANSFORMER_FACTORY.newTransformerHandler();
Properties properties = new Properties();
@@ -64,8 +69,7 @@
saxBuffer.toSAX(new EmbeddedXMLPipe(transformerHandler));
transformerHandler.endDocument();
} catch (Exception e) {
- throw new RuntimeException("Can't stream the provided SaxBuffer.", e);
+ throw new ProcessingException("Can't stream the provided SaxBuffer.", e);
}
}
-
}
\ No newline at end of file
Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java (original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java Thu Oct 9 09:28:34 2008
@@ -32,6 +32,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.cocoon.controller.Controller;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.util.URLConnectionUtils;
import org.apache.cocoon.rest.controller.annotation.BaseURL;
import org.apache.cocoon.rest.controller.annotation.Inject;
@@ -73,7 +74,7 @@
public void invoke(OutputStream outputStream, String functionName, Map<String, Object> inputParameters,
Map<String, ? extends Object> configuration) {
if (!this.applicationContext.isPrototype(functionName)) {
- throw new RuntimeException("A REST controller bean MUST run within the 'prototype' scope.");
+ throw new ProcessingException("A REST controller bean MUST run within the 'prototype' scope.");
}
try {
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/TimestampGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/TimestampGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/TimestampGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/TimestampGenerator.java Thu Oct 9 09:28:34 2008
@@ -16,6 +16,7 @@
*/
package org.apache.cocoon.sample.generation;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.caching.CacheKey;
import org.apache.cocoon.pipeline.caching.SimpleCacheKey;
import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
@@ -38,7 +39,7 @@
consumer.endDocument();
} catch (SAXException e) {
- throw new RuntimeException(e);
+ throw new ProcessingException(e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/component/RedirectorComponent.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/component/RedirectorComponent.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/component/RedirectorComponent.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/component/RedirectorComponent.java Thu Oct 9 09:28:34 2008
@@ -26,6 +26,7 @@
import javax.servlet.http.HttpServletResponse;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.AbstractPipelineComponent;
import org.apache.cocoon.pipeline.component.Finisher;
import org.apache.cocoon.pipeline.component.Starter;
@@ -68,7 +69,7 @@
}
} catch (IOException e) {
this.logger.error("Can't redirect to " + this.uri, e);
- throw new RuntimeException(e);
+ throw new ProcessingException(e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServiceConsumerGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServiceConsumerGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServiceConsumerGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServiceConsumerGenerator.java Thu Oct 9 09:28:34 2008
@@ -22,6 +22,7 @@
import javax.servlet.http.HttpServletRequest;
+import org.apache.cocoon.pipeline.PipelineException;
import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.Starter;
import org.apache.cocoon.pipeline.component.sax.AbstractXMLProducer;
@@ -42,10 +43,16 @@
try {
inputStream = request.getInputStream();
} catch (IOException e) {
- throw new RuntimeException("Can't open inputStream on request.");
+ throw new ProcessingException("Can't open inputStream on request.");
}
- XMLUtils.toSax(inputStream, this.getXMLConsumer());
+ try {
+ XMLUtils.toSax(inputStream, this.getXMLConsumer());
+ } catch (PipelineException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ProcessingException("Can't parse inputStream.", e);
+ }
}
@Override
Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceGenerator.java Thu Oct 9 09:28:34 2008
@@ -19,6 +19,7 @@
import java.net.URL;
import java.util.Map;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.Starter;
import org.apache.cocoon.pipeline.component.sax.AbstractXMLProducer;
import org.apache.cocoon.pipeline.util.URLConnectionUtils;
@@ -35,7 +36,7 @@
try {
URLConnectionUtils.toSax(this.service.openConnection(), this.getXMLConsumer());
} catch (Exception e) {
- throw new RuntimeException("Can't parse " + this.service, e);
+ throw new ProcessingException("Can't parse " + this.service, e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceSerializer.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceSerializer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/ssf/ServletServiceSerializer.java Thu Oct 9 09:28:34 2008
@@ -23,6 +23,7 @@
import java.util.Map;
import org.apache.cocoon.pipeline.ProcessingException;
+import org.apache.cocoon.pipeline.SetupException;
import org.apache.cocoon.pipeline.component.sax.AbstractSerializer;
import org.apache.cocoon.pipeline.util.SaxBuffer;
import org.apache.cocoon.pipeline.util.URLConnectionUtils;
@@ -80,7 +81,7 @@
try {
this.service = new URL((String) configuration.get("service"));
} catch (MalformedURLException e) {
- throw new ProcessingException(("Can't create an URL for " + configuration.get("service") + "."), e);
+ throw new SetupException(("Can't create an URL for " + configuration.get("service") + "."), e);
}
}
}
\ No newline at end of file
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/component/ExceptionGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/component/ExceptionGenerator.java?rev=703203&r1=703202&r2=703203&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/component/ExceptionGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/component/ExceptionGenerator.java Thu Oct 9 09:28:34 2008
@@ -23,6 +23,7 @@
import java.util.Locale;
import java.util.Map;
+import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.Starter;
import org.apache.cocoon.pipeline.component.sax.AbstractXMLProducer;
import org.apache.cocoon.sitemap.util.ParameterHelper;
@@ -60,7 +61,7 @@
this.toSAX(throwable, this.getXMLConsumer());
this.getXMLConsumer().endDocument();
} catch (SAXException e) {
- throw new RuntimeException("Failed to generate exception document.", e);
+ throw new ProcessingException("Failed to generate exception document.", e);
}
}