Search in sources :

Example 51 with ProvisioningException

use of org.jboss.galleon.ProvisioningException 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 52 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class StateAddFeatureCommand method getSpec.

private FeatureSpecInfo getSpec(State state, String id) throws PathParserException, PathConsumerException, ProvisioningException {
    String path = FeatureContainerPathConsumer.FEATURES_PATH + id;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(new AllFeaturesContainer(state.getContainer()), false);
    PathParser.parse(path, consumer);
    Group grp = consumer.getCurrentNode(path);
    if (grp == null) {
        throw new ProvisioningException("Invalid path");
    }
    if (grp.getSpec() == null) {
        throw new ProvisioningException("Path is not a feature-spec");
    }
    return grp.getSpec();
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 53 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class StateAddFeatureCommand method getConfiguration.

private ConfigInfo getConfiguration(State state) throws PathParserException, PathConsumerException, ProvisioningException {
    @SuppressWarnings("unchecked") List<String> args = (List<String>) getValue(ARGUMENT_NAME);
    String config = args.get(0);
    String path = FeatureContainerPathConsumer.FINAL_CONFIGS_PATH + config + PathParser.PATH_SEPARATOR;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(state.getContainer(), false);
    PathParser.parse(path, consumer);
    ConfigInfo ci = consumer.getConfig();
    if (ci == null) {
        throw new ProvisioningException("Not a valid config " + config);
    }
    return ci;
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) ProvisioningException(org.jboss.galleon.ProvisioningException) ArrayList(java.util.ArrayList) List(java.util.List) ConfigInfo(org.jboss.galleon.cli.model.ConfigInfo)

Example 54 with ProvisioningException

use of org.jboss.galleon.ProvisioningException 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)

Example 55 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class StateExcludePackageCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc, State session, FeaturePackConfig config) throws IOException, ProvisioningException, CommandExecutionException {
    try {
        int i = getPackage().indexOf("/");
        String name = getPackage().substring(i + 1);
        // but no transitive dependency has been created yet.
        if (config == null) {
            session.excludePackageFromNewTransitive(invoc.getPmSession(), getProducer(invoc.getPmSession()), name);
        } else {
            session.excludePackage(invoc.getPmSession(), name, config);
        }
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.excludeFailed(), ex);
    }
}
Also used : CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Aggregations

ProvisioningException (org.jboss.galleon.ProvisioningException)101 IOException (java.io.IOException)45 Path (java.nio.file.Path)35 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)24 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)15 XMLStreamException (javax.xml.stream.XMLStreamException)13 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)10 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)10 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)9 ProvisioningManager (org.jboss.galleon.ProvisioningManager)9 BufferedReader (java.io.BufferedReader)8 HashMap (java.util.HashMap)8 ConfigId (org.jboss.galleon.config.ConfigId)8 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)7 BufferedWriter (java.io.BufferedWriter)6