use of org.jboss.galleon.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class StateInfoUtil method buildDependencies.
private static String buildDependencies(PmCommandInvocation invoc, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException {
Map<FPID, FeaturePackConfig> configs = new HashMap<>();
List<FeaturePackLocation> dependencies = new ArrayList<>();
for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
boolean isProduct = true;
for (FeaturePackLayout fpLayout2 : layout.getOrderedFeaturePacks()) {
if (fpLayout2.getSpec().hasTransitiveDep(fpLayout.getFPID().getProducer()) || fpLayout2.getSpec().getFeaturePackDep(fpLayout.getFPID().getProducer()) != null) {
isProduct = false;
break;
}
}
if (!isProduct) {
FeaturePackLocation loc = invoc.getPmSession().getExposedLocation(null, fpLayout.getFPID().getLocation());
dependencies.add(loc);
FeaturePackConfig transitiveConfig = layout.getConfig().getTransitiveDep(fpLayout.getFPID().getProducer());
configs.put(loc.getFPID(), transitiveConfig);
}
}
return buildDependencies(dependencies, configs);
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class StateInfoUtil method buildPatches.
public static String buildPatches(PmCommandInvocation invoc, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException {
if (!layout.hasPatches()) {
return null;
}
Table table = new Table(Headers.PATCH, Headers.PATCH_FOR, Headers.UPDATE_CHANNEL);
for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
List<FeaturePackLayout> patches = layout.getPatches(fpLayout.getFPID());
for (FeaturePackLayout patch : patches) {
FeaturePackLocation loc = invoc.getPmSession().getExposedLocation(null, patch.getFPID().getLocation());
FPID patchFor = patch.getSpec().getPatchFor();
table.addLine(patch.getFPID().getBuild(), patchFor.getProducer().getName() + FeaturePackLocation.BUILD_START + patchFor.getBuild(), formatChannel(loc));
}
}
if (!table.isEmpty()) {
table.sort(Table.SortType.ASCENDANT);
return table.build();
}
return null;
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class ProvisioningLayout method getFeaturePackUpdate.
/**
* 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()));
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class ProvisioningLayoutFactory method addLocal.
/**
* 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();
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();
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class PatchTestCase method test.
@Test
public void test() throws Exception {
CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
Path install1 = CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
// No patches information
Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
Path patchDir = cli.newDir("patches", true);
FPID patchID = CliTestUtils.installPatch(cli, universeSpec, PRODUCER1, "1.0.0", "Alpha1", patchDir);
Path patchFile = patchDir.toFile().listFiles()[0].toPath();
// try to install from the FPID, should fail.
try {
cli.execute("install " + patchID + " --dir=" + install1);
throw new Exception("Install should have failed");
} catch (CommandException ex) {
// XXX OK.
}
// import the patch into universe
cli.execute("feature-pack import " + patchFile + " --install-in-universe=true");
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.toString()));
// Now we can use it.
cli.execute("install " + patchID + " --dir=" + install1);
ProvisioningConfig config = CliTestUtils.getConfig(install1);
FeaturePackConfig cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
Assert.assertTrue(cf1.hasPatches());
Assert.assertTrue(cf1.getPatches().contains(patchID));
// Get info from the patch
cli.execute("feature-pack get-info --file=" + patchFile);
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(GetInfoCommand.PATCH_FOR + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1")));
// Check that output contains the patch.
cli.execute("get-info --dir=" + install1);
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
// Check that output contains the patch.
cli.execute("get-info --dir=" + install1 + " --type=patches");
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH_FOR));
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH));
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
// uninstall the patch
cli.execute("uninstall --dir=" + install1 + " " + patchID);
config = CliTestUtils.getConfig(install1);
cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
Assert.assertFalse(cf1.hasPatches());
// install the patch using the file
cli.execute("install --dir=" + install1 + " --file=" + patchFile);
config = CliTestUtils.getConfig(install1);
cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
Assert.assertTrue(cf1.hasPatches());
Assert.assertTrue(cf1.getPatches().contains(patchID));
}
Aggregations