/**
* Process one coplet
*/
public void run() {
XMLSerializer compiler = null;
Element copletConf = (Element)this.loadedCoplet[1];
SourceParameters p = (SourceParameters)loadedCoplet[2];
try {
// Determine the resource to load
// If the coplet is customizable and has no customization info
// the customization resource is loaded, otherwise the resource
String resource = null;
boolean showCustomizePage = p.getParameterAsBoolean(PortalConstants.PARAMETER_CUSTOMIZE, false);
if (showCustomizePage == true) {
final String value = DOMUtil.getValueOf(copletConf, "customization/@uri", null);
if (value == null) {
this.logger.error("The coplet '"+this.copletID+"' is customizable but has no customization info.");
}
resource = value;
}
if (resource == null) {
resource = DOMUtil.getValueOf(copletConf, "resource/@uri");
}
boolean handlesSizable = DOMUtil.getValueAsBooleanOf(copletConf, "configuration/handlesSizable", false);
if (handlesSizable == false && p.getParameter("size", "max").equals("max") == false) {
// do nothing here
loadedCoplet[0] = new byte[0];
} else {
compiler = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
compiler.startDocument();
XMLConsumer nextConsumer = compiler;
NodeList transformations = DOMUtil.selectNodeList(copletConf,
"transformation/stylesheet");
Transformer xslT = null;
ArrayList transformers = new ArrayList();
ComponentSelector selector = null;
Request request = ObjectModelHelper.getRequest(this.objectModel);
try {
if (transformations != null && transformations.getLength() > 0) {
selector = (ComponentSelector) this.manager.lookup(Transformer.ROLE + "Selector");
nextConsumer = new IncludeXMLConsumer(nextConsumer);
for(int k = transformations.getLength()-1; k >=0; k--) {
xslT = (Transformer)selector.select("xslt");
transformers.add(xslT);
xslT.setup(resolver,
objectModel,
DOMUtil.getValueOfNode(transformations.item(k)),
new Parameters());
xslT.setConsumer(nextConsumer);
nextConsumer = xslT;
}
nextConsumer.startDocument();
}
boolean includeFragment = true;
boolean handlesParameters = DOMUtil.getValueAsBooleanOf(copletConf, "configuration/handlesParameters", true);
String size = p.getParameter("size", "max");
includeFragment = size.equals("max");
if (includeFragment == false) {
if (this.logger.isWarnEnabled() == true) {
this.logger.warn("Minimized coplet '"+copletID+"' not handled correctly.");
}
}
if ( includeFragment ) {
if (this.logger.isDebugEnabled() ) {
this.logger.debug("portal: Loading coplet " + copletID);
}
// add the parameters to the request attributes
Map info = new HashMap(3);
SessionContextImpl.copletInfo.set(info);
info.put(PortalConstants.COPLETINFO_PARAMETERS, p);
info.put(PortalConstants.COPLETINFO_PORTALURI, request.getRequestURI());
info.put(PortalConstants.COPLETINFO_STATUSPROFILE, loadedCoplet[7]);
XMLConsumer xc = new IncludeXMLConsumer(nextConsumer);
Source source = null;
try {
source = SourceUtil.getSource(resource,
null,
(handlesParameters == true ? p : null),
resolver);
resolver.toSAX(source, xc);
} finally {
resolver.release(source);
}
if (this.logger.isDebugEnabled()) {
this.logger.debug("portal: Loaded coplet " + copletID);
}
}
if (xslT != null) {
xslT.endDocument();
xslT = null;
}
} finally {
SessionContextImpl.copletInfo.set(null);
if (selector != null) {
for(int i=0; i<transformers.size(); i++) {
selector.release((Component)transformers.get(i));
}
this.manager.release(selector);
}
}
transformers.clear();
nextConsumer = null;
compiler.endDocument();
loadedCoplet[0] = compiler.getSAXFragment();
}
} catch (Exception local) {
// this exception is ignored and an error message is included
// later on when the coplet is processed
this.logger.error("Exception during processing of coplet: " + copletID, local);