Search in sources :

Example 66 with ProvisioningException

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);
        }
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) UniverseSpec(org.jboss.galleon.universe.UniverseSpec)

Example 67 with ProvisioningException

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();
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) Set(java.util.Set) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 68 with ProvisioningException

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();
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 69 with ProvisioningException

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);
    }
}
Also used : State(org.jboss.galleon.cli.model.state.State) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Example 70 with ProvisioningException

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();
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer)

Aggregations

ProvisioningException (org.jboss.galleon.ProvisioningException)101 IOException (java.io.IOException)45 Path (java.nio.file.Path)35 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)24 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)15 XMLStreamException (javax.xml.stream.XMLStreamException)13 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)10 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)10 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)9 ProvisioningManager (org.jboss.galleon.ProvisioningManager)9 BufferedReader (java.io.BufferedReader)8 HashMap (java.util.HashMap)8 ConfigId (org.jboss.galleon.config.ConfigId)8 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)7 BufferedWriter (java.io.BufferedWriter)6