use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisionedConfigXmlWriter method toElement.
protected ElementNode toElement(ProvisionedConfig config, String ns) throws XMLStreamException {
final ElementNode configE = addElement(null, Element.CONFIG.getLocalName(), ns);
if (config.getName() != null) {
addAttribute(configE, Attribute.NAME, config.getName());
}
if (config.getModel() != null) {
addAttribute(configE, Attribute.MODEL, config.getModel());
}
if (config.hasProperties()) {
final ElementNode propsE = addElement(configE, Element.PROPS.getLocalName(), ns);
for (Map.Entry<String, String> entry : config.getProperties().entrySet()) {
final ElementNode propE = addElement(propsE, Element.PROP.getLocalName(), ns);
addAttribute(propE, Attribute.NAME, entry.getKey());
addAttribute(propE, Attribute.VALUE, entry.getValue());
}
}
if (config.hasLayers()) {
final ElementNode propsE = addElement(configE, Element.LAYERS.getLocalName(), ns);
for (ConfigId layerId : config.getLayers()) {
final ElementNode propE = addElement(propsE, Element.LAYER.getLocalName(), ns);
if (layerId.getModel() != null) {
addAttribute(propE, Attribute.MODEL, layerId.getModel());
}
addAttribute(propE, Attribute.NAME, layerId.getName());
}
}
if (config.hasFeatures()) {
try {
config.handle(new XmlConfigHandler(configE));
} catch (ProvisioningException e) {
throw new XMLStreamException("Failed to marshal ProvisionedConfig", e);
}
}
return configE;
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisionedStateXmlWriter method writeFeaturePack.
private void writeFeaturePack(ElementNode fp, FeaturePack<?> featurePack) {
addAttribute(fp, Attribute.LOCATION, featurePack.getFPID().toString());
if (featurePack.hasPackages()) {
final ElementNode packages = addElement(fp, Element.PACKAGES);
for (FeaturePackPackage pkg : featurePack.getPackages()) {
final ElementNode pkgElement = addElement(packages, Element.PACKAGE);
addAttribute(pkgElement, Attribute.NAME, pkg.getName());
}
}
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class ProvisionedStateXmlWriter method toElement.
@Override
protected ElementNode toElement(FeaturePackSet<?> provisionedState) throws XMLStreamException {
final ElementNode pkg = addElement(null, Element.INSTALLATION);
if (provisionedState.hasFeaturePacks()) {
for (FeaturePack<?> fp : provisionedState.getFeaturePacks()) {
final ElementNode fpElement = addElement(pkg, Element.FEATURE_PACK);
writeFeaturePack(fpElement, fp);
}
}
if (provisionedState.hasConfigs()) {
for (ProvisionedConfig config : provisionedState.getConfigs()) {
pkg.addChild(ProvisionedConfigXmlWriter.getInstance().toElement(config, Element.CONFIG.getNamespace()));
}
}
return pkg;
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureGroupDepBody.
public static void addFeatureGroupDepBody(FeatureGroupSupport dep, final ElementNode depE, String ns) {
if (dep.getName() != null) {
addAttribute(depE, Attribute.NAME, dep.getName());
}
if (!dep.isInheritFeatures()) {
addAttribute(depE, Attribute.INHERIT_FEATURES, FALSE);
}
addFeatureGroupIncludeExclude(dep, ns, depE);
writeFeatureGroupSpecBody(depE, dep, ns);
if (dep.hasExternalFeatureGroups()) {
for (Map.Entry<String, FeatureGroup> entry : dep.getExternalFeatureGroups().entrySet()) {
final ElementNode fpE = addElement(depE, Element.ORIGIN.getLocalName(), ns);
addAttribute(fpE, Attribute.NAME, entry.getKey());
addFeatureGroupIncludeExclude(entry.getValue(), ns, fpE);
}
}
if (dep.hasPackageDeps()) {
PackageXmlWriter.writePackageDeps(dep, addElement(depE, Element.PACKAGES.getLocalName(), ns));
}
}
use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureConfig.
public static void addFeatureConfig(ElementNode parentE, FeatureConfig fc, String ns) {
final ElementNode fcE = addElement(parentE, Element.FEATURE.getLocalName(), ns);
addAttribute(fcE, Attribute.SPEC, fc.getSpecId().toString());
if (fc.getParentRef() != null) {
addAttribute(fcE, Attribute.PARENT_REF, fc.getParentRef());
}
addFeatureConfigBody(fcE, null, fc, ns);
}
Aggregations