package org.greenstone.gsdl3.core; import java.io.File ; import java.io.FileReader; import org.apache.xerces.parsers.DOMParser; import org.greenstone.gsdl3.util.*; import org.w3c.dom.*; import org.xml.sax.InputSource; import java.util.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; public class Skin { public File rootDirectory ; public Document config ; private Receptionist receptionist ; protected DOMParser parser = null; TransformerFactory transformerFactory=null; private HashMap xsltPagesByAction ; public Skin(Page page, Receptionist receptionist) throws Exception{ this.receptionist = receptionist ; this.transformerFactory = org.apache.xalan.processor.TransformerFactoryImpl.newInstance(); transformerFactory.setURIResolver(new MyUriResolver()) ; this.parser = new DOMParser(); this.parser.setFeature("http://xml.org/sax/features/validation", false); // don't try and load external DTD - no need if we are not validating, and may cause connection errors if a proxy is not set up. this.parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); // a performance test showed that having this on lead to increased // memory use for small-medium docs, and not much gain for large // docs. // http://www.sosnoski.com/opensrc/xmlbench/conclusions.html this.parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false); String siteHome = GSFile.siteHome(GlobalProperties.getGSDL3Home(), page.getSite()) ; Document collectUi = page.getCollectUi() ; if (collectUi != null) { //System.out.println("looking for skin defined at collect level") ; String collectHome = GSFile.collectionBaseDir(siteHome, page.getCollection()) ; Element xmlSkin = (Element) GSXML.getChildByTagName(collectUi.getFirstChild(), "skin") ; if (xmlSkin != null) { //System.out.println("skin defined at collect level") ; boolean inherit = Boolean.parseBoolean(xmlSkin.getAttribute("inherit")) ; if (inherit != true) { boolean local = Boolean.parseBoolean(xmlSkin.getAttribute("local")) ; if (local == true) { rootDirectory = new File(collectHome + File.separatorChar + "ui") ; } else { String name = xmlSkin.getAttribute("name") ; rootDirectory = new File(GlobalProperties.getGSDL3Home() + File.separatorChar + "ui" + File.separatorChar + "skins" + File.separatorChar + File.separatorChar + name) ; } } } } Document siteUi = page.getSiteUi() ; if (rootDirectory == null && siteUi != null) { //System.out.println("lookding for skin defined at site level") ; Element xmlSkin = (Element) GSXML.getChildByTagName(siteUi.getFirstChild(), "skin") ; if (xmlSkin != null) { //System.out.println("skin defined at site level") ; boolean local = Boolean.parseBoolean(xmlSkin.getAttribute("local")) ; if (local == true) { rootDirectory = new File(siteHome + File.separatorChar + "ui") ; } else { String name = xmlSkin.getAttribute("name") ; rootDirectory = new File(GlobalProperties.getGSDL3Home() + File.separatorChar + "ui" + File.separatorChar + "skins" + File.separatorChar + name) ; } } } if(rootDirectory == null) { rootDirectory = new File(GlobalProperties.getGSDL3Home() + File.separatorChar + "ui" + File.separatorChar + "skins" + File.separatorChar + "default") ; } File configFile = new File(rootDirectory.getAbsolutePath() + File.separatorChar + "skin.xml") ; config = receptionist.converter.getDOM(configFile, "utf-8"); // store which xslt pages are responsible for which actions xsltPagesByAction = new HashMap() ; NodeList actions = config.getElementsByTagName("action") ; for (int ai=0 , an=actions.getLength() ; ai