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;
}
use of java.util.SortedSet in project felix by apache.
the class ConfigurationAdminConfigurationPrinter method printConfiguration.
private void printConfiguration(PrintWriter pw, Configuration config) {
ConfigurationRender.infoLine(pw, "", "PID", config.getPid());
if (config.getFactoryPid() != null) {
ConfigurationRender.infoLine(pw, " ", "Factory PID", config.getFactoryPid());
}
String loc = (config.getBundleLocation() != null) ? config.getBundleLocation() : "Unbound";
ConfigurationRender.infoLine(pw, " ", "BundleLocation", loc);
Dictionary props = config.getProperties();
if (props != null) {
SortedSet keys = new TreeSet();
for (Enumeration ke = props.keys(); ke.hasMoreElements(); ) {
keys.add(ke.nextElement());
}
for (Iterator ki = keys.iterator(); ki.hasNext(); ) {
String key = (String) ki.next();
ConfigurationRender.infoLine(pw, " ", key, props.get(key));
}
}
pw.println();
}
use of java.util.SortedSet in project processdash by dtuma.
the class AbstractLabelColumn method getValuesInUse.
protected Set<String> getValuesInUse() {
SortedSet values = new TreeSet();
collectValuesInUse(values, wbsModel.getRoot());
return values;
}
use of java.util.SortedSet in project gatk by broadinstitute.
the class RecalibrationReport method logTablesWithMissingReadGroups.
/**
* helper function to output log messages if there are tables that are missing read groups that were seen in the other tables
* @param allReadGroups a set of all of the read groups across inputs
* @param inputReadGroups a map from file to the read groups that file contains
*/
private static void logTablesWithMissingReadGroups(SortedSet<String> allReadGroups, Map<File, Set<String>> inputReadGroups) {
// Log the read groups that are missing from specific inputs
for (final Map.Entry<File, Set<String>> entry : inputReadGroups.entrySet()) {
final File input = entry.getKey();
final Set<String> readGroups = entry.getValue();
if (allReadGroups.size() != readGroups.size()) {
// Since this is not completely unexpected, more than debug, but less than a proper warning.
logger.info("Missing read group(s)" + ": " + input.getAbsolutePath());
for (final Object readGroup : CollectionUtils.subtract(allReadGroups, readGroups)) {
logger.info(" " + readGroup);
}
}
}
}
use of java.util.SortedSet in project bnd by bndtools.
the class Project method getBundlesWildcard.
/**
* Get all bundles matching a wildcard expression.
*
* @param bsnPattern A bsn wildcard, e.g. "osgi*" or just "*".
* @param range A range to narrow the versions of bundles found, or null to
* return any version.
* @param strategyx The version selection strategy, which may be 'HIGHEST'
* or 'LOWEST' only -- 'EXACT' is not permitted.
* @param attrs Additional search attributes.
* @throws Exception
*/
public List<Container> getBundlesWildcard(String bsnPattern, String range, Strategy strategyx, Map<String, String> attrs) throws Exception {
if (VERSION_ATTR_SNAPSHOT.equals(range) || VERSION_ATTR_PROJECT.equals(range))
return Collections.singletonList(new Container(this, bsnPattern, range, TYPE.ERROR, null, "Cannot use snapshot or project version with wildcard matches", null, null));
if (strategyx == Strategy.EXACT)
return Collections.singletonList(new Container(this, bsnPattern, range, TYPE.ERROR, null, "Cannot use exact version strategy with wildcard matches", null, null));
VersionRange versionRange;
if (range == null || VERSION_ATTR_LATEST.equals(range))
versionRange = new VersionRange("0");
else
versionRange = new VersionRange(range);
RepoFilter repoFilter = parseRepoFilter(attrs);
if (bsnPattern != null) {
bsnPattern = bsnPattern.trim();
if (bsnPattern.length() == 0 || bsnPattern.equals("*"))
bsnPattern = null;
}
SortedMap<String, Pair<Version, RepositoryPlugin>> providerMap = new TreeMap<String, Pair<Version, RepositoryPlugin>>();
List<RepositoryPlugin> plugins = workspace.getRepositories();
for (RepositoryPlugin plugin : plugins) {
if (repoFilter != null && !repoFilter.match(plugin))
continue;
List<String> bsns = plugin.list(bsnPattern);
if (bsns != null)
for (String bsn : bsns) {
SortedSet<Version> versions = plugin.versions(bsn);
if (versions != null && !versions.isEmpty()) {
Pair<Version, RepositoryPlugin> currentProvider = providerMap.get(bsn);
Version candidate;
switch(strategyx) {
case HIGHEST:
candidate = versions.last();
if (currentProvider == null || candidate.compareTo(currentProvider.getFirst()) > 0) {
providerMap.put(bsn, new Pair<Version, RepositoryPlugin>(candidate, plugin));
}
break;
case LOWEST:
candidate = versions.first();
if (currentProvider == null || candidate.compareTo(currentProvider.getFirst()) < 0) {
providerMap.put(bsn, new Pair<Version, RepositoryPlugin>(candidate, plugin));
}
break;
default:
// we shouldn't have reached this point!
throw new IllegalStateException("Cannot use exact version strategy with wildcard matches");
}
}
}
}
List<Container> containers = new ArrayList<Container>(providerMap.size());
for (Entry<String, Pair<Version, RepositoryPlugin>> entry : providerMap.entrySet()) {
String bsn = entry.getKey();
Version version = entry.getValue().getFirst();
RepositoryPlugin repo = entry.getValue().getSecond();
DownloadBlocker downloadBlocker = new DownloadBlocker(this);
File bundle = repo.get(bsn, version, attrs, downloadBlocker);
if (bundle != null && !bundle.getName().endsWith(".lib")) {
containers.add(new Container(this, bsn, range, Container.TYPE.REPO, bundle, null, attrs, downloadBlocker));
}
}
return containers;
}
Aggregations