Search in sources :

Example 21 with PortletCategory

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;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 22 with PortletCategory

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;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 23 with PortletCategory

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;
}
Also used : HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 24 with PortletCategory

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());
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) PortletPreferences(javax.portlet.PortletPreferences) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 25 with PortletCategory

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;
}
Also used : JsonEntityBean(org.apereo.portal.layout.dlm.remoting.JsonEntityBean) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Aggregations

PortletCategory (org.apereo.portal.portlet.om.PortletCategory)29 HashSet (java.util.HashSet)19 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)12 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)7 EntityIdentifier (org.apereo.portal.EntityIdentifier)6 IGroupMember (org.apereo.portal.groups.IGroupMember)6 ArrayList (java.util.ArrayList)5 MarketplaceEntry (org.apereo.portal.rest.layout.MarketplaceEntry)5 IPerson (org.apereo.portal.security.IPerson)5 IEntityGroup (org.apereo.portal.groups.IEntityGroup)4 Locale (java.util.Locale)3 SortedSet (java.util.SortedSet)3 TreeSet (java.util.TreeSet)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 PortletPreferences (javax.portlet.PortletPreferences)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 IEntity (org.apereo.portal.groups.IEntity)2 ExternalPermissionDefinition (org.apereo.portal.io.xml.portlettype.ExternalPermissionDefinition)2