Search in sources :

Example 11 with UniverseSpec

use of org.jboss.galleon.universe.UniverseSpec in project galleon by wildfly.

the class FeaturePackLocationStringTestCase method testChannelWithoutFrequencyToString.

@Test
public void testChannelWithoutFrequencyToString() throws Exception {
    final ChannelSpec channel = new FeaturePackLocation(new UniverseSpec("factory", "location"), "producer", "channel", null, "build").getChannel();
    Assert.assertEquals("producer@factory(location):channel", channel.toString());
}
Also used : FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) ChannelSpec(org.jboss.galleon.universe.FeaturePackLocation.ChannelSpec) Test(org.junit.Test)

Example 12 with UniverseSpec

use of org.jboss.galleon.universe.UniverseSpec in project galleon by wildfly.

the class ProvisioningManager method install.

public void install(FeaturePackConfig fpConfig, Map<String, String> options) throws ProvisioningException {
    ProvisioningConfig config = getProvisioningConfig();
    if (config == null) {
        config = ProvisioningConfig.builder().build();
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = getLayoutFactory().newConfigLayout(config, ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        final UniverseSpec configuredUniverse = getConfiguredUniverse(fpConfig.getLocation());
        layout.install(configuredUniverse == null ? fpConfig : FeaturePackConfig.builder(fpConfig.getLocation().replaceUniverse(configuredUniverse)).init(fpConfig).build(), options);
        doProvision(layout, getFsDiff(), false);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder) UniverseSpec(org.jboss.galleon.universe.UniverseSpec)

Example 13 with UniverseSpec

use of org.jboss.galleon.universe.UniverseSpec in project galleon by wildfly.

the class FPLocationCompleter method getProducer.

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

Example 14 with UniverseSpec

use of org.jboss.galleon.universe.UniverseSpec in project galleon by wildfly.

the class UniverseTestCase method setup.

@BeforeClass
public static void setup() throws Exception {
    universeSpec_builtin = new UniverseSpec(MavenUniverseFactory.ID, TestConstants.GROUP_ID + ":" + UNIVERSE_NAME_BUILTIN);
    cli = new CliWrapper(universeSpec_builtin);
    MvnUniverse universe3 = MvnUniverse.getInstance(UNIVERSE_NAME_BUILTIN, cli.getSession().getMavenRepoManager());
    CliTestUtils.setupUniverse(universe3, cli, UNIVERSE_NAME_BUILTIN, Arrays.asList(PRODUCER3));
    MvnUniverse universe1 = MvnUniverse.getInstance(UNIVERSE_NAME, cli.getSession().getMavenRepoManager());
    universeSpec1 = CliTestUtils.setupUniverse(universe1, cli, UNIVERSE_NAME, Arrays.asList(PRODUCER1));
    MvnUniverse universe2 = MvnUniverse.getInstance(UNIVERSE_NAME2, cli.getSession().getMavenRepoManager());
    universeSpec2 = CliTestUtils.setupUniverse(universe2, cli, UNIVERSE_NAME2, Arrays.asList(PRODUCER2));
}
Also used : MvnUniverse(org.jboss.galleon.universe.MvnUniverse) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) BeforeClass(org.junit.BeforeClass)

Example 15 with UniverseSpec

use of org.jboss.galleon.universe.UniverseSpec in project galleon by wildfly.

the class ListFeaturePacksCommand method runCommand.

@Override
public void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    Map<UniverseSpec, Table> tables = new HashMap<>();
    Map<UniverseSpec, Set<String>> exceptions = new HashMap<>();
    // Search for an installation in the context
    Path installation = null;
    try {
        installation = Util.lookupInstallationDir(invoc.getConfiguration().getAeshContext(), null);
    } catch (ProvisioningException ex) {
    // XXX OK, no installation.
    }
    Path finalPath = installation;
    UniverseVisitor visitor = new UniverseVisitor() {

        @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()));
            }
        }

        @Override
        public void exception(UniverseSpec spec, Exception ex) {
            Set<String> set = exceptions.get(spec);
            if (set == null) {
                set = new HashSet<>();
                exceptions.put(spec, set);
            }
            set.add(ex.getLocalizedMessage() == null ? ex.getMessage() : ex.getLocalizedMessage());
        }
    };
    try {
        if (fromUniverse != null) {
            invoc.getPmSession().getUniverse().visitUniverse(UniverseSpec.fromString(fromUniverse), visitor, true);
        } else {
            invoc.getPmSession().getUniverse().visitAllUniverses(visitor, true, finalPath);
        }
    } catch (ProvisioningException ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.resolvedUniverseFailed(), ex);
    }
    FindCommand.printExceptions(invoc, exceptions);
    for (Entry<UniverseSpec, Table> entry : tables.entrySet()) {
        Table table = entry.getValue();
        table.sort(Table.SortType.ASCENDANT);
        invoc.println(table.build());
    }
}
Also used : Path(java.nio.file.Path) Table(org.jboss.galleon.cli.cmd.Table) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException) Producer(org.jboss.galleon.universe.Producer) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) UniverseVisitor(org.jboss.galleon.cli.UniverseManager.UniverseVisitor)

Aggregations

UniverseSpec (org.jboss.galleon.universe.UniverseSpec)29 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)18 Test (org.junit.Test)14 ProvisioningException (org.jboss.galleon.ProvisioningException)6 ProvisioningManager (org.jboss.galleon.ProvisioningManager)4 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)4 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)4 Path (java.nio.file.Path)3 ChannelSpec (org.jboss.galleon.universe.FeaturePackLocation.ChannelSpec)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)2 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)2 UniverseVisitor (org.jboss.galleon.cli.UniverseManager.UniverseVisitor)2 Table (org.jboss.galleon.cli.cmd.Table)2 Producer (org.jboss.galleon.universe.Producer)2 IOException (java.io.IOException)1 Comparator (java.util.Comparator)1