InputSource source = new InputSource(new FileInputStream(portletXml));
source.setSystemId(portletXml.toURL().toExternalForm());
Unmarshaller unmarshaller = new Unmarshaller(this.mappingPortletXml);
unmarshaller.setIgnoreExtraElements(true);
PortletApplicationDefinitionImpl portletApp =
(PortletApplicationDefinitionImpl)unmarshaller.unmarshal( source );
WebApplicationDefinitionImpl webApp = null;
if (webXml.exists())
{
org.w3c.dom.Document webDocument =
XmlParser.parseWebXml(new FileInputStream(webXml));
unmarshaller = new Unmarshaller(this.mappingWebXml);
unmarshaller.setIgnoreExtraElements(true);
webApp = (WebApplicationDefinitionImpl)unmarshaller.unmarshal(webDocument);
Vector structure = new Vector();
structure.add(portletApp);
structure.add("/" + resolveURI(webModule));
webApp.postLoad(structure);
// refill structure with necessary information
webApp.preBuild(structure);
webApp.postBuild(structure);
if (log.isDebugEnabled())
{
log.debug(webApp.toString());
}
}
else
{
if (log.isDebugEnabled())
{
log.debug("no web.xml...");
}
Vector structure = new Vector();
structure.add("/" + resolveURI(webModule));
structure.add(null);
structure.add(null);
portletApp.postLoad(structure);
portletApp.preBuild(structure);
portletApp.postBuild(structure);
}
log.debug("Adding portletApp to registry[" + registry + "]:" + portletApp.toString());
log.debug("Before:" + registry.size());
registry.add( portletApp );
log.debug("After:" + registry.size());
if (log.isDebugEnabled())
{
if (webApp!=null)
{
log.debug("Dumping content of web.xml...");
log.debug(webApp.toString());
}
log.debug("Dumping content of portlet.xml...");
log.debug(portletApp.toString());
}
}
else
{
log.debug("Could not find " + portletXml);