use of org.jboss.galleon.cli.model.Group in project galleon by wildfly.
the class FeatureContainerPathConsumer method enterPackagesContent.
private void enterPackagesContent(PathParser.Node node) throws PathConsumerException {
Group next = null;
if (current == null) {
current = info.getPackages().get(packagesGav);
if (current == null) {
throw new PathConsumerException("no package in " + packagesGav);
}
}
for (Group info : current.getGroups()) {
if (info.getIdentity().getName().equals(node.getName())) {
next = info;
break;
}
}
if (next == null) {
if (completion) {
if (inError) {
throw new PathConsumerException("no node for name " + node.getName());
} else {
inError = true;
}
} else {
throw new PathConsumerException("no node for name " + node.getName());
}
} else {
current = next;
}
packagesGav = null;
}
use of org.jboss.galleon.cli.model.Group in project galleon by wildfly.
the class StateInfoUtil method displayPackage.
private static void displayPackage(PmCommandInvocation session, Group grp) throws IOException {
PackageInfo pkg = grp.getPackage();
session.println("");
session.println("Package name : " + pkg.getIdentity().getName());
session.println("Package origin : " + pkg.getIdentity().getOrigin());
session.println(Config.getLineSeparator() + "Package providers (features that depend on this package)");
if (pkg.getProviders().isEmpty()) {
session.println("default provider");
} else {
for (Identity id : pkg.getProviders()) {
session.println(id.toString());
}
}
session.println(Config.getLineSeparator() + "Package dependencies");
if (grp.getGroups().isEmpty()) {
session.println("NONE");
} else {
for (Group dep : grp.getGroups()) {
session.println(dep.getIdentity().toString());
}
}
session.println(Config.getLineSeparator() + "Package content");
String customContent = pkg.getCustomContent();
if (customContent != null) {
session.println(customContent);
} else if (pkg.getContent().isEmpty()) {
session.println("NONE");
} else {
StringBuilder contentBuilder = new StringBuilder();
for (String name : pkg.getContent()) {
contentBuilder.append(" " + name + Config.getLineSeparator());
}
session.println(contentBuilder.toString());
}
}
use of org.jboss.galleon.cli.model.Group 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.model.Group 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.model.Group 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