use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletRequestParameterProcessor method processParameters.
/* (non-Javadoc)
* @see org.apereo.portal.url.processing.IRequestParameterProcessor#processParameters(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
for (final IPortletRequestInfo portletRequestInfo : portalRequestInfo.getPortletRequestInfoMap().values()) {
final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);
final UrlType urlType = portalRequestInfo.getUrlType();
switch(urlType) {
case RENDER:
{
final Map<String, List<String>> portletParameters = portletRequestInfo.getPortletParameters();
portletWindow.setRenderParameters(ParameterMap.convertListMap(portletParameters));
// fall through, render uses state/mode info
}
case ACTION:
{
final WindowState windowState = portletRequestInfo.getWindowState();
if (windowState != null) {
portletWindow.setWindowState(windowState);
}
final PortletMode portletMode = portletRequestInfo.getPortletMode();
if (portletMode != null) {
portletWindow.setPortletMode(portletMode);
}
break;
}
default:
}
// Override the window state of the targeted portlet window based on the url state
if (portletWindowId.equals(targetedPortletWindowId)) {
final UrlState urlState = portalRequestInfo.getUrlState();
switch(urlState) {
case MAX:
{
portletWindow.setWindowState(WindowState.MAXIMIZED);
break;
}
case DETACHED:
{
portletWindow.setWindowState(IPortletRenderer.DETACHED);
break;
}
case EXCLUSIVE:
{
portletWindow.setWindowState(IPortletRenderer.EXCLUSIVE);
break;
}
default:
}
}
this.portletWindowRegistry.storePortletWindow(request, portletWindow);
}
return true;
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletUtils method getStringFromPortletUrl.
/**
* A static EL function that is defined in portletUrl.tld Takes a portletUrl object and coverts
* it into an actual Url Example is in search, returns a marketplace entry Url
*
* @param portletUrl
* @param request
* @return the Url represented by portletUrl
*/
public static String getStringFromPortletUrl(PortletUrl portletUrl, HttpServletRequest request) {
if (portletUrl == null) {
return null;
}
// Default urlType
UrlType urlType = UrlType.RENDER;
final PortletUrlType type = portletUrl.getType();
switch(type) {
case ACTION:
urlType = UrlType.ACTION;
break;
case RESOURCE:
urlType = UrlType.RESOURCE;
break;
default:
urlType = UrlType.RENDER;
break;
}
IPortletWindow marketplaceWindow = portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, MarketplacePortletDefinition.MARKETPLACE_FNAME);
IPortalUrlBuilder portalUrlBuilder = portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, marketplaceWindow.getPortletWindowId(), urlType);
IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
final String portletMode = portletUrl.getPortletMode();
if (portletMode != null) {
portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(portletMode));
}
final String windowState = portletUrl.getWindowState();
if (windowState != null) {
portletUrlBuilder.setWindowState(PortletUtils.getWindowState(windowState));
}
for (final PortletUrlParameter param : portletUrl.getParam()) {
final String name = param.getName();
final List<String> values = param.getValue();
portletUrlBuilder.addParameter(name, values.toArray(new String[values.size()]));
}
return portalUrlBuilder.getUrlString();
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletCacheControlServiceImpl method getPortletResourceState.
@Override
public CacheState<CachedPortletResourceData<Long>, Long> getPortletResourceState(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<CachedPortletResourceData<Long>, Long>();
}
// Generate the public resource cache key
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final Locale locale = RequestContextUtils.getLocale(request);
final PublicPortletCacheKey publicCacheKey = PublicPortletCacheKey.createPublicPortletResourceCacheKey(portletWindow, portalRequestInfo, locale);
return this.<CachedPortletResourceData<Long>, Long>getPortletState(request, portletWindow, publicCacheKey, this.publicScopePortletResourceOutputCache, this.privateScopePortletResourceOutputCache, true);
}
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);
}
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();
// 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);
}
}
Aggregations