use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class AbstractInstallationCommand method getFeatureContainer.
public FeatureContainer getFeatureContainer(PmSession session, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException, CommandExecutionException, IOException {
FeatureContainer container;
ProvisioningManager manager = getManager(session);
if (manager.getProvisionedState() == null) {
throw new CommandExecutionException("Specified directory doesn't contain an installation");
}
if (layout == null) {
ProvisioningConfig config = manager.getProvisioningConfig();
try (ProvisioningRuntime runtime = manager.getRuntime(config)) {
container = FeatureContainers.fromProvisioningRuntime(session, runtime);
}
} else {
try (ProvisioningRuntime runtime = manager.getRuntime(layout)) {
container = FeatureContainers.fromProvisioningRuntime(session, runtime);
}
}
return container;
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class StateExportCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
if (file != null) {
final Path targetFile = file.toPath();
State session = invoc.getPmSession().getState();
try {
session.export(targetFile);
} catch (Exception ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.exportProvisionedFailed(), ex);
}
invoc.println("Provisioning file generated in " + targetFile);
} else {
ByteArrayOutputStream output = null;
try {
ProvisioningConfig config = invoc.getPmSession().getState().getConfig();
output = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8));
ProvisioningXmlWriter.getInstance().write(config, writer);
} catch (Exception e) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.exportProvisionedFailed(), e);
}
try {
invoc.println(output.toString(StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.exportProvisionedFailed(), e);
}
}
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class StateGetInfoCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
try {
ProvisioningConfig config = invoc.getPmSession().getContainer().getProvisioningConfig();
Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {
public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
return invoc.getPmSession().getState().getContainer();
}
};
StateInfoUtil.displayInfo(invoc, null, config, type, supplier);
} catch (Exception ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
}
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class UninstallCommand method getDynamicOptions.
@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
String fpid = getFPID();
Path dir = getAbsolutePath(getUninstallDir(), pmSession.getAeshContext());
// Build layout from this directory.
ProvisioningConfig config = ProvisioningXmlParser.parse(PathsUtils.getProvisioningXml(dir));
if (config != null) {
// Silent resolution.
pmSession.unregisterTrackers();
try {
try (ProvisioningLayout<FeaturePackLayout> layout = pmSession.getLayoutFactory().newConfigLayout(config)) {
layout.uninstall(pmSession.getResolvedLocation(getInstallationDirectory(pmSession.getAeshContext()), fpid).getFPID());
Set<ProvisioningOption> opts = PluginResolver.newResolver(pmSession, layout).resolve().getInstall();
List<DynamicOption> options = new ArrayList<>();
for (ProvisioningOption opt : opts) {
DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
options.add(dynOption);
}
return options;
}
} finally {
pmSession.registerTrackers();
}
} else {
return Collections.emptyList();
}
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class ProvisioningXmlParserTestCase method readValid.
@Test
public void readValid() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addUniverse("universe1", "factory1", "location1").addUniverse(null, "factory2", "location2").addUniverse("universe3", "factory3", "location3").addFeaturePackDep(FeaturePackConfig.forTransitiveDep(FeaturePackLocation.fromString("fp4@maven(universe):0#0.0.4"))).addFeaturePackDep(FeaturePackConfig.forTransitiveDep(FeaturePackLocation.fromString("fp5@maven(universe):0#0.0.5"))).addFeaturePackDep(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1")).addFeaturePackDep(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2")).addFeaturePackDep(FeaturePackLocation.fromString("fp3@maven(universe):0#0.0.3")).setInheritConfigs(false).setInheritModelOnlyConfigs(false).includeDefaultConfig("model1", "name1").includeDefaultConfig(null, "name2").excludeDefaultConfig("model1", "name2").excludeDefaultConfig(null, "name1").addOption("name1", "value1").addOption("name2", "value2").build();
Assert.assertEquals(expected, found);
}
Aggregations