tsList = context.getUserLayoutStore().getThemeStylesheetList(profile.getStructureStylesheetId());
} catch (Exception e) {
throw new PortalException(e);
}
if (tsList == null) {
throw new ResourceMissingException("", "List of theme stylesheets for the structure stylesheet \"" + profile.getStructureStylesheetId()+ "\"", "Unable to obtain a list of theme stylesheets for the specified structure stylesheet");
}
// see if the current Theme stylesheet is still in the list, otherwise assign a first one in the hastable
if (tsList.get(new Integer(profile.getThemeStylesheetId())) == null) {
if (!tsList.isEmpty()) {
Enumeration e = tsList.keys();
profile.setThemeStylesheetId(((Integer)e.nextElement()).intValue());
}
else {
// profile.setThemeStylesheetId(-1);
}
}
for (Enumeration me = tsList.keys(); me.hasMoreElements();) {
Integer ssId = (Integer)me.nextElement();
// check if the stylesheet is current
boolean current = (ssId.intValue() == profile.getThemeStylesheetId());
Element altEl;
if (current) {
altEl = doc.createElement("current");
} else {
altEl = doc.createElement("alternate");
}
ThemeStylesheetDescription tsd = (ThemeStylesheetDescription)tsList.get(ssId);
Element altnEl = doc.createElement("name");
altnEl.appendChild(doc.createTextNode(tsd.getStylesheetName()));
Element altidEl = doc.createElement("id");
altidEl.appendChild(doc.createTextNode(Integer.toString(tsd.getId())));
Element altdEl = doc.createElement("description");
altdEl.appendChild(doc.createTextNode(tsd.getStylesheetWordDescription()));
Element altmEl = doc.createElement("mimetype");
altmEl.appendChild(doc.createTextNode(tsd.getMimeType()));
// determine device icon
String deviceIconURI;
if ((deviceIconURI = mimeImagesProps.getProperty(tsd.getDeviceType())) == null) {
deviceIconURI = mimeImagesProps.getProperty("unknown");
}
Element altdiuEl = doc.createElement("deviceiconuri");
altdiuEl.appendChild(doc.createTextNode(deviceIconURI));
Element altsuEl = doc.createElement("sampleuri");
if (tsd.getSamplePictureURI() == null || tsd.getSamplePictureURI().equals("")) {
altsuEl.appendChild(doc.createTextNode(""));
} else {
altsuEl.appendChild(doc.createTextNode(tsd.getSamplePictureURI()));
}
Element altsiuEl = doc.createElement("sampleiconuri");
if (tsd.getSampleIconURI() == null || tsd.getSampleIconURI().equals("")) {
altsiuEl.appendChild(doc.createTextNode(""));
} else {
altsiuEl.appendChild(doc.createTextNode(tsd.getSampleIconURI()));
}
altEl.appendChild(altnEl);
altEl.appendChild(altidEl);
altEl.appendChild(altdEl);
altEl.appendChild(altmEl);
altEl.appendChild(altdiuEl);
altEl.appendChild(altsuEl);
altEl.appendChild(altsiuEl);
themeEl.appendChild(altEl);
}
profileEl.appendChild(themeEl);
}
doc.appendChild(profileEl);
// debug printout of the prepared xml
if (log.isDebugEnabled()) {
try {
StringWriter outString = new StringWriter();
/*
* This should be reviewed at some point to see if we can
* use the DOM3 LS capability and hence a standard way of
* doing this rather than using an internal implementation
* class.
*/
OutputFormat format = new OutputFormat();
format.setOmitXMLDeclaration(true);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(outString,
format);
serializer.serialize(doc);
log.debug(outString.toString());
} catch (Exception e) {
log.debug(e, e);
}
}
// end debug block
StylesheetSet set = context.getStylesheetSet();
if (set == null)
throw new GeneralRenderingException("Unable to determine the stylesheet list");
String xslURI = set.getStylesheetURI("editProfile", runtimeData.getBrowserInfo());
if (xslURI != null) {
ResourceBundle l18n = ResourceBundle.getBundle(bundleLocation,runtimeData.getLocales()[0]);
//Now perform the transformation
XSLT xslt = XSLT.getTransformer(this, runtimeData.getLocales());
xslt.setResourceBundle(l18n);
xslt.setXML(doc);
xslt.setXSL(this.getClass().getResource(xslURI).toString());
xslt.setTarget(out);
xslt.setStylesheetParameter("baseActionURL", runtimeData.getBaseActionURL());
xslt.transform();
} else {
throw new ResourceMissingException("", "stylesheet", "Unable to find stylesheet to display content for this media");
}
}