Search in sources :

Example 21 with IUserProfile

use of org.apereo.portal.IUserProfile in project uPortal by Jasig.

the class ThemeNameRequestPropertiesManager method populateRequestProperties.

@Override
public <P extends Populator<String, String>> void populateRequestProperties(HttpServletRequest portletRequest, IPortletWindow portletWindow, P propertiesPopulator) {
    // get the current user profile
    IUserInstance ui = userInstanceManager.getUserInstance(portletRequest);
    IUserPreferencesManager upm = ui.getPreferencesManager();
    IUserProfile profile = upm.getUserProfile();
    // get the theme for this profile
    long themeId = profile.getThemeStylesheetId();
    IStylesheetDescriptor theme = stylesheetDao.getStylesheetDescriptor(themeId);
    // set the theme name as a portlet response property
    final String themeName = theme.getName();
    propertiesPopulator.put(IPortletRenderer.THEME_NAME_PROPERTY, themeName);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserProfile(org.apereo.portal.IUserProfile) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 22 with IUserProfile

use of org.apereo.portal.IUserProfile in project uPortal by Jasig.

the class UserInstanceManagerImpl method getUserInstance.

/**
     * Returns the UserInstance object that is associated with the given request.
     *
     * @param request Incoming HttpServletRequest
     * @return UserInstance object associated with the given request
     */
@Override
public IUserInstance getUserInstance(HttpServletRequest request) throws PortalException {
    try {
        request = this.portalRequestUtils.getOriginalPortalRequest(request);
    } catch (IllegalArgumentException iae) {
    //ignore, just means that this isn't a wrapped request
    }
    // Use request attributes first for the fastest possible retrieval
    IUserInstance userInstance = (IUserInstance) request.getAttribute(KEY);
    if (userInstance != null) {
        return userInstance;
    }
    final IPerson person;
    try {
        // Retrieve the person object that is associated with the request
        person = this.personManager.getPerson(request);
    } catch (Exception e) {
        logger.error("Exception while retrieving IPerson!", e);
        throw new PortalSecurityException("Could not retrieve IPerson", e);
    }
    if (person == null) {
        throw new PortalSecurityException("PersonManager returned null person for this request.  With no user, there's no UserInstance.  Is PersonManager misconfigured?  RDBMS access misconfigured?");
    }
    final HttpSession session = request.getSession();
    if (session == null) {
        throw new IllegalStateException("HttpServletRequest.getSession() returned a null session for request: " + request);
    }
    // Return the UserInstance object if it's in the session
    UserInstanceHolder userInstanceHolder = getUserInstanceHolder(session);
    if (userInstanceHolder != null) {
        userInstance = userInstanceHolder.getUserInstance();
        if (userInstance != null) {
            return userInstance;
        }
    }
    // Create either a UserInstance or a GuestUserInstance
    final LocaleManager localeManager = this.getLocaleManager(request, person);
    final String userAgent = this.getUserAgent(request);
    final IUserProfile userProfile = this.getUserProfile(request, person, localeManager, userAgent);
    //Create the user layout manager and user instance object
    IUserLayoutManager userLayoutManager = userLayoutManagerFactory.getUserLayoutManager(person, userProfile);
    final UserPreferencesManager userPreferencesManager = new UserPreferencesManager(person, userProfile, userLayoutManager);
    userInstance = new UserInstance(person, userPreferencesManager, localeManager);
    //Ensure the newly created UserInstance is cached in the session
    if (userInstanceHolder == null) {
        userInstanceHolder = new UserInstanceHolder();
    }
    userInstanceHolder.setUserInstance(userInstance);
    session.setAttribute(KEY, userInstanceHolder);
    request.setAttribute(KEY, userInstance);
    // Return the new UserInstance
    return userInstance;
}
Also used : HttpSession(javax.servlet.http.HttpSession) PortalSecurityException(org.apereo.portal.security.PortalSecurityException) PortalException(org.apereo.portal.PortalException) PortalSecurityException(org.apereo.portal.security.PortalSecurityException) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) IPerson(org.apereo.portal.security.IPerson) IUserProfile(org.apereo.portal.IUserProfile) LocaleManager(org.apereo.portal.i18n.LocaleManager) UserInstance(org.apereo.portal.UserInstance) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager)

Example 23 with IUserProfile

use of org.apereo.portal.IUserProfile in project uPortal by Jasig.

the class RDBMUserLayoutStore method getSystemProfileByFname.

public IUserProfile getSystemProfileByFname(String profileFname) {
    IUserProfile up = this.getUserProfileByFname(this.getSystemUser(), profileFname);
    up.setSystemProfile(true);
    return up;
}
Also used : IUserProfile(org.apereo.portal.IUserProfile)

Aggregations

IUserProfile (org.apereo.portal.IUserProfile)23 IUserInstance (org.apereo.portal.user.IUserInstance)10 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)9 IPerson (org.apereo.portal.security.IPerson)7 LocaleManager (org.apereo.portal.i18n.LocaleManager)4 IStylesheetDescriptor (org.apereo.portal.layout.om.IStylesheetDescriptor)4 Locale (java.util.Locale)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 PortalException (org.apereo.portal.PortalException)3 BrokenSecurityContext (org.apereo.portal.security.provider.BrokenSecurityContext)3 PersonImpl (org.apereo.portal.security.provider.PersonImpl)3 Document (org.w3c.dom.Document)3 ArrayList (java.util.ArrayList)2 AuthorizationException (org.apereo.portal.AuthorizationException)2 UserProfile (org.apereo.portal.UserProfile)2 IStylesheetUserPreferences (org.apereo.portal.layout.om.IStylesheetUserPreferences)2 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 Test (org.junit.Test)2 Node (org.w3c.dom.Node)2 Connection (java.sql.Connection)1