use of org.apereo.portal.IUserPreferencesManager in project uPortal by Jasig.
the class PortalUrlProviderImpl method verifyPortletWindowId.
/**
* Verify the requested portlet window corresponds to a node in the user's layout and return the
* corresponding layout node id
*/
protected String verifyPortletWindowId(HttpServletRequest request, IPortletWindowId portletWindowId) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
final IPortletWindowId delegationParentWindowId = portletWindow.getDelegationParentId();
if (delegationParentWindowId != null) {
return verifyPortletWindowId(request, delegationParentWindowId);
}
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final String channelSubscribeId = portletEntity.getLayoutNodeId();
final IUserLayoutNodeDescription node = userLayoutManager.getNode(channelSubscribeId);
if (node == null) {
throw new IllegalArgumentException("No layout node exists for id " + channelSubscribeId + " of window " + portletWindowId);
}
return node.getId();
}
use of org.apereo.portal.IUserPreferencesManager in project uPortal by Jasig.
the class UserLocaleHelper method updateUserLocale.
/**
* Update the current user's locale to match the selected locale. This implementation will
* update the session locale, and if the user is not a guest, will also update the locale in the
* user's persisted preferences.
*
* @param request
* @param localeString
*/
public void updateUserLocale(HttpServletRequest request, String localeString) {
IUserInstance ui = userInstanceManager.getUserInstance(request);
IUserPreferencesManager upm = ui.getPreferencesManager();
final IUserProfile userProfile = upm.getUserProfile();
LocaleManager localeManager = userProfile.getLocaleManager();
if (localeString != null) {
// build a new Locale[] array from the specified locale
Locale userLocale = parseLocale(localeString);
Locale[] locales = new Locale[] { userLocale };
// set this locale in the session
localeManager.setSessionLocales(locales);
// if the current user is logged in, also update the persisted
// user locale
final IPerson person = ui.getPerson();
if (!person.isGuest()) {
try {
localeManager.persistUserLocales(new Locale[] { userLocale });
localeStore.updateUserLocales(person, new Locale[] { userLocale });
// remove person layout framgent from session since it contains some of the data in previous
// translation and won't be cleared until next logout-login (applies when using
// RDBMDistributedLayoutStore as user layout store).
person.setAttribute(Constants.PLF, null);
upm.getUserLayoutManager().loadUserLayout(true);
} catch (Exception e) {
throw new PortalException(e);
}
}
}
}
use of org.apereo.portal.IUserPreferencesManager in project uPortal by Jasig.
the class LayoutRESTController method getRESTController.
/**
* A REST call to get a json feed of the current users layout. Intent was to provide a layout
* document without per-tab information for mobile device rendering.
*
* @param request The servlet request. Utilized to get the users instance and eventually there
* layout
* @param tab The tab name of which you would like to filter; optional; if not provided, will
* return entire layout.
* @return json feed of the layout
* @deprecated Use /api/v4-3/dlm/layout.json. It has much more information about portlets and
* includes regions and breakout per tab
*/
@Deprecated
@RequestMapping(value = "/layoutDoc", method = RequestMethod.GET)
public ModelAndView getRESTController(HttpServletRequest request, @RequestParam(value = "tab", required = false) String tab) {
final IPerson person = personManager.getPerson(request);
List<LayoutPortlet> portlets = new ArrayList<LayoutPortlet>();
try {
final IUserInstance ui = userInstanceManager.getUserInstance(request);
final IUserPreferencesManager upm = ui.getPreferencesManager();
final IUserProfile profile = upm.getUserProfile();
final DistributedUserLayout userLayout = userLayoutStore.getUserLayout(person, profile);
Document document = userLayout.getLayout();
NodeList portletNodes = null;
if (tab != null) {
NodeList folders = document.getElementsByTagName("folder");
for (int i = 0; i < folders.getLength(); i++) {
Node node = folders.item(i);
if (tab.equalsIgnoreCase(node.getAttributes().getNamedItem("name").getNodeValue())) {
TabListOfNodes tabNodes = new TabListOfNodes();
tabNodes.addAllChannels(node.getChildNodes());
portletNodes = tabNodes;
break;
}
}
} else {
portletNodes = document.getElementsByTagName("channel");
}
for (int i = 0; i < portletNodes.getLength(); i++) {
try {
NamedNodeMap attributes = portletNodes.item(i).getAttributes();
IPortletDefinition def = portletDao.getPortletDefinitionByFname(attributes.getNamedItem("fname").getNodeValue());
LayoutPortlet portlet = new LayoutPortlet(def);
portlet.setNodeId(attributes.getNamedItem("ID").getNodeValue());
//get alt max URL
String alternativeMaximizedLink = def.getAlternativeMaximizedLink();
if (alternativeMaximizedLink != null) {
portlet.setUrl(alternativeMaximizedLink);
portlet.setAltMaxUrl(true);
} else {
// get the maximized URL for this portlet
final IPortalUrlBuilder portalUrlBuilder = urlProvider.getPortalUrlBuilderByLayoutNode(request, attributes.getNamedItem("ID").getNodeValue(), UrlType.RENDER);
final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
if (targetPortletWindowId != null) {
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(targetPortletWindowId);
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
}
portlet.setUrl(portalUrlBuilder.getUrlString());
portlet.setAltMaxUrl(false);
}
portlets.add(portlet);
} catch (Exception e) {
log.warn("Exception construction JSON representation of mobile portlet", e);
}
}
ModelAndView mv = new ModelAndView();
mv.addObject("layout", portlets);
mv.setViewName("json");
return mv;
} catch (Exception e) {
log.error("Error retrieving user layout document", e);
}
return null;
}
use of org.apereo.portal.IUserPreferencesManager in project uPortal by Jasig.
the class StylesheetUserPreferencesServiceImpl method getStylesheetPreferencesKey.
protected final StylesheetPreferencesKey getStylesheetPreferencesKey(HttpServletRequest request, PreferencesScope prefScope) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserProfile userProfile = preferencesManager.getUserProfile();
final IStylesheetDescriptor stylesheetDescriptor = getStylesheetDescriptor(request, prefScope);
return new StylesheetPreferencesKey(person, userProfile, stylesheetDescriptor);
}
use of org.apereo.portal.IUserPreferencesManager in project uPortal by Jasig.
the class StylesheetUserPreferencesServiceImpl method getDistributedStylesheetUserPreferences.
protected final IStylesheetUserPreferences getDistributedStylesheetUserPreferences(HttpServletRequest request, PreferencesScope prefScope) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final IUserLayout userLayout = userLayoutManager.getUserLayout();
return prefScope.getDistributedIStylesheetUserPreferences(userLayout);
}
Aggregations