Search in sources :

Example 16 with FPID

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);
}
Also used : FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 17 with FPID

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;
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 18 with FPID

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()));
}
Also used : HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProvisioningException(org.jboss.galleon.ProvisioningException) Channel(org.jboss.galleon.universe.Channel) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 19 with FPID

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();
}
Also used : UniverseFeaturePackInstaller(org.jboss.galleon.universe.UniverseFeaturePackInstaller) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 20 with FPID

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));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Aggregations

FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)23 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)14 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)11 ArrayList (java.util.ArrayList)8 ProvisioningException (org.jboss.galleon.ProvisioningException)8 IOException (java.io.IOException)5 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)5 Path (java.nio.file.Path)4 HashMap (java.util.HashMap)4 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)4 Table (org.jboss.galleon.cli.cmd.Table)4 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)4 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)4 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)4 HashSet (java.util.HashSet)3 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 Cell (org.jboss.galleon.cli.cmd.Table.Cell)3 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2