Search in sources :

Example 6 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class PortletEntityRegistryImpl method getOrCreateDefaultPortletEntity.

@Override
public IPortletEntity getOrCreateDefaultPortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(portletDefinitionId, "portletDefinitionId cannot be null");
    final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionId);
    if (portletDefinition == null) {
        throw new IllegalArgumentException("No portlet definition found for id '" + portletDefinitionId + "'.");
    }
    //Determine the appropriate portlet window ID for the definition
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    //Determine the subscribe ID
    final String portletFName = portletDefinition.getFName();
    final String layoutNodeId = userLayoutManager.getSubscribeId(portletFName);
    if (layoutNodeId == null) {
        throw new IllegalArgumentException("No layout node ID found for fname '" + portletFName + "'.");
    }
    this.logger.trace("Found layout node {} for portlet definition {}", layoutNodeId, portletFName);
    final IPerson person = userInstance.getPerson();
    final int personId = person.getID();
    return this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, personId);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 7 with IUserInstance

use of org.apereo.portal.user.IUserInstance 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 8 with IUserInstance

use of org.apereo.portal.user.IUserInstance 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 9 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindowByFname.

@Override
public IPortletWindow getOrCreateDefaultPortletWindowByFname(HttpServletRequest request, String fname) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(fname, "fname cannot be null");
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
    if (portletEntity == null) {
        return null;
    }
    final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntity.getPortletEntityId());
    logger.trace("Found portlet window {} for portlet definition fname {}", portletWindow, fname);
    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 10 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class PortletWindowRegistryImpl method getThemeStylesheetDescriptor.

protected IStylesheetDescriptor getThemeStylesheetDescriptor(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserProfile userProfile = preferencesManager.getUserProfile();
    final int themeStylesheetId = userProfile.getThemeStylesheetId();
    return stylesheetDescriptorDao.getStylesheetDescriptor(themeStylesheetId);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserProfile(org.apereo.portal.IUserProfile) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Aggregations

IUserInstance (org.apereo.portal.user.IUserInstance)62 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)28 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)27 IPerson (org.apereo.portal.security.IPerson)25 PortalException (org.apereo.portal.PortalException)14 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 IUserLayoutNodeDescription (org.apereo.portal.layout.node.IUserLayoutNodeDescription)12 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)12 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)12 ModelAndView (org.springframework.web.servlet.ModelAndView)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)10 IUserProfile (org.apereo.portal.IUserProfile)10 Locale (java.util.Locale)9 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 HashMap (java.util.HashMap)6 IUserLayout (org.apereo.portal.layout.IUserLayout)6 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)6 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)6 UserLayoutFolderDescription (org.apereo.portal.layout.node.UserLayoutFolderDescription)5