Search in sources :

Example 6 with MarketplaceEntry

use of org.apereo.portal.rest.layout.MarketplaceEntry in project uPortal by Jasig.

the class MarketplaceService method featuredEntriesForUser.

@Override
public Set<MarketplaceEntry> featuredEntriesForUser(final IPerson user, final Set<PortletCategory> categories) {
    Validate.notNull(user, "Cannot determine relevant featured portlets for null user.");
    final Set<MarketplaceEntry> browseablePortlets = browseableMarketplaceEntriesFor(user, categories);
    final Set<MarketplaceEntry> featuredPortlets = new HashSet<>();
    for (final MarketplaceEntry entry : browseablePortlets) {
        final IPortletDefinition portletDefinition = entry.getMarketplacePortletDefinition();
        for (final PortletCategory category : this.portletCategoryRegistry.getParentCategories(portletDefinition)) {
            if (FEATURED_CATEGORY_NAME.equalsIgnoreCase(category.getName())) {
                featuredPortlets.add(entry);
            }
        }
    }
    return featuredPortlets;
}
Also used : MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 7 with MarketplaceEntry

use of org.apereo.portal.rest.layout.MarketplaceEntry in project uPortal by Jasig.

the class MarketplaceService method browseableNonEmptyPortletCategoriesFor.

@Override
public Set<PortletCategory> browseableNonEmptyPortletCategoriesFor(final IPerson user, final Set<PortletCategory> categories) {
    final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
    final Set<MarketplaceEntry> browseablePortlets = browseableMarketplaceEntriesFor(user, categories);
    final Set<PortletCategory> browseableCategories = new HashSet<PortletCategory>();
    // categories containing zero browseable portlets are excluded.
    for (final MarketplaceEntry entry : browseablePortlets) {
        IPortletDefinition portletDefinition = entry.getMarketplacePortletDefinition();
        for (final PortletCategory category : this.portletCategoryRegistry.getParentCategories(portletDefinition)) {
            final String categoryId = category.getId();
            if (mayBrowse(principal, categoryId)) {
                browseableCategories.add(category);
            } else {
                logger.trace("Portlet {} is browseable by {} but it is in category {} " + "which is not browseable by that user.  " + "This may be as intended, " + "or it may be that that portlet category ought to be more widely browseable.", portletDefinition, user, category);
            }
        }
    }
    logger.trace("These categories {} are browseable by {}.", browseableCategories, user);
    return browseableCategories;
}
Also used : MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

MarketplaceEntry (org.apereo.portal.rest.layout.MarketplaceEntry)7 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)5 HashSet (java.util.HashSet)4 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)4 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)4 IPerson (org.apereo.portal.security.IPerson)4 PortletPreferences (javax.portlet.PortletPreferences)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 MarketplacePortletDefinition (org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Element (net.sf.ehcache.Element)1 IMarketplaceRating (org.apereo.portal.portlet.marketplace.IMarketplaceRating)1 Async (org.springframework.scheduling.annotation.Async)1 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)1 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)1