use of org.apereo.portal.portlet.rendering.PortletOutputHandler in project uPortal by Jasig.
the class PortletDelegationView method render.
/* (non-Javadoc)
* @see org.springframework.web.servlet.View#render(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
final IPortletWindowId portletWindowId = (IPortletWindowId) model.get(DELEGATE_PORTLET_WINDOW_ID);
final DelegationRequest delegationRequest = (DelegationRequest) model.get(DELEGATE_REQUEST);
final PortletRequest portletRequest = (PortletRequest) request.getAttribute(Constants.PORTLET_REQUEST);
final PortletResponse portletResponse = (PortletResponse) request.getAttribute(Constants.PORTLET_RESPONSE);
final PortletDelegationDispatcher requestDispatcher = portletDelegationLocator.getRequestDispatcher(portletRequest, portletWindowId);
if (requestDispatcher == null) {
throw new IllegalArgumentException("No PortletDelegationDispatcher exists for portlet window id: " + portletWindowId);
}
this.logger.debug("Found delegation dispatcher for portlet window id {} - {}", portletWindowId, requestDispatcher);
final DelegationResponse delegationResponse;
final String phase = (String) request.getAttribute(PortletRequest.LIFECYCLE_PHASE);
if (PortletRequest.RENDER_PHASE.equals(phase)) {
final PortletOutputHandler portletOutputHandler = (PortletOutputHandler) model.get(DELEGATE_RENDER_OUTPUT_HANDLER);
if (portletOutputHandler != null) {
this.logger.debug("Delegating RenderRequest with custom Writer and {}", delegationRequest);
delegationResponse = requestDispatcher.doRender((RenderRequest) portletRequest, (RenderResponse) portletResponse, delegationRequest, portletOutputHandler);
} else {
this.logger.debug("Delegating RenderRequest with default Writer and {}", delegationRequest);
delegationResponse = requestDispatcher.doRender((RenderRequest) portletRequest, (RenderResponse) portletResponse, delegationRequest);
}
} else if (PortletRequest.RESOURCE_PHASE.equals(phase)) {
this.logger.debug("Delegating ResourceRequest and {}", delegationRequest);
delegationResponse = requestDispatcher.doServeResource((ResourceRequest) portletRequest, (ResourceResponse) portletResponse, delegationRequest);
} else {
throw new UnsupportedOperationException("Portlet lifecycle phase " + phase + " is not supported by the delegation view");
}
this.logger.debug("{}", delegationResponse);
}
Aggregations