use of org.apereo.portal.portlet.om.IPortletEntity 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.portlet.om.IPortletEntity 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.portlet.om.IPortletEntity in project uPortal by Jasig.
the class PortletWindowRegistryImpl method storePortletWindow.
@Override
public void storePortletWindow(HttpServletRequest request, IPortletWindow portletWindow) {
if (isDisablePersistentWindowStates(request)) {
return;
}
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
if (person.isGuest()) {
//Never persist things for the guest user, just rely on in-memory storage
return;
}
final IStylesheetDescriptor themeStylesheetDescriptor = this.getThemeStylesheetDescriptor(request);
final WindowState windowState = portletWindow.getWindowState();
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final WindowState entityWindowState = portletEntity.getWindowState(themeStylesheetDescriptor);
//If the window and entity states are different
if (windowState != entityWindowState && !windowState.equals(entityWindowState)) {
final WindowState defaultWindowState = this.getDefaultWindowState(themeStylesheetDescriptor);
//If a window state is set and is one of the persistent states set it on the entity
if (!defaultWindowState.equals(windowState) && persistentWindowStates.contains(windowState)) {
portletEntity.setWindowState(themeStylesheetDescriptor, windowState);
} else //If not remove the state from the entity
if (entityWindowState != null) {
portletEntity.setWindowState(themeStylesheetDescriptor, null);
}
//Persist the modified entity
this.portletEntityRegistry.storePortletEntity(request, portletEntity);
}
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class MobileUrlNodeSyntaxHelper method getPortletForFolderName.
/* (non-Javadoc)
* @see org.apereo.portal.url.IUrlNodeSyntaxHelper#getPortletForFolderName(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)
*/
@Override
public IPortletWindowId getPortletForFolderName(HttpServletRequest request, String targetedLayoutNodeId, String folderName) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final String fname;
final IPortletEntity portletEntity;
final int seperatorIndex = folderName.indexOf(PORTLET_PATH_ELEMENT_SEPERATOR);
if (seperatorIndex <= 0 || seperatorIndex + 1 == folderName.length()) {
fname = folderName;
portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
} else {
fname = folderName.substring(0, seperatorIndex);
final String subscribeId = folderName.substring(seperatorIndex + 1);
portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname, subscribeId);
}
if (portletEntity != null) {
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, portletEntityId);
return portletWindow.getPortletWindowId();
} else {
this.logger.warn(targetedLayoutNodeId + " node for portlet of folder " + folderName + " can't be targeted by the request.");
return null;
}
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class JpaPortletEntityDao method deletePortletEntity.
@Override
@PortalTransactional
public void deletePortletEntity(IPortletEntity portletEntity) {
Validate.notNull(portletEntity, "portletEntity can not be null");
final IPortletEntity persistentPortletEntity;
final EntityManager entityManager = this.getEntityManager();
if (entityManager.contains(portletEntity)) {
persistentPortletEntity = portletEntity;
} else {
persistentPortletEntity = entityManager.merge(portletEntity);
}
entityManager.remove(persistentPortletEntity);
}
Aggregations