use of org.apereo.portal.user.IUserInstance 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);
}
}
use of org.apereo.portal.user.IUserInstance 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);
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class CachedPasswordUserInfoService method getUserInfo.
/*
* (non-Javadoc)
* @see org.apache.pluto.container.UserInfoService#getUserInfo(javax.portlet.PortletRequest, org.apache.pluto.container.PortletWindow)
*/
@Override
public Map<String, String> getUserInfo(PortletRequest request, PortletWindow portletWindow) throws PortletContainerException {
Map<String, String> userInfo = new HashMap<String, String>();
// check to see if a password is expected by this portlet
if (isPasswordRequested(request, portletWindow)) {
log.debug("Portlet named {} wants a password", portletWindow.getPortletDefinition().getPortletName());
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final IUserInstance userInstance = userInstanceManager.getUserInstance(httpServletRequest);
final IPerson person = userInstance.getPerson();
final ISecurityContext context = person.getSecurityContext();
// if it is, attempt to request a password
String password = getPassword(context);
log.debug(password != null ? "Have a non-null password" : "password was null");
if (this.decryptPassword && password != null) {
log.debug("Attempting to decrypt password");
password = stringEncryptionService.decrypt(password);
log.debug("Password decryption complete, password is length {}", password != null ? password.length() : "is null");
}
if (password != null) {
userInfo.put(this.passwordKey, password);
log.debug("Found password with length {} for portlet name {}", password.length() != 0 ? "non-zero" : 0, portletWindow.getPortletDefinition().getPortletName());
}
}
return userInfo;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class FavoritesController method initializeView.
/**
* Handles all Favorites portlet VIEW mode renders. Populates model with user's favorites and
* selects a view to display those favorites.
*
* <p>View selection:
*
* <p>Returns "jsp/Favorites/view" in the normal case where the user has at least one favorited
* portlet or favorited collection.
*
* <p>Returns "jsp/Favorites/view_zero" in the edge case where the user has zero favorited
* portlets AND zero favorited collections.
*
* <p>Model: marketPlaceFname --> String functional name of Marketplace portlet, or null if not
* available. collections --> List of favorited collections (IUserLayoutNodeDescription s)
* favorites --> List of favorited individual portlets (IUserLayoutNodeDescription s)
*
* @param model . Spring model. This method adds three model attributes.
* @return jsp/Favorites/view[_zero]
*/
@RenderMapping
public String initializeView(Model model) {
IUserInstance ui = userInstanceManager.getUserInstance(portalRequestUtils.getCurrentPortalRequest());
UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
IUserLayoutManager ulm = upm.getUserLayoutManager();
IUserLayout userLayout = ulm.getUserLayout();
// TODO: the portlet could predicate including a non-null marketplace portlet fname
// on the accessing user having permission to render the portlet referenced by that fname
// so that portlet would gracefully degrade when configured with bad marketplace portlet fname
// and also gracefully degrade when the accessing user doesn't have permission to access an otherwise
// viable configured marketplace. This complexity may not be worth it. Anyway it is not yet implemented.
model.addAttribute("marketplaceFname", this.marketplaceFName);
List<IUserLayoutNodeDescription> collections = FavoritesUtils.getFavoriteCollections(userLayout);
model.addAttribute("collections", collections);
List<IUserLayoutNodeDescription> favorites = FavoritesUtils.getFavoritePortlets(userLayout);
model.addAttribute("favorites", favorites);
// default to the regular old view
String viewName = "jsp/Favorites/view";
if (collections.isEmpty() && favorites.isEmpty()) {
// special edge case of zero favorites, switch to special view
viewName = "jsp/Favorites/view_zero";
}
logger.trace("Favorites Portlet VIEW mode render populated model [{}] for render by view {}.", model, viewName);
return viewName;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletWorkerFactoryImpl method getErrorPortletWindowId.
protected IPortletWindowId getErrorPortletWindowId(HttpServletRequest request, String fname) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPortletEntity errorPortletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, errorPortletEntity.getPortletEntityId());
return portletWindow.getPortletWindowId();
}
Aggregations