use of org.apereo.portal.portlet.om.IPortletWindow 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.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getOrCreateStatelessPortletWindow.
@Override
public IPortletWindow getOrCreateStatelessPortletWindow(HttpServletRequest request, IPortletWindowId basePortletWindowId) {
//Need the basePortletWindowId to be an instance of PortletWindowIdImpl so that we can extract the entity ID
if (!(basePortletWindowId instanceof PortletWindowIdImpl)) {
final String basePortletWindowIdStr = basePortletWindowId.getStringId();
basePortletWindowId = this.getPortletWindowId(request, basePortletWindowIdStr);
}
//Get the entity ID for the portlet window
final IPortletEntityId portletEntityId = ((PortletWindowIdImpl) basePortletWindowId).getPortletEntityId();
//Create the stateless ID
final PortletWindowIdImpl statelessPortletWindowId = this.createPortletWindowId(STATELESS_PORTLET_WINDOW_ID, portletEntityId);
//See if there is already a request cached stateless window
IPortletWindow statelessPortletWindow = this.getPortletWindow(request, statelessPortletWindowId);
if (statelessPortletWindow != null) {
return statelessPortletWindow;
}
//Lookup the base portlet window to clone the stateless from
final IPortletWindow basePortletWindow = this.getPortletWindow(request, basePortletWindowId);
final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, true);
//If no base to clone from lookup the entity and pluto definition data
if (basePortletWindow == null) {
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
if (portletEntity == null) {
throw new IllegalArgumentException("No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId);
}
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
statelessPortletWindowDataMap.storeWindow(portletWindowData);
statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
} else //Clone the existing base window
{
final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
portletWindowData.setExpirationCache(basePortletWindow.getExpirationCache());
portletWindowData.setPortletMode(basePortletWindow.getPortletMode());
portletWindowData.setWindowState(basePortletWindow.getWindowState());
portletWindowData.setPublicRenderParameters(basePortletWindow.getPublicRenderParameters());
portletWindowData.setRenderParameters(basePortletWindow.getRenderParameters());
statelessPortletWindowDataMap.storeWindow(portletWindowData);
final IPortletEntity portletEntity = basePortletWindow.getPortletEntity();
final PortletDefinition portletDescriptor = basePortletWindow.getPlutoPortletWindow().getPortletDefinition();
statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
}
//Cache the stateless window in the request
final PortletWindowCache<IPortletWindow> portletWindowMap = this.getPortletWindowMap(request);
portletWindowMap.storeWindow(statelessPortletWindow);
return statelessPortletWindow;
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletWindowRegistryImpl method addPortletWindowData.
/**
* @param request
* @param portletEntityId
* @param portletWindows
* @param portletWindowMap
* @param portletWindowDataMap
*/
protected void addPortletWindowData(HttpServletRequest request, IPortletEntityId portletEntityId, final Set<IPortletWindow> portletWindows, final PortletWindowCache<IPortletWindow> portletWindowMap, final PortletWindowCache<PortletWindowData> portletWindowDataMap) {
final Set<PortletWindowData> windows = portletWindowDataMap.getWindows(portletEntityId);
if (windows == null) {
return;
}
for (final PortletWindowData portletWindowData : windows) {
final IPortletWindowId portletWindowId = portletWindowData.getPortletWindowId();
//Skip data windows that aren't for this entity and for windows that are already in the request cache
if (!portletEntityId.equals(portletWindowData.getPortletEntityId()) || portletWindowMap.containsWindow(portletWindowId)) {
continue;
}
//Wrap the data in a window and stick it in the request cache
IPortletWindow portletWindow = this.wrapPortletWindowData(request, portletWindowData);
portletWindow = portletWindowMap.storeIfAbsentWindow(portletWindow);
portletWindows.add(portletWindow);
}
}
use of org.apereo.portal.portlet.om.IPortletWindow 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.IPortletWindow in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getAllPortletWindowsForEntity.
@Override
public Set<IPortletWindow> getAllPortletWindowsForEntity(HttpServletRequest request, IPortletEntityId portletEntityId) {
Validate.notNull(request, "request can not be null");
Validate.notNull(portletEntityId, "portletEntityId can not be null");
final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request);
final Set<IPortletWindow> portletWindows = new LinkedHashSet<IPortletWindow>(portletWindowMap.getWindows(portletEntityId));
//Check for session cached windows that haven't been accessed in this request
final PortletWindowCache<PortletWindowData> portletWindowDataMap = this.getPortletWindowDataMap(request);
this.addPortletWindowData(request, portletEntityId, portletWindows, portletWindowMap, portletWindowDataMap);
//Check for stateless windows that exist on this request
final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, false);
if (statelessPortletWindowDataMap != null) {
this.addPortletWindowData(request, portletEntityId, portletWindows, portletWindowMap, statelessPortletWindowDataMap);
}
//If there were no windows in the set create the default one for the entity
if (portletWindows.isEmpty()) {
final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntityId);
portletWindows.add(portletWindow);
}
return portletWindows;
}
Aggregations