Search in sources :

Example 11 with IUserInstance

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

the class PortletWindowRegistryImpl method storePortletWindow.

@Override
public void storePortletWindow(HttpServletRequest request, IPortletWindow portletWindow) {
    if (isDisablePersistentWindowStates(request)) {
        return;
    }
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPerson person = userInstance.getPerson();
    if (person.isGuest()) {
        //Never persist things for the guest user, just rely on in-memory storage
        return;
    }
    final IStylesheetDescriptor themeStylesheetDescriptor = this.getThemeStylesheetDescriptor(request);
    final WindowState windowState = portletWindow.getWindowState();
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final WindowState entityWindowState = portletEntity.getWindowState(themeStylesheetDescriptor);
    //If the window and entity states are different
    if (windowState != entityWindowState && !windowState.equals(entityWindowState)) {
        final WindowState defaultWindowState = this.getDefaultWindowState(themeStylesheetDescriptor);
        //If a window state is set and is one of the persistent states set it on the entity
        if (!defaultWindowState.equals(windowState) && persistentWindowStates.contains(windowState)) {
            portletEntity.setWindowState(themeStylesheetDescriptor, windowState);
        } else //If not remove the state from the entity
        if (entityWindowState != null) {
            portletEntity.setWindowState(themeStylesheetDescriptor, null);
        }
        //Persist the modified entity
        this.portletEntityRegistry.storePortletEntity(request, portletEntity);
    }
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) WindowState(javax.portlet.WindowState) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor)

Example 12 with IUserInstance

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

the class BaseTransformerSource method getStylesheetDescriptor.

protected IStylesheetDescriptor getStylesheetDescriptor(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final long id = this.getStylesheetDescriptorId(preferencesManager);
    return this.stylesheetDescriptorDao.getStylesheetDescriptor(id);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 13 with IUserInstance

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

the class UserLayoutStoreComponent method getUserLayoutManager.

/** Get the {@link IUserLayoutManager} for the user making the request */
protected IUserLayoutManager getUserLayoutManager(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    return preferencesManager.getUserLayoutManager();
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 14 with IUserInstance

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

the class MobileUrlNodeSyntaxHelper method getPortletForFolderName.

/* (non-Javadoc)
     * @see org.apereo.portal.url.IUrlNodeSyntaxHelper#getPortletForFolderName(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)
     */
@Override
public IPortletWindowId getPortletForFolderName(HttpServletRequest request, String targetedLayoutNodeId, String folderName) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final String fname;
    final IPortletEntity portletEntity;
    final int seperatorIndex = folderName.indexOf(PORTLET_PATH_ELEMENT_SEPERATOR);
    if (seperatorIndex <= 0 || seperatorIndex + 1 == folderName.length()) {
        fname = folderName;
        portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
    } else {
        fname = folderName.substring(0, seperatorIndex);
        final String subscribeId = folderName.substring(seperatorIndex + 1);
        portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname, subscribeId);
    }
    if (portletEntity != null) {
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, portletEntityId);
        return portletWindow.getPortletWindowId();
    } else {
        this.logger.warn(targetedLayoutNodeId + " node for portlet of folder " + folderName + " can't be targeted by the request.");
        return null;
    }
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 15 with IUserInstance

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

the class PortalHttpServletRequestWrapper method getLocale.

/* (non-Javadoc)
     * @see org.apereo.portal.url.AbstractHttpServletRequestWrapper#getLocale()
     */
@Override
public Locale getLocale() {
    if (super.getSession(false) == null) {
        return super.getLocale();
    }
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(this.getWrappedRequest());
    final LocaleManager localeManager = userInstance.getLocaleManager();
    final Locale[] locales = localeManager.getLocales();
    return locales[0];
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) Locale(java.util.Locale) LocaleManager(org.apereo.portal.i18n.LocaleManager)

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