Search in sources :

Example 11 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class ProvisioningLayout method apply.

public void apply(ProvisioningPlan plan, Map<String, String> pluginOptions) throws ProvisioningException {
    if (plan.isEmpty()) {
        return;
    }
    final ProvisioningConfig.Builder configBuilder = ProvisioningConfig.builder(config);
    if (plan.hasUpdates()) {
        Map<ProducerSpec, FeaturePackUpdatePlan> updates = plan.getUpdateMap();
        Set<ProducerSpec> processed = new HashSet<>(updates.size());
        for (FeaturePackConfig fpConfig : config.getFeaturePackDeps()) {
            final ProducerSpec producer = fpConfig.getLocation().getProducer();
            final FeaturePackUpdatePlan fpPlan = updates.get(producer);
            if (fpPlan != null && !fpPlan.isEmpty()) {
                if (!fpPlan.getInstalledLocation().equals(fpConfig.getLocation())) {
                    throw new ProvisioningException("Location in the update plan " + fpPlan.getInstalledLocation() + " does not match the installed location " + fpConfig.getLocation());
                }
                final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.builder(fpPlan.getNewLocation()).init(fpConfig);
                if (fpPlan.hasNewPatches()) {
                    for (FPID patchId : fpPlan.getNewPatches()) {
                        fpBuilder.addPatch(patchId);
                    }
                }
                configBuilder.updateFeaturePackDep(fpBuilder.build());
                processed.add(producer);
            }
        }
        for (FeaturePackConfig fpConfig : config.getTransitiveDeps()) {
            final ProducerSpec producer = fpConfig.getLocation().getProducer();
            final FeaturePackUpdatePlan fpPlan = updates.get(producer);
            if (fpPlan != null && !fpPlan.isEmpty()) {
                if (fpConfig.getLocation().getBuild() != null && !fpPlan.getInstalledLocation().equals(fpConfig.getLocation())) {
                    throw new ProvisioningException("Update plan build " + fpPlan.getInstalledLocation() + " does not match the installed build " + fpConfig.getLocation());
                }
                final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.transitiveBuilder(fpPlan.getNewLocation()).init(fpConfig);
                if (fpPlan.hasNewPatches()) {
                    for (FPID patchId : fpPlan.getNewPatches()) {
                        fpBuilder.addPatch(patchId);
                    }
                }
                configBuilder.updateFeaturePackDep(fpBuilder.build());
                processed.add(producer);
            }
        }
        if (processed.size() < updates.size()) {
            for (Map.Entry<ProducerSpec, FeaturePackUpdatePlan> entry : updates.entrySet()) {
                if (processed.contains(entry.getKey())) {
                    continue;
                }
                final FeaturePackUpdatePlan update = entry.getValue();
                final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.transitiveBuilder(update.getNewLocation());
                if (update.hasNewPatches()) {
                    for (FPID patchId : update.getNewPatches()) {
                        fpBuilder.addPatch(patchId);
                    }
                }
                configBuilder.addFeaturePackDep(fpBuilder.build());
            }
        }
    }
    if (plan.hasInstall()) {
        for (FeaturePackConfig fpConfig : plan.getInstall()) {
            install(fpConfig, configBuilder);
        }
    }
    if (plan.hasUninstall()) {
        for (ProducerSpec producer : plan.getUninstall()) {
            uninstall(producer.getLocation().getFPID(), configBuilder);
        }
    }
    final ProvisioningConfig config = configBuilder.build();
    initBuiltInOptions(config, pluginOptions);
    rebuild(config, true);
    initPluginOptions(pluginOptions, plan.hasUninstall());
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningException(org.jboss.galleon.ProvisioningException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 12 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method findFeatureSpec.

private ResolvedFeatureSpec findFeatureSpec(FeaturePackRuntimeBuilder origin, String name, boolean switchOrigin) throws ProvisioningException {
    final FeaturePackDepsConfig fpDeps;
    if (origin != null) {
        if (origin.isFlagOn(FeaturePackRuntimeBuilder.VISIT)) {
            return null;
        }
        final ResolvedFeatureSpec fs = origin.getFeatureSpec(name);
        if (fs != null) {
            if (switchOrigin) {
                currentOrigin = origin;
            }
            return fs;
        }
        fpDeps = origin.getSpec();
        setFlag(origin, FeaturePackRuntimeBuilder.VISIT);
    } else {
        fpDeps = config;
    }
    if (!fpDeps.hasFeaturePackDeps()) {
        return null;
    }
    for (FeaturePackConfig fpDep : fpDeps.getFeaturePackDeps()) {
        final ResolvedFeatureSpec fs = findFeatureSpec(layout.getFeaturePack(fpDep.getLocation().getProducer()), name, switchOrigin);
        if (fs != null) {
            return fs;
        }
    }
    return null;
}
Also used : FeaturePackDepsConfig(org.jboss.galleon.config.FeaturePackDepsConfig) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 13 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method resolveConfigLayer.

private boolean resolveConfigLayer(ProducerSpec producer, ConfigModelStack layerStack, ConfigId layerId) throws ProvisioningException {
    final FeaturePackRuntimeBuilder fp = layout.getFeaturePack(producer);
    if (!setFlag(fp, FeaturePackRuntimeBuilder.RESOLVE_LAYER)) {
        return fp.getConfigLayer(layerId) != null;
    }
    final FeaturePackRuntimeBuilder prevOrigin = currentOrigin;
    try {
        boolean resolved;
        final ConfigLayerSpec configLayer = fp.getConfigLayer(layerId);
        resolved = configLayer != null;
        if (resolved) {
            layerStack.pushGroup(configLayer);
        }
        if (fp.getSpec().hasFeaturePackDeps()) {
            for (FeaturePackConfig depConfig : fp.getSpec().getFeaturePackDeps()) {
                resolved |= resolveConfigLayer(depConfig.getLocation().getProducer(), layerStack, layerId);
            }
        }
        if (configLayer != null) {
            setOrigin(fp);
            processConfigLayer(layerStack, popLayer(layerStack));
        }
        return resolved;
    } finally {
        setOrigin(prevOrigin);
    }
}
Also used : ConfigLayerSpec(org.jboss.galleon.spec.ConfigLayerSpec) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 14 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method getFeatureGroupSpec.

private FeatureGroup getFeatureGroupSpec(FeaturePackRuntimeBuilder origin, String name) throws ProvisioningException {
    final FeaturePackDepsConfig fpDeps;
    if (origin != null) {
        if (origin.isFlagOn(FeaturePackRuntimeBuilder.VISIT)) {
            return null;
        }
        final FeatureGroup fg = origin.getFeatureGroupSpec(name);
        if (fg != null) {
            currentOrigin = origin;
            return fg;
        }
        fpDeps = origin.getSpec();
        setFlag(origin, FeaturePackRuntimeBuilder.VISIT);
    } else {
        fpDeps = config;
    }
    if (!fpDeps.hasFeaturePackDeps()) {
        return null;
    }
    for (FeaturePackConfig fpDep : fpDeps.getFeaturePackDeps()) {
        final FeatureGroup fg = getFeatureGroupSpec(layout.getFeaturePack(fpDep.getLocation().getProducer()), name);
        if (fg != null) {
            return fg;
        }
    }
    return null;
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) FeaturePackDepsConfig(org.jboss.galleon.config.FeaturePackDepsConfig) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 15 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class ProvisioningDiffProvider method initProvisioningConfig.

private ProvisioningConfig.Builder initProvisioningConfig() throws ProvisioningDescriptionException {
    final ProvisioningConfig.Builder configBuilder = ProvisioningConfig.builder();
    configBuilder.initUniverses(provisionedConfig);
    if (provisionedConfig.hasOptions()) {
        configBuilder.addOptions(provisionedConfig.getOptions());
    }
    for (FeaturePackConfig fp : provisionedConfig.getFeaturePackDeps()) {
        final FeaturePackConfig.Builder fpcBuilder = updatedDirectFps.get(fp.getLocation().getFPID());
        if (fpcBuilder == null) {
            configBuilder.addFeaturePackDep(provisionedConfig.originOf(fp.getLocation().getProducer()), fp);
        } else {
            configBuilder.addFeaturePackDep(provisionedConfig.originOf(fp.getLocation().getProducer()), fpcBuilder.build());
        }
    }
    for (FeaturePackConfig fp : provisionedConfig.getTransitiveDeps()) {
        final FeaturePackConfig.Builder fpcBuilder = updatedTransitiveFps.get(fp.getLocation().getFPID());
        if (fpcBuilder == null) {
            configBuilder.addFeaturePackDep(provisionedConfig.originOf(fp.getLocation().getProducer()), fp);
        } else {
            configBuilder.addFeaturePackDep(provisionedConfig.originOf(fp.getLocation().getProducer()), fpcBuilder.build());
        }
    }
    for (FeaturePackConfig.Builder fpcBuilder : addedTransitiveFps.values()) {
        configBuilder.addFeaturePackDep(fpcBuilder.build());
    }
    final Boolean inheritConfigs = provisionedConfig.getInheritConfigs();
    if (inheritConfigs != null) {
        configBuilder.setInheritConfigs(inheritConfigs);
    }
    configBuilder.setInheritModelOnlyConfigs(provisionedConfig.isInheritModelOnlyConfigs());
    if (provisionedConfig.hasFullModelsExcluded()) {
        for (Map.Entry<String, Boolean> entry : provisionedConfig.getFullModelsExcluded().entrySet()) {
            configBuilder.excludeConfigModel(entry.getKey(), entry.getValue());
        }
    }
    if (provisionedConfig.hasFullModelsIncluded()) {
        for (String model : provisionedConfig.getFullModelsIncluded()) {
            configBuilder.includeConfigModel(model);
        }
    }
    return configBuilder;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)40 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)12 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)12 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)11 ProvisioningException (org.jboss.galleon.ProvisioningException)9 ArrayList (java.util.ArrayList)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 Path (java.nio.file.Path)6 HashMap (java.util.HashMap)6 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)6 Test (org.junit.Test)5 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CommandException (org.aesh.command.CommandException)3 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 ConfigModel (org.jboss.galleon.config.ConfigModel)3 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)3