}
} catch ( SocketException se ) {
if (se.getMessage().indexOf("reset") > 0
|| se.getMessage().indexOf("aborted") > 0
|| se.getMessage().indexOf("connection abort") > 0) {
throw new ConnectionResetException(
"Connection reset by peer", se);
} else {
throw new ProcessingException(
"Failed to execute pipeline.", se);
}
} catch ( Exception e ) {
if (e instanceof ProcessingException)
throw (ProcessingException)e;
throw new ProcessingException("Error executing pipeline.",e);
}
} else {
if (this.getLogger().isDebugEnabled() && this.toCacheKey != null) {
this.getLogger().debug(
"processXMLPipeline: caching content for further" +
" requests of '" + environment.getURI() +
"' using key " + this.toCacheKey);
}
try {
OutputStream os = null;
if (this.cacheCompleteResponse && this.toCacheKey != null) {
os = new CachingOutputStream(environment.getOutputStream(
this.outputBufferSize));
}
if (super.serializer != super.lastConsumer) {
if (os == null) {
os = environment.getOutputStream(this.outputBufferSize);
}
// internal processing
if (this.xmlDeserializer != null) {
this.xmlDeserializer.deserialize(this.cachedResponse);
} else {
this.generator.generate();
}
} else {
if (this.serializer.shouldSetContentLength()) {
if (os == null) {
os = environment.getOutputStream(0);
}
// set the output stream
ByteArrayOutputStream baos =
new ByteArrayOutputStream();
this.serializer.setOutputStream(baos);
// execute the pipeline:
if ( this.xmlDeserializer != null ) {
this.xmlDeserializer.deserialize(
this.cachedResponse);
} else {
this.generator.generate();
}
environment.setContentLength(baos.size());
baos.writeTo(os);
} else {
if (os == null) {
os = environment.getOutputStream(
this.outputBufferSize);
}
// set the output stream
this.serializer.setOutputStream(os);
// execute the pipeline:
if (this.xmlDeserializer != null) {
this.xmlDeserializer.deserialize(
this.cachedResponse);
} else {
this.generator.generate();
}
}
}
//
// Now that we have processed the pipeline,
// we do the actual caching
//
this.cacheResults(environment,os);
} catch (SocketException se) {
if (se.getMessage().indexOf("reset") > 0
|| se.getMessage().indexOf("aborted") > 0
|| se.getMessage().indexOf("connection abort") > 0) {
throw new ConnectionResetException(
"Connection reset by peer", se);
} else {
throw new ProcessingException(
"Failed to execute pipeline.", se);
}