use of org.jboss.galleon.cli.CommandExecutionException 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);
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class AbstractPackageCommand method getProvisionedFP.
@Override
public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException {
FeaturePackConfig config = super.getProvisionedFP(session);
if (config == null) {
// Problem, the package is not directly part of the added FP. Must retrieve it in the packages of
// its internal dependencies.
int i = getPackage().indexOf("/");
String orig = getPackage().substring(0, i);
String name = getPackage().substring(i + 1);
FeaturePackLocation.FPID fpid = null;
FeatureContainer container = session.getContainer().getFullDependencies().get(orig);
if (container != null) {
if (container.getAllPackages().containsKey(Identity.fromString(orig, name))) {
fpid = container.getFPID();
}
}
if (fpid == null) {
throw new CommandExecutionException("No package found for " + getPackage());
}
for (FeaturePackConfig c : session.getState().getConfig().getFeaturePackDeps()) {
if (c.getLocation().getFPID().equals(fpid)) {
config = c;
break;
}
}
if (config == null) {
// reset buildID
FeaturePackLocation noBuildLocation = new FeaturePackLocation(fpid.getUniverse(), fpid.getProducer().getName(), null, null, null);
for (FeaturePackConfig c : session.getState().getConfig().getTransitiveDeps()) {
if (c.getLocation().equals(c.getLocation().hasBuild() ? fpid.getLocation() : noBuildLocation)) {
config = c;
break;
}
}
}
}
return config;
}
use of org.jboss.galleon.cli.CommandExecutionException 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);
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class StateSearchCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
try {
if (query == null && pkg == null) {
throw new CommandExecutionException("One of --query or --package must be set");
}
FeatureContainer container = invoc.getPmSession().getContainer();
run(invoc.getPmSession().getContainer(), invoc, false);
if (inDependencies) {
if (!container.getFullDependencies().isEmpty()) {
invoc.println("");
invoc.println("Search in dependencies");
for (FeatureContainer c : container.getFullDependencies().values()) {
invoc.println("dependency: " + c.getFPID());
run(c, invoc, true);
}
}
}
} catch (Exception ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.searchFailed(), ex);
}
}
use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.
the class StateEditCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
State state;
try {
state = new State(invoc.getPmSession(), getInstallationHome(invoc.getConfiguration().getAeshContext()));
} catch (ProvisioningException | IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.readContentFailed(), ex);
}
invoc.getPmSession().setState(state);
invoc.setPrompt(invoc.getPmSession().buildPrompt(state.getPath()));
invoc.println(WELCOME_STATE_MSG);
}
Aggregations