Search in sources :

Example 1 with UrlType

use of org.apereo.portal.url.UrlType 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();
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) PortletUrlParameter(org.apereo.portal.search.PortletUrlParameter) PortletUrlType(org.apereo.portal.search.PortletUrlType) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) PortletUrlType(org.apereo.portal.search.PortletUrlType) UrlType(org.apereo.portal.url.UrlType) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 2 with UrlType

use of org.apereo.portal.url.UrlType 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;
                }
        }
        //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;
                    }
            }
        }
        this.portletWindowRegistry.storePortletWindow(request, portletWindow);
    }
    return true;
}
Also used : WindowState(javax.portlet.WindowState) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) UrlType(org.apereo.portal.url.UrlType) ParameterMap(org.apereo.portal.url.ParameterMap) Map(java.util.Map) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) PortletMode(javax.portlet.PortletMode) UrlState(org.apereo.portal.url.UrlState)

Example 3 with UrlType

use of org.apereo.portal.url.UrlType in project uPortal by Jasig.

the class PortletURLProviderImpl method getType.

/* (non-Javadoc)
     * @see org.apache.pluto.container.PortletURLProvider#getType()
     */
@Override
public TYPE getType() {
    final IPortalUrlBuilder portalUrlBuilder = this.portletUrlBuilder.getPortalUrlBuilder();
    final UrlType urlType = portalUrlBuilder.getUrlType();
    return urlType.getPortletUrlType();
}
Also used : IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) UrlType(org.apereo.portal.url.UrlType)

Example 4 with UrlType

use of org.apereo.portal.url.UrlType in project uPortal by Jasig.

the class PortletMimeResponseContextImpl method getPortletURLProvider.

/* (non-Javadoc)
     * @see org.apache.pluto.container.PortletMimeResponseContext#getPortletURLProvider(org.apache.pluto.container.PortletURLProvider.TYPE)
     */
@Override
public PortletURLProvider getPortletURLProvider(TYPE type) {
    final IPortletWindowId portletWindowId = this.portletWindow.getPortletWindowId();
    final UrlType urlType = UrlType.fromPortletUrlType(type);
    final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(containerRequest, portletWindowId, urlType);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    return new PortletURLProviderImpl(portletUrlBuilder);
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) PortletURLProviderImpl(org.apereo.portal.portlet.url.PortletURLProviderImpl) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) UrlType(org.apereo.portal.url.UrlType) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 5 with UrlType

use of org.apereo.portal.url.UrlType in project uPortal by Jasig.

the class SearchPortletController method getResultUrl.

/** Determine the url for the search result */
protected String getResultUrl(HttpServletRequest httpServletRequest, SearchResult result, IPortletWindowId portletWindowId) {
    final String externalUrl = result.getExternalUrl();
    if (externalUrl != null) {
        return externalUrl;
    }
    UrlType urlType = UrlType.RENDER;
    final PortletUrl portletUrl = result.getPortletUrl();
    if (portletUrl != null) {
        final PortletUrlType type = portletUrl.getType();
        if (type != null) {
            switch(type) {
                case ACTION:
                    {
                        urlType = UrlType.ACTION;
                        break;
                    }
                default:
                case RENDER:
                    {
                        urlType = UrlType.RENDER;
                        break;
                    }
                case RESOURCE:
                    {
                        urlType = UrlType.RESOURCE;
                        break;
                    }
            }
        }
    }
    final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(httpServletRequest, portletWindowId, urlType);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
    if (portletUrl != null) {
        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();
}
Also used : IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) PortletUrlParameter(org.apereo.portal.search.PortletUrlParameter) PortletUrl(org.apereo.portal.search.PortletUrl) PortletUrlType(org.apereo.portal.search.PortletUrlType) IPortalUrlBuilder(org.apereo.portal.url.IPortalUrlBuilder) UrlType(org.apereo.portal.url.UrlType) PortletUrlType(org.apereo.portal.search.PortletUrlType)

Aggregations

UrlType (org.apereo.portal.url.UrlType)5 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)4 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)3 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)2 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2 PortletUrlParameter (org.apereo.portal.search.PortletUrlParameter)2 PortletUrlType (org.apereo.portal.search.PortletUrlType)2 Map (java.util.Map)1 PortletMode (javax.portlet.PortletMode)1 WindowState (javax.portlet.WindowState)1 PortletURLProviderImpl (org.apereo.portal.portlet.url.PortletURLProviderImpl)1 PortletUrl (org.apereo.portal.search.PortletUrl)1 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)1 IPortletRequestInfo (org.apereo.portal.url.IPortletRequestInfo)1 ParameterMap (org.apereo.portal.url.ParameterMap)1 UrlState (org.apereo.portal.url.UrlState)1