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());
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations