if (contextPath == null) {
throw new IllegalArgumentException(
"Portlet application context path cannot be null.");
}
try {
PortletApplicationConfig portletAppConfig =
new PortletApplicationConfig();
portletAppConfig.setContextPath(contextPath);
ServletContext portletAppServletContext = servletContext.getContext(contextPath);
if (portletAppServletContext == null) {
final String msg = "Unable to locate servlet context: " + contextPath
+ ": ensure that crossContext support is enabled "
+ "and the portlet application has been deployed.";
LOG.error(msg);
throw new DriverAdministrationException(msg);
}
PortletContainer container = (PortletContainer)servletContext
.getAttribute(AttributeKeys.PORTLET_CONTAINER);
PortletAppDD portletAppDD = container.getPortletApplicationDescriptor(contextPath);
if (portletAppDD == null) {
final String msg = "Unable to retrieve portlet application descriptor from "
+ contextPath + ": ensure that the portlet application "
+ "has been deployed.";
LOG.error(msg);
throw new DriverAdministrationException(msg);
}
for (Iterator it = portletAppDD.getPortlets().iterator();
it.hasNext(); ) {
PortletDD portletDD = (PortletDD) it.next();
PortletWindowConfig portletWindowConfig = new PortletWindowConfig();
portletWindowConfig.setContextPath(contextPath);
portletWindowConfig.setPortletName(portletDD.getPortletName());
portletAppConfig.addPortlet(portletWindowConfig);
}
config.addPortletApp(portletAppConfig);
} catch (PortletContainerException ex) {
final String msg = "Unable to add portlet application from " + contextPath;