}
if(renderingStatus==IChannelRenderer.RENDERING_SUCCESSFUL) {
// obtain content
if(contentHandler instanceof CachingSerializer && this.characterCaching) {
CachingSerializer cs=(CachingSerializer) contentHandler;
// need to get characters
String characterContent=cr.getCharacters();
if(characterContent==null) {
// obtain a SAX Buffer content then
SAX2BufferImpl bufferedContent=cr.getBuffer();
if(bufferedContent!=null) {
// translate SAX Buffer into the character version
try {
if(!cs.startCaching()) {
log.error("unable to restart character cache while compiling character cache for channel '"+channelSubscribeId+"' !");
}
// dump SAX buffer into the serializer
bufferedContent.outputBuffer(contentHandler);
// extract compiled character cache
if(cs.stopCaching()) {
try {
characterContent=cs.getCache();
log.debug("outputChannel 2: "+characterContent);
if(characterContent!=null) {
// save compiled character cache
cr.setCharacterCache(characterContent);
} else {
log.error("character caching serializer returned NULL character cache for channel '"+channelSubscribeId+"' !");
}
} catch (UnsupportedEncodingException e) {
log.error("unable to compile character cache for channel '"+channelSubscribeId+"'! Invalid encoding specified.",e);
} catch (IOException ioe) {
log.error("IO exception occurred while compiling character cache for channel '"+channelSubscribeId+"' !",ioe);
}
} else {
log.error("unable to reset cache state while compiling character cache for channel '"+channelSubscribeId+"' ! Serializer was not caching when it should've been ! Partial output possible!");
return;
}
} catch (IOException ioe) {
handleRenderingError(request, response, channelSubscribeId,contentHandler,ioe,renderingStatus,"encountered a problem compiling channel character content","Encountered IO exception while trying to output channel content SAX to the character caching serializer",true);
return;
} catch (org.xml.sax.SAXException se) {
handleRenderingError(request, response, channelSubscribeId,contentHandler,se,renderingStatus,"encountered a problem compiling channel character content","Encountered SAX exception while trying to output channel content SAX to the character caching serializer",true);
return;
}
} else {
handleRenderingError(request, response, channelSubscribeId,contentHandler,null,renderingStatus,"unable to obtain channel rendering","IChannelRenderer.getBuffer() returned null",false);
return;
}
} else { // non-null characterContent case
// output character content
try {
if (log.isDebugEnabled()) {
log.debug("Getting output - Writing " + characterContent.length() + " characters for " + cr.toString() + " for subscribe id: " + channelSubscribeId);
}
cs.printRawCharacters(characterContent);
} catch (IOException ioe) {
if (log.isDebugEnabled())
log.debug("" +
"exception thrown while trying to output character " +
"cache for channelSubscribeId=" +