Search in sources :

Example 1 with TextNode

use of org.jboss.galleon.xml.util.TextNode 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 TextNode

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

the class ProvisioningXmlWriter method writeFeaturePackConfig.

static void writeFeaturePackConfig(ElementNode fp, FeaturePackLocation location, FeaturePackConfig featurePack, String origin) {
    final String ns = fp.getNamespace();
    addAttribute(fp, Attribute.LOCATION, location.toString());
    if (origin != null) {
        addElement(fp, Element.ORIGIN.getLocalName(), ns).addChild(new TextNode(origin));
    }
    if (featurePack.hasPatches()) {
        final ElementNode patches = addElement(fp, Element.PATCHES.getLocalName(), ns);
        for (FPID patchId : featurePack.getPatches()) {
            final ElementNode patch = addElement(patches, Element.PATCH.getLocalName(), ns);
            addAttribute(patch, Attribute.ID, patchId.toString());
        }
    }
    writeConfigCustomizations(fp, ns, featurePack);
    ElementNode packages = null;
    final Boolean inheritPackages = featurePack.getInheritPackages();
    if (inheritPackages != null) {
        packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
        addAttribute(packages, Attribute.INHERIT, String.valueOf(inheritPackages));
    }
    if (featurePack.hasExcludedPackages()) {
        if (packages == null) {
            packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
        }
        for (String excluded : featurePack.getExcludedPackages()) {
            final ElementNode exclude = addElement(packages, Element.EXCLUDE.getLocalName(), ns);
            addAttribute(exclude, Attribute.NAME, excluded);
        }
    }
    if (featurePack.hasIncludedPackages()) {
        if (packages == null) {
            packages = addElement(fp, Element.PACKAGES.getLocalName(), ns);
        }
        for (String included : featurePack.getIncludedPackages()) {
            final ElementNode include = addElement(packages, Element.INCLUDE.getLocalName(), ns);
            addAttribute(include, Attribute.NAME, included);
        }
    }
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) TextNode(org.jboss.galleon.xml.util.TextNode) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 3 with TextNode

use of org.jboss.galleon.xml.util.TextNode 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 4 with TextNode

use of org.jboss.galleon.xml.util.TextNode 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)4 TextNode (org.jboss.galleon.xml.util.TextNode)4 XMLStreamException (javax.xml.stream.XMLStreamException)2 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)1 MavenArtifact (org.jboss.galleon.universe.maven.MavenArtifact)1