use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class ProvisionCommand method doRunCommand.
@Override
protected void doRunCommand(PmCommandInvocation invoc, Map<String, String> options) throws CommandExecutionException {
String file = getFile();
if (file == null) {
throw new CommandExecutionException("No provisioning file provided.");
}
try {
final Path provisioningFile = getAbsolutePath(file, invoc.getConfiguration().getAeshContext());
if (!Files.exists(provisioningFile)) {
throw new CommandExecutionException("Failed to locate provisioning file " + provisioningFile.toAbsolutePath());
}
getManager(invoc).provision(provisioningFile, options);
} catch (ProvisioningException | IOException e) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.provisioningFailed(), e);
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class StateNewCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
State state;
try {
state = new State(invoc.getPmSession());
} catch (Exception ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.newStateFailed(), ex);
}
invoc.getPmSession().setState(state);
invoc.setPrompt(invoc.getPmSession().buildPrompt(state.getPath()));
invoc.println(WELCOME_STATE_MSG);
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class StateProvisionCommand method doRunCommand.
@Override
protected void doRunCommand(PmCommandInvocation invoc, Map<String, String> options) throws CommandExecutionException {
State state = invoc.getPmSession().getState();
try {
getManager(invoc).provision(state.getConfig(), options);
} catch (ProvisioningException | IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.provisioningFailed(), ex);
}
Path home = getInstallationDirectory(invoc.getConfiguration().getAeshContext());
if (home != null && Files.exists(home)) {
try {
invoc.println("Installation done in " + home.toFile().getCanonicalPath());
} catch (IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.retrievePath(), ex);
}
} else {
invoc.println("Nothing to install");
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class UndoCommand method doRunCommand.
@Override
protected void doRunCommand(PmCommandInvocation session, Map<String, String> options) throws CommandExecutionException {
try {
ProvisioningManager mgr = getManager(session);
mgr.undo();
} catch (ProvisioningException | IOException ex) {
throw new CommandExecutionException(session.getPmSession(), CliErrors.undoFailed(), ex);
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class StateRemoveFeatureCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException {
try {
String path = FeatureContainerPathConsumer.FINAL_CONFIGS_PATH + (feature.endsWith("" + PathParser.PATH_SEPARATOR) ? feature : feature + PathParser.PATH_SEPARATOR);
FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(session.getContainer(), false);
PathParser.parse(path, consumer);
ConfigInfo ci = consumer.getConfig();
if (ci == null) {
throw new ProvisioningException("Not a valid configuration " + feature);
}
Group grp = consumer.getCurrentNode(path);
if (grp == null) {
throw new ProvisioningException("Not a valid feature " + feature);
}
FeatureInfo fi = grp.getFeature();
if (fi == null) {
throw new ProvisioningException("Not a valid feature " + feature);
}
session.removeFeature(invoc.getPmSession(), ci, fi);
} catch (Exception ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.removeFeatureFailed(), ex);
}
}
Aggregations