use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletCategoryRegistryImpl method getParentCategories.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.registry.IPortletCategoryRegistry#getParentCategories(org.apereo.portal.portlet.om.PortletCategory)
*/
@Override
public Set<PortletCategory> getParentCategories(PortletCategory child) {
String childKey = String.valueOf(child.getId());
IEntityGroup childGroup = GroupService.findGroup(childKey);
Set<PortletCategory> parents = new HashSet<PortletCategory>();
for (IGroupMember gm : childGroup.getParentGroups()) {
if (gm.isGroup()) {
String categoryId = gm.getKey();
parents.add(getPortletCategory(categoryId));
}
}
return parents;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletCategoryRegistryImpl method getChildCategories.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.registry.IPortletCategoryRegistry#getChildCategories(org.apereo.portal.portlet.om.PortletCategory)
*/
@Override
public Set<PortletCategory> getChildCategories(PortletCategory parent) {
String parentKey = String.valueOf(parent.getId());
IEntityGroup parentGroup = GroupService.findGroup(parentKey);
Set<PortletCategory> categories = new HashSet<PortletCategory>();
for (IGroupMember gm : parentGroup.getChildren()) {
if (gm.isGroup()) {
String categoryId = gm.getKey();
categories.add(getPortletCategory(categoryId));
}
}
return categories;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletCategoryRegistryImpl method getAllParentCategories.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.registry.IPortletCategoryRegistry#getAllParentCategories(org.apereo.portal.portlet.om.PortletCategory)
*/
@Override
public Set<PortletCategory> getAllParentCategories(PortletCategory child) {
Set<PortletCategory> rslt = new HashSet<PortletCategory>();
for (PortletCategory parent : getParentCategories(child)) {
// recurse
rslt.add(parent);
rslt.addAll(getAllParentCategories(parent));
}
return rslt;
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletMarketplaceController method setUpInitialView.
private void setUpInitialView(WebRequest webRequest, PortletRequest portletRequest, Model model, String initialFilter) {
// We'll track and potentially log the time it takes to perform this initialization
final long timestamp = System.currentTimeMillis();
final HttpServletRequest servletRequest = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final PortletPreferences preferences = portletRequest.getPreferences();
final boolean isLogLevelDebug = logger.isDebugEnabled();
final IPerson user = personManager.getPerson(servletRequest);
final Map<String, Set<?>> registry = getRegistry(user, portletRequest);
@SuppressWarnings("unchecked") final Set<MarketplaceEntry> marketplaceEntries = (Set<MarketplaceEntry>) registry.get("portlets");
model.addAttribute("marketplaceEntries", marketplaceEntries);
@SuppressWarnings("unchecked") Set<PortletCategory> categoryList = (Set<PortletCategory>) registry.get("categories");
@SuppressWarnings("unchecked") final Set<MarketplaceEntry> featuredPortlets = (Set<MarketplaceEntry>) registry.get("featured");
model.addAttribute("featuredEntries", featuredPortlets);
//Determine if the marketplace is going to show the root category
String showRootCategoryPreferenceValue = preferences.getValue(SHOW_ROOT_CATEGORY_PREFERENCE, "false");
boolean showRootCategory = Boolean.parseBoolean(showRootCategoryPreferenceValue);
if (isLogLevelDebug) {
logger.debug("Going to show Root Category?: {}", Boolean.toString(showRootCategory));
}
if (showRootCategory == false) {
categoryList.remove(this.portletCategoryRegistry.getTopLevelPortletCategory());
}
model.addAttribute("categoryList", categoryList);
model.addAttribute("initialFilter", initialFilter);
logger.debug("Marketplace took {}ms in setUpInitialView for user '{}'", System.currentTimeMillis() - timestamp, user.getUserName());
}
use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.
the class PortletAdministrationHelper method createPortletDefinitionForm.
/**
* Construct a new PortletDefinitionForm for the given IPortletDefinition id. If a
* PortletDefinition matching this ID already exists, the form will be pre-populated with the
* PortletDefinition's current configuration. If the PortletDefinition does not yet exist, a new
* default form will be created.
*
* @param person user that is required to have related lifecycle permission
* @param portletId identifier for the portlet definition
* @return {@PortletDefinitionForm} with set values based on portlet definition or default
* category and principal if no definition is found
*/
public PortletDefinitionForm createPortletDefinitionForm(IPerson person, String portletId) {
IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(portletId);
// create the new form
final PortletDefinitionForm form;
if (def != null) {
// if this is a pre-existing portlet, set the category and permissions
form = new PortletDefinitionForm(def);
form.setId(def.getPortletDefinitionId().getStringId());
// create a JsonEntityBean for each current category and add it
// to our form bean's category list
Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(def);
for (PortletCategory cat : categories) {
form.addCategory(new JsonEntityBean(cat));
}
addSubscribePermissionsToForm(def, form);
} else {
form = createNewPortletDefinitionForm();
}
// hierarchical, so we'll test with the weakest.
if (!hasLifecyclePermission(person, PortletLifecycleState.CREATED, form.getCategories())) {
logger.warn("User '" + person.getUserName() + "' attempted to edit the following portlet without MANAGE permission: " + def);
throw new SecurityException("Not Authorized");
}
return form;
}
Aggregations