Search in sources :

Example 1 with IPortletRenderExecutionWorker

use of org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker 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;
}
Also used : MaintenanceModeException(org.apereo.portal.portlets.error.MaintenanceModeException) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) IPortletRenderExecutionWorker(org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IOException(java.io.IOException) MaintenanceModeException(org.apereo.portal.portlets.error.MaintenanceModeException) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 2 with IPortletRenderExecutionWorker

use of org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker in project uPortal by Jasig.

the class PortletExecutionManager method getPortletRenderResult.

/**
 * Returns the PortletRenderResult waiting up to the portlet's timeout
 *
 * @return The PortletRenderResult from the portlet's execution
 * @throws TimeoutException If the portlet's timeout was hit before a result was returned
 * @throws Exception The exception thrown by the portlet during execution
 */
protected PortletRenderResult getPortletRenderResult(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) throws Exception {
    final IPortletRenderExecutionWorker tracker = getRenderedPortletBodyWorker(portletWindowId, request, response);
    final long timeout = getPortletRenderTimeout(portletWindowId, request);
    return tracker.get(timeout);
}
Also used : IPortletRenderExecutionWorker(org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker)

Example 3 with IPortletRenderExecutionWorker

use of org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker 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;
}
Also used : IPortletRenderExecutionWorker(org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 4 with IPortletRenderExecutionWorker

use of org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker 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;
}
Also used : IPortletRenderExecutionWorker(org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 5 with IPortletRenderExecutionWorker

use of org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker in project uPortal by Jasig.

the class PortletExecutionManager method isPortletRenderRequested.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#isPortletRenderRequested(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public boolean isPortletRenderRequested(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
    final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletRenderingMap = this.getPortletRenderingMap(request);
    final IPortletRenderExecutionWorker tracker = portletRenderingMap.get(portletWindowId);
    return tracker != null;
}
Also used : IPortletRenderExecutionWorker(org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Aggregations

IPortletRenderExecutionWorker (org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker)10 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)7 IOException (java.io.IOException)3 MaintenanceModeException (org.apereo.portal.portlets.error.MaintenanceModeException)3 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)1 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)1 IPortletFailureExecutionWorker (org.apereo.portal.portlet.rendering.worker.IPortletFailureExecutionWorker)1