File portletXml = new File(webAppsDir + webModule + webInfDir + "portlet.xml");
File webXml = new File(webAppsDir + webModule + webInfDir + "web.xml");
Unmarshaller unmarshaller = new Unmarshaller(mappingPortletXml);
PortletApplicationDefinitionImpl portletApp =
(PortletApplicationDefinitionImpl)unmarshaller.unmarshal(new FileReader(portletXml));
// refill structure with necessary information
Vector structure = new Vector();
structure.add(webModule);
structure.add(null);
structure.add(null);
portletApp.preBuild(structure);
if (debug) {
System.out.println(portletApp);
}
// now generate web part
WebApplicationDefinitionImpl webApp = null;
if (webXml.exists()) {
Unmarshaller unmarshallerWeb = new Unmarshaller(mappingWebXml);
unmarshallerWeb.setIgnoreExtraElements(true);
webApp =
(WebApplicationDefinitionImpl) unmarshallerWeb.unmarshal(
new FileReader(webXml));
} else {
webApp = new WebApplicationDefinitionImpl();
DisplayNameImpl dispName = new DisplayNameImpl();
dispName.setDisplayName(webModule);
dispName.setLocale(Locale.ENGLISH);
DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
dispSet.add(dispName);
webApp.setDisplayNames(dispSet);
DescriptionImpl desc = new DescriptionImpl();
desc.setDescription("Automated generated Application Wrapper");
desc.setLocale(Locale.ENGLISH);
DescriptionSetImpl descSet = new DescriptionSetImpl();
descSet.add(desc);
webApp.setDescriptions(descSet);
}
ControllerFactory controllerFactory = new ControllerFactoryImpl();
ServletDefinitionListCtrl servletDefinitionSetCtrl =
(ServletDefinitionListCtrl) controllerFactory.get(
webApp.getServletDefinitionList());
Collection servletMappings = webApp.getServletMappings();
Iterator portlets = portletApp.getPortletDefinitionList().iterator();
while (portlets.hasNext()) {
PortletDefinition portlet = (PortletDefinition) portlets.next();
if ( debug ) {