Search in sources :

Example 16 with IPortletWindow

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

the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindowByFname.

@Override
public IPortletWindow getOrCreateDefaultPortletWindowByFname(HttpServletRequest request, String fname) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(fname, "fname cannot be null");
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
    if (portletEntity == null) {
        return null;
    }
    final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntity.getPortletEntityId());
    logger.trace("Found portlet window {} for portlet definition fname {}", portletWindow, fname);
    return portletWindow;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 17 with IPortletWindow

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

the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindow.

@Override
public IPortletWindow getOrCreateDefaultPortletWindow(HttpServletRequest request, IPortletEntityId portletEntityId) {
    Validate.notNull(request, "request can not be null");
    Validate.notNull(portletEntityId, "portletEntityId can not be null");
    final IPortletWindowId portletWindowId = this.getDefaultPortletWindowId(request, portletEntityId);
    final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request);
    //Check if there is portlet window cached in the request
    IPortletWindow portletWindow = portletWindowMap.getWindow(portletWindowId);
    if (portletWindow != null) {
        logger.trace("Found IPortletWindow {} in request cache", portletWindow.getPortletWindowId());
        return portletWindow;
    }
    final PortletWindowData portletWindowData = this.getOrCreateDefaultPortletWindowData(request, portletEntityId, portletWindowId);
    portletWindow = wrapPortletWindowData(request, portletWindowData);
    if (portletWindow == null) {
        return null;
    }
    //Cache the wrapped window in the request
    return portletWindowMap.storeIfAbsentWindow(portletWindow);
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 18 with IPortletWindow

use of org.apereo.portal.portlet.om.IPortletWindow 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 19 with IPortletWindow

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

the class PortletPlaceholderEventSource method generateCharacterEvents.

@Override
public void generateCharacterEvents(HttpServletRequest servletRequest, MatchResult matchResult, Collection<CharacterEvent> eventBuffer) {
    final String subscribeId = matchResult.group(this.portletIdGroup);
    if (subscribeId == null) {
        this.logger.warn("MatchResult returned null for group " + this.portletIdGroup + ". No PortletPlaceholderEvent will be generated. " + matchResult);
        return;
    }
    final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(servletRequest, subscribeId);
    final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
    this.generateCharacterEvents(portletWindowId, matchResult, eventBuffer);
}
Also used : IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 20 with IPortletWindow

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();
}
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)

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