Search in sources :

Example 1 with DelegationActionResponse

use of org.apereo.portal.api.portlet.DelegationActionResponse 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;
}
Also used : ActionRequest(javax.portlet.ActionRequest) PortletDelegationDispatcher(org.apereo.portal.api.portlet.PortletDelegationDispatcher) DelegateState(org.apereo.portal.api.portlet.DelegateState) ActionResponse(javax.portlet.ActionResponse) DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse)

Example 2 with DelegationActionResponse

use of org.apereo.portal.api.portlet.DelegationActionResponse in project uPortal by Jasig.

the class PortletDelegationDispatcherImpl method doAction.

@Override
public DelegationActionResponse doAction(ActionRequest actionRequest, ActionResponse actionResponse, DelegationRequest delegationRequest) throws IOException {
    final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(actionRequest);
    final HttpServletResponse response = this.portalRequestUtils.getOriginalPortalResponse(actionRequest);
    // Sanity check that the dispatch is being called by the same user it was created for
    final IPerson person = this.personManager.getPerson(request);
    if (this.userId != person.getID()) {
        throw new IllegalStateException("This dispatcher was created for userId " + this.userId + " but is being executed for userId " + person.getID());
    }
    this.setupDelegateRequestInfo(request, delegationRequest);
    final IPortletWindowId portletWindowId = this.portletWindow.getPortletWindowId();
    try {
        // TODO canRender permission checks!
        this.portletRenderer.doAction(portletWindowId, request, response);
    } catch (RuntimeException e) {
        this.logger.error("Failed to execute action on delegate", e);
        throw e;
    }
    // Get the portal URL builders for this request and check if a redirect was sent
    final IPortalActionUrlBuilder portalActionUrlBuilder = this.portalUrlProvider.getPortalActionUrlBuilder(request);
    final String redirectLocation = portalActionUrlBuilder.getRedirectLocation();
    if (redirectLocation != null) {
        final String renderUrlParamName = portalActionUrlBuilder.getRenderUrlParamName();
        // clear out the redirect from the delegate, leave it up to the parent if the redirect
        // should happen
        portalActionUrlBuilder.setRedirectLocation(null, null);
        return new DelegationActionResponse(this.getDelegateState(), redirectLocation, renderUrlParamName);
    }
    // No redirect so get the portlet's url builder and copy the state-changing data into the
    // delegate response
    final IPortletUrlBuilder portletUrlBuilder = portalActionUrlBuilder.getPortletUrlBuilder(portletWindowId);
    final WindowState windowState = portletUrlBuilder.getWindowState();
    final PortletMode portletMode = portletUrlBuilder.getPortletMode();
    final Map<String, String[]> parameters = portletUrlBuilder.getParameters();
    return new DelegationActionResponse(this.getDelegateState(), portletMode, windowState, parameters);
}
Also used : WindowState(javax.portlet.WindowState) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) HttpServletResponse(javax.servlet.http.HttpServletResponse) IPortalActionUrlBuilder(org.apereo.portal.url.IPortalActionUrlBuilder) DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) PortletMode(javax.portlet.PortletMode) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 3 with DelegationActionResponse

use of org.apereo.portal.api.portlet.DelegationActionResponse in project uPortal by Jasig.

the class DelegationActionResponseTest method testGetRenderUrlParamName.

@Test
public void testGetRenderUrlParamName() {
    delegationActionResponse = new DelegationActionResponse(null, "redirect:/index.html", "renderparam");
    Assert.assertEquals("renderparam", delegationActionResponse.getRenderUrlParamName());
}
Also used : DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) Test(org.junit.Test)

Example 4 with DelegationActionResponse

use of org.apereo.portal.api.portlet.DelegationActionResponse in project uPortal by Jasig.

the class DelegationActionResponseTest method testGetRenderParameters.

@Test
public void testGetRenderParameters() {
    delegationActionResponse = new DelegationActionResponse(null, "redirect:/index.html", "renderparam");
    Assert.assertTrue(delegationActionResponse.getRenderParameters().isEmpty());
}
Also used : DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) Test(org.junit.Test)

Example 5 with DelegationActionResponse

use of org.apereo.portal.api.portlet.DelegationActionResponse in project uPortal by Jasig.

the class DelegationActionResponseTest method testGetRenderUrlParamNameNull.

@Test
public void testGetRenderUrlParamNameNull() {
    delegationActionResponse = new DelegationActionResponse(null, null, null, null);
    Assert.assertNull(delegationActionResponse.getRenderUrlParamName());
}
Also used : DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) Test(org.junit.Test)

Aggregations

DelegationActionResponse (org.apereo.portal.api.portlet.DelegationActionResponse)7 Test (org.junit.Test)5 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2 ActionRequest (javax.portlet.ActionRequest)1 ActionResponse (javax.portlet.ActionResponse)1 PortletMode (javax.portlet.PortletMode)1 WindowState (javax.portlet.WindowState)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DelegateState (org.apereo.portal.api.portlet.DelegateState)1 PortletDelegationDispatcher (org.apereo.portal.api.portlet.PortletDelegationDispatcher)1 IPerson (org.apereo.portal.security.IPerson)1 IPortalActionUrlBuilder (org.apereo.portal.url.IPortalActionUrlBuilder)1 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)1