}
PortalRequestContext portalRequestContext =
new PortalRequestContext(getServletContext(), request, response);
PortalURL portalURL = null;
try {
portalURL = portalRequestContext.getRequestedPortalURL();
} catch(Exception ex) {
String msg = "Cannot handle request for portal URL. Problem: " + ex.getMessage();
LOG.error(msg, ex);
throw new ServletException(msg, ex);
}
String actionWindowId = portalURL.getActionWindow();
String resourceWindowId = portalURL.getResourceWindow();
PortletWindowConfig actionWindowConfig = null;
PortletWindowConfig resourceWindowConfig = null;
if (resourceWindowId != null){
resourceWindowConfig = PortletWindowConfig.fromId(resourceWindowId);
} else if(actionWindowId != null){
actionWindowConfig = PortletWindowConfig.fromId(actionWindowId);
}
// Action window config will only exist if there is an action request.
if (actionWindowConfig != null) {
PortletWindowImpl portletWindow = new PortletWindowImpl(container,
actionWindowConfig, portalURL);
if (LOG.isDebugEnabled()) {
LOG.debug("Processing action request for window: "
+ portletWindow.getId().getStringId());
}
try {
container.doAction(portletWindow, request, response);
} catch (PortletContainerException ex) {
LOG.error(ex.getMessage(), ex);
throw new ServletException(ex);
} catch (PortletException ex) {
LOG.error(ex.getMessage(), ex);
throw new ServletException(ex);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Action request processed.\n\n");
}
}
//Resource request
else if (resourceWindowConfig != null) {
PortletWindowImpl portletWindow = new PortletWindowImpl(container,
resourceWindowConfig, portalURL);
if (LOG.isDebugEnabled()) {
LOG.debug("Processing resource Serving request for window: "
+ portletWindow.getId().getStringId());
}
try {
container.doServeResource(portletWindow, request, response);
} catch (PortletContainerException ex) {
LOG.error(ex.getMessage(), ex);
throw new ServletException(ex);
} catch (PortletException ex) {
LOG.error(ex.getMessage(), ex);
throw new ServletException(ex);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Resource serving request processed.\n\n");
}
}
// Otherwise (actionWindowConfig == null), handle the render request.
else {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing render request.");
}
PageConfig pageConfig = portalURL.getPageConfig(servletContext);
if (pageConfig == null)
{
String renderPath = (portalURL == null ? "" : portalURL.getRenderPath());
String msg = "PageConfig for render path [" + renderPath + "] could not be found.";
LOG.error(msg);
throw new ServletException(msg);
}