Search in sources :

Example 81 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.

the class PortletEventCoordinatationService method processEvents.

@Override
public void processEvents(PortletContainer container, PortletWindow plutoPortletWindow, HttpServletRequest request, HttpServletResponse response, List<Event> events) {
    final PortletEventQueue requestPortletEventQueue = this.getPortletEventQueue(request);
    this.logger.debug("Queued {} from {}", events, plutoPortletWindow);
    final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(request, plutoPortletWindow);
    final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
    // Add list transformer to convert Event to QueuedEvent
    final List<QueuedEvent> queuedEvents = Lists.transform(events, new Function<Event, QueuedEvent>() {

        /* (non-Javadoc)
                             * @see com.google.common.base.Function#apply(java.lang.Object)
                             */
        @Override
        public QueuedEvent apply(Event event) {
            return new QueuedEvent(portletWindowId, event);
        }
    });
    requestPortletEventQueue.addEvents(queuedEvents);
}
Also used : Event(javax.portlet.Event) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 82 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.

the class PortletExecutionManager method doesPortletNeedHeaderWorker.

/**
 * @param portletWindowId
 * @param request
 * @return
 */
protected boolean doesPortletNeedHeaderWorker(IPortletWindowId portletWindowId, HttpServletRequest request) {
    IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    PortletDefinition portletDefinition = portletWindow.getPlutoPortletWindow().getPortletDefinition();
    ContainerRuntimeOption renderHeaderOption = portletDefinition.getContainerRuntimeOption(PORTLET_RENDER_HEADERS_OPTION);
    boolean result = false;
    if (renderHeaderOption != null) {
        result = renderHeaderOption.getValues().contains(Boolean.TRUE.toString());
    }
    logger.debug("Portlet {} need render header worker: {}", portletDefinition.getPortletName(), result);
    return result;
}
Also used : ContainerRuntimeOption(org.apache.pluto.container.om.portlet.ContainerRuntimeOption) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 83 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.

the class PortletExecutionManager method cancelWorker.

/**
 * Cancel the worker and add it to the hung workers queue
 */
protected void cancelWorker(HttpServletRequest request, IPortletExecutionWorker<?> portletExecutionWorker) {
    final IPortletWindowId portletWindowId = portletExecutionWorker.getPortletWindowId();
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    this.logger.warn("{} has not completed, adding to hung-worker cleanup queue: {}", portletExecutionWorker, portletWindow);
    portletExecutionWorker.cancel();
    this.portletExecutionEventFactory.publishPortletHungEvent(request, this, portletExecutionWorker);
    hungWorkers.offer(portletExecutionWorker);
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 84 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.

the class PortletExecutionManager method checkWorkerCompletion.

/**
 * Checks to see if a worker has been retrieved (not orphaned) and if it is complete.
 */
protected void checkWorkerCompletion(HttpServletRequest request, IPortletRenderExecutionWorker portletRenderExecutionWorker) {
    if (!portletRenderExecutionWorker.isRetrieved()) {
        final IPortletWindowId portletWindowId = portletRenderExecutionWorker.getPortletWindowId();
        final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
        this.logger.warn("Portlet worker started but never retrieved for {}, worker {}." + " If random portlet fnames it may be users switching tabs before page is done rendering" + " (would see separate log message with java.net.SocketException on socket write)." + " If repeatedly occurring with one portlet fname your theme layout xsl may not be including" + " a portlet present in your layout xml files (see" + " http://jasig.275507.n4.nabble.com/Portlet-worker-started-but-never-retrieved-td4580698.html)", portletWindow, portletRenderExecutionWorker);
        try {
            portletRenderExecutionWorker.get(0);
        } catch (Exception e) {
        // Ignore exception here, we just want to get this worker to complete
        }
    }
    if (!portletRenderExecutionWorker.isComplete()) {
        cancelWorker(request, portletRenderExecutionWorker);
    }
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IOException(java.io.IOException) MaintenanceModeException(org.apereo.portal.portlets.error.MaintenanceModeException)

Example 85 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.

the class PortletRendererImpl method doReset.

/*
     * (non-Javadoc)
     * @see org.apereo.portal.portlet.rendering.IPortletRenderer#doReset(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public void doReset(IPortletWindowId portletWindowId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
    // Don't enforce config mode restriction because this is going to snap the portlet window
    // back into view mode.
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
    if (portletWindow != null) {
        portletWindow.setPortletMode(PortletMode.VIEW);
        portletWindow.setRenderParameters(new ParameterMap());
        portletWindow.setExpirationCache(null);
        httpServletRequest = this.setupPortletRequest(httpServletRequest);
        httpServletResponse = new PortletHttpServletResponseWrapper(httpServletResponse, portletWindow);
        httpServletRequest.setAttribute(AdministrativeRequestListenerController.DEFAULT_LISTENER_KEY_ATTRIBUTE, "sessionActionListener");
        httpServletRequest.setAttribute(PortletSessionAdministrativeRequestListener.ACTION, PortletSessionAdministrativeRequestListener.SessionAction.CLEAR);
        httpServletRequest.setAttribute(PortletSessionAdministrativeRequestListener.SCOPE, PortletSession.PORTLET_SCOPE);
        // TODO modify PortletContainer.doAdmin to create a specific "admin" req/res object and
        // context so we don't have to fake it with a render req
        // These are required for a render request to be created and admin requests use a render
        // request under the hood
        final String characterEncoding = httpServletResponse.getCharacterEncoding();
        httpServletRequest.setAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_OUTPUT_HANDLER, new RenderPortletOutputHandler(characterEncoding));
        httpServletRequest.setAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_CACHE_CONTROL, new CacheControlImpl());
        try {
            this.portletContainer.doAdmin(portletWindow.getPlutoPortletWindow(), httpServletRequest, httpServletResponse);
        } catch (PortletException pe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing admin command to clear session.", portletWindow, pe);
        } catch (PortletContainerException pce) {
            throw new PortletDispatchException("The portlet container threw an exception while executing admin command to clear session on portlet window '" + portletWindow + "'.", portletWindow, pce);
        } catch (IOException ioe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing admin command to clear session.", portletWindow, ioe);
        }
    } else {
        logger.debug("ignoring doReset as portletWindowRegistry#getPortletWindow returned a null result for portletWindowId {}", portletWindowId);
    }
}
Also used : CacheControlImpl(org.apereo.portal.portlet.container.cache.CacheControlImpl) PortletException(javax.portlet.PortletException) PortletDispatchException(org.apereo.portal.portlet.PortletDispatchException) ParameterMap(org.apereo.portal.url.ParameterMap) IOException(java.io.IOException) PortletHttpServletResponseWrapper(org.apereo.portal.utils.web.PortletHttpServletResponseWrapper) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Aggregations

IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)88 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)32 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)32 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)23 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)12 IUserInstance (org.apereo.portal.user.IUserInstance)12 List (java.util.List)10 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)10 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)9 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)9 IOException (java.io.IOException)8 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)7 WindowState (javax.portlet.WindowState)6 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 LinkedHashMap (java.util.LinkedHashMap)5 Locale (java.util.Locale)5 PortletException (javax.portlet.PortletException)5 PortletMode (javax.portlet.PortletMode)5