use of org.apereo.portal.api.portlet.DelegateState in project uPortal by Jasig.
the class PortletAdministrationHelper method configModeAction.
public boolean configModeAction(ExternalContext externalContext, String fname) throws IOException {
final ActionRequest actionRequest = (ActionRequest) externalContext.getNativeRequest();
final ActionResponse actionResponse = (ActionResponse) externalContext.getNativeResponse();
final IPortletWindowId portletWindowId = this.getDelegateWindowId(externalContext, fname);
if (portletWindowId == null) {
throw new IllegalStateException("Cannot execute configModeAciton without a delegate window ID in the session for key: " + RenderPortletTag.DEFAULT_SESSION_KEY_PREFIX + fname);
}
final PortletDelegationDispatcher requestDispatcher = this.portletDelegationLocator.getRequestDispatcher(actionRequest, portletWindowId);
final DelegationActionResponse delegationResponse = requestDispatcher.doAction(actionRequest, actionResponse);
final String redirectLocation = delegationResponse.getRedirectLocation();
final DelegateState delegateState = delegationResponse.getDelegateState();
if (redirectLocation != null || (delegationResponse.getPortletMode() != null && !IPortletRenderer.CONFIG.equals(delegationResponse.getPortletMode())) || !IPortletRenderer.CONFIG.equals(delegateState.getPortletMode())) {
//The portlet sent a redirect OR changed it's mode away from CONFIG, assume it is done
return true;
}
return false;
}
use of org.apereo.portal.api.portlet.DelegateState 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;
}
use of org.apereo.portal.api.portlet.DelegateState in project uPortal by Jasig.
the class PortletDelegationDispatcherImpl method setupDelegateRequestInfo.
protected void setupDelegateRequestInfo(HttpServletRequest request, DelegationRequest delegationRequest) {
if (delegationRequest == null) {
return;
}
final DelegateState delegateState = delegationRequest.getDelegateState();
if (delegateState != null) {
final PortletMode portletMode = delegateState.getPortletMode();
if (portletMode != null) {
this.portletWindow.setPortletMode(portletMode);
}
final WindowState windowState = delegateState.getWindowState();
if (windowState != null) {
this.portletWindow.setWindowState(windowState);
}
}
final IPortletWindowId portletWindowId = this.portletWindow.getPortletWindowId();
//Store the DelegationRequest so it can be accessed elsewhere
this.portletDelegationManager.setDelegationRequest(request, portletWindowId, delegationRequest);
}
Aggregations