use of org.apereo.portal.IUserProfile in project uPortal by Jasig.
the class UserLocaleHelper method getCurrentUserLocale.
/**
* Return the current user's locale.
*
* @param request
* @return
*/
public Locale getCurrentUserLocale(PortletRequest request) {
final HttpServletRequest originalPortalRequest = this.portalRequestUtils.getPortletHttpRequest(request);
IUserInstance ui = userInstanceManager.getUserInstance(originalPortalRequest);
IUserPreferencesManager upm = ui.getPreferencesManager();
final IUserProfile userProfile = upm.getUserProfile();
LocaleManager localeManager = userProfile.getLocaleManager();
// first check the session locales
Locale[] sessionLocales = localeManager.getSessionLocales();
if (sessionLocales != null && sessionLocales.length > 0) {
return sessionLocales[0];
}
// if no session locales were found, check the user locales
Locale[] userLocales = localeManager.getUserLocales();
if (userLocales != null && userLocales.length > 0) {
return userLocales[0];
}
// just return null
return null;
}
use of org.apereo.portal.IUserProfile in project uPortal by Jasig.
the class UrlNodeSyntaxHelperRegistryImpl method getCurrentUrlNodeSyntaxHelper.
@Override
public IUrlNodeSyntaxHelper getCurrentUrlNodeSyntaxHelper(HttpServletRequest request) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserProfile userProfile = preferencesManager.getUserProfile();
final int themeStylesheetId = userProfile.getThemeStylesheetId();
final IUrlNodeSyntaxHelper themeUrlSyntaxHelper = getUrlNodeSyntaxHelperForStylesheet(themeStylesheetId);
if (themeUrlSyntaxHelper != null) {
return themeUrlSyntaxHelper;
}
final int structureStylesheetId = userProfile.getStructureStylesheetId();
final IUrlNodeSyntaxHelper structureUrlSyntaxHelper = getUrlNodeSyntaxHelperForStylesheet(structureStylesheetId);
if (structureUrlSyntaxHelper != null) {
return structureUrlSyntaxHelper;
}
throw new IllegalStateException("No IUrlNodeSyntaxHelper could be found for the current request. Review the IStylesheetDescriptor configuration.");
}
use of org.apereo.portal.IUserProfile in project uPortal by Jasig.
the class FragmentActivator method loadLayout.
private void loadLayout(UserView view, FragmentDefinition fragment, IPerson owner, Locale locale) {
// if fragment not bound to user can't return any layouts.
if (view.getUserId() == -1)
return;
// this area is hacked right now. Time won't permit how to handle
// matching up multiple profiles for a fragment with an appropriate
// one for incorporating into a user's layout based on their profile
// when they log in with a certain user agent. The challenge is
// being able to match up profiles for a user with those of a
// fragment. Until this is resolved only one profile will be supported
// and will have a hard coded id of 1 which is the default for profiles.
// If anyone changes this user all heck could break loose for dlm. :-(
Document layout = null;
try {
// fix hard coded 1 later for multiple profiles
IUserProfile profile = userLayoutStore.getUserProfileByFname(owner, "default");
profile.setLocaleManager(new LocaleManager(owner, new Locale[] { locale }));
// If not then fall back on system's selected stylesheets.
if (profile.getStructureStylesheetId() == 0 || profile.getThemeStylesheetId() == 0)
profile = userLayoutStore.getSystemProfileByFname(profile.getProfileFname());
view.setProfileId(profile.getProfileId());
view.setLayoutId(profile.getLayoutId());
layout = userLayoutStore.getFragmentLayout(owner, profile);
Element root = layout.getDocumentElement();
root.setAttribute(Constants.ATT_ID, Constants.FRAGMENT_ID_USER_PREFIX + view.getUserId() + Constants.FRAGMENT_ID_LAYOUT_PREFIX + view.getLayoutId());
view.setLayout(layout);
} catch (Exception e) {
LOG.error("Anomaly occurred while loading layout for fragment '" + fragment.getName() + "'. The fragment will not be " + "available for inclusion into user layouts.", e);
}
}
use of org.apereo.portal.IUserProfile in project uPortal by Jasig.
the class FragmentActivator method saveLayout.
/**
* Saves the loaded layout in the database for the user and profile.
*
* @param view
* @param owner
* @throws Exception
*/
private void saveLayout(UserView view, IPerson owner) throws Exception {
IUserProfile profile = new UserProfile();
profile.setProfileId(view.getProfileId());
userLayoutStore.setUserLayout(owner, profile, view.getLayout(), true, false);
}
use of org.apereo.portal.IUserProfile in project uPortal by Jasig.
the class StylesheetUserPreferencesServiceImpl method getStylesheetDescriptor.
@Override
public IStylesheetDescriptor getStylesheetDescriptor(HttpServletRequest request, PreferencesScope prefScope) {
String stylesheetName = this.getStyleSheetName(request, prefScope);
if (!StringUtils.isBlank(stylesheetName)) {
return this.stylesheetDescriptorDao.getStylesheetDescriptorByName(stylesheetName);
} else {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserProfile userProfile = preferencesManager.getUserProfile();
final int stylesheetId = prefScope.getStylesheetId(userProfile);
return this.stylesheetDescriptorDao.getStylesheetDescriptor(stylesheetId);
}
}
Aggregations