Search in sources :

Example 36 with ConfigId

use of org.jboss.galleon.config.ConfigId 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;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigId(org.jboss.galleon.config.ConfigId) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 37 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ConfigXmlWriter method toElement.

protected ElementNode toElement(ConfigModel config, String ns) {
    final ElementNode configE = addElement(null, Element.CONFIG.getLocalName(), ns);
    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> prop : config.getProperties().entrySet()) {
            final ElementNode propE = addElement(propsE, Element.PROP.getLocalName(), ns);
            addAttribute(propE, Attribute.NAME, prop.getKey());
            addAttribute(propE, Attribute.VALUE, prop.getValue());
        }
    }
    if (config.hasConfigDeps()) {
        final ElementNode configDeps = addElement(configE, Element.CONFIG_DEPS.getLocalName(), ns);
        for (Map.Entry<String, ConfigId> dep : config.getConfigDeps().entrySet()) {
            final ElementNode configDep = addElement(configDeps, Element.CONFIG_DEP.getLocalName(), ns);
            addAttribute(configDep, Attribute.ID.getLocalName(), dep.getKey());
            final ConfigId configId = dep.getValue();
            if (configId.getModel() != null) {
                addAttribute(configDep, Attribute.MODEL.getLocalName(), configId.getModel());
            }
            if (configId.getName() != null) {
                addAttribute(configDep, Attribute.NAME.getLocalName(), configId.getName());
            }
        }
    }
    ElementNode layers = null;
    if (!config.isInheritLayers()) {
        layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        addAttribute(layers, Attribute.INHERIT, "false");
    }
    if (config.hasIncludedLayers()) {
        if (layers == null) {
            layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        }
        for (String layerDep : config.getIncludedLayers()) {
            final ElementNode layer = addElement(layers, Element.INCLUDE.getLocalName(), ns);
            addAttribute(layer, Attribute.NAME, layerDep);
        }
    }
    if (config.hasExcludedLayers()) {
        if (layers == null) {
            layers = addElement(configE, Element.LAYERS.getLocalName(), ns);
        }
        for (String layerDep : config.getExcludedLayers()) {
            final ElementNode layer = addElement(layers, Element.EXCLUDE.getLocalName(), ns);
            addAttribute(layer, Attribute.NAME, layerDep);
        }
    }
    FeatureGroupXmlWriter.addFeatureGroupDepBody(config, configE, ns);
    return configE;
}
Also used : ConfigId(org.jboss.galleon.config.ConfigId) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 38 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class State method resetConfiguration.

public void resetConfiguration(PmSession pmSession, ConfigInfo configuration) throws ProvisioningException, IOException {
    ConfigId id = new ConfigId(configuration.getModel(), configuration.getName());
    Action action = configProvisioning.resetConfiguration(id);
    config = pushState(action, pmSession);
}
Also used : ConfigId(org.jboss.galleon.config.ConfigId)

Example 39 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class State method addFeature.

public void addFeature(PmSession pmSession, FeatureSpecInfo spec, ConfigInfo configuration, Map<String, String> options) throws ProvisioningException, IOException {
    ConfigId id = new ConfigId(configuration.getModel(), configuration.getName());
    Action action = configProvisioning.addFeature(id, spec, options);
    config = pushState(action, pmSession);
}
Also used : ConfigId(org.jboss.galleon.config.ConfigId)

Aggregations

ConfigId (org.jboss.galleon.config.ConfigId)39 ConfigModel (org.jboss.galleon.config.ConfigModel)12 Path (java.nio.file.Path)11 Map (java.util.Map)10 ProvisioningException (org.jboss.galleon.ProvisioningException)9 IOException (java.io.IOException)7 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)6 HashMap (java.util.HashMap)5 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)5 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)3 ElementNode (org.jboss.galleon.xml.util.ElementNode)3 BufferedWriter (java.io.BufferedWriter)2 FileVisitResult (java.nio.file.FileVisitResult)2