public synchronized Universe<?> getUniverse(UniverseSpec spec) throws ProvisioningException { return universeResolver.getUniverse(spec); }
public synchronized Path resolve(FeaturePackLocation fpl) throws ProvisioningException { return universeResolver.resolve(fpl); }
public synchronized FeaturePackLocation resolveLatestBuild(FeaturePackLocation fpl) throws ProvisioningException { return universeResolver.resolveLatestBuild(fpl); }
public static ProvisioningLayoutFactory getInstance() throws ProvisioningException { return getInstance(UniverseResolver.builder().build()); }
protected UniverseResolver buildUniverseResolver() throws ProvisioningException { return new UniverseResolver(this); }
public synchronized boolean isResolved(FeaturePackLocation fpl) throws ProvisioningException { return universeResolver.isResolved(fpl); }
/** * Returns repository artifact resolver for specific repository type. * * @param repositoryId repository id * @return artifact resolver * @throws ProvisioningException in case artifact resolver was not configured for the repository type */ public RepositoryArtifactResolver getArtifactResolver(String repositoryId) throws ProvisioningException { return layout.getFactory().getUniverseResolver().getArtifactResolver(repositoryId); }
public PmSession(Configuration config, boolean interactive, UniverseSpec builtin) throws Exception { this.config = config; this.mavenListener = new MavenListener(); this.maven = new CliMavenArtifactRepositoryManager(config.getMavenConfig(), mavenListener); UniverseResolver universeResolver = UniverseResolver.builder().addArtifactResolver(maven).build(); universe = new UniverseManager(this, config, maven, universeResolver, builtin); this.interactive = interactive; cacheManager = new FeaturePackCacheManager(config.getLayoutCache(), policy); if (interactive) { layoutFactory = ProvisioningLayoutFactory.getInstance(universeResolver, cacheManager); } else { layoutFactory = ProvisioningLayoutFactory.getInstance(universeResolver); } resolver = new ResourceResolver(this); // Abort running universe resolution if any. Runtime.getRuntime().addShutdownHook(new Thread(() -> { close(); })); }
public UniverseResolver build() throws ProvisioningException { return new UniverseResolver(this); } }
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()) { } } }
if(branchId == null) { if(fpl.getBuild() == null) { fpl = layoutFactory.getUniverseResolver().resolveLatestBuild(fpl); if(resolvedVersions == null) { resolvedVersions = new LinkedHashMap<>();
public Path put(UniverseResolver universeResolver, FeaturePackLocation fpl) throws ProvisioningException { Path fpDir = LayoutUtils.getFeaturePackDir(home, fpl.getFPID(), false); if (Files.exists(fpDir)) { if (!overwritePolicy.hasExpired(fpDir, fpl.getFPID())) { return fpDir; } IoUtils.recursiveDelete(fpDir); } unpack(fpDir, universeResolver.resolve(fpl)); overwritePolicy.cached(fpl.getFPID()); return fpDir; }
/** * 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); }
fpl = layoutFactory.getUniverseResolver().resolveLatestBuild(fpl);
builtinUniverse = (MavenUniverse) universeResolver.getUniverse(builtinUniverseSpec); if (closed) { return;
/** * 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())); }
public boolean isResolved(FeaturePackLocation fpl) throws ProvisioningException { return getUniverse(fpl.getUniverse()).getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName()).isResolved(fpl); }
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); } }
/** * Adds feature-pack archive to the local provisioning feature-pack cache. * Optionally, installs the feature-pack archive to the universe repository. * * @param featurePack feature-pack archive * @param installInUniverse whether to install the feature-pack into the universe repository * @return feature-pack location which was added to the local cache * @throws ProvisioningException in case of a failure */ public synchronized FeaturePackLocation addLocal(Path featurePack, boolean installInUniverse) throws ProvisioningException { final FPID fpid = FeaturePackDescriber.readSpec(featurePack).getFPID(); cacheManager.put(featurePack, fpid); if(!installInUniverse) { return fpid.getLocation(); } if(universeInstallers == null) { universeInstallers = UniverseFeaturePackInstaller.load(); } final Universe<?> universe = universeResolver.getUniverse(fpid.getUniverse()); final UniverseFeaturePackInstaller fpInstaller = universeInstallers.get(universe.getFactoryId()); if(fpInstaller == null) { throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), universeInstallers.keySet())); } fpInstaller.install(universe, fpid, featurePack); return fpid.getLocation(); }
/** * 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; }