use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class DefinitionHeaderProvider method createHeader.
@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
// Username
final String username = getUsername(renderRequest);
// Obtain the MarketplacePortletDefinition for this soffit
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);
final IPerson user = personManager.getPerson(httpr);
final Locale locale = getUserLocale(user);
// Title
final String title = mpdef.getTitle(locale.toString());
// FName
final String fname = mpdef.getFName();
// Description
final String description = mpdef.getDescription(locale.toString());
// Categories
List<String> categories = new ArrayList<>();
for (PortletCategory pc : mpdef.getCategories()) {
categories.add(pc.getName());
}
// Parameters
Map<String, List<String>> parameters = new HashMap<>();
for (IPortletDefinitionParameter param : mpdef.getParameters()) {
parameters.put(param.getName(), Collections.singletonList(param.getValue()));
}
final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest));
final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken());
logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt);
return rslt;
}
use of org.apereo.portal.portlet.om.PortletCategory 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.portlet.om.PortletCategory 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;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class MarketplaceService method collectSpecifiedAndDescendantCategories.
/** Called recursively to gather all specified categories and descendants */
private void collectSpecifiedAndDescendantCategories(PortletCategory specified, Set<PortletCategory> gathered) {
final Set<PortletCategory> children = portletCategoryRegistry.getAllChildCategories(specified);
for (PortletCategory child : children) {
collectSpecifiedAndDescendantCategories(child, gathered);
}
gathered.add(specified);
}
Aggregations