use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletEntityRegistryImpl method getOrCreateDefaultPortletEntity.
@Override
public IPortletEntity getOrCreateDefaultPortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
Validate.notNull(request, "HttpServletRequest cannot be null");
Validate.notNull(portletDefinitionId, "portletDefinitionId cannot be null");
final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionId);
if (portletDefinition == null) {
throw new IllegalArgumentException("No portlet definition found for id '" + portletDefinitionId + "'.");
}
//Determine the appropriate portlet window ID for the definition
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
//Determine the subscribe ID
final String portletFName = portletDefinition.getFName();
final String layoutNodeId = userLayoutManager.getSubscribeId(portletFName);
if (layoutNodeId == null) {
throw new IllegalArgumentException("No layout node ID found for fname '" + portletFName + "'.");
}
this.logger.trace("Found layout node {} for portlet definition {}", layoutNodeId, portletFName);
final IPerson person = userInstance.getPerson();
final int personId = person.getID();
return this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, personId);
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindowByLayoutNodeId.
@Override
public IPortletWindow getOrCreateDefaultPortletWindowByLayoutNodeId(HttpServletRequest request, String subscribeId) {
Validate.notNull(request, "HttpServletRequest cannot be null");
Validate.notNull(subscribeId, "subscribeId cannot be null");
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, subscribeId);
if (portletEntity == null) {
logger.debug("No portlet entity found for id {}, no IPortletWindow will be returned.", subscribeId);
return null;
}
logger.trace("Found portlet entity {} for id {}", portletEntity, subscribeId);
final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntity.getPortletEntityId());
logger.trace("Found portlet window {} for layout node {}", portletWindow, subscribeId);
return portletWindow;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getAllLayoutPortletWindows.
@Override
@RequestCache(keyMask = { false })
public Set<IPortletWindow> getAllLayoutPortletWindows(HttpServletRequest request) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final Set<String> allSubscribedChannels = userLayoutManager.getAllSubscribedChannels();
final Set<IPortletWindow> allLayoutWindows = new LinkedHashSet<IPortletWindow>(allSubscribedChannels.size());
for (final String channelSubscribeId : allSubscribedChannels) {
final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, channelSubscribeId);
if (portletEntity == null) {
this.logger.debug("No portlet entity found for layout node {} for user {}", channelSubscribeId, userInstance.getPerson().getUserName());
continue;
}
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntityId);
if (portletWindow == null) {
this.logger.debug("No portlet window found for {}", portletEntity);
continue;
}
allLayoutWindows.add(portletWindow);
}
return allLayoutWindows;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindowByFname.
@Override
public IPortletWindow getOrCreateDefaultPortletWindowByFname(HttpServletRequest request, String fname) {
Validate.notNull(request, "HttpServletRequest cannot be null");
Validate.notNull(fname, "fname cannot be null");
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
if (portletEntity == null) {
return null;
}
final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntity.getPortletEntityId());
logger.trace("Found portlet window {} for portlet definition fname {}", portletWindow, fname);
return portletWindow;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getThemeStylesheetDescriptor.
protected IStylesheetDescriptor getThemeStylesheetDescriptor(HttpServletRequest request) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserProfile userProfile = preferencesManager.getUserProfile();
final int themeStylesheetId = userProfile.getThemeStylesheetId();
return stylesheetDescriptorDao.getStylesheetDescriptor(themeStylesheetId);
}
Aggregations