use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisioningXmlWriter method writeConfigCustomizations.
static void writeConfigCustomizations(ElementNode parent, String ns, ConfigCustomizations configCustoms) {
ElementNode defConfigsE = null;
final Boolean inheritConfigs = configCustoms.getInheritConfigs();
if (inheritConfigs != null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
addAttribute(defConfigsE, Attribute.INHERIT, inheritConfigs.toString());
}
if (!configCustoms.isInheritModelOnlyConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
addAttribute(defConfigsE, Attribute.INHERIT_UNNAMED_MODELS, FALSE);
}
if (configCustoms.hasFullModelsExcluded()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (Map.Entry<String, Boolean> excluded : configCustoms.getFullModelsExcluded().entrySet()) {
final ElementNode exclude = addElement(defConfigsE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(exclude, Attribute.MODEL, excluded.getKey());
if (!excluded.getValue()) {
addAttribute(exclude, Attribute.NAMED_MODELS_ONLY, FALSE);
}
}
}
if (configCustoms.hasFullModelsIncluded()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
final String[] array = configCustoms.getFullModelsIncluded().toArray(new String[configCustoms.getFullModelsIncluded().size()]);
Arrays.sort(array);
for (String modelName : array) {
final ElementNode included = addElement(defConfigsE, Element.INCLUDE.getLocalName(), ns);
addAttribute(included, Attribute.MODEL, modelName);
}
}
if (configCustoms.hasExcludedConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (ConfigId configId : configCustoms.getExcludedConfigs()) {
final ElementNode excluded = addElement(defConfigsE, Element.EXCLUDE.getLocalName(), ns);
if (configId.getModel() != null) {
addAttribute(excluded, Attribute.MODEL, configId.getModel());
}
if (configId.getName() != null) {
addAttribute(excluded, Attribute.NAME, configId.getName());
}
}
}
if (configCustoms.hasIncludedConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (ConfigId config : configCustoms.getIncludedConfigs()) {
final ElementNode includeElement = addElement(defConfigsE, Element.INCLUDE.getLocalName(), ns);
if (config.getModel() != null) {
addAttribute(includeElement, Attribute.MODEL, config.getModel());
}
if (config.getName() != null) {
addAttribute(includeElement, Attribute.NAME, config.getName());
}
}
}
if (configCustoms.hasDefinedConfigs()) {
for (ConfigModel config : configCustoms.getDefinedConfigs()) {
parent.addChild(ConfigXmlWriter.getInstance().toElement(config, ns));
}
}
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisioningXmlWriter method toElement.
protected ElementNode toElement(ProvisioningConfig config) {
final ElementNode install = addElement(null, Element.INSTALLATION);
writeUniverseSpecs(config, install);
if (config.hasTransitiveDeps()) {
final ElementNode transitives = addElement(install, Element.TRANSITIVE);
for (FeaturePackConfig dep : config.getTransitiveDeps()) {
writeFeaturePackConfig(addElement(transitives, Element.FEATURE_PACK), config.getUserConfiguredLocation(dep.getLocation()), dep, config.originOf(dep.getLocation().getProducer()));
}
}
if (config.hasFeaturePackDeps()) {
for (FeaturePackConfig fp : config.getFeaturePackDeps()) {
final ElementNode fpElement = addElement(install, Element.FEATURE_PACK);
writeFeaturePackConfig(fpElement, config.getUserConfiguredLocation(fp.getLocation()), fp, config.originOf(fp.getLocation().getProducer()));
}
}
writeConfigCustomizations(install, Element.INSTALLATION.getNamespace(), config);
if (config.hasOptions()) {
final Map<String, String> pluginOptions = config.getOptions();
final String[] names = pluginOptions.keySet().toArray(new String[pluginOptions.size()]);
Arrays.sort(names);
final ElementNode optionsE = addElement(install, Element.OPTIONS);
for (String name : names) {
final ElementNode optionE = addElement(optionsE, Element.OPTION);
addAttribute(optionE, Attribute.NAME, name);
final String value = pluginOptions.get(name);
if (value != null) {
addAttribute(optionE, Attribute.VALUE, value);
}
}
}
return install;
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisioningXmlWriter method writeUniverseConfig.
private static void writeUniverseConfig(ElementNode universesEl, String name, String factory, String location) {
final ElementNode universeEl = addElement(universesEl, Element.UNIVERSE.getLocalName(), universesEl.getNamespace());
if (name != null) {
addAttribute(universeEl, Attribute.NAME, name);
}
addAttribute(universeEl, Attribute.FACTORY, factory);
if (location != null) {
addAttribute(universeEl, Attribute.LOCATION, location);
}
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class MavenProducerXmlWriter method toElement.
@Override
protected ElementNode toElement(MavenProducerDescription<?> producer) throws XMLStreamException {
final ElementNode producerEl = addElement(null, Element.PRODUCER);
addAttribute(producerEl, Attribute.NAME, producer.getName());
if (producer.getFeaturePackGroupId() != null) {
addElement(producerEl, Element.FP_GROUP_ID).addChild(new TextNode(producer.getFeaturePackGroupId()));
}
if (producer.getFeaturePackArtifactId() != null) {
addElement(producerEl, Element.FP_ARTIFACT_ID).addChild(new TextNode(producer.getFeaturePackArtifactId()));
}
if (producer.hasDefaultChannel()) {
addElement(producerEl, Element.DEFAULT_CHANNEL).addChild(new TextNode(producer.getDefaultChannelName()));
}
final ElementNode frequenciesEl = addElement(producerEl, Element.FREQUENCIES);
final Collection<String> frequencies = producer.getFrequencies();
final String defaultFrequency = producer.getDefaultFrequency();
for (String frequency : frequencies) {
final ElementNode frequencyE = addElement(frequenciesEl, Element.FREQUENCY);
if (defaultFrequency != null && frequency.equals(defaultFrequency)) {
addAttribute(frequencyE, Attribute.DEFAULT, "true");
}
frequencyE.addChild(new TextNode(frequency));
}
return producerEl;
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class MavenChannelSpecXmlWriter method toElement.
@Override
protected ElementNode toElement(MavenChannelDescription channel) throws XMLStreamException {
final ElementNode producerEl = addElement(null, Element.CHANNEL);
addAttribute(producerEl, Attribute.NAME, channel.getName());
String value = channel.getVersionRange();
if (value == null) {
throw new XMLStreamException("Channel " + channel.getName() + " is missing version-range");
}
addElement(producerEl, Element.VERSION_RANGE).addChild(new TextNode(value));
String includeRegex = channel.getVersionIncludeRegex();
if (includeRegex != null) {
addElement(producerEl, Element.VERSION_INCLUDE_REGEX).addChild(new TextNode(includeRegex));
}
String excludeRegex = channel.getVersionExcludeRegex();
if (excludeRegex != null) {
addElement(producerEl, Element.VERSION_EXCLUDE_REGEX).addChild(new TextNode(excludeRegex));
}
return producerEl;
}
Aggregations