use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class State method removeExcludedLayersConfiguration.
public void removeExcludedLayersConfiguration(PmSession pmSession, ConfigInfo configuration, String[] layers) throws ProvisioningException, IOException {
ConfigId id = new ConfigId(configuration.getModel(), configuration.getName());
Action action = configProvisioning.removeExcludedLayersConfiguration(id, layers);
config = pushState(action, pmSession);
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class FeaturePackLayout method loadLayers.
public Set<ConfigId> loadLayers() throws ProvisioningException, IOException {
Path layersDir = getDir().resolve(Constants.LAYERS);
if (!Files.exists(layersDir)) {
return Collections.emptySet();
}
Set<ConfigId> layers = new HashSet<>();
Files.walkFileTree(layersDir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.getFileName().toString().equals(Constants.LAYER_SPEC_XML)) {
ConfigId id;
Path rootDir = file.getParent().getParent();
// No model
if (rootDir.equals(layersDir)) {
id = new ConfigId(null, file.getParent().getFileName().toString());
} else {
id = new ConfigId(rootDir.getFileName().toString(), file.getParent().getFileName().toString());
}
layers.add(id);
}
return FileVisitResult.CONTINUE;
}
});
return layers;
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class FeaturePackBuilder method build.
void build() throws ProvisioningException {
final FeaturePackLocation fps = fpBuilder.getFPID().getLocation();
if (fps == null) {
throw new ProvisioningDescriptionException("Feature-pack location has not been set");
}
if (fps.getProducerName() == null) {
throw new ProvisioningDescriptionException("Feature-pack producer has not been set");
}
/*
if(fps.getChannelName() == null) {
throw new ProvisioningDescriptionException("Feature-pack channel has not been set");
}
*/
if (fps.getBuild() == null) {
throw new ProvisioningDescriptionException("Feature-pack build number has not been set");
}
final Path fpWorkDir = LayoutUtils.getFeaturePackDir(creator.getWorkDir(), fps.getFPID(), false);
final FeaturePackSpec fpSpec;
try {
ensureDir(fpWorkDir);
for (PackageBuilder pkg : pkgs) {
final PackageSpec pkgDescr = pkg.build(fpWorkDir);
if (pkg.isDefault()) {
fpBuilder.addDefaultPackage(pkgDescr.getName());
}
}
if (!specs.isEmpty()) {
final Path featuresDir = fpWorkDir.resolve(Constants.FEATURES);
final FeatureSpecXmlWriter specWriter = FeatureSpecXmlWriter.getInstance();
for (FeatureSpec spec : specs.values()) {
final Path featureDir = featuresDir.resolve(spec.getName());
ensureDir(featureDir);
specWriter.write(spec, featureDir.resolve(Constants.SPEC_XML));
}
}
if (!featureGroups.isEmpty()) {
final Path fgsDir = fpWorkDir.resolve(Constants.FEATURE_GROUPS);
ensureDir(fgsDir);
final FeatureGroupXmlWriter fgWriter = FeatureGroupXmlWriter.getInstance();
for (FeatureGroup fg : featureGroups.values()) {
fgWriter.write(fg, fgsDir.resolve(fg.getName() + ".xml"));
}
}
if (!classes.isEmpty()) {
createPluginJar(classes, services, fpWorkDir.resolve(Constants.PLUGINS).resolve(pluginFileName));
}
if (!plugins.isEmpty()) {
final Path pluginsDir = fpWorkDir.resolve(Constants.PLUGINS);
ensureDir(pluginsDir);
for (Path plugin : plugins) {
Files.copy(plugin, pluginsDir.resolve(plugin.getFileName()));
}
}
if (!layers.isEmpty()) {
for (Map.Entry<ConfigId, ConfigLayerSpec> entry : layers.entrySet()) {
final ConfigId id = entry.getKey();
final Path xml = LayoutUtils.getLayerSpecXml(fpWorkDir, id.getModel(), id.getName(), false);
if (Files.exists(xml)) {
throw new ProvisioningException("Failed to create feature-pack: " + xml + " already exists");
}
ConfigLayerXmlWriter.getInstance().write(entry.getValue(), xml);
}
}
if (!configs.isEmpty()) {
for (ConfigModel config : configs.values()) {
final Path modelXml = LayoutUtils.getConfigXml(fpWorkDir, config.getId(), false);
if (Files.exists(modelXml)) {
throw new ProvisioningException("Failed to create feature-pack: " + modelXml + " already exists");
}
ConfigXmlWriter.getInstance().write(config, modelXml);
}
}
fpSpec = fpBuilder.build();
final FeaturePackXmlWriter writer = FeaturePackXmlWriter.getInstance();
writer.write(fpSpec, fpWorkDir.resolve(Constants.FEATURE_PACK_XML));
if (tasks != null && !tasks.isEmpty()) {
tasks.execute(FsTaskContext.builder().setTargetRoot(fpWorkDir.resolve(Constants.RESOURCES)).build());
}
creator.install(fps.getFPID(), fpWorkDir);
} catch (ProvisioningDescriptionException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException(e);
} finally {
IoUtils.recursiveDelete(fpWorkDir);
}
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method orderConfig.
private void orderConfig(ConfigModelStack config, List<ProvisionedConfig> configList, Set<ConfigId> scheduledIds) throws ProvisioningException {
if (!config.hasConfigDeps()) {
configList.add(ResolvedConfig.build(config));
return;
}
scheduledIds = CollectionUtils.add(scheduledIds, config.id);
for (ConfigId depId : config.getConfigDeps().values()) {
if (scheduledIds.contains(depId) || contains(configList, depId)) {
continue;
}
if (depId.isModelOnly()) {
final Map<String, ConfigModelStack> configs = namedModelConfigs.get(depId.getModel());
if (configs == null) {
throw new ProvisioningDescriptionException("Config " + config.id + " has unsatisfied dependency on config " + depId);
}
for (ConfigModelStack dep : configs.values()) {
if (contains(configList, dep.id)) {
continue;
}
orderConfig(dep, configList, scheduledIds);
}
} else {
final ConfigModelStack configStack;
if (depId.getModel() == null) {
configStack = nameOnlyConfigs.get(depId.getName());
} else {
final Map<String, ConfigModelStack> configs = namedModelConfigs.get(depId.getModel());
if (configs == null) {
throw new ProvisioningDescriptionException("Config " + config.id + " has unsatisfied dependency on config " + depId);
}
configStack = configs.get(depId.getName());
}
if (configStack == null) {
throw new ProvisioningDescriptionException("Config " + config.id + " has unsatisfied dependency on config " + depId);
}
if (contains(configList, configStack.id)) {
continue;
}
orderConfig(configStack, configList, scheduledIds);
}
}
scheduledIds = CollectionUtils.remove(scheduledIds, config.id);
configList.add(ResolvedConfig.build(config));
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method mergeModelOnlyConfigs.
private void mergeModelOnlyConfigs() throws ProvisioningException {
if (namedModelConfigs.isEmpty()) {
return;
}
for (Map.Entry<String, Map<String, ConfigModelStack>> entry : namedModelConfigs.entrySet()) {
final ConfigId modelOnlyId = new ConfigId(entry.getKey(), null);
final ConfigModelStack modelOnlyStack = resolveModelOnlyConfig(modelOnlyId);
if (modelOnlyStack == null) {
continue;
}
for (ConfigModelStack configStack : entry.getValue().values()) {
configStack.merge(modelOnlyStack);
}
}
}
Aggregations