use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class ChannelListController method getPortletRegistry.
/**
* Updated version of this API. Supports an optional 'categoryId' parameter. If provided, this
* URL will return the portlet registry beginning with the specified category, including all
* descendants, and <em>excluding</em> uncategorized portlets. If no 'categoryId' is provided,
* this method returns the portlet registry beginning with 'All Categories' (the root) and
* <em>including</em> uncategorized portlets. Access is based on the SUBSCRIBE permission.
*
* @since 4.3
*/
@RequestMapping(value = "/v4-3/dlm/portletRegistry.json", method = RequestMethod.GET)
public ModelAndView getPortletRegistry(WebRequest webRequest, HttpServletRequest request, @RequestParam(value = "categoryId", required = false) String categoryId) {
final PortletCategory rootCategory = categoryId != null ? portletCategoryRegistry.getPortletCategory(categoryId) : portletCategoryRegistry.getTopLevelPortletCategory();
final boolean includeUncategorized = categoryId != null ? // Don't provide uncategorized portlets
false : // if a specific category was requested
true;
final IPerson user = personManager.getPerson(request);
final Map<String, SortedSet<?>> registry = getRegistry43(webRequest, user, rootCategory, includeUncategorized);
return new ModelAndView("jsonView", "registry", registry);
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class ChannelListController method prepareCategoryBean.
private ChannelCategoryBean prepareCategoryBean(WebRequest request, PortletCategory category, Set<IPortletDefinition> portletsNotYetCategorized, IPerson user, Locale locale) {
// construct a new channel category bean for this category
ChannelCategoryBean categoryBean = new ChannelCategoryBean(category);
categoryBean.setName(messageSource.getMessage(category.getName(), new Object[] {}, locale));
// add the direct child channels for this category
Set<IPortletDefinition> portlets = portletCategoryRegistry.getChildPortlets(category);
EntityIdentifier ei = user.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
for (IPortletDefinition portlet : portlets) {
if (authorizationService.canPrincipalBrowse(ap, portlet)) {
// construct a new channel bean from this channel
ChannelBean channel = getChannel(portlet, request, locale);
categoryBean.addChannel(channel);
}
/*
* Remove the portlet from the uncategorized collection;
* note -- this approach will not prevent portlets from
* appearing in multiple categories (as appropriate).
*/
portletsNotYetCategorized.remove(portlet);
}
/* Now add child categories. */
for (PortletCategory childCategory : this.portletCategoryRegistry.getChildCategories(category)) {
ChannelCategoryBean childCategoryBean = prepareCategoryBean(request, childCategory, portletsNotYetCategorized, user, locale);
categoryBean.addCategory(childCategoryBean);
}
return categoryBean;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class ChannelListController method getRegistry43.
/*
* Private methods that support the 4.3 version of the API
*/
/**
* Gathers and organizes the response based on the specified rootCategory and the permissions of
* the specified user.
*/
private Map<String, SortedSet<?>> getRegistry43(WebRequest request, IPerson user, PortletCategory rootCategory, boolean includeUncategorized) {
/*
* This collection of all the portlets in the portal is for the sake of
* tracking which ones are uncategorized. They will be added to the
* output if includeUncategorized=true.
*/
Set<IPortletDefinition> portletsNotYetCategorized = includeUncategorized ? new HashSet<IPortletDefinition>(portletDefinitionRegistry.getAllPortletDefinitions()) : new HashSet<// Not necessary to fetch them if we're not tracking them
IPortletDefinition>();
// construct a new channel registry
Map<String, SortedSet<?>> rslt = new TreeMap<String, SortedSet<?>>();
SortedSet<PortletCategoryBean> categories = new TreeSet<PortletCategoryBean>();
// add the root category and all its children to the registry
final Locale locale = getUserLocale(user);
categories.add(preparePortletCategoryBean(request, rootCategory, portletsNotYetCategorized, user, locale));
if (includeUncategorized) {
/*
* uPortal historically has provided for a convention that portlets not in any category
* may potentially be viewed by users but may not be subscribed to.
*
* As of uPortal 4.2, the logic below now takes any portlets the user has BROWSE access to
* that have not already been identified as belonging to a category and adds them to a category
* called Uncategorized.
*/
EntityIdentifier ei = user.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
for (IPortletDefinition portlet : portletsNotYetCategorized) {
if (authorizationService.canPrincipalBrowse(ap, portlet)) {
PortletDefinitionBean pdb = preparePortletDefinitionBean(request, portlet, locale);
marketplacePortlets.add(pdb);
}
}
// construct a new channel category bean for this category
final String uncName = messageSource.getMessage(UNCATEGORIZED, new Object[] {}, locale);
final String uncDescription = messageSource.getMessage(UNCATEGORIZED_DESC, new Object[] {}, locale);
PortletCategory pc = new PortletCategory(// Use of this String for Id matches earlier version of API
uncName);
pc.setName(uncName);
pc.setDescription(uncDescription);
PortletCategoryBean unc = PortletCategoryBean.fromPortletCategory(pc, null, marketplacePortlets);
// Add even if no portlets in category
categories.add(unc);
}
rslt.put("categories", categories);
return rslt;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class MarketplaceRESTController method marketplaceEntriesFeed.
@RequestMapping(value = "/marketplace/entries.json", method = RequestMethod.GET)
public ModelAndView marketplaceEntriesFeed(HttpServletRequest request) {
final IPerson user = personManager.getPerson(request);
final Set<PortletCategory> empty = // Produces an complete/unfiltered collection
Collections.emptySet();
final Set<MarketplaceEntry> marketplaceEntries = marketplaceService.browseableMarketplaceEntriesFor(user, empty);
return new ModelAndView("json", "portlets", marketplaceEntries);
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletsRESTController method getPortletCategories.
private Set<String> getPortletCategories(IPortletDefinition pdef) {
Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(pdef);
Set<String> rslt = new HashSet<String>();
for (PortletCategory category : categories) {
rslt.add(StringUtils.capitalize(category.getName().toLowerCase()));
}
return rslt;
}
Aggregations