Search in sources :

Example 26 with PortletCategory

use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.

the class DefinitionHeaderProvider method createHeader.

@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
    // Username
    final String username = getUsername(renderRequest);
    // Obtain the MarketplacePortletDefinition for this soffit
    final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
    final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
    final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
    final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
    final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);
    final IPerson user = personManager.getPerson(httpr);
    final Locale locale = getUserLocale(user);
    // Title
    final String title = mpdef.getTitle(locale.toString());
    // FName
    final String fname = mpdef.getFName();
    // Description
    final String description = mpdef.getDescription(locale.toString());
    // Categories
    List<String> categories = new ArrayList<>();
    for (PortletCategory pc : mpdef.getCategories()) {
        categories.add(pc.getName());
    }
    // Parameters
    Map<String, List<String>> parameters = new HashMap<>();
    for (IPortletDefinitionParameter param : mpdef.getParameters()) {
        parameters.put(param.getName(), Collections.singletonList(param.getValue()));
    }
    final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest));
    final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken());
    logger.debug("Produced the following {} header for username='{}':  {}", Headers.DEFINITION.getName(), username, rslt);
    return rslt;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Definition(org.apereo.portal.soffit.model.v1_0.Definition) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) ArrayList(java.util.ArrayList) List(java.util.List) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) BasicHeader(org.apache.http.message.BasicHeader) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 27 with PortletCategory

use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.

the class MarketplaceService method featuredEntriesForUser.

@Override
public Set<MarketplaceEntry> featuredEntriesForUser(final IPerson user, final Set<PortletCategory> categories) {
    Validate.notNull(user, "Cannot determine relevant featured portlets for null user.");
    final Set<MarketplaceEntry> browseablePortlets = browseableMarketplaceEntriesFor(user, categories);
    final Set<MarketplaceEntry> featuredPortlets = new HashSet<>();
    for (final MarketplaceEntry entry : browseablePortlets) {
        final IPortletDefinition portletDefinition = entry.getMarketplacePortletDefinition();
        for (final PortletCategory category : this.portletCategoryRegistry.getParentCategories(portletDefinition)) {
            if (FEATURED_CATEGORY_NAME.equalsIgnoreCase(category.getName())) {
                featuredPortlets.add(entry);
            }
        }
    }
    return featuredPortlets;
}
Also used : MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 28 with PortletCategory

use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.

the class MarketplaceService method browseableNonEmptyPortletCategoriesFor.

@Override
public Set<PortletCategory> browseableNonEmptyPortletCategoriesFor(final IPerson user, final Set<PortletCategory> categories) {
    final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
    final Set<MarketplaceEntry> browseablePortlets = browseableMarketplaceEntriesFor(user, categories);
    final Set<PortletCategory> browseableCategories = new HashSet<PortletCategory>();
    // categories containing zero browseable portlets are excluded.
    for (final MarketplaceEntry entry : browseablePortlets) {
        IPortletDefinition portletDefinition = entry.getMarketplacePortletDefinition();
        for (final PortletCategory category : this.portletCategoryRegistry.getParentCategories(portletDefinition)) {
            final String categoryId = category.getId();
            if (mayBrowse(principal, categoryId)) {
                browseableCategories.add(category);
            } else {
                logger.trace("Portlet {} is browseable by {} but it is in category {} " + "which is not browseable by that user.  " + "This may be as intended, " + "or it may be that that portlet category ought to be more widely browseable.", portletDefinition, user, category);
            }
        }
    }
    logger.trace("These categories {} are browseable by {}.", browseableCategories, user);
    return browseableCategories;
}
Also used : MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 29 with PortletCategory

use of org.apereo.portal.portlet.om.PortletCategory in project uPortal by Jasig.

the class MarketplaceService method collectSpecifiedAndDescendantCategories.

/** Called recursively to gather all specified categories and descendants */
private void collectSpecifiedAndDescendantCategories(PortletCategory specified, Set<PortletCategory> gathered) {
    final Set<PortletCategory> children = portletCategoryRegistry.getAllChildCategories(specified);
    for (PortletCategory child : children) {
        collectSpecifiedAndDescendantCategories(child, gathered);
    }
    gathered.add(specified);
}
Also used : 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