Search in sources :

Example 1 with ProvisioningPlan

use of org.jboss.galleon.layout.ProvisioningPlan in project galleon by wildfly.

the class ProvisioningManager method getUpdates.

/**
 * Query for available updates and patches for specific producers.
 * If no producer is passed as an argument, the method will return
 * the update plan for only the feature-packs installed directly by the user.
 *
 * @param producers  producers to include into the update plan
 * @return  update plan
 * @throws ProvisioningException in case of a failure
 */
public ProvisioningPlan getUpdates(ProducerSpec... producers) throws ProvisioningException {
    final ProvisioningConfig config = getProvisioningConfig();
    ProvisioningPlan plan;
    if (config == null) {
        plan = ProvisioningPlan.builder();
    } else {
        try (ProvisioningLayout<?> layout = getLayoutFactory().newConfigLayout(config)) {
            plan = layout.getUpdates(producers);
        }
    }
    return plan;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningPlan(org.jboss.galleon.layout.ProvisioningPlan)

Example 2 with ProvisioningPlan

use of org.jboss.galleon.layout.ProvisioningPlan in project galleon by wildfly.

the class ProvisioningManager method getUpdates.

/**
 * Query for available updates and patches for feature-packs in this layout.
 *
 * @param includeTransitive  whether to include transitive dependencies into the result
 * @return  available updates
 * @throws ProvisioningException in case of a failure
 */
public ProvisioningPlan getUpdates(boolean includeTransitive) throws ProvisioningException {
    final ProvisioningConfig config = getProvisioningConfig();
    ProvisioningPlan plan;
    if (config == null) {
        plan = ProvisioningPlan.builder();
    } else {
        try (ProvisioningLayout<?> layout = getLayoutFactory().newConfigLayout(config)) {
            plan = layout.getUpdates(includeTransitive);
        }
    }
    return plan;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningPlan(org.jboss.galleon.layout.ProvisioningPlan)

Example 3 with ProvisioningPlan

use of org.jboss.galleon.layout.ProvisioningPlan in project galleon by wildfly.

the class CheckUpdatesCommand method getUpdatesTable.

static Updates getUpdatesTable(ProvisioningManager mgr, PmCommandInvocation session, boolean includeAll, String fp) throws ProvisioningException, CommandExecutionException {
    if (includeAll && fp != null) {
        throw new CommandExecutionException(CliErrors.onlyOneOptionOf(FP_OPTION_NAME, ALL_DEPENDENCIES_OPTION_NAME));
    }
    ProvisioningPlan plan;
    if (fp == null) {
        plan = mgr.getUpdates(includeAll);
    } else {
        String[] split = fp.split(",+");
        List<ProducerSpec> resolved = new ArrayList<>();
        List<FeaturePackLocation> locs = new ArrayList<>();
        for (String producer : split) {
            FeaturePackLocation loc = session.getPmSession().getResolvedLocation(mgr.getInstallationHome(), producer);
            if (loc.hasBuild()) {
                locs.add(loc);
            } else {
                resolved.add(loc.getProducer());
            }
        }
        if (!resolved.isEmpty()) {
            ProducerSpec[] arr = new ProducerSpec[resolved.size()];
            plan = mgr.getUpdates(resolved.toArray(arr));
        } else {
            plan = ProvisioningPlan.builder();
        }
        if (!locs.isEmpty()) {
            addCustomUpdates(plan, locs, mgr);
        }
    }
    Updates updates = new Updates();
    updates.plan = plan;
    if (plan.isEmpty()) {
        return updates;
    }
    boolean hasPatches = false;
    for (FeaturePackUpdatePlan p : plan.getUpdates()) {
        if (p.hasNewPatches()) {
            hasPatches = true;
            break;
        }
    }
    List<String> headers = new ArrayList<>();
    headers.add(Headers.PRODUCT);
    headers.add(Headers.CURRENT_BUILD);
    headers.add(Headers.UPDATE);
    if (hasPatches) {
        headers.add(Headers.PATCHES);
    }
    if (includeAll) {
        headers.add(Headers.DEPENDENCY);
    }
    headers.add(Headers.UPDATE_CHANNEL);
    updates.t = new Table(headers);
    for (FeaturePackUpdatePlan p : plan.getUpdates()) {
        FeaturePackLocation loc = p.getInstalledLocation();
        String update = p.hasNewLocation() ? p.getNewLocation().getBuild() : NONE;
        Cell patches = null;
        if (hasPatches) {
            patches = new Cell();
            if (p.hasNewPatches()) {
                for (FPID id : p.getNewPatches()) {
                    patches.addLine(id.getBuild());
                }
            } else {
                patches.addLine(NONE);
            }
        }
        List<Cell> line = new ArrayList<>();
        line.add(new Cell(loc.getProducerName()));
        line.add(new Cell(loc.getBuild()));
        line.add(new Cell(update));
        if (hasPatches) {
            line.add(patches);
        }
        if (includeAll) {
            line.add(new Cell(p.isTransitive() ? "Y" : "N"));
        }
        FeaturePackLocation newLocation = session.getPmSession().getExposedLocation(mgr.getInstallationHome(), p.getNewLocation());
        line.add(new Cell(StateInfoUtil.formatChannel(newLocation)));
        updates.t.addCellsLine(line);
    }
    updates.t.sort(Table.SortType.ASCENDANT);
    return updates;
}
Also used : ProvisioningPlan(org.jboss.galleon.layout.ProvisioningPlan) Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) ArrayList(java.util.ArrayList) FeaturePackUpdatePlan(org.jboss.galleon.layout.FeaturePackUpdatePlan) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) Cell(org.jboss.galleon.cli.cmd.Table.Cell)

Aggregations

ProvisioningPlan (org.jboss.galleon.layout.ProvisioningPlan)3 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)2 ArrayList (java.util.ArrayList)1 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 Table (org.jboss.galleon.cli.cmd.Table)1 Cell (org.jboss.galleon.cli.cmd.Table.Cell)1 FeaturePackUpdatePlan (org.jboss.galleon.layout.FeaturePackUpdatePlan)1 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)1 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)1 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)1