use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayout method initPluginOptions.
private void initPluginOptions(Map<String, String> extraOptions, boolean cleanupConfigOptions) throws ProvisioningException {
options = config.getOptions();
if (!extraOptions.isEmpty()) {
options = CollectionUtils.putAll(CollectionUtils.clone(options), extraOptions);
}
final Map<String, ProvisioningOption> recognizedOptions;
final List<ProvisioningOption> overridenOptions;
if (options.isEmpty()) {
recognizedOptions = Collections.emptyMap();
overridenOptions = Collections.emptyList();
} else {
final int size = options.size();
recognizedOptions = new HashMap<>(size);
overridenOptions = new ArrayList<>(size);
}
// process built-in options
processOptions(ProvisioningOption.getStandardList(), extraOptions, recognizedOptions, overridenOptions);
// process plugin options
handle.visitPlugins(new FeaturePackPluginVisitor<InstallPlugin>() {
@Override
public void visitPlugin(InstallPlugin plugin) throws ProvisioningException {
processOptions(plugin.getOptions().values(), extraOptions, recognizedOptions, overridenOptions);
}
}, InstallPlugin.class);
ProvisioningConfig.Builder configBuilder = null;
if (recognizedOptions.size() != options.size()) {
final Set<String> nonRecognized = new HashSet<>(options.keySet());
nonRecognized.removeAll(recognizedOptions.keySet());
if (cleanupConfigOptions) {
final Iterator<String> i = nonRecognized.iterator();
while (i.hasNext()) {
final String optionName = i.next();
if (!config.hasOption(optionName)) {
continue;
}
if (configBuilder == null) {
configBuilder = ProvisioningConfig.builder(config);
}
configBuilder.removeOption(optionName);
i.remove();
}
}
if (!nonRecognized.isEmpty()) {
throw new ProvisioningException(Errors.pluginOptionsNotRecognized(nonRecognized));
}
}
if (!overridenOptions.isEmpty()) {
if (configBuilder == null) {
configBuilder = ProvisioningConfig.builder(config);
}
for (ProvisioningOption option : overridenOptions) {
final String optionName = option.getName();
if (!extraOptions.containsKey(optionName)) {
continue;
}
final String value = extraOptions.get(optionName);
if (option.isPersistent()) {
configBuilder.addOption(optionName, value);
} else if (value == null) {
if (config.getOption(optionName) != null) {
configBuilder.removeOption(optionName);
}
} else if (!value.equals(config.getOption(optionName))) {
configBuilder.removeOption(optionName);
}
}
config = configBuilder.build();
} else if (configBuilder != null) {
config = configBuilder.build();
}
options = CollectionUtils.unmodifiable(options);
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayout method getFeaturePackUpdate.
/**
* Query for available version update and patches for the specific producer.
*
* @param producer the producer to check the updates for
* @return available updates for the producer
* @throws ProvisioningException in case of a failure
*/
public FeaturePackUpdatePlan getFeaturePackUpdate(ProducerSpec producer) throws ProvisioningException {
final F f = featurePacks.get(producer);
if (f == null) {
throw new ProvisioningException(Errors.unknownFeaturePack(producer.getLocation().getFPID()));
}
final FeaturePackLocation fpl = f.getFPID().getLocation();
final Universe<?> universe = layoutFactory.getUniverseResolver().getUniverse(fpl.getUniverse());
final Channel channel = universe.getProducer(fpl.getProducerName()).getChannel(fpl.getChannelName());
final List<F> patches = fpPatches.get(fpl.getFPID());
final Set<FPID> patchIds;
if (patches == null || patches.isEmpty()) {
patchIds = Collections.emptySet();
} else if (patches.size() == 1) {
patchIds = Collections.singleton(patches.get(0).getFPID());
} else {
final Set<FPID> tmp = new HashSet<>(patches.size());
for (F p : patches) {
tmp.add(p.getFPID());
}
patchIds = CollectionUtils.unmodifiable(tmp);
}
return channel.getUpdatePlan(FeaturePackUpdatePlan.request(fpl, patchIds, f.isTransitiveDep()));
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayout method initBuiltInOptions.
private void initBuiltInOptions(ProvisioningConfig config, Map<String, String> extraOptions) throws ProvisioningException {
String setValue = extraOptions.get(ProvisioningOption.VERSION_CONVERGENCE.getName());
if (setValue == null && options.containsKey(ProvisioningOption.VERSION_CONVERGENCE.getName())) {
setValue = ProvisioningOption.VERSION_CONVERGENCE.getDefaultValue();
}
if (setValue == null) {
setValue = config.getOption(ProvisioningOption.VERSION_CONVERGENCE.getName());
if (setValue == null && config.hasOption(ProvisioningOption.VERSION_CONVERGENCE.getName())) {
setValue = ProvisioningOption.VERSION_CONVERGENCE.getDefaultValue();
}
}
failOnConvergence = false;
if (setValue != null) {
if (Constants.FAIL.equals(setValue)) {
failOnConvergence = true;
} else if (!Constants.FIRST_PROCESSED.equals(setValue)) {
throw new ProvisioningException(Errors.pluginOptionIllegalValue(ProvisioningOption.VERSION_CONVERGENCE.getName(), setValue, ProvisioningOption.VERSION_CONVERGENCE.getValueSet()));
}
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayoutFactory method addLocal.
/**
* Adds feature-pack archive to the local provisioning feature-pack cache.
* Optionally, installs the feature-pack archive to the universe repository.
*
* @param featurePack feature-pack archive
* @param installInUniverse whether to install the feature-pack into the universe repository
* @return feature-pack location which was added to the local cache
* @throws ProvisioningException in case of a failure
*/
public synchronized FeaturePackLocation addLocal(Path featurePack, boolean installInUniverse) throws ProvisioningException {
final FPID fpid = FeaturePackDescriber.readSpec(featurePack).getFPID();
put(featurePack, fpid);
if (!installInUniverse) {
return fpid.getLocation();
}
if (universeInstallers == null) {
universeInstallers = UniverseFeaturePackInstaller.load();
}
final Universe<?> universe = universeResolver.getUniverse(fpid.getUniverse());
final UniverseFeaturePackInstaller fpInstaller = universeInstallers.get(universe.getFactoryId());
if (fpInstaller == null) {
throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), universeInstallers.keySet()));
}
fpInstaller.install(universe, fpid, featurePack);
return fpid.getLocation();
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayoutFactory method put.
private Path put(Path featurePack, FeaturePackLocation.FPID fpid) throws ProvisioningException {
final FileSystem packFs;
try {
packFs = ZipUtils.newFileSystem(featurePack);
} catch (IOException e) {
throw new ProvisioningException(Errors.openFile(featurePack), e);
}
cachedPacks.put(fpid, packFs);
return getFpDir(packFs);
}
Aggregations