Search in sources :

Example 11 with ElementNode

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));
        }
    }
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) ConfigId(org.jboss.galleon.config.ConfigId) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 12 with ElementNode

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;
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 13 with ElementNode

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);
    }
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 14 with ElementNode

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;
}
Also used : TextNode(org.jboss.galleon.xml.util.TextNode) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 15 with ElementNode

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;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) TextNode(org.jboss.galleon.xml.util.TextNode) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Aggregations

ElementNode (org.jboss.galleon.xml.util.ElementNode)27 Map (java.util.Map)8 TextNode (org.jboss.galleon.xml.util.TextNode)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)2 FeatureDependencySpec (org.jboss.galleon.spec.FeatureDependencySpec)2 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigItem (org.jboss.galleon.config.ConfigItem)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeatureConfig (org.jboss.galleon.config.FeatureConfig)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 CapabilitySpec (org.jboss.galleon.spec.CapabilitySpec)1 ConfigLayerDependency (org.jboss.galleon.spec.ConfigLayerDependency)1 FeatureAnnotation (org.jboss.galleon.spec.FeatureAnnotation)1 FeatureId (org.jboss.galleon.spec.FeatureId)1 FeaturePackPlugin (org.jboss.galleon.spec.FeaturePackPlugin)1 FeatureParameterSpec (org.jboss.galleon.spec.FeatureParameterSpec)1 FeatureReferenceSpec (org.jboss.galleon.spec.FeatureReferenceSpec)1 PackageDependencySpec (org.jboss.galleon.spec.PackageDependencySpec)1