use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean 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
IPortletDefinition>();
// tracking them
// 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 = AuthorizationServiceFacade.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.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class ChannelListController method filterCategoryFavoritesOnly.
/**
* Returns the filtered category, or <code>null</code> if there is no content remaining in the
* category.
*/
private PortletCategoryBean filterCategoryFavoritesOnly(PortletCategoryBean category) {
// Subcategories
final Set<PortletCategoryBean> subcategories = new HashSet<>();
category.getSubcategories().forEach(sub -> {
final PortletCategoryBean filteredBean = filterCategoryFavoritesOnly(sub);
if (filteredBean != null) {
subcategories.add(filteredBean);
}
});
// Portlets
final Set<PortletDefinitionBean> portlets = new HashSet<>();
category.getPortlets().forEach(child -> {
if (child.getFavorite()) {
log.debug("Including portlet '{}' because it is a favorite: {}", child.getFname());
portlets.add(child);
} else {
log.debug("Skipping portlet '{}' because it IS NOT a favorite: {}", child.getFname());
}
});
return !subcategories.isEmpty() || !portlets.isEmpty() ? PortletCategoryBean.create(category.getId(), category.getName(), category.getDescription(), subcategories, portlets) : null;
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean 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<PortletCategoryBean>> getRegistry43(WebRequest request, IPerson user, PortletCategory rootCategory, boolean includeUncategorized, Set<IPortletDefinition> favorites) {
/*
* 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<>(portletDefinitionRegistry.getAllPortletDefinitions()) : // Not necessary to fetch them if we're not
new HashSet<>();
// tracking them
// construct a new channel registry
Map<String, SortedSet<PortletCategoryBean>> rslt = new TreeMap<>();
SortedSet<PortletCategoryBean> categories = new TreeSet<>();
// add the root category and all its children to the registry
final Locale locale = getUserLocale(user);
categories.add(preparePortletCategoryBean(request, rootCategory, portletsNotYetCategorized, user, locale, favorites));
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 = AuthorizationServiceFacade.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, favorites.contains(portlet));
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_MAP_KEY, categories);
return rslt;
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class PortletCategoryBeanTest method testEqualsNull.
@Test
public void testEqualsNull() {
PortletCategoryBean pcb1 = buildTestPortletCategoryBean("id1", "name1", "desc");
assertFalse(pcb1.equals(null));
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class PortletCategoryBeanTest method testEqualsSameID.
@Test
public void testEqualsSameID() {
String id1 = "id1";
PortletCategoryBean pcb1 = buildTestPortletCategoryBean(id1, "name1", "desc");
PortletCategoryBean pcb2 = buildTestPortletCategoryBean(id1, "name2", "desc");
assertTrue(pcb1.equals(pcb2));
}
Aggregations