use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class UniverseManager method visitAllUniverses.
public void visitAllUniverses(UniverseVisitor visitor, boolean allBuilds, Path installation) {
try {
visit(visitor, getUniverse(builtinUniverseSpec), builtinUniverseSpec, allBuilds);
} catch (ProvisioningException ex) {
visitor.exception(builtinUniverseSpec, ex);
}
UniverseSpec defaultUniverse = getDefaultUniverseSpec(null);
try {
if (defaultUniverse != null && !builtinUniverseSpec.equals(defaultUniverse)) {
visit(visitor, getUniverse(defaultUniverse), defaultUniverse, allBuilds);
}
} catch (ProvisioningException ex) {
visitor.exception(defaultUniverse, ex);
}
Set<String> universes = getUniverseNames(installation);
for (String u : universes) {
UniverseSpec universeSpec = getUniverseSpec(installation, u);
try {
visit(visitor, getUniverse(universeSpec), universeSpec, allBuilds);
} catch (ProvisioningException ex) {
visitor.exception(universeSpec, ex);
}
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateInfoUtil method buildOptionalPackages.
public static String buildOptionalPackages(PmSession session, FeatureContainer container, ProvisioningLayout<FeaturePackLayout> pLayout) throws ProvisioningException, IOException {
String optionValue = container.getProvisioningConfig().getOption(ProvisioningOption.OPTIONAL_PACKAGES.getName());
if (optionValue == null) {
optionValue = Constants.ALL;
}
Table.Tree t = null;
boolean passivePresent = !container.getPassivePackages().isEmpty() || !container.getOrphanPassivePackages().isEmpty();
Set<String> optionalProducers = container.getOptionalPackagesProducers();
if (!optionalProducers.isEmpty()) {
if (passivePresent) {
t = new Table.Tree(Headers.PRODUCT, Headers.FEATURE, Headers.PACKAGE, Headers.PASSIVE);
} else {
t = new Table.Tree(Headers.PRODUCT, Headers.FEATURE, Headers.PACKAGE);
}
for (String producer : optionalProducers) {
String displayProducer = producer;
try {
ProducerSpec pSpec = FeaturePackLocation.fromString(producer).getProducer();
if (session.getUniverse().getBuiltinUniverseSpec().equals(pSpec.getUniverse())) {
displayProducer = pSpec.getName();
}
} catch (Exception ex) {
// Not a producerSpec, keep original one.
}
Table.Node producerNode = new Table.Node(displayProducer);
t.add(producerNode);
Map<String, Set<String>> optionalPkgs = container.getOptionalPackages().get(producer);
if (optionalPkgs != null && !optionalPkgs.isEmpty()) {
for (Entry<String, Set<String>> entry : optionalPkgs.entrySet()) {
Table.Node feat = new Table.Node(entry.getKey());
producerNode.addNext(feat);
for (String p : entry.getValue()) {
Table.Node pkg = new Table.Node(p);
feat.addNext(pkg);
if (passivePresent) {
pkg.addNext(new Table.Node(""));
}
}
Map<String, Set<String>> passivePkgs = container.getPassivePackages().get(producer);
if (passivePkgs != null) {
Set<String> passives = passivePkgs.get(entry.getKey());
if (passives != null) {
for (String p : passives) {
Table.Node pkg = new Table.Node(p);
feat.addNext(pkg);
pkg.addNext(new Table.Node("true"));
}
}
}
}
} else {
Map<String, Set<String>> passivePkgs = container.getPassivePackages().get(producer);
if (passivePkgs != null && !passivePkgs.isEmpty()) {
for (Entry<String, Set<String>> entry : passivePkgs.entrySet()) {
Table.Node feat = new Table.Node(entry.getKey());
producerNode.addNext(feat);
for (String p : entry.getValue()) {
Table.Node pkg = new Table.Node(p);
feat.addNext(pkg);
pkg.addNext(new Table.Node("true"));
}
}
}
}
Set<String> orphanOptionals = container.getOrphanOptionalPackages().get(producer);
Set<String> orphanPassives = container.getOrphanPassivePackages().get(producer);
if (orphanOptionals != null || orphanPassives != null) {
Table.Node feat = new Table.Node("{no-feature}");
producerNode.addNext(feat);
if (orphanOptionals != null) {
for (String p : orphanOptionals) {
Table.Node pkg = new Table.Node(p);
feat.addNext(pkg);
if (passivePresent) {
pkg.addNext(new Table.Node(""));
}
}
}
if (orphanPassives != null) {
for (String p : orphanPassives) {
Table.Node pkg = new Table.Node(p);
feat.addNext(pkg);
pkg.addNext(new Table.Node("true"));
}
}
}
}
}
StringBuilder builder = new StringBuilder();
builder.append("Optional packages (Provisioning option: " + optionValue + ")" + Config.getLineSeparator());
if (t == null) {
builder.append(NO_OPTIONAL_PACKAGES);
} else {
builder.append(t.build());
}
return builder.toString();
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateSearchCommand method getPackage.
private PackageInfo getPackage(FeatureContainer container, String id) throws PathParserException, PathConsumerException, ProvisioningException {
String path = FeatureContainerPathConsumer.PACKAGES_PATH + id;
FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(container, false);
PathParser.parse(path, consumer);
Group grp = consumer.getCurrentNode(path);
if (grp == null) {
throw new ProvisioningException("Invalid path");
}
if (grp.getPackage() == null) {
throw new ProvisioningException("Path is not a package");
}
return grp.getPackage();
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateUndoCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
try {
State state = invoc.getPmSession().getState();
if (!state.hasActions()) {
throw new ProvisioningException(Errors.historyIsEmpty());
}
state.pop(invoc.getPmSession());
} catch (ProvisioningException | IOException ex) {
throw new CommandExecutionException(invoc.getPmSession(), CliErrors.undoFailed(), ex);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class PackagesUtil method getPackage.
public static String getPackage(PmSession session, FeaturePackLocation.FPID fpid, String pkg) throws PathParserException, PathConsumerException, ProvisioningException, Exception {
String path = FeatureContainerPathConsumer.PACKAGES_PATH + pkg + (pkg.endsWith("" + PathParser.PATH_SEPARATOR) ? "" : PathParser.PATH_SEPARATOR);
FeatureContainer full = FeatureContainers.fromFeaturePackId(session, fpid, null);
FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(full, false);
PathParser.parse(path, consumer);
Group grp = consumer.getCurrentNode(path);
if (grp == null || grp.getPackage() == null) {
throw new ProvisioningException("Not a valid package " + pkg);
}
return grp.getPackage().getSpec().getName();
}
Aggregations