this.portletDelegationLocator = portletDelegationLocator;
}
public IPortletWindowId doInit(IPortletEntity portletEntity, IPortletWindowId portletWindowId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
final IPortletWindow portletWindow;
if (portletWindowId != null) {
portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
if (portletWindow == null) {
throw new IllegalArgumentException("Portlet window is null but a portlet window ID has been configured for it: " + portletWindowId);
}
}
else {
portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(httpServletRequest, portletEntityId);
}
//init the portlet window
final StringWriter initResultsOutput = new StringWriter();
final PortletHttpServletResponseWrapper portletHttpServletResponseWrapper = new PortletHttpServletResponseWrapper(httpServletResponse, new PrintWriter(initResultsOutput));
httpServletRequest = this.setupPortletRequest(httpServletRequest, portletWindow, null);
try {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Loading portlet window '" + portletWindow + "'");
}
this.portletContainer.doLoad(portletWindow, httpServletRequest, portletHttpServletResponseWrapper);
}
catch (PortletException pe) {
throw new PortletLoadFailureException("The portlet window '" + portletWindow + "' threw an exception while being loaded.", portletWindow, pe);
}
catch (PortletContainerException pce) {
throw new PortletLoadFailureException("The portlet container threw an exception while loading portlet window '" + portletWindow + "'.", portletWindow, pce);
}
catch (IOException ioe) {
throw new PortletLoadFailureException("The portlet window '" + portletWindow + "' threw an exception while being loaded.", portletWindow, ioe);
}
final StringBuffer initResults = initResultsOutput.getBuffer();
if (initResults.length() > 0) {
throw new PortletLoadFailureException("Content was written to response during loading of portlet window '" + portletWindow + "' . Response Content: " + initResults, portletWindow);
}
return portletWindow.getPortletWindowId();
}