use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class GetInfoCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
try {
Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {
public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
try {
return getFeatureContainer(invoc.getPmSession(), layout);
} catch (CommandExecutionException | ProvisioningException | IOException ex) {
throw new RuntimeException(ex);
}
}
};
ProvisioningManager mgr = getManager(invoc.getPmSession());
StateInfoUtil.displayInfo(invoc, mgr.getInstallationHome(), mgr.getProvisioningConfig(), type, supplier);
} catch (ProvisioningException | CommandExecutionException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class InstallCommand method getId.
@Override
protected String getId(PmSession session) throws CommandExecutionException {
String filePath = (String) getValue(FILE_OPTION_NAME);
if (filePath == null) {
filePath = getOptionValue(FILE_OPTION_NAME);
if (filePath == null) {
return super.getId(session);
}
}
Path path;
try {
path = Util.resolvePath(session.getAeshContext(), filePath);
} catch (IOException ex) {
throw new CommandExecutionException(ex.getMessage());
}
if (!Files.exists(path)) {
return null;
}
try {
return FeaturePackDescriber.readSpec(path).getFPID().toString();
} catch (ProvisioningException ex) {
throw new CommandExecutionException(session, CliErrors.retrieveFeaturePackID(), ex);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ListFeaturePacksCommand method runCommand.
@Override
public void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
Map<UniverseSpec, Table> tables = new HashMap<>();
Map<UniverseSpec, Set<String>> exceptions = new HashMap<>();
// Search for an installation in the context
Path installation = null;
try {
installation = Util.lookupInstallationDir(invoc.getConfiguration().getAeshContext(), null);
} catch (ProvisioningException ex) {
// XXX OK, no installation.
}
Path finalPath = installation;
UniverseVisitor visitor = new UniverseVisitor() {
@Override
public void visit(Producer<?> producer, FeaturePackLocation loc) {
if (loc.getFrequency() == null) {
return;
}
if (allFrequencies || loc.getFrequency().equals(producer.getDefaultFrequency())) {
Table table = tables.get(loc.getUniverse());
if (table == null) {
table = new Table(Headers.PRODUCT, Headers.UPDATE_CHANNEL, Headers.LATEST_BUILD);
tables.put(loc.getUniverse(), table);
}
loc = invoc.getPmSession().getExposedLocation(finalPath, loc);
table.addLine(producer.getName(), StateInfoUtil.formatChannel(loc), (loc.getBuild() == null ? NONE : loc.getBuild()));
}
}
@Override
public void exception(UniverseSpec spec, Exception ex) {
Set<String> set = exceptions.get(spec);
if (set == null) {
set = new HashSet<>();
exceptions.put(spec, set);
}
set.add(ex.getLocalizedMessage() == null ? ex.getMessage() : ex.getLocalizedMessage());
}
};
try {
if (fromUniverse != null) {
invoc.getPmSession().getUniverse().visitUniverse(UniverseSpec.fromString(fromUniverse), visitor, true);
} else {
invoc.getPmSession().getUniverse().visitAllUniverses(visitor, true, finalPath);
}
} catch (ProvisioningException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.resolvedUniverseFailed(), ex);
}
FindCommand.printExceptions(invoc, exceptions);
for (Entry<UniverseSpec, Table> entry : tables.entrySet()) {
Table table = entry.getValue();
table.sort(Table.SortType.ASCENDANT);
invoc.println(table.build());
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisionCommand method doRunCommand.
@Override
protected void doRunCommand(PmCommandInvocation invoc, Map<String, String> options) throws CommandExecutionException {
String file = getFile();
if (file == null) {
throw new CommandExecutionException("No provisioning file provided.");
}
try {
final Path provisioningFile = getAbsolutePath(file, invoc.getConfiguration().getAeshContext());
if (!Files.exists(provisioningFile)) {
throw new CommandExecutionException("Failed to locate provisioning file " + provisioningFile.toAbsolutePath());
}
getManager(invoc).provision(provisioningFile, options);
} catch (ProvisioningException | IOException e) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.provisioningFailed(), e);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateProvisionCommand method doRunCommand.
@Override
protected void doRunCommand(PmCommandInvocation invoc, Map<String, String> options) throws CommandExecutionException {
State state = invoc.getPmSession().getState();
try {
getManager(invoc).provision(state.getConfig(), options);
} catch (ProvisioningException | IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.provisioningFailed(), ex);
}
Path home = getInstallationDirectory(invoc.getConfiguration().getAeshContext());
if (home != null && Files.exists(home)) {
try {
invoc.println("Installation done in " + home.toFile().getCanonicalPath());
} catch (IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.retrievePath(), ex);
}
} else {
invoc.println("Nothing to install");
}
}
Aggregations