private static void visit(UniverseVisitor visitor, Universe<?> universe, UniverseSpec universeSpec, boolean allBuilds) throws ProvisioningException { for (Producer<?> producer : universe.getProducers()) { for (Channel channel : producer.getChannels()) { if (allBuilds) { List<String> builds = getAllBuilds(universeSpec, producer, channel); if (builds != null && !builds.isEmpty()) { for (String build : builds) { visitor.visit(producer, new FeaturePackLocation(universeSpec, producer.getName(), channel.getName(), null, build)); } } } for (String freq : producer.getFrequencies()) { String build = getBuild(universeSpec, producer, channel, freq); // We have a latest build for the frequency. if (build != null) { FeaturePackLocation loc = new FeaturePackLocation(universeSpec, producer.getName(), channel.getName(), freq, build); visitor.visit(producer, loc); } } } } }
private void getAllProducers(String name, UniverseSpec spec, Universe<?> universe, List<String> candidates) throws ProvisioningException { for (Producer<?> p : universe.getProducers()) { for (Channel c : p.getChannels()) { if (!candidates.contains(p.getName())) { candidates.add(p.getName() + FeaturePackLocation.CHANNEL_START + c.getName()); } } } }
/** * Resolves feature-pack location to a path in a local repository * * @param fpl feature-pack location * @return local feature-pack path * @throws ProvisioningException in case the feature-pack could not be resolved */ public Path resolve(FeaturePackLocation fpl) throws ProvisioningException { if (localFeaturePacks.containsKey(fpl.getFPID())) { return localFeaturePacks.get(fpl.getFPID()); } return getUniverse(fpl.getUniverse()).getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName()).resolve(fpl); }
@Override public void visit(Producer<?> producer, FeaturePackLocation loc) { if (loc.getFrequency() == null) { return; } if (allFrequencies || loc.getFrequency().equals(producer.getDefaultFrequency())) { Table table = tables.get(loc.getUniverse()); if (table == null) { table = new Table(Headers.PRODUCT, Headers.UPDATE_CHANNEL, Headers.LATEST_BUILD); tables.put(loc.getUniverse(), table); } loc = invoc.getPmSession().getExposedLocation(finalPath, loc); table.addLine(producer.getName(), StateInfoUtil.formatChannel(loc), (loc.getBuild() == null ? NONE : loc.getBuild())); } }
private static List<String> getAllBuilds(UniverseSpec spec, Producer<?> producer, Channel channel) { FeaturePackLocation loc = new FeaturePackLocation(spec, producer.getName(), channel.getName(), null, null); List<String> build = Collections.emptyList(); try { build = channel.getAllBuilds(loc); } catch (ProvisioningException ex) { // OK, no build. } return build; }
private void resolveUniverse(UniverseSpec u) throws ProvisioningException { // Resolve universe synchronously. Universe<?> universe = universeResolver.getUniverse(u); for (Producer<?> p : universe.getProducers()) { for (Channel c : p.getChannels()) { } } }
@Override public void completeFrequency(FPLocationParser.ParsedFPLocation parsedLocation, String frequency) throws FPLocationParserException, ProvisioningException { Producer<?> p = getProducer(parsedLocation, pmSession); if (p == null) { return; } for (String freq : p.getFrequencies()) { if (freq.equals(frequency)) { // Do not inline the build separator, separator is to be added explicitly // this could be revisited. candidates.add(freq); } else if (freq.startsWith(frequency)) { candidates.add(freq); } } }
/** * Query for available version update and patches for the specific producer. * * @param producer the producer to check the updates for * @return available updates for the producer * @throws ProvisioningException in case of a failure */ public FeaturePackUpdatePlan getFeaturePackUpdate(ProducerSpec producer) throws ProvisioningException { final F f = featurePacks.get(producer); if(f == null) { throw new ProvisioningException(Errors.unknownFeaturePack(producer.getLocation().getFPID())); } final FeaturePackLocation fpl = f.getFPID().getLocation(); final Universe<?> universe = layoutFactory.getUniverseResolver().getUniverse(fpl.getUniverse()); final Channel channel = universe.getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName()); final List<F> patches = fpPatches.get(fpl.getFPID()); final Set<FPID> patchIds; if (patches == null || patches.isEmpty()) { patchIds = Collections.emptySet(); } else if (patches.size() == 1) { patchIds = Collections.singleton(patches.get(0).getFPID()); } else { final Set<FPID> tmp = new HashSet<>(patches.size()); for (F p : patches) { tmp.add(p.getFPID()); } patchIds = CollectionUtils.unmodifiable(tmp); } return channel.getUpdatePlan(FeaturePackUpdatePlan.request(fpl, patchIds, f.isTransitiveDep())); }
private void getProducers(String producerName, String universeName, Universe<?> universe, List<String> candidates) throws ProvisioningException { for (Producer<?> p : universe.getProducers()) { if (!candidates.contains(p.getName())) { // Display producer:channel as a whole, makes it clear that we require both. if (p.getName().startsWith(producerName)) { if (universeName == null) { for (Channel c : p.getChannels()) { candidates.add(p.getName() + FeaturePackLocation.CHANNEL_START + c.getName()); } } else { for (Channel c : p.getChannels()) { candidates.add(p.getName() + FeaturePackLocation.UNIVERSE_START + universeName + FeaturePackLocation.CHANNEL_START + c.getName()); } } } } } }
private static String getBuild(UniverseSpec spec, Producer<?> producer, Channel channel, String freq) { FeaturePackLocation loc = new FeaturePackLocation(spec, producer.getName(), channel.getName(), freq, null); String build = null; try { build = channel.getLatestBuild(loc); } catch (ProvisioningException ex) { // OK, no build. } return build; }
@Override public void completeChannel(FPLocationParser.ParsedFPLocation parsedLocation, String channel) throws FPLocationParserException, ProvisioningException { Producer<?> p = getProducer(parsedLocation, pmSession); if (p == null) { return; } for (Channel c : p.getChannels()) { if (c.getName().equals(channel)) { // Do nothing, do not inline separators. Separators are to be added explicitly // this could be revisited. candidates.add(channel); } else if (c.getName().startsWith(channel)) { candidates.add(c.getName()); } } }
@Override public boolean hasExpired(Path fpDir, FeaturePackLocation.FPID fpid) { try { boolean devBuild = universe.getUniverse(fpid.getUniverse()). getProducer(fpid.getProducer().getName()).getChannel(fpid.getChannel().getName()). isDevBuild(fpid); return devBuild && !seen.contains(fpid); } catch (ProvisioningException ex) { CliLogging.exception(ex); return true; } }
return; for (Channel c : p.getChannels()) { if (closed) { return; FeaturePackLocation ploc = new FeaturePackLocation(builtinUniverseSpec, p.getName(), c.getName(), null, null); deps.add(ploc);
private Producer<?> getProducer(FPLocationParser.ParsedFPLocation parsedLocation, PmSession pmSession) { try { UniverseSpec spec = null; if (parsedLocation.getUniverseName() != null) { spec = pmSession.getUniverse().getUniverseSpec(installation, parsedLocation.getUniverseName()); } else if (parsedLocation.getUniverseFactory() == null) { // default universe spec = pmSession.getUniverse().getDefaultUniverseSpec(installation); } else { spec = new UniverseSpec(parsedLocation.getUniverseFactory(), parsedLocation.getUniverseLocation()); } if (spec == null) { return null; } Universe<?> universe = pmSession.getUniverse().getUniverse(spec); if (universe == null) { return null; } for (Producer<?> p : universe.getProducers()) { if (p.getName().equals(parsedLocation.getProducer())) { return p; } } } catch (ProvisioningException ex) { CliLogging.completionException(ex); } return null; }
public boolean isResolved(FeaturePackLocation fpl) throws ProvisioningException { return getUniverse(fpl.getUniverse()).getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName()).isResolved(fpl); }
@Override public void visit(Producer<?> producer, FeaturePackLocation loc) { try { if (resolvedOnly && !producer.getChannel(loc.getChannelName()).isResolved(loc)) { return;
/** * Resolves latest available feature-pack ID * * @param fpl feature-pack location * @return latest available feature-pack id * @throws ProvisioningException in case of any error */ public FeaturePackLocation resolveLatestBuild(FeaturePackLocation fpl) throws ProvisioningException { Channel channel = getUniverse(fpl.getUniverse()) .getProducer(fpl.getProducerName()) .getChannel(fpl.getChannelName()); final String latestBuild = channel.getLatestBuild(fpl); FeaturePackLocation latestLocation = new FeaturePackLocation(fpl.getUniverse(), fpl.getProducerName(), fpl.getChannelName(), fpl.getFrequency(), latestBuild); channel.resolve(latestLocation); return latestLocation; }
parsedLocation.getChannel(), null, null).getFPID(); latestBuild = pmSession.getUniverse().getUniverse(spec). getProducer(parsedLocation.getProducer()).getChannel(parsedLocation.getChannel()).getLatestBuild(id); } else { FeaturePackLocation loc = new FeaturePackLocation(spec, parsedLocation.getProducer(), parsedLocation.getChannel(), parsedLocation.getFrequency(), null); latestBuild = pmSession.getUniverse().getUniverse(spec). getProducer(parsedLocation.getProducer()).getChannel(parsedLocation.getChannel()).getLatestBuild(loc);