Search in sources :

Example 11 with IUserProfile

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

the class RDBMUserLayoutStore method getSystemProfileList.

public Hashtable getSystemProfileList() {
    Hashtable pl = this.getUserProfileList(this.getSystemUser());
    for (Enumeration e = pl.elements(); e.hasMoreElements(); ) {
        IUserProfile up = (IUserProfile) e.nextElement();
        up.setSystemProfile(true);
    }
    return pl;
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable) IUserProfile(org.apereo.portal.IUserProfile)

Example 12 with IUserProfile

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

the class NodeReferenceFactory method getUserLayoutTuple.

/*
     * Implementation.
     */
/**
     * Provides a {@link Tuple} containing the "fragmentized" version of a DLM fragment
     * owner's layout, together with the username. This version of the layout consistent with what
     * DLM uses internally for fragments, and is created by FragmentActivator.fragmentizeLayout.
     * It's important that the version returned by this method matches what DLM uses internally
     * because it will be used to establish relationships between fragment layout nodes and user
     * customizations of DLM fragments.
     *
     * @param userId
     * @return
     */
/* TODO:  make private */
Tuple<String, DistributedUserLayout> getUserLayoutTuple(String userName, int userId) {
    final PersonImpl person = new PersonImpl();
    person.setUserName(userName);
    person.setID(userId);
    person.setSecurityContext(new BrokenSecurityContext());
    final IUserProfile profile = layoutStore.getUserProfileByFname(person, UserProfile.DEFAULT_PROFILE_FNAME);
    final DistributedUserLayout userLayout = layoutStore.getUserLayout(person, (UserProfile) profile);
    return new Tuple<String, DistributedUserLayout>(userName, userLayout);
}
Also used : PersonImpl(org.apereo.portal.security.provider.PersonImpl) IUserProfile(org.apereo.portal.IUserProfile) BrokenSecurityContext(org.apereo.portal.security.provider.BrokenSecurityContext) Tuple(org.apereo.portal.utils.Tuple)

Example 13 with IUserProfile

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

the class UserInstanceManagerImpl method getUserProfile.

protected IUserProfile getUserProfile(HttpServletRequest request, IPerson person, LocaleManager localeManager, String userAgent) {
    final String profileFname = profileMapper.getProfileFname(person, request);
    IUserProfile userProfile = userLayoutStore.getUserProfileByFname(person, profileFname);
    if (userProfile == null) {
        userProfile = userLayoutStore.getSystemProfileByFname(profileFname);
    }
    if (localeManager != null && LocaleManager.isLocaleAware()) {
        userProfile.setLocaleManager(localeManager);
    }
    return userProfile;
}
Also used : IUserProfile(org.apereo.portal.IUserProfile)

Example 14 with IUserProfile

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

the class StylesheetUserPreferencesServiceImplTest method testThemeStylesheetUserPreferences.

/** @throws Exception */
@Test
public void testThemeStylesheetUserPreferences() throws Exception {
    //Setup mocks
    final HttpServletRequest request = new MockHttpServletRequest();
    //initialize the session
    request.getSession();
    final IStylesheetDescriptorDao stylesheetDescriptorDao = mock(IStylesheetDescriptorDao.class);
    final IUserInstanceManager userInstanceManager = mock(IUserInstanceManager.class);
    final IStylesheetUserPreferencesDao stylesheetUserPreferencesDao = mock(IStylesheetUserPreferencesDao.class);
    final IFragmentDefinitionUtils fragmentUtils = mock(IFragmentDefinitionUtils.class);
    final IUserInstance userInstance = mock(IUserInstance.class);
    when(userInstanceManager.getUserInstance(request)).thenReturn(userInstance);
    final IPerson person = mock(IPerson.class);
    when(userInstance.getPerson()).thenReturn(person);
    final IUserPreferencesManager preferencesManager = mock(IUserPreferencesManager.class);
    when(userInstance.getPreferencesManager()).thenReturn(preferencesManager);
    final IUserProfile userProfile = mock(IUserProfile.class);
    when(preferencesManager.getUserProfile()).thenReturn(userProfile);
    final IUserLayoutManager userLayoutManager = mock(IUserLayoutManager.class);
    when(preferencesManager.getUserLayoutManager()).thenReturn(userLayoutManager);
    final IUserLayout userLayout = mock(IUserLayout.class);
    when(userLayoutManager.getUserLayout()).thenReturn(userLayout);
    when(userProfile.getThemeStylesheetId()).thenReturn(1);
    final IStylesheetDescriptor stylesheetDescriptor = mock(IStylesheetDescriptor.class);
    when(stylesheetDescriptorDao.getStylesheetDescriptor(1)).thenReturn(stylesheetDescriptor);
    final ILayoutAttributeDescriptor skinLayoutAttributeDescriptor = mock(ILayoutAttributeDescriptor.class);
    when(stylesheetDescriptor.getLayoutAttributeDescriptor("minimized")).thenReturn(skinLayoutAttributeDescriptor);
    when(skinLayoutAttributeDescriptor.getName()).thenReturn("minimized");
    when(skinLayoutAttributeDescriptor.getScope()).thenReturn(Scope.REQUEST);
    when(skinLayoutAttributeDescriptor.getTargetElementNames()).thenReturn(Collections.singleton("folder"));
    final IOutputPropertyDescriptor mediaOutputPropertyDescriptor = mock(IOutputPropertyDescriptor.class);
    when(stylesheetDescriptor.getOutputPropertyDescriptor("media")).thenReturn(mediaOutputPropertyDescriptor);
    when(mediaOutputPropertyDescriptor.getName()).thenReturn("media");
    when(mediaOutputPropertyDescriptor.getScope()).thenReturn(Scope.SESSION);
    final IStylesheetParameterDescriptor skinStylesheetParameterDescriptor = mock(IStylesheetParameterDescriptor.class);
    when(stylesheetDescriptor.getStylesheetParameterDescriptor("skin")).thenReturn(skinStylesheetParameterDescriptor);
    when(skinStylesheetParameterDescriptor.getName()).thenReturn("media");
    when(skinStylesheetParameterDescriptor.getScope()).thenReturn(Scope.PERSISTENT);
    final IStylesheetUserPreferences persistentStylesheetUserPreferences = mock(IStylesheetUserPreferences.class);
    when(stylesheetUserPreferencesDao.createStylesheetUserPreferences(stylesheetDescriptor, person, userProfile)).thenReturn(persistentStylesheetUserPreferences);
    when(stylesheetUserPreferencesDao.getStylesheetUserPreferences(stylesheetDescriptor, person, userProfile)).thenReturn(persistentStylesheetUserPreferences);
    when(persistentStylesheetUserPreferences.getStylesheetParameter("skin")).thenReturn(null).thenReturn("red");
    //Create and initialize service bean
    final StylesheetUserPreferencesServiceImpl stylesheetUserPreferencesService = new StylesheetUserPreferencesServiceImpl();
    stylesheetUserPreferencesService.setStylesheetDescriptorDao(stylesheetDescriptorDao);
    stylesheetUserPreferencesService.setUserInstanceManager(userInstanceManager);
    stylesheetUserPreferencesService.setStylesheetUserPreferencesDao(stylesheetUserPreferencesDao);
    stylesheetUserPreferencesService.setFragmentDefinitionUtils(fragmentUtils);
    //Run test
    String actual;
    actual = stylesheetUserPreferencesService.getLayoutAttribute(request, PreferencesScope.THEME, "u1l1n1", "minimized");
    assertNull(actual);
    actual = stylesheetUserPreferencesService.setLayoutAttribute(request, PreferencesScope.THEME, "u1l1n1", "minimized", "true");
    assertNull(actual);
    actual = stylesheetUserPreferencesService.getLayoutAttribute(request, PreferencesScope.THEME, "u1l1n1", "minimized");
    assertEquals("true", actual);
    actual = stylesheetUserPreferencesService.getStylesheetParameter(request, PreferencesScope.THEME, "skin");
    assertNull(actual);
    actual = stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.THEME, "skin", "red");
    verify(persistentStylesheetUserPreferences).setStylesheetParameter("skin", "red");
    assertNull(actual);
    actual = stylesheetUserPreferencesService.getStylesheetParameter(request, PreferencesScope.THEME, "skin");
    assertEquals("red", actual);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) IStylesheetDescriptorDao(org.apereo.portal.layout.dao.IStylesheetDescriptorDao) ILayoutAttributeDescriptor(org.apereo.portal.layout.om.ILayoutAttributeDescriptor) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IOutputPropertyDescriptor(org.apereo.portal.layout.om.IOutputPropertyDescriptor) IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) IStylesheetUserPreferencesDao(org.apereo.portal.layout.dao.IStylesheetUserPreferencesDao) IUserProfile(org.apereo.portal.IUserProfile) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IStylesheetUserPreferences(org.apereo.portal.layout.om.IStylesheetUserPreferences) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserInstanceManager(org.apereo.portal.user.IUserInstanceManager) IFragmentDefinitionUtils(org.apereo.portal.utils.IFragmentDefinitionUtils) Test(org.junit.Test)

Example 15 with IUserProfile

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

the class LoginPortletHelper method getSelectedProfile.

/**
     * Get the profile that should be pre-selected in the local login form.
     *
     * @param request
     * @return
     */
public String getSelectedProfile(PortletRequest request) {
    // if a profile selection exists in the session, use it
    final PortletSession session = request.getPortletSession();
    String profileName = (String) session.getAttribute(SessionAttributeProfileMapperImpl.DEFAULT_SESSION_ATTRIBUTE_NAME, PortletSession.APPLICATION_SCOPE);
    // the user
    if (profileName == null) {
        // get the profile for the current request
        final HttpServletRequest httpServletRequest = portalRequestUtils.getPortletHttpRequest(request);
        final IUserInstance ui = userInstanceManager.getUserInstance(httpServletRequest);
        final IUserProfile profile = ui.getPreferencesManager().getUserProfile();
        // the profile key map used by the session attribute profile mapper
        for (Map.Entry<String, String> entry : mappings.entrySet()) {
            if (entry.getValue().equals(profile.getProfileFname())) {
                profileName = entry.getKey();
                break;
            }
        }
    }
    return profileName;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IUserInstance(org.apereo.portal.user.IUserInstance) PortletSession(javax.portlet.PortletSession) IUserProfile(org.apereo.portal.IUserProfile) Map(java.util.Map)

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