OutputFormat outputFormat = null;
if (logXMLBeforeStructureTransformation) {
dbwr1 = new StringWriter();
outputFormat = new OutputFormat();
outputFormat.setIndenting(true);
XMLSerializer dbser1 = new XMLSerializer(dbwr1, outputFormat);
SAX2DuplicatingFilterImpl dupl1 = new SAX2DuplicatingFilterImpl(ssth, dbser1);
dupl1.setParent(saif);
}
// if operating in the detach mode, need wrap everything
// in a document node and a <layout_fragment> node
boolean detachMode=!rootNodeId.equals(USER_LAYOUT_ROOT_NODE);
if (detachMode) {
saif.startDocument();
saif.startElement("","layout_fragment","layout_fragment", new org.xml.sax.helpers.AttributesImpl());
// emptyt.transform(new DOMSource(rElement),new SAXResult(new ChannelSAXStreamFilter((ContentHandler)saif)));
if(rElement==null) {
ulm.getUserLayout(new ChannelSAXStreamFilter((ContentHandler)saif));
} else {
ulm.getUserLayout(rElement.getId(),new ChannelSAXStreamFilter((ContentHandler)saif));
}
saif.endElement("","layout_fragment","layout_fragment");
saif.endDocument();
} else {
if(rElement==null) {
ulm.getUserLayout((ContentHandler)saif);
} else {
ulm.getUserLayout(rElement.getId(),(ContentHandler)saif);
}
// emptyt.transform(new DOMSource(rElement),new SAXResult((ContentHandler)saif));
}
// all channels should be rendering now
// Debug piece to print out the recorded pre-structure transformation XML
if (logXMLBeforeStructureTransformation) {
if (log.isDebugEnabled())
log.debug("UserInstance::renderState() : XML incoming to the structure transformation :\n\n" + dbwr1.toString() + "\n\n");
}
// prepare for the theme transformation
// set up of the parameters
tst.setParameter("baseActionURL", uPElement.getUPFile());
tst.setParameter("baseIdempotentActionURL",uPIdempotentElement.getUPFile());
Hashtable tupTable = userPreferences.getThemeStylesheetUserPreferences().getParameterValues();
for (Enumeration e = tupTable.keys(); e.hasMoreElements();) {
String pName = (String)e.nextElement();
String pValue = (String)tupTable.get(pName);
if (log.isDebugEnabled())
log.debug("UserInstance::renderState() : setting tparam \"" + pName + "\"=\"" + pValue + "\".");
tst.setParameter(pName, pValue);
}
tst.setParameter("uP_productAndVersion", Version.getProductAndVersion());
// tst.setParameter("locale", localeManager.getLocaleFromSessionParameter());
// initialize a filter to fill in channel attributes for the "theme" (second) transformation.
// attach it downstream of the channel rendering buffer
ThemeAttributesIncorporationFilter taif = new ThemeAttributesIncorporationFilter((XMLReader)crb, userPreferences.getThemeStylesheetUserPreferences());
// attach theme transformation downstream of the theme attribute incorporation filter
taif.setAllHandlers(tsth);
// This is a debug statement that will print out XML incoming to the
// theme transformation to a log file serializer to a printstream
StringWriter dbwr2 = null;
if (logXMLBeforeThemeTransformation) {
dbwr2 = new StringWriter();
XMLSerializer dbser2 = new XMLSerializer(dbwr2, outputFormat);
SAX2DuplicatingFilterImpl dupl2 = new SAX2DuplicatingFilterImpl(tsth, dbser2);
dupl2.setParent(taif);
}
if(UserInstance.CACHE_ENABLED && !ccaching) {