defaultCoplets == null ||
mediaCoplets == null ||
portalLayouts == null ||
copleyLayouts == null ||
miscNodes == null) {
throw new ProcessingException("portal: No portal profile found.");
}
// get the configuration
Map config = this.getConfiguration();
if (config == null) {
throw new ProcessingException("No configuration for portal found.");
}
boolean processCopletsParallel = false;
long defaultCopletTimeout = 600000;
Boolean boolValue = (Boolean)config.get(PortalConstants.CONF_PARALLEL_COPLETS);
if (boolValue != null) processCopletsParallel = boolValue.booleanValue();
Long longValue = (Long)config.get(PortalConstants.CONF_COPLET_TIMEOUT);
if (longValue != null) defaultCopletTimeout = longValue.longValue();
Element element;
// now start producing xml:
AttributesImpl attr = new AttributesImpl();
if (configMode == true) {
this.sendStartElementEvent(consumer, PortalConstants.ELEMENT_PORTALCONF);
} else {
this.sendStartElementEvent(consumer, PortalConstants.ELEMENT_PORTAL);
}
// configuration
this.streamConfiguration(consumer, this.request.getRequestURI(), profileID, mediaType, null);
// LAYOUT:
if (configMode == true) {
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","layout-profile"}, false),
consumer, consumer);
// copletsConfiguration (only for configMode)
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","coplets-profile"}, false),
consumer, consumer);
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","type-profile","typedefs"}, false),
consumer, consumer);
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","portal-profile"}, false),
consumer, consumer);
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","personal-profile"}, false),
consumer, consumer);
IncludeXMLConsumer.includeNode(DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","status-profile"}, false),
consumer, consumer);
} else {
PortalManager.streamLayoutProfile(consumer, portalLayouts, copleyLayouts, mediaType);
}
// END LAYOUT
if (configMode == false) {
Element statusProfile = (Element)DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","status-profile"}, false);
String copletNotAvailableMessage = "The coplet is currently not available.";
Node messages = miscNodes[PortalConstants.PROFILE_MISC_MESSAGES_NODE];
if (messages != null) {
messages = DOMUtil.getFirstNodeFromPath(messages, new String[] {"coplet_not_available"}, false);
if (messages != null) copletNotAvailableMessage = DOMUtil.getValueOfNode(messages,
copletNotAvailableMessage);
}
// LOAD COPLETS
List[] copletContents;
copletContents = (List[])context.getAttribute(PortalConstants.ATTRIBUTE_COPLET_REPOSITORY);
if (copletContents == null) {
copletContents = new List[PortalConstants.MAX_COLUMNS+2];
context.setAttribute(PortalConstants.ATTRIBUTE_COPLET_REPOSITORY, copletContents);
}
if (copletContents[0] == null) {
copletContents[0] = new ArrayList(1);
} else {
copletContents[0].clear();
}
if (copletContents[1] == null) {
copletContents[1] = new ArrayList(1);
} else {
copletContents[1].clear();
}
// test for header
String value;
value = DOMUtil.getValueOfNode(miscNodes[PortalConstants.PROFILE_MISC_HEADER_NODE]);
if (value != null && new Boolean(value).booleanValue() == true) {
element = (Element)miscNodes[PortalConstants.PROFILE_MISC_HEADER_CONTENT_NODE];
if (element != null) {
this.loadCoplets(element,
defaultCoplets,
mediaCoplets,
copletContents[0],
processCopletsParallel,
defaultCopletTimeout,
statusProfile);
}
}
// content
value = DOMUtil.getValueOfNode(miscNodes[PortalConstants.PROFILE_MISC_COLUMNS_NODE]);
// for a simpler XSL-Stylesheet: The columns must be inserted in the
// correct order!!!
if (value != null && new Integer(value).intValue() > 0) {
Element columnElement;
int columns = new Integer(value).intValue();
if (columns > PortalConstants.MAX_COLUMNS) {
throw new ProcessingException("portal: Maximum number of columns supported is: "+PortalConstants.MAX_COLUMNS);
}
for(int colindex = 1; colindex <= columns; colindex++) {
if (copletContents[colindex+1] == null) {
copletContents[colindex+1] = new ArrayList(10);
} else {
copletContents[colindex+1].clear();
}
columnElement = (Element)miscNodes[7 + colindex];
element = (Element)DOMUtil.getFirstNodeFromPath(columnElement, new String[] {"coplets"}, false);
if (element != null) {
this.loadCoplets(element,
defaultCoplets,
mediaCoplets,
copletContents[colindex+1],
processCopletsParallel,
defaultCopletTimeout,
statusProfile);
}
}
for(int colindex = columns+2; colindex <= PortalConstants.MAX_COLUMNS+1; colindex++) {
if (copletContents[colindex] != null) {
copletContents[colindex] = null;
}
}
} else {
for(int colindex = 1; colindex <= PortalConstants.MAX_COLUMNS; colindex++) {
if (copletContents[colindex+1] != null) {
copletContents[colindex+1] = null;
}
}
}
// test for footer
value = DOMUtil.getValueOfNode(miscNodes[PortalConstants.PROFILE_MISC_FOOTER_NODE]);
if (value != null && new Boolean(value).booleanValue() == true) {
element = (Element)miscNodes[PortalConstants.PROFILE_MISC_FOOTER_CONTENT_NODE];
if (element != null) {
this.loadCoplets(element,
defaultCoplets,
mediaCoplets,
copletContents[1],
processCopletsParallel,
defaultCopletTimeout,
statusProfile);
}
}
// END LOAD COPLETS
// DESIGN
// test for header
if (copletContents[0].size() > 0) {
consumer.startElement("", "header", "header", attr);
this.processCopletList(copletContents[0], consumer, copletNotAvailableMessage, defaultCopletTimeout);
consumer.endElement("", "header", "header");
}
// content
value = DOMUtil.getValueOfNode(miscNodes[PortalConstants.PROFILE_MISC_COLUMNS_NODE]);
// for a simpler XSL-Stylesheet: The columns must be inserted in the
// correct order!!!
if (value != null && new Integer(value).intValue() > 0) {
attr.addAttribute("", "number", "number", "CDATA", value);
this.sendStartElementEvent(consumer, "columns", attr);
attr.clear();
int columns = new Integer(value).intValue();
if (columns > PortalConstants.MAX_COLUMNS) {
throw new ProcessingException("portal: Maximum number of columns supported is: "+PortalConstants.MAX_COLUMNS);
}
// determine the width of the columns
String[] width = new String[columns];
int normalWidth = 100 / columns;
Element columnElement;
for(int colindex = 1; colindex <= columns; colindex++) {
columnElement = (Element)miscNodes[7 + colindex];
value = DOMUtil.getValueOf(columnElement, "width");
if (value == null) {
width[colindex-1] = "" + normalWidth + "%";
} else {
width[colindex-1] = value;
}
}
for(int colindex = 1; colindex <= columns; colindex++) {
attr.addAttribute("", "position", "position", "CDATA", "" + colindex);
attr.addAttribute("", "width", "width", "CDATA", width[colindex-1]);
this.sendStartElementEvent(consumer, "column", attr);
attr.clear();
this.processCopletList(copletContents[colindex+1], consumer, copletNotAvailableMessage, defaultCopletTimeout);
this.sendEndElementEvent(consumer, "column");
}
this.sendEndElementEvent(consumer, "columns");
} else {
attr.addAttribute("", "number", "number", "CDATA", "0");
this.sendStartElementEvent(consumer, "columns", attr);
this.sendEndElementEvent(consumer, "columns");
attr.clear();
}
// test for footer
if (copletContents[1].size() > 0) {
this.sendStartElementEvent(consumer, "footer");
this.processCopletList(copletContents[1], consumer, copletNotAvailableMessage, defaultCopletTimeout);
this.sendEndElementEvent(consumer, "footer");
}
// END DESIGN
for(int i=0; i<copletContents.length;i++) {
if (copletContents[i]!=null) copletContents[i].clear();
}
// Personal information and status information
this.sendEvents(consumer, DOMUtil.getFirstNodeFromPath(profile, new String[] {"profile","personal-profile"}, false));
this.sendEvents(consumer, statusProfile);
}
if (configMode == true) {
this.sendEndElementEvent(consumer, PortalConstants.ELEMENT_PORTALCONF);
} else {
this.sendEndElementEvent(consumer, PortalConstants.ELEMENT_PORTAL);
}
} catch (javax.xml.transform.TransformerException local) { // end synchronized
throw new ProcessingException("TransformerException: " + local, local);
} finally {
this.getSessionManager().stopReadingTransaction(context);
}
if (this.getLogger().isDebugEnabled() == true) {
this.getLogger().debug("END showPortal");