Search in sources :

Example 41 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeaturePackDepsConfigBuilder method addFeaturePackDep.

@SuppressWarnings("unchecked")
public B addFeaturePackDep(int index, FeaturePackConfig dependency) throws ProvisioningDescriptionException {
    if (index >= fpDeps.size()) {
        addFeaturePackDep(dependency);
        return (B) this;
    }
    FeaturePackLocation fpl = dependency.getLocation();
    final UniverseSpec resolvedUniverse = getConfiguredUniverse(fpl);
    if (resolvedUniverse != null) {
        fpl = fpl.replaceUniverse(resolvedUniverse);
        dependency = FeaturePackConfig.builder(fpl).init(dependency).build();
    }
    if (fpDeps.containsKey(fpl.getProducer())) {
        throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(fpl.getProducer()));
    }
    // reconstruct the linkedMap.
    Map<ProducerSpec, FeaturePackConfig> tmp = Collections.emptyMap();
    int i = 0;
    for (Entry<ProducerSpec, FeaturePackConfig> entry : fpDeps.entrySet()) {
        if (i == index) {
            tmp = CollectionUtils.putLinked(tmp, fpl.getProducer(), dependency);
        }
        tmp = CollectionUtils.putLinked(tmp, entry.getKey(), entry.getValue());
        i += 1;
    }
    fpDeps = tmp;
    return (B) this;
}
Also used : ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)41 XMLStreamException (javax.xml.stream.XMLStreamException)19 Path (java.nio.file.Path)12 IOException (java.io.IOException)9 ProvisioningException (org.jboss.galleon.ProvisioningException)8 BufferedReader (java.io.BufferedReader)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)5 HashMap (java.util.HashMap)4 FeatureGroup (org.jboss.galleon.config.FeatureGroup)4 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 UnsatisfiedPackageDependencyException (org.jboss.galleon.UnsatisfiedPackageDependencyException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)3 Reader (java.io.Reader)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 FeatureConfig (org.jboss.galleon.config.FeatureConfig)2