use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class PortletCategoryBeanTest method testCompareToDifferent.
@Test
public void testCompareToDifferent() {
String name1 = "name1";
String name2 = "name2";
PortletCategoryBean pcb1 = buildTestPortletCategoryBean("id1", name1, "desc");
PortletCategoryBean pcb2 = buildTestPortletCategoryBean("id1", name2, "desc");
assertEquals(name1.compareTo(name2), pcb1.compareTo(pcb2));
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class PortletCategoryBeanTest method testCompareToSimilar.
@Test
public void testCompareToSimilar() {
String name1 = "name1";
String name2 = "name1";
PortletCategoryBean pcb1 = buildTestPortletCategoryBean("id1", name1, "desc");
PortletCategoryBean pcb2 = buildTestPortletCategoryBean("id1", name2, "desc");
assertEquals(name1.compareTo(name2), pcb1.compareTo(pcb2));
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class ChannelListController method preparePortletCategoryBean.
private PortletCategoryBean preparePortletCategoryBean(WebRequest req, PortletCategory category, Set<IPortletDefinition> portletsNotYetCategorized, IPerson user, Locale locale, Set<IPortletDefinition> favorites) {
/* Prepare child categories. */
Set<PortletCategoryBean> subcategories = new HashSet<>();
for (PortletCategory childCategory : this.portletCategoryRegistry.getChildCategories(category)) {
PortletCategoryBean childBean = preparePortletCategoryBean(req, childCategory, portletsNotYetCategorized, user, locale, favorites);
subcategories.add(childBean);
}
// add the direct child channels for this category
Set<IPortletDefinition> portlets = portletCategoryRegistry.getChildPortlets(category);
EntityIdentifier ei = user.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
for (IPortletDefinition portlet : portlets) {
if (authorizationService.canPrincipalBrowse(ap, portlet)) {
PortletDefinitionBean pdb = preparePortletDefinitionBean(req, portlet, locale, favorites.contains(portlet));
marketplacePortlets.add(pdb);
}
/*
* Remove the portlet from the uncategorized collection;
* note -- this approach will not prevent portlets from
* appearing in multiple categories (as appropriate).
*/
portletsNotYetCategorized.remove(portlet);
}
// construct a new portlet category bean for this category
PortletCategoryBean categoryBean = PortletCategoryBean.fromPortletCategory(category, subcategories, marketplacePortlets);
categoryBean.setName(messageSource.getMessage(category.getName(), new Object[] {}, locale));
return categoryBean;
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class ChannelListController method filterRegistryFavoritesOnly.
private Map<String, SortedSet<PortletCategoryBean>> filterRegistryFavoritesOnly(Map<String, SortedSet<PortletCategoryBean>> registry) {
final Set<PortletCategoryBean> inpt = registry.get(CATEGORIES_MAP_KEY);
final SortedSet<PortletCategoryBean> otpt = new TreeSet<>();
inpt.forEach(categoryIn -> {
final PortletCategoryBean categoryOut = filterCategoryFavoritesOnly(categoryIn);
if (categoryOut != null) {
otpt.add(categoryOut);
}
});
final Map<String, SortedSet<PortletCategoryBean>> rslt = new TreeMap<>();
rslt.put(CATEGORIES_MAP_KEY, otpt);
return rslt;
}
use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.
the class PortletCategoryBeanTest method testFromPortletCategoryInflatedSubCatsAndPortlets.
@Test
public void testFromPortletCategoryInflatedSubCatsAndPortlets() {
String id = "id_test";
String name = "name_test";
String desc = "desc_test";
String cat1id = "cat1_id_test";
String cat1name = "cat1_name_test";
String cat1desc = "cat1_desc_test";
PortletCategoryBean pcb = buildTestPortletCategoryBean(id, name, desc, cat1id, cat1name, cat1desc);
assertEquals(id, pcb.getId());
assertEquals(name, pcb.getName());
assertEquals(desc, pcb.getDescription());
// Check the portlets set
assertEquals(Collections.emptySet(), pcb.getPortlets());
// Check the subCat set
assertEquals(1, pcb.getSubcategories().size());
assertEquals(cat1id, pcb.getSubcategories().first().getId());
assertEquals(cat1name, pcb.getSubcategories().first().getName());
assertEquals(cat1desc, pcb.getSubcategories().first().getDescription());
}
Aggregations