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;
}
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();
}
}
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;
}
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;
}
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);
}
}
}
Aggregations