Search in sources :

Example 11 with IPortletWindowId

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

the class XsltPortalUrlProvider method getPortletUrlBuilder.

/**
 * Get the portlet URL builder for the specified fname or layoutId (fname takes precedence)
 *
 * @param request
 * @param portalUrlBuilder
 * @param fname - can be empty string
 * @param layoutId - can by empty string
 * @param state - can be empty string
 * @param mode - can be empty string
 * @param copyCurrentRenderParameters
 * @param resourceId - can be empty string
 * @return IPortletUrlBuilder
 * @since 4.1
 */
public IPortletUrlBuilder getPortletUrlBuilder(HttpServletRequest request, IPortalUrlBuilder portalUrlBuilder, String fname, String layoutId, String state, String mode, String copyCurrentRenderParameters, String resourceId) {
    final IPortletUrlBuilder portletUrlBuilder;
    if (StringUtils.isNotEmpty(fname)) {
        final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
        final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
        portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    } else if (StringUtils.isNotEmpty(layoutId)) {
        final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutId);
        final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
        portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    } else {
        final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
        if (targetPortletWindowId == null) {
            if (this.logger.isDebugEnabled()) {
                this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet.", new Throwable());
            } else {
                this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet. Enable debug for stack trace.");
            }
            return new FailSafePortletUrlBuilder(null, portalUrlBuilder);
        }
        portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
    }
    portletUrlBuilder.setCopyCurrentRenderParameters(Boolean.parseBoolean(copyCurrentRenderParameters));
    if (StringUtils.isNotEmpty(state)) {
        portletUrlBuilder.setWindowState(PortletUtils.getWindowState(state));
    }
    if (StringUtils.isNotEmpty(mode)) {
        portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(mode));
    }
    if (StringUtils.isNotEmpty(resourceId) && portletUrlBuilder.getPortalUrlBuilder().getUrlType() == UrlType.RESOURCE) {
        portletUrlBuilder.setResourceId(resourceId);
    }
    return portletUrlBuilder;
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 12 with IPortletWindowId

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

the class PortalController method renderExclusive.

@RequestMapping(headers = { "org.apereo.portal.url.UrlType=RENDER", "org.apereo.portal.url.UrlState.EXCLUSIVE=true" })
public void renderExclusive(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
    if (portletRequestInfo == null) {
        throw new IllegalArgumentException("A portlet must be targeted when using the EXCLUSIVE WindowState: " + portalRequestInfo);
    }
    final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
    this.portletExecutionManager.getPortletOutput(portletWindowId, request, response);
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with IPortletWindowId

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

the class PortalController method resourceRequest.

@RequestMapping(headers = { "org.apereo.portal.url.UrlType=RESOURCE" })
public void resourceRequest(HttpServletRequest request, HttpServletResponse response) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
    if (portletRequestInfo != null) {
        final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
        this.portletExecutionManager.doPortletServeResource(targetWindowId, request, response);
    } else {
        this.logger.error("portletRequestInfo was null for resourceRequest");
    }
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with IPortletWindowId

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

the class PortletDefinitionAttributeSource method getCacheKey.

@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.name);
    // We need something that makes for a unique cache key.  For lack of anything else useful,
    // use the set of all layout portlet window ids in the user's layout.
    final Set<IPortletWindow> portletWindows = this.portletWindowRegistry.getAllLayoutPortletWindows(request);
    for (final IPortletWindow portletWindow : portletWindows) {
        if (portletWindow != null) {
            final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
            cacheKeyBuilder.add(portletWindowId);
        } else {
            this.logger.warn("portletWindowRegistry#getAllLayoutPortletWindows() returned a null portletWindow");
        }
    }
    return cacheKeyBuilder.build();
}
Also used : CacheKeyBuilder(org.apereo.portal.utils.cache.CacheKey.CacheKeyBuilder) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 15 with IPortletWindowId

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

the class RequestRenderingPipelineUtilsImpl method getPortletDefinitionFromServletRequest.

@Override
public IPortletDefinition getPortletDefinitionFromServletRequest(HttpServletRequest request) {
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    if (portalRequestInfo != null && portalRequestInfo.getTargetedPortletWindowId() != null) {
        IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
        IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);
        if (portletWindow != null && portletWindow.getPortletEntity() != null) {
            final IPortletEntity portletEntity = portletWindow.getPortletEntity();
            IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
            return portletDefinition;
        }
    }
    return null;
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)85 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)31 Test (org.junit.Test)19 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)15 WindowState (javax.portlet.WindowState)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)9 PortletMode (javax.portlet.PortletMode)8 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)8 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 IPortletRenderExecutionWorker (org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker)7 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)7 LinkedHashMap (java.util.LinkedHashMap)6 IPerson (org.apereo.portal.security.IPerson)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 IOException (java.io.IOException)5 List (java.util.List)5 IUserInstance (org.apereo.portal.user.IUserInstance)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5