Search in sources :

Example 1 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class MavenProducerSpecXmlWriter method toElement.

@Override
protected ElementNode toElement(MavenProducerBase producer) throws XMLStreamException {
    final ElementNode producerEl = addElement(null, Element.PRODUCER);
    addAttribute(producerEl, Attribute.NAME, producer.getName());
    final MavenArtifact artifact = producer.getArtifact();
    String value = artifact.getGroupId();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing groupId");
    }
    addElement(producerEl, Element.GROUP_ID).addChild(new TextNode(value));
    value = artifact.getArtifactId();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing artifactId");
    }
    addElement(producerEl, Element.ARTIFACT_ID).addChild(new TextNode(value));
    value = artifact.getVersionRange();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing version-range");
    }
    addElement(producerEl, Element.VERSION_RANGE).addChild(new TextNode(value));
    return producerEl;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) TextNode(org.jboss.galleon.xml.util.TextNode) ElementNode(org.jboss.galleon.xml.util.ElementNode) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact)

Example 2 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class BaseXmlWriter method write.

public void write(T t, Writer stream) throws XMLStreamException, IOException {
    final ElementNode root = toElement(t);
    try (FormattingXmlStreamWriter writer = new FormattingXmlStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream))) {
        writer.writeStartDocument();
        root.marshall(writer);
        writer.writeEndDocument();
    }
}
Also used : FormattingXmlStreamWriter(org.jboss.galleon.xml.util.FormattingXmlStreamWriter) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 3 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeatureGroupXmlWriter method toElement.

protected ElementNode toElement(FeatureGroup featureGroup, String ns) {
    final ElementNode fgE = addElement(null, Element.FEATURE_GROUP_SPEC.getLocalName(), ns);
    if (featureGroup.getName() != null) {
        addAttribute(fgE, Attribute.NAME, featureGroup.getName());
    }
    // addFeatureGroupIncludeExclude(featureGroup, ns, fgE);
    writeFeatureGroupSpecBody(fgE, featureGroup, ns);
    if (featureGroup.hasPackageDeps()) {
        PackageXmlWriter.writePackageDeps(featureGroup, addElement(fgE, Element.PACKAGES.getLocalName(), ns));
    }
    return fgE;
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 4 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeaturePackXmlWriter method toElement.

protected ElementNode toElement(FeaturePackSpec fpSpec) {
    final ElementNode fp = addElement(null, Element.FEATURE_PACK);
    addAttribute(fp, Attribute.LOCATION, fpSpec.getFPID().toString());
    ProvisioningXmlWriter.writeUniverseSpecs(fpSpec, fp);
    if (fpSpec.isPatch()) {
        final ElementNode patchFor = addElement(fp, Element.PATCH);
        addAttribute(patchFor, Attribute.FOR, fpSpec.getPatchFor().toString());
    }
    if (fpSpec.hasTransitiveDeps()) {
        final ElementNode transitives = addElement(fp, Element.TRANSITIVE);
        for (FeaturePackConfig dep : fpSpec.getTransitiveDeps()) {
            final ElementNode depElement = addElement(transitives, Element.DEPENDENCY);
            ProvisioningXmlWriter.writeFeaturePackConfig(depElement, fpSpec.getUserConfiguredLocation(dep.getLocation()), dep, fpSpec.originOf(dep.getLocation().getProducer()));
        }
    }
    if (fpSpec.hasFeaturePackDeps()) {
        final ElementNode deps = addElement(fp, Element.DEPENDENCIES);
        for (FeaturePackConfig dep : fpSpec.getFeaturePackDeps()) {
            final ElementNode depElement = addElement(deps, Element.DEPENDENCY);
            ProvisioningXmlWriter.writeFeaturePackConfig(depElement, fpSpec.getUserConfiguredLocation(dep.getLocation()), dep, fpSpec.originOf(dep.getLocation().getProducer()));
        }
    }
    ProvisioningXmlWriter.writeConfigCustomizations(fp, Element.FEATURE_PACK.getNamespace(), fpSpec);
    if (fpSpec.hasDefaultPackages()) {
        final ElementNode pkgs = addElement(fp, Element.DEFAULT_PACKAGES);
        final String[] pkgNames = fpSpec.getDefaultPackageNames().toArray(new String[0]);
        Arrays.sort(pkgNames);
        for (String name : pkgNames) {
            addAttribute(addElement(pkgs, Element.PACKAGE), Attribute.NAME, name);
        }
    }
    if (fpSpec.hasPlugins()) {
        final ElementNode plugins = addElement(fp, Element.PLUGINS);
        for (FeaturePackPlugin plugin : fpSpec.getPlugins().values()) {
            final ElementNode pluginE = addElement(plugins, Element.PLUGIN);
            addAttribute(pluginE, Attribute.ID, plugin.getId());
            addAttribute(pluginE, Attribute.LOCATION, plugin.getLocation());
        }
    }
    return fp;
}
Also used : FeaturePackPlugin(org.jboss.galleon.spec.FeaturePackPlugin) ElementNode(org.jboss.galleon.xml.util.ElementNode) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 5 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeatureSpecXmlWriter method writeCaps.

private void writeCaps(final ElementNode parent, Set<CapabilitySpec> caps) {
    for (CapabilitySpec cap : caps) {
        final ElementNode capE = addElement(parent, Element.CAPABILITY);
        addAttribute(capE, Attribute.NAME, cap.toString());
        if (cap.isOptional()) {
            addAttribute(capE, Attribute.OPTIONAL, TRUE);
        }
    }
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) 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