Search in sources :

Example 61 with SortedSet

use of java.util.SortedSet in project cxf by apache.

the class CollectionType method createCollection.

@Override
@SuppressWarnings("unchecked")
protected Collection<Object> createCollection() {
    Collection<Object> values = null;
    /*
         * getTypeClass returns the type of the object. These 'if's asked if the proposed
         * type can be assigned to the object, not the other way around. Thus List before
         * Vector and Set before SortedSet.
         */
    Class<?> userTypeClass = getTypeClass();
    if (userTypeClass.isAssignableFrom(List.class)) {
        values = new ArrayList<>();
    } else if (userTypeClass.isAssignableFrom(LinkedList.class)) {
        values = new LinkedList<Object>();
    } else if (userTypeClass.isAssignableFrom(Set.class)) {
        values = new HashSet<>();
    } else if (userTypeClass.isAssignableFrom(SortedSet.class)) {
        values = new TreeSet<Object>();
    } else if (userTypeClass.isAssignableFrom(Vector.class)) {
        values = new Vector<Object>();
    } else if (userTypeClass.isAssignableFrom(Stack.class)) {
        values = new Stack<Object>();
    } else if (userTypeClass.isInterface()) {
        values = new ArrayList<>();
    } else {
        try {
            values = (Collection<Object>) userTypeClass.newInstance();
        } catch (Exception e) {
            throw new DatabindingException("Could not create map implementation: " + userTypeClass.getName(), e);
        }
    }
    return values;
}
Also used : DatabindingException(org.apache.cxf.aegis.DatabindingException) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet) LinkedList(java.util.LinkedList) DatabindingException(org.apache.cxf.aegis.DatabindingException) Stack(java.util.Stack)

Example 62 with SortedSet

use of java.util.SortedSet 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;
}
Also used : Locale(java.util.Locale) EntityIdentifier(org.apereo.portal.EntityIdentifier) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) TreeSet(java.util.TreeSet) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 63 with SortedSet

use of java.util.SortedSet in project uPortal by Jasig.

the class ChannelListController method getRegistryOriginal.

/*
     * Private methods that support the original (pre-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<?>> getRegistryOriginal(WebRequest request, IPerson user) {
    /*
         * This collection of all the portlets in the portal is for the sake of
         * tracking which ones are uncategorized.
         */
    Set<IPortletDefinition> portletsNotYetCategorized = new HashSet<IPortletDefinition>(portletDefinitionRegistry.getAllPortletDefinitions());
    // construct a new channel registry
    Map<String, SortedSet<?>> rslt = new TreeMap<String, SortedSet<?>>();
    SortedSet<ChannelCategoryBean> categories = new TreeSet<ChannelCategoryBean>();
    // add the root category and all its children to the registry
    final PortletCategory rootCategory = portletCategoryRegistry.getTopLevelPortletCategory();
    final Locale locale = getUserLocale(user);
    categories.add(prepareCategoryBean(request, rootCategory, portletsNotYetCategorized, user, locale));
    /*
         * 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());
    // construct a new channel category bean for this category
    String uncategorizedString = messageSource.getMessage(UNCATEGORIZED, new Object[] {}, locale);
    ChannelCategoryBean uncategorizedPortletsBean = new ChannelCategoryBean(new PortletCategory(uncategorizedString));
    uncategorizedPortletsBean.setName(UNCATEGORIZED);
    uncategorizedPortletsBean.setDescription(messageSource.getMessage(UNCATEGORIZED_DESC, new Object[] {}, locale));
    for (IPortletDefinition portlet : portletsNotYetCategorized) {
        if (authorizationService.canPrincipalBrowse(ap, portlet)) {
            // construct a new channel bean from this channel
            ChannelBean channel = getChannel(portlet, request, locale);
            uncategorizedPortletsBean.addChannel(channel);
        }
    }
    // Add even if no portlets in category
    categories.add(uncategorizedPortletsBean);
    rslt.put("categories", categories);
    return rslt;
}
Also used : Locale(java.util.Locale) EntityIdentifier(org.apereo.portal.EntityIdentifier) ChannelBean(org.apereo.portal.layout.dlm.remoting.registry.ChannelBean) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) ChannelCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.ChannelCategoryBean) TreeSet(java.util.TreeSet) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 64 with SortedSet

use of java.util.SortedSet in project uPortal by Jasig.

the class ChannelListController method getPortletRegistry.

/**
 * Updated version of this API. Supports an optional 'categoryId' parameter. If provided, this
 * URL will return the portlet registry beginning with the specified category, including all
 * descendants, and <em>excluding</em> uncategorized portlets. If no 'categoryId' is provided,
 * this method returns the portlet registry beginning with 'All Categories' (the root) and
 * <em>including</em> uncategorized portlets. Access is based on the SUBSCRIBE permission.
 *
 * @since 4.3
 */
@RequestMapping(value = "/v4-3/dlm/portletRegistry.json", method = RequestMethod.GET)
public ModelAndView getPortletRegistry(WebRequest webRequest, HttpServletRequest request, @RequestParam(value = "categoryId", required = false) String categoryId) {
    final PortletCategory rootCategory = categoryId != null ? portletCategoryRegistry.getPortletCategory(categoryId) : portletCategoryRegistry.getTopLevelPortletCategory();
    final boolean includeUncategorized = categoryId != null ? // Don't provide uncategorized portlets
    false : // if a specific category was requested
    true;
    final IPerson user = personManager.getPerson(request);
    final Map<String, SortedSet<?>> registry = getRegistry43(webRequest, user, rootCategory, includeUncategorized);
    return new ModelAndView("jsonView", "registry", registry);
}
Also used : IPerson(org.apereo.portal.security.IPerson) ModelAndView(org.springframework.web.servlet.ModelAndView) SortedSet(java.util.SortedSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 65 with SortedSet

use of java.util.SortedSet in project uPortal by Jasig.

the class BasePortletLayoutStatisticsController method createColumnDiscriminatorMap.

protected Map<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>> createColumnDiscriminatorMap(F form) {
    // Collections used to track the queried groups and the results
    final Map<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>> groupedAggregations = new TreeMap<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>>(PortletLayoutAggregationDiscriminatorImpl.Comparator.INSTANCE);
    // Get concrete group mapping objects that are being queried for
    List<Long> groups = form.getGroups();
    Set<String> portletFNames = form.getPortlets();
    for (final Long queryGroupId : groups) {
        AggregatedGroupMapping groupMapping = this.aggregatedGroupLookupDao.getGroupMapping(queryGroupId);
        for (final String portletFName : portletFNames) {
            AggregatedPortletMapping tabMapping = this.aggregatedPortletLookupDao.getMappedPortletForFname(portletFName);
            final PortletLayoutAggregationDiscriminator mapping = new PortletLayoutAggregationDiscriminatorImpl(groupMapping, tabMapping);
            // Create the set the aggregations for this report column will be stored in, sorted
            // chronologically
            final SortedSet<PortletLayoutAggregation> aggregations = new TreeSet<PortletLayoutAggregation>(BaseAggregationDateTimeComparator.INSTANCE);
            // Map the group to the set
            groupedAggregations.put(mapping, aggregations);
        }
    }
    return groupedAggregations;
}
Also used : PortletLayoutAggregationDiscriminator(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminator) PortletLayoutAggregation(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) TreeSet(java.util.TreeSet) PortletLayoutAggregationDiscriminatorImpl(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminatorImpl)

Aggregations

SortedSet (java.util.SortedSet)127 TreeSet (java.util.TreeSet)49 Iterator (java.util.Iterator)43 HashMap (java.util.HashMap)24 NavigableSet (java.util.NavigableSet)22 ArrayList (java.util.ArrayList)20 Map (java.util.Map)20 List (java.util.List)19 Set (java.util.Set)19 TreeMap (java.util.TreeMap)18 HashSet (java.util.HashSet)15 Test (org.junit.Test)13 IOException (java.io.IOException)12 Collection (java.util.Collection)10 Comparator (java.util.Comparator)7 LinkedHashMap (java.util.LinkedHashMap)7 LinkedList (java.util.LinkedList)5 SolverException (cbit.vcell.solver.SolverException)3 TestStringSortedSetGenerator (com.google.common.collect.testing.TestStringSortedSetGenerator)3 File (java.io.File)3