Search in sources :

Example 26 with IPortletWindow

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

the class PortletCacheControlServiceImpl method getPortletRenderHeaderState.

@Override
public CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> getPortletRenderHeaderState(HttpServletRequest request, IPortletWindowId portletWindowId) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    if (portletWindow == null) {
        logger.warn("portletWindowRegistry returned null for {}, returning default cacheControl and no cached portlet data", portletWindowId);
        return new CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult>();
    }
    //Generate the public render-header cache key
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final Locale locale = RequestContextUtils.getLocale(request);
    final PublicPortletCacheKey publicCacheKey = PublicPortletCacheKey.createPublicPortletRenderHeaderCacheKey(portletWindow, portalRequestInfo, locale);
    return this.<CachedPortletData<PortletRenderResult>, PortletRenderResult>getPortletState(request, portletWindow, publicCacheKey, this.publicScopePortletRenderHeaderOutputCache, this.privateScopePortletRenderHeaderOutputCache, false);
}
Also used : Locale(java.util.Locale) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) PortletRenderResult(org.apereo.portal.portlet.rendering.PortletRenderResult) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 27 with IPortletWindow

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

the class PortletCacheControlServiceImpl method cachePortletOutput.

private <D extends CachedPortletResultHolder<T>, T extends Serializable> void cachePortletOutput(IPortletWindowId portletWindowId, HttpServletRequest httpRequest, CacheState<D, T> cacheState, D cachedPortletData, Ehcache publicOutputCache, Ehcache privateOutputCache) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpRequest, portletWindowId);
    final CacheControl cacheControl = cacheState.getCacheControl();
    if (cacheControl.isPublicScope()) {
        final PublicPortletCacheKey publicCacheKey = cacheState.getPublicPortletCacheKey();
        this.cacheElement(publicOutputCache, publicCacheKey, cachedPortletData, cacheControl);
        logger.debug("Cached public data under key {} for {}", publicCacheKey, portletWindow);
    } else {
        PrivatePortletCacheKey privateCacheKey = cacheState.getPrivatePortletCacheKey();
        //Private key can be null if getPortletState found publicly cached data but the portlet's response is now privately scoped
        if (privateCacheKey == null) {
            final HttpSession session = httpRequest.getSession();
            final String sessionId = session.getId();
            final IPortletEntityId entityId = portletWindow.getPortletEntityId();
            final PublicPortletCacheKey publicCacheKey = cacheState.getPublicPortletCacheKey();
            privateCacheKey = new PrivatePortletCacheKey(sessionId, portletWindowId, entityId, publicCacheKey);
        }
        this.cacheElement(privateOutputCache, privateCacheKey, cachedPortletData, cacheControl);
        logger.debug("Cached private data under key {} for {}", privateCacheKey, portletWindow);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) CacheControl(javax.portlet.CacheControl) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId)

Example 28 with IPortletWindow

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

the class LocalPortletRequestContextServiceImpl method getPortletResourceRequestContext.

/* (non-Javadoc)
     * @see org.apache.pluto.container.PortletRequestContextService#getPortletResourceRequestContext(org.apache.pluto.container.PortletContainer, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.pluto.container.PortletWindow)
     */
@Override
public PortletResourceRequestContext getPortletResourceRequestContext(PortletContainer container, HttpServletRequest containerRequest, HttpServletResponse containerResponse, PortletWindow window) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(containerRequest, window);
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(containerRequest);
    return new PortletResourceRequestContextImpl(container, portletWindow, containerRequest, containerResponse, this.requestPropertiesManager, portalRequestInfo, this.portletCookieService, requestAttributeService);
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) PortletResourceRequestContextImpl(org.apereo.portal.portlet.container.PortletResourceRequestContextImpl)

Example 29 with IPortletWindow

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

the class PortletCacheControlServiceImpl method getPortletRenderState.

@Override
public CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> getPortletRenderState(HttpServletRequest request, IPortletWindowId portletWindowId) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    if (portletWindow == null) {
        logger.warn("portletWindowRegistry returned null for {}, returning default cacheControl and no cached portlet data", portletWindowId);
        return new CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult>();
    }
    //Generate the public render cache key
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final Locale locale = RequestContextUtils.getLocale(request);
    final PublicPortletCacheKey publicCacheKey = PublicPortletCacheKey.createPublicPortletRenderCacheKey(portletWindow, portalRequestInfo, locale);
    return this.<CachedPortletData<PortletRenderResult>, PortletRenderResult>getPortletState(request, portletWindow, publicCacheKey, this.publicScopePortletRenderOutputCache, this.privateScopePortletRenderOutputCache, false);
}
Also used : Locale(java.util.Locale) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) PortletRenderResult(org.apereo.portal.portlet.rendering.PortletRenderResult) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 30 with IPortletWindow

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

the class PortletRendererImpl method doEvent.

/*
     * PLT 22.1 If the content of a portlet is cached and the portlet is target of request
     * with an action-type semantic (e.g. an action or event call), the portlet container should discard the cache and
     * invoke the corresponding request handling methods of the portlet like processAction,or processEvent.
     *
     * (non-Javadoc)
     * @see org.apereo.portal.portlet.rendering.IPortletRenderer#doEvent(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.portlet.Event)
     */
@Override
public long doEvent(IPortletWindowId portletWindowId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Event event) {
    this.portletCacheControlService.purgeCachedPortletData(portletWindowId, httpServletRequest);
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
    enforceConfigPermission(httpServletRequest, portletWindow);
    httpServletRequest = this.setupPortletRequest(httpServletRequest);
    httpServletResponse = new PortletHttpServletResponseWrapper(httpServletResponse, portletWindow);
    //Execute the action,
    this.logger.debug("Executing portlet event for window '{}'", portletWindow);
    final long start = System.nanoTime();
    try {
        this.portletContainer.doEvent(portletWindow.getPlutoPortletWindow(), httpServletRequest, httpServletResponse, event);
    } catch (PortletException pe) {
        throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing event.", portletWindow, pe);
    } catch (PortletContainerException pce) {
        throw new PortletDispatchException("The portlet container threw an exception while executing event on portlet window '" + portletWindow + "'.", portletWindow, pce);
    } catch (IOException ioe) {
        throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing event.", portletWindow, ioe);
    }
    final long executionTime = System.nanoTime() - start;
    this.portalEventFactory.publishPortletEventExecutionEvent(httpServletRequest, this, portletWindowId, executionTime, event.getQName());
    return executionTime;
}
Also used : PortletException(javax.portlet.PortletException) PortletDispatchException(org.apereo.portal.portlet.PortletDispatchException) 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)24 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 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