use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletExecutionManager method startPortletRenderInternal.
/**
* create and submit the portlet content rendering job to the thread pool
*/
protected IPortletRenderExecutionWorker startPortletRenderInternal(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
// first check to see if there is a Throwable in the session for this IPortletWindowId
final Map<IPortletWindowId, Exception> portletFailureMap = getPortletErrorMap(request);
final Exception cause = portletFailureMap.remove(portletWindowId);
final IPortletRenderExecutionWorker portletRenderExecutionWorker;
if (null != cause) {
// previous action failed, dispatch to errorPortlet immediately
portletRenderExecutionWorker = this.portletWorkerFactory.createFailureWorker(request, response, portletWindowId, cause);
} else {
IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(request, portletWindowId);
IPortletDefinition portletDef = portletWindow.getPortletEntity().getPortletDefinition();
if (portletDef.getLifecycleState().equals(PortletLifecycleState.MAINTENANCE)) {
// Prevent the portlet from rendering; replace with a helpful "Out of Service"
// message
final IPortletDefinitionParameter messageParam = portletDef.getParameter(PortletLifecycleState.CUSTOM_MAINTENANCE_MESSAGE_PARAMETER_NAME);
final Exception mme = messageParam != null && StringUtils.isNotBlank(messageParam.getValue()) ? new MaintenanceModeException(messageParam.getValue()) : new MaintenanceModeException();
portletRenderExecutionWorker = this.portletWorkerFactory.createFailureWorker(request, response, portletWindowId, mme);
} else {
// Happy path
portletRenderExecutionWorker = this.portletWorkerFactory.createRenderWorker(request, response, portletWindowId);
}
}
portletRenderExecutionWorker.submit();
final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletRenderingMap = this.getPortletRenderingMap(request);
portletRenderingMap.put(portletWindowId, portletRenderExecutionWorker);
return portletRenderExecutionWorker;
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletExecutionManager method doPortletEvents.
public void doPortletEvents(PortletEventQueue eventQueue, HttpServletRequest request, HttpServletResponse response) {
if (eventQueue.getUnresolvedEvents().isEmpty()) {
return;
}
final Map<IPortletWindowId, IPortletExecutionWorker<Long>> eventWorkers = new LinkedHashMap<IPortletWindowId, IPortletExecutionWorker<Long>>();
// TODO what to do if we hit the max iterations?
int iteration = 0;
for (; iteration < this.maxEventIterations; iteration++) {
// Make sure all queued events have been resolved
this.eventCoordinationService.resolvePortletEvents(request, eventQueue);
// Create and submit an event worker for each window with a queued event
for (final IPortletWindowId eventWindowId : eventQueue) {
if (eventWorkers.containsKey(eventWindowId)) {
/*
* PLT.15.2.5 says that event processing per window must be serialized, if there
* is already a working in the map for the window ID skip it for now. we'll get back to it eventually
*/
continue;
}
final QueuedEvent queuedEvent = eventQueue.pollEvent(eventWindowId);
if (queuedEvent != null) {
final Event event = queuedEvent.getEvent();
final IPortletExecutionWorker<Long> portletEventExecutionWorker = this.portletWorkerFactory.createEventWorker(request, response, eventWindowId, event);
eventWorkers.put(eventWindowId, portletEventExecutionWorker);
portletEventExecutionWorker.submit();
}
}
// If no event workers exist we're done with event processing!
if (eventWorkers.isEmpty()) {
return;
}
// See if any of the events have completed
int completedEventWorkers = 0;
final Set<Entry<IPortletWindowId, IPortletExecutionWorker<Long>>> entrySet = eventWorkers.entrySet();
for (final Iterator<Entry<IPortletWindowId, IPortletExecutionWorker<Long>>> eventWorkerEntryItr = entrySet.iterator(); eventWorkerEntryItr.hasNext(); ) {
final Entry<IPortletWindowId, IPortletExecutionWorker<Long>> eventWorkerEntry = eventWorkerEntryItr.next();
final IPortletExecutionWorker<Long> eventWorker = eventWorkerEntry.getValue();
if (eventWorker.isComplete()) {
final IPortletWindowId portletWindowId = eventWorkerEntry.getKey();
// TODO return number of new queued events, use to break the loop earlier
waitForEventWorker(request, eventQueue, eventWorker, portletWindowId);
eventWorkerEntryItr.remove();
completedEventWorkers++;
}
}
/*
* If no event workers have completed without waiting wait for the first one and then loop again
* Not waiting for all events since each event may spawn more events and we want to start them
* processing as soon as possible
*/
if (completedEventWorkers == 0) {
final Iterator<Entry<IPortletWindowId, IPortletExecutionWorker<Long>>> eventWorkerEntryItr = entrySet.iterator();
final Entry<IPortletWindowId, IPortletExecutionWorker<Long>> eventWorkerEntry = eventWorkerEntryItr.next();
eventWorkerEntryItr.remove();
final IPortletWindowId portletWindowId = eventWorkerEntry.getKey();
final IPortletExecutionWorker<Long> eventWorker = eventWorkerEntry.getValue();
waitForEventWorker(request, eventQueue, eventWorker, portletWindowId);
}
}
if (iteration == this.maxEventIterations) {
this.logger.error("The Event dispatching iteration maximum of " + this.maxEventIterations + " was hit, consider either raising this limit or reviewing the portlets that use events to reduce the number of events spawned");
}
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletExecutionManager method startPortletHeaderRenderInternal.
/**
* create and submit the portlet header rendering job to the thread pool
*
* @param portletWindowId
* @param request
* @param response
* @return
*/
protected IPortletRenderExecutionWorker startPortletHeaderRenderInternal(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
IPortletRenderExecutionWorker portletHeaderRenderWorker = this.portletWorkerFactory.createRenderHeaderWorker(request, response, portletWindowId);
portletHeaderRenderWorker.submit();
final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletHeaderRenderingMap = this.getPortletHeaderRenderingMap(request);
portletHeaderRenderingMap.put(portletWindowId, portletHeaderRenderWorker);
return portletHeaderRenderWorker;
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletExecutionManager method getRenderedPortletHeaderWorker.
protected IPortletRenderExecutionWorker getRenderedPortletHeaderWorker(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletHeaderRenderingMap = this.getPortletHeaderRenderingMap(request);
IPortletRenderExecutionWorker portletHeaderRenderWorker = portletHeaderRenderingMap.get(portletWindowId);
if (portletHeaderRenderWorker == null) {
portletHeaderRenderWorker = this.startPortletHeaderRenderInternal(portletWindowId, request, response);
}
return portletHeaderRenderWorker;
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletRendererImpl method publishResourceEvent.
/**
* Publish the portlet resource event
*/
protected void publishResourceEvent(IPortletWindow portletWindow, HttpServletRequest httpServletRequest, long executionTime, boolean usedBrowserCache, boolean usedPortalCache) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
this.portalEventFactory.publishPortletResourceExecutionEvent(httpServletRequest, this, portletWindowId, executionTime, usedBrowserCache, usedPortalCache);
}
Aggregations