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