private Set<String> getRequiredFeatureIds(Repository repo) throws Exception { synchronized (lock) { return Stream.of(repo.getFeatures()) .filter(this::isRequired) .map(Feature::getId) .collect(toSet()); } }
@Override public Feature[] listFeatures() throws Exception { assertValid(); Set<Feature> allfeatures = new HashSet<Feature>(); Repository[] repositories = listRepositories(); for (Repository repository : repositories) { try { for (Feature feature : repository.getFeatures()) { if (!allfeatures.contains(feature)) { allfeatures.add(feature); } } } catch (Exception ex) { LOGGER.debug("Could not load features from %s.", repository.getURI()); } } return allfeatures.toArray(new Feature[allfeatures.size()]); }
@Override public Feature[] listFeatures() throws Exception { assertValid(); Set<Feature> allfeatures = new HashSet<Feature>(); Repository[] repositories = listRepositories(); for (Repository repository : repositories) { try { for (Feature feature : repository.getFeatures()) { if (!allfeatures.contains(feature)) { allfeatures.add(feature); } } } catch (Exception ex) { LOGGER.debug("Could not load features from %s.", repository.getURI()); } } return allfeatures.toArray(new Feature[allfeatures.size()]); }
private List<ExtendedFeature> getFeatures(List<Repository> repositories) { List<ExtendedFeature> features = new ArrayList<>(); if (featuresService == null) { this.log.error("Features service is not available"); return features; } try { for (Repository r : repositories) { for (Feature f : r.getFeatures()) { ExtendedFeature.State state = featuresService.isInstalled(f) ? ExtendedFeature.State.INSTALLED : ExtendedFeature.State.UNINSTALLED; features.add(new ExtendedFeature(state, r.getName(), f)); } } } catch (Exception e) { this.log.error(e.getMessage()); } Collections.sort(features, new ExtendedFeatureComparator()); return features; }
private Map<String, Map<String, Feature>> getFeatures(Iterable<Repository> repositories) throws Exception { Map<String, Map<String, Feature>> features = new HashMap<String, Map<String, Feature>>(); for (Repository repo : repositories) { try { for (Feature f : repo.getFeatures()) { if (features.get(f.getName()) == null) { Map<String, Feature> versionMap = new TreeMap<String, Feature>(); versionMap.put(f.getVersion(), f); features.put(f.getName(), versionMap); } else { features.get(f.getName()).put(f.getVersion(), f); } } } catch (Exception ex) { LOGGER.debug("Could not load features from %s.", repo.getURI()); } } return features; }
private Map<String, Map<String, Feature>> getFeatures(Iterable<Repository> repositories) throws Exception { Map<String, Map<String, Feature>> features = new HashMap<String, Map<String, Feature>>(); for (Repository repo : repositories) { try { for (Feature f : repo.getFeatures()) { if (features.get(f.getName()) == null) { Map<String, Feature> versionMap = new TreeMap<String, Feature>(); versionMap.put(f.getVersion(), f); features.put(f.getName(), versionMap); } else { features.get(f.getName()).put(f.getVersion(), f); } } } catch (Exception ex) { LOGGER.debug("Could not load features from %s.", repo.getURI()); } } return features; }
public JmxRepository(Repository repository) { try { String[] itemNames = FeaturesServiceMBean.REPOSITORY; Object[] itemValues = new Object[itemNames.length]; itemValues[0] = repository.getName(); itemValues[1] = repository.getURI().toString(); itemValues[2] = toStringArray(repository.getRepositories()); itemValues[3] = getFeatureIdentifierTable(Arrays.asList(repository.getFeatures())); itemValues[4] = repository.isBlacklisted(); data = new CompositeDataSupport(REPOSITORY, itemNames, itemValues); } catch (Exception e) { throw new IllegalStateException("Cannot form repository open data", e); } }
for (Feature f : repo.getFeatures()) { Map<String, Feature> versionMap = map.computeIfAbsent(f.getName(), key -> new HashMap<>()); versionMap.put(f.getVersion(), f);
for (Feature feature : repo.getFeatures()) { featureMap.put(feature.getName(), feature);
for (Feature f : rep.getFeatures()) { features.remove(new FeatureReq(f).toRequirement());
@Override public void addRepository(URI uri, boolean install) throws Exception { Repository repository = repositories.create(uri, true); synchronized (lock) { repositories.addRepository(repository); featureCache = null; // Add repo if (!state.repositories.add(uri.toString())) { return; } saveState(); } callListeners(new RepositoryEvent(repository, RepositoryEvent.EventType.RepositoryAdded, false)); // install the features in the repo if (install) { HashSet<String> features = new HashSet<>(); for (Feature feature : repository.getFeatures()) { features.add(feature.getId()); } installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class)); } }
if (repository.getURI().equals(karFeatureRepoUri)) { try { for (Feature feature : repository.getFeatures()) { if (feature.getInstall() == null || Feature.DEFAULT_INSTALL_MODE.equals(feature.getInstall())) { EnumSet<FeaturesService.Option> options = EnumSet.noneOf(FeaturesService.Option.class);
/** * Uninstall all features contained in the list of features XML. * * @param featuresRepositories the list of features XML. */ private void uninstallFeatures(List<URI> featuresRepositories) throws Exception { for (Repository repository : featuresService.listRepositories()) { for (URI karFeatureRepoUri : featuresRepositories) { if (repository.getURI().equals(karFeatureRepoUri)) { try { for (Feature feature : repository.getFeatures()) { if (feature.getInstall() == null || Feature.DEFAULT_INSTALL_MODE.equals(feature.getInstall())) { try { featuresService.uninstallFeature(feature.getName(), feature.getVersion()); } catch (Exception e) { LOGGER.warn("Unable to uninstall Kar feature {}", feature.getName() + "/" + feature.getVersion(), e); } } } } catch (Exception e) { LOGGER.warn("Can't get features for KAR {}", karFeatureRepoUri, e); } } } } }
public static Feature search(String name, String version, Collection<Repository> repositories) { VersionRange range = new VersionRange(version, false, true); Feature bestFeature = null; Version bestVersion = null; for (Repository repo : repositories) { Feature[] features; try { features = repo.getFeatures(); } catch (Exception e) { // This should not happen as the repository has been loaded already throw new IllegalStateException(e); } for (Feature feature : features) { if (name.equals(feature.getName())) { Version v = new Version(VersionCleaner.clean(feature.getVersion())); if (range.contains(v)) { if (bestVersion == null || bestVersion.compareTo(v) < 0) { bestFeature = feature; bestVersion = v; } } } } } return bestFeature; } }
public static Feature search(String name, String version, Collection<Repository> repositories) { VersionRange range = new VersionRange(version, false, true); Feature bestFeature = null; Version bestVersion = null; for (Repository repo : repositories) { Feature[] features; try { features = repo.getFeatures(); } catch (Exception e) { // This should not happen as the repository has been loaded already throw new IllegalStateException(e); } for (Feature feature : features) { if (name.equals(feature.getName())) { Version v = new Version(VersionCleaner.clean(feature.getVersion())); if (range.contains(v)) { if (bestVersion == null || bestVersion.compareTo(v) < 0) { bestFeature = feature; bestVersion = v; } } } } } return bestFeature; } }
/** * checks if all required features are available * @param featureRepos the repositories within the kar * @return <code>null</code> if the contained features have no unresolvable dependencies. Otherwise the first missing dependency * @throws Exception */ private Dependency findMissingDependency(List<URI> featureRepos) throws Exception { for (URI uri : featureRepos) { Feature[] includedFeatures = featuresService.getRepository(uri).getFeatures(); for (Feature includedFeature : includedFeatures) { List<Dependency> dependencies = includedFeature.getDependencies(); for (Dependency dependency : dependencies) { Feature feature = featuresService.getFeature(dependency.getName(), dependency.getVersion()); if(feature==null) { return dependency; } } } } return null; }
protected void doExecute(FeaturesService admin) throws Exception { ShellTable table = new ShellTable(); table.column("Version"); table.column("Repository"); table.column("Repository URL"); table.emptyTableText("No versions available for features '" + feature + "'"); for (Repository r : Arrays.asList(admin.listRepositories())) { for (Feature f : r.getFeatures()) { if (f.getName().equals(feature)) { table.addRow().addContent(f.getVersion(), r.getName(), r.getURI()); } } } table.print(System.out, !noFormat); }
protected void doExecute(FeaturesService admin) throws Exception { ShellTable table = new ShellTable(); table.column("Version"); table.column("Repository"); table.column("Repository URL"); table.emptyTableText("No versions available for features '" + feature + "'"); for (Repository r : Arrays.asList(admin.listRepositories())) { for (Feature f : r.getFeatures()) { if (f.getName().equals(feature)) { table.addRow().addContent(f.getVersion(), r.getName(), r.getURI()); } } } table.print(System.out, !noFormat); }
List<Feature> features = Arrays.asList(r.getFeatures()); if (ordered) { Collections.sort(features, new FeatureComparator());
List<Feature> features = Arrays.asList(r.getFeatures()); if (ordered) { Collections.sort(features, new FeatureComparator());