Search in sources :

Example 1 with FeatureContainerPathConsumer

use of org.jboss.galleon.cli.path.FeatureContainerPathConsumer 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 2 with FeatureContainerPathConsumer

use of org.jboss.galleon.cli.path.FeatureContainerPathConsumer 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 3 with FeatureContainerPathConsumer

use of org.jboss.galleon.cli.path.FeatureContainerPathConsumer 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 4 with FeatureContainerPathConsumer

use of org.jboss.galleon.cli.path.FeatureContainerPathConsumer in project galleon by wildfly.

the class AbstractLayersCommand method getConfiguration.

protected ConfigInfo getConfiguration(State state) throws PathParserException, PathConsumerException, ProvisioningException, Exception {
    String path = FeatureContainerPathConsumer.FINAL_CONFIGS_PATH + configuration + 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 " + configuration);
    }
    return ci;
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigInfo(org.jboss.galleon.cli.model.ConfigInfo)

Example 5 with FeatureContainerPathConsumer

use of org.jboss.galleon.cli.path.FeatureContainerPathConsumer in project galleon by wildfly.

the class AbstractPackageCommand method getProducer.

@Override
public ProducerSpec getProducer(PmSession session) throws CommandExecutionException {
    if (pkg == null) {
        throw new CommandExecutionException("No package set.");
    }
    String fullpath = FeatureContainerPathConsumer.PACKAGES_PATH + pkg;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(new AllPackagesContainer(session.getState().getContainer()), false);
    try {
        PathParser.parse(fullpath, consumer);
        Group grp = consumer.getCurrentNode(fullpath);
        if (grp == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        PackageInfo info = grp.getPackage();
        if (info == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        return info.getFPID().getProducer();
    } catch (PathParserException | PathConsumerException ex) {
        throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex);
    }
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException)

Aggregations

FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)12 ProvisioningException (org.jboss.galleon.ProvisioningException)7 Group (org.jboss.galleon.cli.model.Group)7 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)5 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)3 PmSession (org.jboss.galleon.cli.PmSession)2 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)2 PathParserException (org.jboss.galleon.cli.path.PathParserException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FeatureInfo (org.jboss.galleon.cli.model.FeatureInfo)1 PackageInfo (org.jboss.galleon.cli.model.PackageInfo)1