Search in sources :

Example 1 with IPortletRequestInfo

use of org.apereo.portal.url.IPortletRequestInfo in project uPortal by Jasig.

the class PortalEventFactoryImpl method getParameters.

protected Map<String, List<String>> getParameters(HttpServletRequest httpServletRequest, IPortletWindowId portletWindowId, boolean renderRequest) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(httpServletRequest);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getPortletRequestInfo(portletWindowId);
    if (portletRequestInfo != null) {
        final Map<String, List<String>> parameters = portletRequestInfo.getPortletParameters();
        return pruneParameters(parameters);
    }
    // Only re-use render parameters on a render request
    if (renderRequest) {
        final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
        final Map<String, String[]> parameters = portletWindow.getRenderParameters();
        return pruneParameters(ParameterMap.immutableCopyOfArrayMap(parameters));
    }
    return Collections.emptyMap();
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 2 with IPortletRequestInfo

use of org.apereo.portal.url.IPortletRequestInfo in project uPortal by Jasig.

the class PortletRequestParameterProcessor method processParameters.

/* (non-Javadoc)
     * @see org.apereo.portal.url.processing.IRequestParameterProcessor#processParameters(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
    for (final IPortletRequestInfo portletRequestInfo : portalRequestInfo.getPortletRequestInfoMap().values()) {
        final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
        final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);
        final UrlType urlType = portalRequestInfo.getUrlType();
        switch(urlType) {
            case RENDER:
                {
                    final Map<String, List<String>> portletParameters = portletRequestInfo.getPortletParameters();
                    portletWindow.setRenderParameters(ParameterMap.convertListMap(portletParameters));
                // fall through, render uses state/mode info
                }
            case ACTION:
                {
                    final WindowState windowState = portletRequestInfo.getWindowState();
                    if (windowState != null) {
                        portletWindow.setWindowState(windowState);
                    }
                    final PortletMode portletMode = portletRequestInfo.getPortletMode();
                    if (portletMode != null) {
                        portletWindow.setPortletMode(portletMode);
                    }
                    break;
                }
            default:
        }
        // Override the window state of the targeted portlet window based on the url state
        if (portletWindowId.equals(targetedPortletWindowId)) {
            final UrlState urlState = portalRequestInfo.getUrlState();
            switch(urlState) {
                case MAX:
                    {
                        portletWindow.setWindowState(WindowState.MAXIMIZED);
                        break;
                    }
                case DETACHED:
                    {
                        portletWindow.setWindowState(IPortletRenderer.DETACHED);
                        break;
                    }
                case EXCLUSIVE:
                    {
                        portletWindow.setWindowState(IPortletRenderer.EXCLUSIVE);
                        break;
                    }
                default:
            }
        }
        this.portletWindowRegistry.storePortletWindow(request, portletWindow);
    }
    return true;
}
Also used : WindowState(javax.portlet.WindowState) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) UrlType(org.apereo.portal.url.UrlType) ParameterMap(org.apereo.portal.url.ParameterMap) Map(java.util.Map) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) PortletMode(javax.portlet.PortletMode) UrlState(org.apereo.portal.url.UrlState)

Example 3 with IPortletRequestInfo

use of org.apereo.portal.url.IPortletRequestInfo in project uPortal by Jasig.

the class PortalController method renderExclusive.

@RequestMapping(headers = { "org.apereo.portal.url.UrlType=RENDER", "org.apereo.portal.url.UrlState.EXCLUSIVE=true" })
public void renderExclusive(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
    if (portletRequestInfo == null) {
        throw new IllegalArgumentException("A portlet must be targeted when using the EXCLUSIVE WindowState: " + portalRequestInfo);
    }
    final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
    this.portletExecutionManager.getPortletOutput(portletWindowId, request, response);
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with IPortletRequestInfo

use of org.apereo.portal.url.IPortletRequestInfo in project uPortal by Jasig.

the class PortalController method resourceRequest.

@RequestMapping(headers = { "org.apereo.portal.url.UrlType=RESOURCE" })
public void resourceRequest(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
    if (portletRequestInfo != null) {
        final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
        this.portletExecutionManager.doPortletServeResource(targetWindowId, request, response);
    } else {
        this.logger.error("portletRequestInfo was null for resourceRequest");
    }
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with IPortletRequestInfo

use of org.apereo.portal.url.IPortletRequestInfo in project uPortal by Jasig.

the class PortalController method actionRequest.

/**
 * HTTP POST required for security.
 */
@RequestMapping(headers = { "org.apereo.portal.url.UrlType=ACTION" }, method = RequestMethod.POST)
public void actionRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
    final IPortalUrlBuilder actionRedirectUrl;
    if (portletRequestInfo != null) {
        final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
        actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, targetWindowId, UrlType.RENDER);
    } else {
        final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
        if (targetedLayoutNodeId != null) {
            actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, targetedLayoutNodeId, UrlType.RENDER);
        } else {
            actionRedirectUrl = this.portalUrlProvider.getDefaultUrl(request);
        }
    }
    // Stuff the action-redirect URL builder into the request so other code can use it during
    // request processing
    this.portalUrlProvider.convertToPortalActionUrlBuilder(request, actionRedirectUrl);
    if (portletRequestInfo != null) {
        final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
        try {
            this.portletExecutionManager.doPortletAction(targetWindowId, request, response);
        } catch (RuntimeException e) {
            this.logger.error("Exception thrown while executing portlet action for: " + portletRequestInfo, e);
            // TODO this should be a constant right?
            actionRedirectUrl.setParameter("portletActionError", targetWindowId.toString());
        }
    }
    sendRedirect(actionRedirectUrl, response);
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)6 IPortletRequestInfo (org.apereo.portal.url.IPortletRequestInfo)6 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)5 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 UrlState (org.apereo.portal.url.UrlState)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 PortletMode (javax.portlet.PortletMode)1 WindowState (javax.portlet.WindowState)1 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)1 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)1 TransientUserLayoutManagerWrapper (org.apereo.portal.layout.TransientUserLayoutManagerWrapper)1 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)1 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)1 ParameterMap (org.apereo.portal.url.ParameterMap)1 UrlType (org.apereo.portal.url.UrlType)1 IUserInstance (org.apereo.portal.user.IUserInstance)1