Search in sources :

Example 1 with UrlState

use of org.apereo.portal.url.UrlState 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;
                }
        }
        //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;
                    }
            }
        }
        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 2 with UrlState

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

the class FocusedOnOnePortletPredicate method apply.

@Override
public boolean apply(final HttpServletRequest request) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    if (null == portalRequestInfo) {
        logger.warn("Portal request info was not available for this request, " + "so assuming that it does not represent focus on one portlet.");
        // focused-on-one-portlet portal state.
        return false;
    }
    final UrlState urlState = portalRequestInfo.getUrlState();
    // true when there is a portal request and that request is not for a portal in NORMAL state
    // i.e. portal is in some other state, like Maximized or Exclusive or Detached.
    // false otherwise.
    final boolean doesRequestFocusOnOnePortlet = (!(UrlState.NORMAL.equals(urlState)));
    logger.debug("Determined request with UrlState {} {} focus on one portlet.", urlState, doesRequestFocusOnOnePortlet ? "does" : "does not");
    return doesRequestFocusOnOnePortlet;
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) UrlState(org.apereo.portal.url.UrlState)

Example 3 with UrlState

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

the class URLInSpecificState method apply.

@Override
public boolean apply(final HttpServletRequest request) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    if (null == portalRequestInfo) {
        logger.warn("Portal request info was not available for this request, " + "so assuming that it does not represent focus on one portlet.");
        // focused-on-one-portlet portal state.
        return false;
    }
    final UrlState urlState = portalRequestInfo.getUrlState();
    boolean stateEqual = urlState.toString().equals(state);
    return isNegated ? !stateEqual : stateEqual;
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) UrlState(org.apereo.portal.url.UrlState)

Example 4 with UrlState

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

the class UserLayoutParameterProcessor method processParameters.

@Override
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    final String tabId = portalRequestInfo.getTargetedLayoutNodeId();
    if (tabId != null) {
        this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "focusedTabID", tabId);
    }
    // on a portlet, it will get overwritten with the new value below.
    if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
        final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
        transientUserLayoutManagerWrapper.setFocusedId(null);
    }
    final UrlState urlState = portalRequestInfo.getUrlState();
    switch(urlState) {
        case DETACHED:
            this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "detached", Boolean.TRUE.toString());
        case MAX:
            {
                final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
                if (portletRequestInfo != null) {
                    final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
                    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetWindowId);
                    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
                    final String channelSubscribeId = portletEntity.getLayoutNodeId();
                    this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", channelSubscribeId);
                    if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
                        // get wrapper implementation for focusing
                        final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
                        // .. and now set it as the focused id
                        transientUserLayoutManagerWrapper.setFocusedId(channelSubscribeId);
                    }
                    //If portletRequestInfo was null just fall through to NORMAL state
                    break;
                }
            }
        case NORMAL:
        default:
            {
                this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", IUserLayout.ROOT_NODE_NAME);
                break;
            }
    }
    return true;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) TransientUserLayoutManagerWrapper(org.apereo.portal.layout.TransientUserLayoutManagerWrapper) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) UrlState(org.apereo.portal.url.UrlState)

Aggregations

IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)4 UrlState (org.apereo.portal.url.UrlState)4 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)2 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2 IPortletRequestInfo (org.apereo.portal.url.IPortletRequestInfo)2 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 ParameterMap (org.apereo.portal.url.ParameterMap)1 UrlType (org.apereo.portal.url.UrlType)1 IUserInstance (org.apereo.portal.user.IUserInstance)1