use of org.apereo.portal.api.portlet.DelegationRequest in project uPortal by Jasig.
the class PortalUrlProviderImpl method getPortalUrlBuilderByPortletWindow.
protected IPortalUrlBuilder getPortalUrlBuilderByPortletWindow(HttpServletRequest request, IPortletWindow portletWindow, UrlType urlType) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
//See if the targeted portlet is actually a delegate
final IPortletWindowId parentPortletWindowId = portletWindow.getDelegationParentId();
if (parentPortletWindowId != null) {
//Get the portal url builder that targets the parent
final IPortalUrlBuilder portalUrlBuilder = this.getPortalUrlBuilderByPortletWindow(request, parentPortletWindowId, urlType);
//See if there is additional delegation request data that needs to be added to the URL
final DelegationRequest delegationRequest = this.portletDelegationManager.getDelegationRequest(request, portletWindowId);
if (delegationRequest != null) {
final IPortletUrlBuilder parentPortletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(parentPortletWindowId);
final Map<String, List<String>> parentParameters = delegationRequest.getParentParameters();
if (parentParameters != null) {
parentPortletUrlBuilder.setParameters(parentParameters);
}
final PortletMode parentPortletMode = delegationRequest.getParentPortletMode();
if (parentPortletMode != null) {
parentPortletUrlBuilder.setPortletMode(parentPortletMode);
}
final WindowState parentWindowState = delegationRequest.getParentWindowState();
if (parentWindowState != null) {
parentPortletUrlBuilder.setWindowState(parentWindowState);
}
}
return portalUrlBuilder;
}
//create the portlet url builder
final String layoutNodeId = this.verifyPortletWindowId(request, portletWindowId);
return new PortalUrlBuilder(this.urlSyntaxProvider, request, layoutNodeId, portletWindowId, urlType);
}
use of org.apereo.portal.api.portlet.DelegationRequest 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);
}
use of org.apereo.portal.api.portlet.DelegationRequest in project uPortal by Jasig.
the class RenderPortletTag method doEndTag.
@Override
public int doEndTag() throws JspException {
//From portlet:defineObjects
final RenderRequest renderRequest = (RenderRequest) this.pageContext.getAttribute("renderRequest");
final RenderResponse renderResponse = (RenderResponse) this.pageContext.getAttribute("renderResponse");
final PortletDelegationLocator portletDelegationLocator = (PortletDelegationLocator) renderRequest.getAttribute(PortletDelegationLocator.PORTLET_DELECATION_LOCATOR_ATTR);
final String sessionKey = this.sessionKeyPrefix + this.fname;
final PortletSession portletSession = renderRequest.getPortletSession();
IPortletWindowId portletWindowId = (IPortletWindowId) portletSession.getAttribute(sessionKey);
final PortletDelegationDispatcher portletDelegationDispatcher;
final DelegateState delegateState;
//No id in session, create a new dispatcher
if (portletWindowId == null) {
portletDelegationDispatcher = portletDelegationLocator.createRequestDispatcher(renderRequest, this.fname);
portletWindowId = portletDelegationDispatcher.getPortletWindowId();
portletSession.setAttribute(sessionKey, portletWindowId);
final PortletMode portletMode = PortletUtils.getPortletMode(this.portletMode);
final WindowState windowState = PortletUtils.getWindowState(this.windowState);
delegateState = new DelegateState(portletMode, windowState);
} else //id in session, get the old dispatcher
{
portletDelegationDispatcher = portletDelegationLocator.getRequestDispatcher(renderRequest, portletWindowId);
delegateState = null;
}
final DelegationRequest delegationRequest = new DelegationRequest();
delegationRequest.setDelegateState(delegateState);
//Setup base for portlet URLs
delegationRequest.setParentPortletMode(this.parentUrlMode);
delegationRequest.setParentWindowState(this.parentUrlState);
delegationRequest.setParentParameters(this.parentUrlParameters);
final JspWriter out = this.pageContext.getOut();
try {
portletDelegationDispatcher.doRender(renderRequest, renderResponse, delegationRequest, new JspWriterPortletOutputHandler(out, renderResponse));
} catch (IOException e) {
throw new JspException("Failed to execute delegate render on portlet '" + this.fname + "'", e);
}
return Tag.EVAL_PAGE;
}
Aggregations