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();
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations