public static ProvisioningPlan builder() { return new ProvisioningPlan(); }
@Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append('['); if(!install.isEmpty()) { buf.append("install "); StringUtils.append(buf, getInstall()); buf.append(';'); } if(!uninstall.isEmpty()) { if(buf.length() > 1) { buf.append(' '); } buf.append("uninstall "); StringUtils.append(buf, uninstall); buf.append(';'); } if(!updates.isEmpty()) { if(buf.length() > 1) { buf.append(' '); } buf.append("update "); StringUtils.append(buf, updates.values()); buf.append(';'); } return buf.toString(); } }
public void apply(ProvisioningPlan plan, Map<String, String> pluginOptions) throws ProvisioningException { if(plan.isEmpty()) { return; if(plan.hasUpdates()) { Map<ProducerSpec, FeaturePackUpdatePlan> updates = plan.getUpdateMap(); Set<ProducerSpec> processed = new HashSet<>(updates.size()); for(FeaturePackConfig fpConfig : config.getFeaturePackDeps()) { if(plan.hasInstall()) { for(FeaturePackConfig fpConfig : plan.getInstall()) { install(fpConfig, configBuilder); if(plan.hasUninstall()) { for(ProducerSpec producer : plan.getUninstall()) { uninstall(producer.getLocation().getFPID(), configBuilder); initPluginOptions(pluginOptions, plan.hasUninstall());
plan = mgr.getUpdates(resolved.toArray(arr)); } else { plan = ProvisioningPlan.builder(); if (plan.isEmpty()) { return updates; for (FeaturePackUpdatePlan p : plan.getUpdates()) { if (p.hasNewPatches()) { hasPatches = true; updates.t = new Table(headers); for (FeaturePackUpdatePlan p : plan.getUpdates()) { FeaturePackLocation loc = p.getInstalledLocation(); String update = p.hasNewLocation() ? p.getNewLocation().getBuild() : NONE;
private ProvisioningPlan getUpdatesInternal(Collection<ProducerSpec> producers) throws ProvisioningException { final ProvisioningPlan plan = ProvisioningPlan.builder(); updatesTracker = getUpdatesTracker(); updatesTracker.starting(producers.size()); for(ProducerSpec producer : producers) { updatesTracker.processing(producer); final FeaturePackUpdatePlan fpPlan = getFeaturePackUpdate(producer); if(!fpPlan.isEmpty()) { plan.update(fpPlan); } updatesTracker.processed(producer); } updatesTracker.complete(); return plan; }
@Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { ProvisioningManager mgr = getManager(session.getPmSession()); Updates updates = getUpdatesTable(mgr, session, includeAll, fp); if (updates.plan.isEmpty()) { session.println(UP_TO_DATE); } else { session.println(UPDATES_AVAILABLE); session.println(updates.t.build()); } } catch (ProvisioningException ex) { throw new CommandExecutionException(session.getPmSession(), CliErrors.checkForUpdatesFailed(), ex); } }
/** * 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; }
private static void addCustomUpdates(ProvisioningPlan plan, List<FeaturePackLocation> custom, ProvisioningManager mgr) throws ProvisioningException { try (ProvisioningLayout<?> layout = mgr.getLayoutFactory().newConfigLayout(mgr.getProvisioningConfig())) { for (FeaturePackLocation loc : custom) { FeaturePackLayout fpl = layout.getFeaturePack(loc.getProducer()); FeaturePackLocation current = fpl.getFPID().getLocation(); FeaturePackUpdatePlan fpPlan = FeaturePackUpdatePlan.request(current, fpl.isTransitiveDep()).setNewLocation(loc).buildPlan(); if (fpPlan.hasNewLocation()) { plan.update(fpPlan); } } } }
ProvisioningManager mgr = getManager(session); Updates updates = CheckUpdatesCommand.getUpdatesTable(mgr, session, allDependencies(), getFP()); if (updates.plan.isEmpty()) { session.println(UP_TO_DATE); } else {
/** * 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; }