Search in sources :

Example 51 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class CliTestUtils method installPatch.

public static FPID installPatch(CliWrapper cli, UniverseSpec universeSpec, String producer, String version, String qualifier, Path directory) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, producer, "1", null, version + "-patch-" + qualifier);
    creator.newFeaturePack(fp1.getFPID()).setPatchFor(buildFPL(universeSpec, producer, "1", null, version + "." + qualifier).getFPID()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1 patch");
    creator.install(directory);
    return fp1.getFPID();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 52 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class CliTestUtils method install.

public static void install(CliWrapper cli, UniverseSpec universeSpec, String producer, String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, producer, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).newPackage("p1", true).writeContent(producer + "/p1.txt", "fp1 p1");
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 53 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation 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());
    }
}
Also used : Path(java.nio.file.Path) Table(org.jboss.galleon.cli.cmd.Table) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException) Producer(org.jboss.galleon.universe.Producer) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) UniverseVisitor(org.jboss.galleon.cli.UniverseManager.UniverseVisitor)

Example 54 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateInfoUtil method buildDependencies.

public static String buildDependencies(List<FeaturePackLocation> dependencies, Map<FPID, FeaturePackConfig> configs) {
    if (!dependencies.isEmpty()) {
        boolean showPatches = configs == null ? false : showPatches(configs.values());
        List<String> headers = new ArrayList<>();
        headers.add(Headers.DEPENDENCY);
        headers.add(Headers.BUILD);
        if (showPatches) {
            headers.add(Headers.PATCHES);
        }
        headers.add(Headers.UPDATE_CHANNEL);
        Table table = new Table(headers);
        for (FeaturePackLocation d : dependencies) {
            List<Cell> line = new ArrayList<>();
            line.add(new Cell(d.getProducerName()));
            line.add(new Cell(d.getBuild()));
            if (showPatches) {
                FeaturePackConfig config = configs.get(d.getFPID());
                if (config != null && config.hasPatches()) {
                    Cell patches = new Cell();
                    for (FPID p : config.getPatches()) {
                        patches.addLine(p.getBuild());
                    }
                    line.add(patches);
                }
            }
            line.add(new Cell(formatChannel(d)));
            table.addCellsLine(line);
        }
        table.sort(Table.SortType.ASCENDANT);
        return table.build();
    }
    return null;
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Cell(org.jboss.galleon.cli.cmd.Table.Cell) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 55 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateInfoUtil method buildFeaturePacks.

private static String buildFeaturePacks(PmCommandInvocation commandInvocation, Path installation, Collection<FeaturePackConfig> fps) {
    boolean showPatches = showPatches(fps);
    List<String> headers = new ArrayList<>();
    headers.add(Headers.PRODUCT);
    headers.add(Headers.BUILD);
    if (showPatches) {
        headers.add(Headers.PATCHES);
    }
    headers.add(Headers.UPDATE_CHANNEL);
    Table t = new Table(headers);
    for (FeaturePackConfig c : fps) {
        FeaturePackLocation loc = commandInvocation.getPmSession().getExposedLocation(installation, c.getLocation());
        List<Cell> line = new ArrayList<>();
        line.add(new Cell(loc.getProducer().getName()));
        line.add(new Cell(loc.getBuild()));
        if (showPatches) {
            if (c.hasPatches()) {
                Cell patches = new Cell();
                for (FPID p : c.getPatches()) {
                    patches.addLine(p.getBuild());
                }
                line.add(patches);
            }
        }
        line.add(new Cell(formatChannel(loc)));
        t.addCellsLine(line);
    }
    if (!t.isEmpty()) {
        t.sort(Table.SortType.ASCENDANT);
        return t.build();
    } else {
        return null;
    }
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Cell(org.jboss.galleon.cli.cmd.Table.Cell) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)111 Test (org.junit.Test)46 Path (java.nio.file.Path)23 ProvisioningException (org.jboss.galleon.ProvisioningException)18 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)18 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)16 ArrayList (java.util.ArrayList)13 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)13 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)12 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)9 XMLStreamException (javax.xml.stream.XMLStreamException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)8 IOException (java.io.IOException)7 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)7 HashMap (java.util.HashMap)6 CommandException (org.aesh.command.CommandException)6 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)6 FeatureConfig (org.jboss.galleon.config.FeatureConfig)6 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)6 Set (java.util.Set)5