@Override public UniverseSpec getDefaultUniverse() { return this.defaultUniverse == null ? fpid.getLocation().getUniverse() : this.defaultUniverse; }
protected UniverseSpec getConfiguredUniverse(FeaturePackLocation source) { return source.hasUniverse() ? universeSpecs.get(source.getUniverse().toString()) : defaultUniverse; }
public static String formatChannel(FeaturePackLocation loc) { String channel = loc.getFrequency() == null ? loc.getChannel().getName() : loc.getChannel().getName() + "/" + loc.getFrequency(); return (loc.getUniverse() == null ? "" : loc.getUniverse() + "@") + channel; }
public static Path getFeaturePackDir(Path fpLayoutDir, FPID fpid, boolean existing) throws ProvisioningDescriptionException { final FeaturePackLocation fps = fpid.getLocation(); final UniverseSpec universe = fps.getUniverse(); Path fpPath = fpLayoutDir.resolve(universe.getFactory()); if (universe.getLocation() != null) { fpPath = fpPath.resolve(ensureValidFileName(universe.getLocation())); } fpPath = fpPath.resolve(ensureValidFileName(fps.getProducerName())).resolve(fps.getChannelName()).resolve(ensureValidFileName(fpid.getBuild())); if (existing && !Files.exists(fpPath)) { throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpPath)); } return fpPath; }
@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())); } }
/** * 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); }
exception(loc.getUniverse(), ex); return; Set<Result> locations = results.get(loc.getUniverse()); if (locations == null) { locations = new TreeSet<>(locComparator); results.put(loc.getUniverse(), locations); exception(loc.getUniverse(), ex); Set<Result> locations = results.get(loc.getUniverse()); if (locations == null) { locations = new TreeSet<>(locComparator); results.put(loc.getUniverse(), locations);
/** * 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())); }
/** * 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; }
public boolean isResolved(FeaturePackLocation fpl) throws ProvisioningException { return getUniverse(fpl.getUniverse()).getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName()).isResolved(fpl); }
public FeaturePackLocation getUserConfiguredLocation(FeaturePackLocation fpl) { final UniverseSpec universeSource = fpl.getUniverse(); if(defaultUniverse != null && defaultUniverse.equals(universeSource)) { return new FeaturePackLocation(null, fpl.getProducerName(), fpl.getChannelName(), fpl.getFrequency(), fpl.getBuild()); } for (Map.Entry<String, UniverseSpec> entry : universeSpecs.entrySet()) { if (entry.getValue().equals(universeSource)) { return new FeaturePackLocation(new UniverseSpec(entry.getKey(), null), fpl.getProducerName(), fpl.getChannelName(), fpl.getFrequency(), fpl.getBuild()); } } return fpl; }
static FeaturePackLocation resolveUniverse(FeaturePackDepsConfigBuilder<?> builder, FeaturePackLocation location) throws XMLStreamException { if(location.getUniverse() == null) { if(!builder.hasDefaultUniverse()) { throw new XMLStreamException("Failed to parse feature-pack configuration for " + location + ": default universe was not configured"); } location = new FeaturePackLocation(builder.getDefaultUniverse(), location.getProducerName(), location.getChannelName(), location.getFrequency(), location.getBuild()); } else { final UniverseSpec resolvedConfig = builder.getUniverseSpec(location.getUniverse().toString()); if(resolvedConfig != null) { location = new FeaturePackLocation(resolvedConfig, location.getProducerName(), location.getChannelName(), location.getFrequency(), location.getBuild()); } } return location; }
private UniverseSpec getConfiguredUniverse(FeaturePackLocation fpl) throws ProvisioningException, ProvisioningDescriptionException { final ProvisioningConfig config = getProvisioningConfig(); if(config == null) { return null; } if(fpl.hasUniverse()) { final String name = fpl.getUniverse().toString(); if(config.hasUniverse(name)) { return config.getUniverseSpec(name); } return null; } return config.getDefaultUniverse(); }
static FeaturePackLocation resolveUniverse(FeaturePackDepsConfigBuilder<?> builder, FeaturePackLocation location) throws XMLStreamException { if(location.getUniverse() == null) { if(!builder.hasDefaultUniverse()) { throw new XMLStreamException("Failed to parse feature-pack configuration for " + location + ": default universe was not configured"); } location = new FeaturePackLocation(builder.getDefaultUniverse(), location.getProducerName(), location.getChannelName(), location.getFrequency(), location.getBuild()); } else { final UniverseSpec resolvedConfig = builder.getUniverseSpec(location.getUniverse().toString()); if(resolvedConfig != null) { location = new FeaturePackLocation(resolvedConfig, location.getProducerName(), location.getChannelName(), location.getFrequency(), location.getBuild()); } } return location; }
void install(FeaturePackLocation.FPID fpid, Path fpContentDir) throws ProvisioningException { Universe<?> universe = null; UniverseFeaturePackInstaller ufpInstaller = null; if (universeResolution) { universe = universeResolver.getUniverse(fpid.getLocation().getUniverse()); ufpInstaller = ufpInstallers.get(universe.getFactoryId()); if (ufpInstaller == null) { throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), ufpInstallers.keySet())); } } final Path fpZip = getBuildDir().resolve(LayoutUtils.ensureValidFileName(fpid.toString())); try { ZipUtils.zip(fpContentDir, fpZip); } catch (IOException e) { throw new ProvisioningException("Failed to create feature-pack archive", e); } if (ufpInstaller != null) { ufpInstaller.install(universe, fpid, fpZip); } }
private FeaturePackLocation getResolvedLocation(Path installation, FeaturePackLocation fplocation) throws ProvisioningException { UniverseSpec spec = fplocation.getUniverse(); if (spec != null) { if (spec.getLocation() == null) { spec = universe.getUniverseSpec(installation, spec.getFactory()); if (spec == null) { throw new ProvisioningException("Unknown universe for " + fplocation); } } } else { spec = universe.getDefaultUniverseSpec(installation); } return new FeaturePackLocation(spec, fplocation.getProducerName(), fplocation.getChannelName(), fplocation.getFrequency(), fplocation.getBuild()); }
public FeaturePackLocation getExposedLocation(Path installation, FeaturePackLocation fplocation) { // Expose the default or name. UniverseSpec spec = fplocation.getUniverse(); boolean rewrite = false; String name = getUniverse().getUniverseName(installation, spec); if (name != null) { rewrite = true; spec = new UniverseSpec(name, null); } else if (getUniverse().getDefaultUniverseSpec(installation).equals(spec)) { rewrite = true; spec = null; } if (rewrite) { fplocation = new FeaturePackLocation(spec, fplocation.getProducerName(), fplocation.getChannelName(), fplocation.getFrequency(), fplocation.getBuild()); } return fplocation; } public void enableMavenTrace(boolean b) {