String pageName = request.getParameter("pageName");
if (pageName != null) {
debugWithName("Retrieved page name from request: " + pageName);
} else {
debugWithName("Creating page name...");
AdminConfiguration adminConfig = (AdminConfiguration)
getServletContext()
.getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
if (adminConfig == null) {
throw new ServletException("Invalid configuration: "
+ "an AdminConfiguration must be specified "
+ "to run the TCK.");
}
pageName = (new DecimalFormat("TCK00000")).format(pageCounter++);
PageConfig pageConfig = new PageConfig();
pageConfig.setName(pageName);
pageConfig.setUri(DEFAULT_PAGE_URI);
for (int i = 0; i < portletNames.length; i++) {
debugWithName("Processing portlet name: " + portletNames[i]);
int index = portletNames[i].indexOf("/");
String contextPath = "/" + portletNames[i].substring(0, index);
String portletName = portletNames[i].substring(index + 1);
pageConfig.addPortlet(contextPath, portletName);
adminConfig.getPortletRegistryAdminService()
.addPortletApplication(contextPath);
}
adminConfig.getRenderConfigAdminService().addPage(pageConfig);
debugWithName("Created TCK Page: " + pageName);
}
// The other possibility would be to redirect to the actual portal.
// I'm not sure which is better at this point.