Search in sources :

Example 11 with CommandExecutionException

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);
    }
}
Also used : Path(java.nio.file.Path) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Example 12 with CommandExecutionException

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);
}
Also used : State(org.jboss.galleon.cli.model.state.State) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 13 with CommandExecutionException

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");
    }
}
Also used : Path(java.nio.file.Path) State(org.jboss.galleon.cli.model.state.State) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Example 14 with CommandExecutionException

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);
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Example 15 with CommandExecutionException

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);
    }
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException) FeatureInfo(org.jboss.galleon.cli.model.FeatureInfo) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ConfigInfo(org.jboss.galleon.cli.model.ConfigInfo) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Aggregations

CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)37 ProvisioningException (org.jboss.galleon.ProvisioningException)25 IOException (java.io.IOException)18 Path (java.nio.file.Path)11 ProvisioningManager (org.jboss.galleon.ProvisioningManager)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)7 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)6 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)6 State (org.jboss.galleon.cli.model.state.State)5 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)5 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 ArrayList (java.util.ArrayList)3 Group (org.jboss.galleon.cli.model.Group)3 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)3 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)3 PathParserException (org.jboss.galleon.cli.path.PathParserException)3 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 PrintWriter (java.io.PrintWriter)2