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