use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackInstaller method install.
public void install() {
try (ProvisioningManager manager = ProvisioningManager.builder().addArtifactResolver(LegacyGalleon1RepositoryManager.newInstance(repoHome)).setInstallationHome(installationDir).setRecordState(recordState).build()) {
System.setProperty("org.wildfly.logging.skipLogManagerCheck", "true");
ConfigModel config = null;
if (customConfig != null && Files.exists(customConfig)) {
try (BufferedReader reader = Files.newBufferedReader(customConfig)) {
config = ConfigXmlParser.getInstance().parse(reader);
} catch (XMLStreamException | IOException ex) {
throw new IllegalArgumentException("Couldn't load the customization configuration " + customConfig, ex);
}
}
if (localPath != null) {
fpl = manager.getLayoutFactory().addLocal(localPath, false);
}
FeaturePackConfig.Builder fpConfigBuilder = FeaturePackConfig.builder(fpl).setInheritPackages(inheritPackages).setInheritConfigs(inheritConfigs);
if (includedConfigs != null && !includedConfigs.isEmpty()) {
for (ConfigurationId configId : includedConfigs) {
if (configId.isModelOnly()) {
fpConfigBuilder.includeConfigModel(configId.getId().getModel());
} else {
fpConfigBuilder.includeDefaultConfig(configId.getId());
}
}
}
if (config != null) {
fpConfigBuilder.addConfig(config);
}
if (includedPackages != null && !includedPackages.isEmpty()) {
for (String includedPackage : includedPackages) {
fpConfigBuilder.includePackage(includedPackage);
}
}
if (excludedPackages != null && !excludedPackages.isEmpty()) {
for (String excludedPackage : excludedPackages) {
fpConfigBuilder.excludePackage(excludedPackage);
}
}
manager.install(fpConfigBuilder.build(), pluginOptions);
} catch (ProvisioningException ex) {
throw new IllegalArgumentException("Couldn't install feature-pack " + fpl, ex);
} finally {
System.clearProperty("org.wildfly.logging.skipLogManagerCheck");
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackRuntimeBuilder method getFeatureGroupSpec.
FeatureGroup getFeatureGroupSpec(String name) throws ProvisioningException {
if (fgSpecs != null) {
final FeatureGroup fgSpec = fgSpecs.get(name);
if (fgSpec != null) {
return fgSpec;
}
}
final Path specXml = dir.resolve(Constants.FEATURE_GROUPS).resolve(name + ".xml");
if (!Files.exists(specXml)) {
return null;
}
try (BufferedReader reader = Files.newBufferedReader(specXml)) {
final FeatureGroup fgSpec = FeatureGroupXmlParser.getInstance().parse(reader);
if (!fgSpec.getName().equals(name)) {
throw new ProvisioningDescriptionException("Feature-pack " + getFPID() + " feature group " + fgSpec.getName() + " does not match the requested feature group name " + name);
}
if (fgSpecs == null) {
fgSpecs = new HashMap<>();
}
fgSpecs.put(name, fgSpec);
return fgSpec;
} catch (Exception e) {
throw new ProvisioningException(Errors.parseXml(specXml), e);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackRuntimeBuilder method resolvePackage.
boolean resolvePackage(String pkgName, ProvisioningRuntimeBuilder rt, PackageRuntime.Builder parent, int type) throws ProvisioningException {
PackageRuntime.Builder pkgBuilder = pkgBuilders.get(pkgName);
if (pkgBuilder == null) {
final Path pkgDir = LayoutUtils.getPackageDir(dir, pkgName, false);
if (!Files.exists(pkgDir)) {
return false;
}
final Path pkgXml = pkgDir.resolve(Constants.PACKAGE_XML);
if (!Files.exists(pkgXml)) {
throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(pkgXml));
}
try (BufferedReader reader = Files.newBufferedReader(pkgXml)) {
pkgBuilder = PackageRuntime.builder(this, PackageXmlParser.getInstance().parse(reader), pkgDir, ++rt.pkgsTotal);
} catch (IOException | XMLStreamException e) {
throw new ProvisioningException(Errors.parseXml(pkgXml), e);
}
if (!pkgBuilder.spec.getName().equals(pkgName)) {
throw new ProvisioningDescriptionException("Feature-pack " + getFPID() + " package spec name " + pkgBuilder.spec.getName() + " does not match the requested package name " + pkgName);
}
pkgBuilders = CollectionUtils.put(pkgBuilders, pkgName, pkgBuilder);
}
pkgBuilder.referencedAs(type);
if (parent == null) {
pkgBuilder.setFlag(PackageRuntime.ROOT);
if (type == PackageDependencySpec.REQUIRED) {
pkgBuilder.include();
}
} else if (!parent.isFlagOn(PackageRuntime.SCHEDULED)) {
parent.addPackageDep(pkgBuilder, type, rt.includedPkgDeps);
}
if (!rt.addToPkgDepBranch(pkgBuilder)) {
// to avoid stack overflow processing circular dependencies
return true;
}
if (pkgBuilder.spec.hasPackageDeps()) {
final FeaturePackRuntimeBuilder currentOrigin = rt.setOrigin(this);
try {
rt.processPackageDeps(pkgBuilder.spec, pkgBuilder);
} catch (UnsatisfiedPackageDependencyException e) {
throw new UnsatisfiedPackageDependencyException(getFPID(), pkgName, e);
} catch (ProvisioningException e) {
throw new ProvisioningException(Errors.resolvePackage(getFPID(), pkgName), e);
} finally {
rt.setOrigin(currentOrigin);
}
}
return true;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningRuntime method provision.
public void provision() throws ProvisioningException {
layout.visitPlugins(new FeaturePackPluginVisitor<InstallPlugin>() {
@Override
public void visitPlugin(InstallPlugin plugin) throws ProvisioningException {
plugin.preInstall(ProvisioningRuntime.this);
}
}, InstallPlugin.class);
// copy package content
for (FeaturePackRuntime fp : layout.getOrderedFeaturePacks()) {
messageWriter.verbose("Installing %s", fp.getFPID());
for (PackageRuntime pkg : fp.getPackages()) {
final Path pkgSrcDir = pkg.getContentDir();
if (Files.exists(pkgSrcDir)) {
try {
IoUtils.copy(pkgSrcDir, stagedDir);
} catch (IOException e) {
throw new FeaturePackInstallException(Errors.packageContentCopyFailed(pkg.getName()), e);
}
}
}
}
layout.visitPlugins(new FeaturePackPluginVisitor<InstallPlugin>() {
@Override
public void visitPlugin(InstallPlugin plugin) throws ProvisioningException {
plugin.postInstall(ProvisioningRuntime.this);
}
}, InstallPlugin.class);
if (recordState) {
// save the config
try {
ProvisioningXmlWriter.getInstance().write(config, PathsUtils.getProvisioningXml(stagedDir));
} catch (XMLStreamException | IOException e) {
throw new FeaturePackInstallException(Errors.writeFile(PathsUtils.getProvisioningXml(stagedDir)), e);
}
// save the provisioned state
try {
ProvisionedStateXmlWriter.getInstance().write(this, PathsUtils.getProvisionedStateXml(stagedDir));
} catch (XMLStreamException | IOException e) {
throw new FeaturePackInstallException(Errors.writeFile(PathsUtils.getProvisionedStateXml(stagedDir)), e);
}
}
emptyStagedDir = null;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method includeLayer.
private void includeLayer(ConfigModelStack configStack, ConfigId layerId) throws ProvisioningException {
if (!configStack.addLayer(layerId)) {
return;
}
final ConfigModelStack layerStack = resolveConfigLayer(layerId);
if (layerStack.hasLayerDeps()) {
for (ConfigLayerDependency layerDep : layerStack.getLayerDeps()) {
if (configStack.isLayerExcluded(layerDep.getName())) {
if (layerDep.isOptional()) {
continue;
}
throw new ProvisioningException(Errors.unsatisfiedLayerDependency(layerId.getName(), layerDep.getName()));
}
includeLayer(configStack, new ConfigId(configStack.id.getModel(), layerDep.getName()));
}
}
configStack.includedLayer(layerId);
for (ResolvedFeature feature : layerStack.orderFeatures(false)) {
if (configStack.isFilteredOut(feature.getSpecId(), feature.getId())) {
continue;
}
configStack.includeFeature(feature.id, feature.spec, feature.params, feature.deps, feature.unsetParams, feature.resetParams);
}
}
Aggregations