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;
}
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;
}
Aggregations