Search in sources :

Example 11 with IPortletWindow

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

the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindowByLayoutNodeId.

@Override
public IPortletWindow getOrCreateDefaultPortletWindowByLayoutNodeId(HttpServletRequest request, String subscribeId) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(subscribeId, "subscribeId cannot be null");
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, subscribeId);
    if (portletEntity == null) {
        logger.debug("No portlet entity found for id {}, no IPortletWindow will be returned.", subscribeId);
        return null;
    }
    logger.trace("Found portlet entity {} for id {}", portletEntity, subscribeId);
    final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntity.getPortletEntityId());
    logger.trace("Found portlet window {} for layout node {}", portletWindow, subscribeId);
    return portletWindow;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 12 with IPortletWindow

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

the class PortletWindowRegistryImpl method getOrCreateStatelessPortletWindow.

@Override
public IPortletWindow getOrCreateStatelessPortletWindow(HttpServletRequest request, IPortletWindowId basePortletWindowId) {
    //Need the basePortletWindowId to be an instance of PortletWindowIdImpl so that we can extract the entity ID
    if (!(basePortletWindowId instanceof PortletWindowIdImpl)) {
        final String basePortletWindowIdStr = basePortletWindowId.getStringId();
        basePortletWindowId = this.getPortletWindowId(request, basePortletWindowIdStr);
    }
    //Get the entity ID for the portlet window
    final IPortletEntityId portletEntityId = ((PortletWindowIdImpl) basePortletWindowId).getPortletEntityId();
    //Create the stateless ID
    final PortletWindowIdImpl statelessPortletWindowId = this.createPortletWindowId(STATELESS_PORTLET_WINDOW_ID, portletEntityId);
    //See if there is already a request cached stateless window
    IPortletWindow statelessPortletWindow = this.getPortletWindow(request, statelessPortletWindowId);
    if (statelessPortletWindow != null) {
        return statelessPortletWindow;
    }
    //Lookup the base portlet window to clone the stateless from
    final IPortletWindow basePortletWindow = this.getPortletWindow(request, basePortletWindowId);
    final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, true);
    //If no base to clone from lookup the entity and pluto definition data
    if (basePortletWindow == null) {
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
        if (portletEntity == null) {
            throw new IllegalArgumentException("No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId);
        }
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
        final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    } else //Clone the existing base window
    {
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        portletWindowData.setExpirationCache(basePortletWindow.getExpirationCache());
        portletWindowData.setPortletMode(basePortletWindow.getPortletMode());
        portletWindowData.setWindowState(basePortletWindow.getWindowState());
        portletWindowData.setPublicRenderParameters(basePortletWindow.getPublicRenderParameters());
        portletWindowData.setRenderParameters(basePortletWindow.getRenderParameters());
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        final IPortletEntity portletEntity = basePortletWindow.getPortletEntity();
        final PortletDefinition portletDescriptor = basePortletWindow.getPlutoPortletWindow().getPortletDefinition();
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    }
    //Cache the stateless window in the request
    final PortletWindowCache<IPortletWindow> portletWindowMap = this.getPortletWindowMap(request);
    portletWindowMap.storeWindow(statelessPortletWindow);
    return statelessPortletWindow;
}
Also used : IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 13 with IPortletWindow

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

the class PortletWindowRegistryImpl method addPortletWindowData.

/**
     * @param request
     * @param portletEntityId
     * @param portletWindows
     * @param portletWindowMap
     * @param portletWindowDataMap
     */
protected void addPortletWindowData(HttpServletRequest request, IPortletEntityId portletEntityId, final Set<IPortletWindow> portletWindows, final PortletWindowCache<IPortletWindow> portletWindowMap, final PortletWindowCache<PortletWindowData> portletWindowDataMap) {
    final Set<PortletWindowData> windows = portletWindowDataMap.getWindows(portletEntityId);
    if (windows == null) {
        return;
    }
    for (final PortletWindowData portletWindowData : windows) {
        final IPortletWindowId portletWindowId = portletWindowData.getPortletWindowId();
        //Skip data windows that aren't for this entity and for windows that are already in the request cache
        if (!portletEntityId.equals(portletWindowData.getPortletEntityId()) || portletWindowMap.containsWindow(portletWindowId)) {
            continue;
        }
        //Wrap the data in a window and stick it in the request cache
        IPortletWindow portletWindow = this.wrapPortletWindowData(request, portletWindowData);
        portletWindow = portletWindowMap.storeIfAbsentWindow(portletWindow);
        portletWindows.add(portletWindow);
    }
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 14 with IPortletWindow

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

the class PortletWindowRegistryImpl method getAllLayoutPortletWindows.

@Override
@RequestCache(keyMask = { false })
public Set<IPortletWindow> getAllLayoutPortletWindows(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    final Set<String> allSubscribedChannels = userLayoutManager.getAllSubscribedChannels();
    final Set<IPortletWindow> allLayoutWindows = new LinkedHashSet<IPortletWindow>(allSubscribedChannels.size());
    for (final String channelSubscribeId : allSubscribedChannels) {
        final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, channelSubscribeId);
        if (portletEntity == null) {
            this.logger.debug("No portlet entity found for layout node {} for user {}", channelSubscribeId, userInstance.getPerson().getUserName());
            continue;
        }
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntityId);
        if (portletWindow == null) {
            this.logger.debug("No portlet window found for {}", portletEntity);
            continue;
        }
        allLayoutWindows.add(portletWindow);
    }
    return allLayoutWindows;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) LinkedHashSet(java.util.LinkedHashSet) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Example 15 with IPortletWindow

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

the class PortletWindowRegistryImpl method getAllPortletWindowsForEntity.

@Override
public Set<IPortletWindow> getAllPortletWindowsForEntity(HttpServletRequest request, IPortletEntityId portletEntityId) {
    Validate.notNull(request, "request can not be null");
    Validate.notNull(portletEntityId, "portletEntityId can not be null");
    final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request);
    final Set<IPortletWindow> portletWindows = new LinkedHashSet<IPortletWindow>(portletWindowMap.getWindows(portletEntityId));
    //Check for session cached windows that haven't been accessed in this request
    final PortletWindowCache<PortletWindowData> portletWindowDataMap = this.getPortletWindowDataMap(request);
    this.addPortletWindowData(request, portletEntityId, portletWindows, portletWindowMap, portletWindowDataMap);
    //Check for stateless windows that exist on this request
    final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, false);
    if (statelessPortletWindowDataMap != null) {
        this.addPortletWindowData(request, portletEntityId, portletWindows, portletWindowMap, statelessPortletWindowDataMap);
    }
    //If there were no windows in the set create the default one for the entity
    if (portletWindows.isEmpty()) {
        final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntityId);
        portletWindows.add(portletWindow);
    }
    return portletWindows;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Aggregations

IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)88 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)32 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)32 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)24 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)12 IUserInstance (org.apereo.portal.user.IUserInstance)12 List (java.util.List)10 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)10 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)9 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)9 IOException (java.io.IOException)8 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)7 WindowState (javax.portlet.WindowState)6 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 LinkedHashMap (java.util.LinkedHashMap)5 Locale (java.util.Locale)5 PortletException (javax.portlet.PortletException)5 PortletMode (javax.portlet.PortletMode)5