Search in sources :

Example 61 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class UserLayoutParameterProcessor method processParameters.

@Override
@SuppressWarnings("FallThrough")
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)

Example 62 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class DynamicRespondrSkinViewController method displaySkinCssHeader.

/**
 * Display Skin CSS include based on skin's configuration values from portlet preferences.<br>
 * dynamic=false: load the pre-built css file from the skins directory and default skin name;
 * e.g. RELATIVE_ROOT/{defaultSkin}.css dynamic=true: Process the default skin less file if
 * needed at RELATIVE_ROOT/{defaultSkin}.less to create a customized skin css file
 * (RELATIVE_ROOT/skin-ID#.css to load.
 */
@RenderMapping
public ModelAndView displaySkinCssHeader(RenderRequest request, RenderResponse response, Model model) throws IOException {
    if (PortletRequest.RENDER_HEADERS.equals(request.getAttribute(PortletRequest.RENDER_PART))) {
        PortletPreferences prefs = request.getPreferences();
        Boolean enabled = Boolean.valueOf(prefs.getValue(DynamicRespondrSkinConstants.PREF_DYNAMIC, "false"));
        String skinName = prefs.getValue(DynamicRespondrSkinConstants.PREF_SKIN_NAME, DynamicRespondrSkinConstants.DEFAULT_SKIN_NAME);
        String cssUrl = enabled ? calculateDynamicSkinUrlPathToUse(request, skinName) : calculateDefaultSkinCssLocationInWebapp(skinName);
        model.addAttribute(DynamicRespondrSkinConstants.SKIN_CSS_URL_MODEL_ATTRIBUTE_NAME, cssUrl);
        return new ModelAndView("jsp/DynamicRespondrSkin/skinHeader");
    } else {
        // We need to know if this user can CONFIG this skin
        // Default
        boolean canAccessSkinConfig = false;
        final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
        final IPerson user = personManager.getPerson(httpr);
        final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
        final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, request.getWindowID());
        final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
        final IPortletEntity portletEntity = portletWindow.getPortletEntity();
        if (principal.canConfigure(portletEntity.getPortletDefinitionId().toString())) {
            canAccessSkinConfig = true;
        }
        // RENDER_MARKUP
        return new ModelAndView("jsp/DynamicRespondrSkin/skinBody", DynamicRespondrSkinConstants.CAN_ACCESS_SKIN_CONFIG_MODEL_NAME, canAccessSkinConfig);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) ModelAndView(org.springframework.web.portlet.ModelAndView) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PortletPreferences(javax.portlet.PortletPreferences) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 63 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletCacheControlServiceImpl method getPortletCacheState.

/**
 * Get the cached portlet data looking in both the public and then private caches returning the
 * first found
 *
 * @param request The current request
 * @param portletWindow The window to get data for
 * @param publicCacheKey The public cache key
 * @param publicOutputCache The public cache
 * @param privateOutputCache The private cache
 */
@SuppressWarnings("unchecked")
protected <D extends CachedPortletResultHolder<T>, T extends Serializable> CacheState<D, T> getPortletCacheState(HttpServletRequest request, IPortletWindow portletWindow, PublicPortletCacheKey publicCacheKey, Ehcache publicOutputCache, Ehcache privateOutputCache) {
    final CacheState<D, T> cacheState = new CacheState<D, T>();
    cacheState.setPublicPortletCacheKey(publicCacheKey);
    final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
    // Check for publicly cached data
    D cachedPortletData = (D) this.getCachedPortletData(publicCacheKey, publicOutputCache, portletWindow);
    if (cachedPortletData != null) {
        cacheState.setCachedPortletData(cachedPortletData);
        return cacheState;
    }
    // Generate private cache key
    final HttpSession session = request.getSession();
    final String sessionId = session.getId();
    final IPortletEntityId entityId = portletWindow.getPortletEntityId();
    final PrivatePortletCacheKey privateCacheKey = new PrivatePortletCacheKey(sessionId, portletWindowId, entityId, publicCacheKey);
    cacheState.setPrivatePortletCacheKey(privateCacheKey);
    // Check for privately cached data
    cachedPortletData = (D) this.getCachedPortletData(privateCacheKey, privateOutputCache, portletWindow);
    if (cachedPortletData != null) {
        cacheState.setCachedPortletData(cachedPortletData);
        return cacheState;
    }
    return cacheState;
}
Also used : HttpSession(javax.servlet.http.HttpSession) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId)

Example 64 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletWindowRegistryImpl method createDelegatePortletWindow.

@Override
public IPortletWindow createDelegatePortletWindow(HttpServletRequest request, IPortletEntityId portletEntityId, IPortletWindowId delegationParentId) {
    Validate.notNull(request, "request can not be null");
    Validate.notNull(portletEntityId, "portletEntityId can not be null");
    // TODO does a delegate portlet entity need some sort of special treatment or do we just
    // assume that the calling code is using one?
    final IPortletWindowId portletWindowId = this.getDefaultPortletWindowId(request, portletEntityId);
    final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request);
    // Check if there is portlet window cached in the request
    IPortletWindow portletWindow = portletWindowMap.getWindow(portletWindowId);
    if (portletWindow != null) {
        logger.trace("Found IPortletWindow {} in request cache", portletWindow.getPortletWindowId());
        return portletWindow;
    }
    final PortletWindowData portletWindowData = this.getOrCreateDefaultPortletWindowData(request, portletEntityId, portletWindowId, delegationParentId);
    portletWindow = wrapPortletWindowData(request, portletWindowData);
    if (portletWindow == null) {
        return null;
    }
    // Cache the wrapped window in the request
    return portletWindowMap.storeIfAbsentWindow(portletWindow);
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 65 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletWindowRegistryImpl method convertPortletWindow.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletWindowRegistry#convertPortletWindow(javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow)
     */
@Override
public IPortletWindow convertPortletWindow(HttpServletRequest request, PortletWindow plutoPortletWindow) {
    Validate.notNull(request, "request can not be null");
    Validate.notNull(plutoPortletWindow, "portletWindow can not be null");
    // Conver the pluto portlet window ID into a uPortal portlet window ID
    final PortletWindowID plutoWindowId = plutoPortletWindow.getId();
    final IPortletWindowId portletWindowId;
    if (plutoWindowId instanceof IPortletWindowId) {
        portletWindowId = (IPortletWindowId) plutoWindowId;
    } else {
        portletWindowId = this.getPortletWindowId(request, plutoWindowId.getStringId());
    }
    // Do a new get to make sure the referenced data gets updated correctly
    return this.getPortletWindow(request, portletWindowId);
}
Also used : PortletWindowID(org.apache.pluto.container.PortletWindowID) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Aggregations

IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)85 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)31 Test (org.junit.Test)19 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)15 WindowState (javax.portlet.WindowState)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)9 PortletMode (javax.portlet.PortletMode)8 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)8 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)8 IPortletRenderExecutionWorker (org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker)7 IPerson (org.apereo.portal.security.IPerson)7 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)7 LinkedHashMap (java.util.LinkedHashMap)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 IUserInstance (org.apereo.portal.user.IUserInstance)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 IOException (java.io.IOException)5 List (java.util.List)5