use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class ProvisioningManagerUniverseManagementTestCase method testAddRemoveUniverseToFreshDir.
@Test
public void testAddRemoveUniverseToFreshDir() throws Exception {
Assert.assertNull(getProvisioningConfig());
ProvisioningManager pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.addUniverse("universe1", new UniverseSpec("factory1", "location1"));
ProvisioningConfig config = getProvisioningConfig();
assertNotNull(config);
assertFalse(config.hasDefaultUniverse());
Map<String, UniverseSpec> universes = config.getUniverseNamedSpecs();
assertEquals(1, universes.size());
assertTrue(universes.containsKey("universe1"));
pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.addUniverse("universe2", new UniverseSpec("factory2", "location2"));
config = getProvisioningConfig();
assertNotNull(config);
assertFalse(config.hasDefaultUniverse());
universes = config.getUniverseNamedSpecs();
assertEquals(2, universes.size());
assertTrue(universes.containsKey("universe1"));
assertTrue(universes.containsKey("universe2"));
pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.removeUniverse("universe1");
config = getProvisioningConfig();
assertNotNull(config);
assertFalse(config.hasDefaultUniverse());
universes = config.getUniverseNamedSpecs();
assertEquals(1, universes.size());
assertTrue(universes.containsKey("universe2"));
pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.removeUniverse("universe2");
config = getProvisioningConfig();
assertFalse(config.hasDefaultUniverse());
assertTrue(config.getUniverseNamedSpecs().isEmpty());
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class ProvisioningManagerUniverseManagementTestCase method testSetUnsetDefaultUniverseOnFreshDir.
@Test
public void testSetUnsetDefaultUniverseOnFreshDir() throws Exception {
Assert.assertNull(getProvisioningConfig());
ProvisioningManager pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.setDefaultUniverse(new UniverseSpec("factory1", "location1"));
ProvisioningConfig config = getProvisioningConfig();
assertNotNull(config);
Map<String, UniverseSpec> universes = config.getUniverseNamedSpecs();
assertEquals(0, universes.size());
assertTrue(config.hasDefaultUniverse());
assertEquals(new UniverseSpec("factory1", "location1"), config.getDefaultUniverse());
pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.setDefaultUniverse(new UniverseSpec("factory2", "location1"));
config = getProvisioningConfig();
assertNotNull(config);
universes = config.getUniverseNamedSpecs();
assertEquals(0, universes.size());
assertTrue(config.hasDefaultUniverse());
assertEquals(new UniverseSpec("factory2", "location1"), config.getDefaultUniverse());
pm = ProvisioningManager.builder().setInstallationHome(home).build();
pm.removeUniverse(null);
config = getProvisioningConfig();
assertNotNull(config);
universes = config.getUniverseNamedSpecs();
assertEquals(0, universes.size());
assertFalse(config.hasDefaultUniverse());
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class UniverseManager method removeUniverse.
public void removeUniverse(Path installation, String name) throws ProvisioningException, IOException {
ProvisioningManager mgr = getProvisioningManager(installation);
// Remove default if name is null
mgr.removeUniverse(name);
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class CheckUpdatesCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation session) throws CommandExecutionException {
try {
ProvisioningManager mgr = getManager(session.getPmSession());
Updates updates = getUpdatesTable(mgr, session, includeAll, fp);
if (updates.plan.isEmpty()) {
session.println(UP_TO_DATE);
} else {
session.println(UPDATES_AVAILABLE);
session.println(updates.t.build());
}
} catch (ProvisioningException ex) {
throw new CommandExecutionException(session.getPmSession(), CliErrors.checkForUpdatesFailed(), ex);
}
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class InstalledProducerCompleter method getInstallationLocations.
public static List<FeaturePackLocation> getInstallationLocations(Path installation, PmSession session, boolean transitive, boolean patches) {
List<FeaturePackLocation> items = new ArrayList<>();
try {
PathsUtils.assertInstallationDir(installation);
ProvisioningManager mgr = session.newProvisioningManager(installation, false);
try (ProvisioningLayout<FeaturePackLayout> layout = mgr.getLayoutFactory().newConfigLayout(mgr.getProvisioningConfig())) {
for (FeaturePackLayout fp : layout.getOrderedFeaturePacks()) {
if (fp.isDirectDep() || (fp.isTransitiveDep() && transitive)) {
items.add(fp.getFPID().getLocation());
}
if (patches) {
List<FeaturePackLayout> appliedPatches = layout.getPatches(fp.getFPID());
for (FeaturePackLayout patch : appliedPatches) {
items.add(patch.getFPID().getLocation());
}
}
}
}
} catch (Exception ex) {
CliLogging.completionException(ex);
}
return items;
}
Aggregations