use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class SpecOnlyConfigArranger method orderCapabilityProviders.
private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException {
for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) {
final List<String> resolvedCaps = capResolver.resolve(capSpec, feature);
if (resolvedCaps.isEmpty()) {
continue;
}
for (String resolvedCap : resolvedCaps) {
final CapabilityProviders providers;
try {
providers = getProviders(resolvedCap, false);
} catch (ProvisioningException e) {
throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap));
}
final List<CircularRefInfo> circles = orderProviders(providers);
if (circularRefs == null) {
circularRefs = circles;
} else {
if (circularRefs.size() == 1) {
final CircularRefInfo first = circularRefs.get(0);
circularRefs = new ArrayList<>(1 + circles.size());
circularRefs.add(first);
}
circularRefs.addAll(circles);
}
}
}
return circularRefs;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackBuilder method build.
void build() throws ProvisioningException {
final FeaturePackLocation fps = fpBuilder.getFPID().getLocation();
if (fps == null) {
throw new ProvisioningDescriptionException("Feature-pack location has not been set");
}
if (fps.getProducerName() == null) {
throw new ProvisioningDescriptionException("Feature-pack producer has not been set");
}
/*
if(fps.getChannelName() == null) {
throw new ProvisioningDescriptionException("Feature-pack channel has not been set");
}
*/
if (fps.getBuild() == null) {
throw new ProvisioningDescriptionException("Feature-pack build number has not been set");
}
final Path fpWorkDir = LayoutUtils.getFeaturePackDir(creator.getWorkDir(), fps.getFPID(), false);
final FeaturePackSpec fpSpec;
try {
ensureDir(fpWorkDir);
for (PackageBuilder pkg : pkgs) {
final PackageSpec pkgDescr = pkg.build(fpWorkDir);
if (pkg.isDefault()) {
fpBuilder.addDefaultPackage(pkgDescr.getName());
}
}
if (!specs.isEmpty()) {
final Path featuresDir = fpWorkDir.resolve(Constants.FEATURES);
final FeatureSpecXmlWriter specWriter = FeatureSpecXmlWriter.getInstance();
for (FeatureSpec spec : specs.values()) {
final Path featureDir = featuresDir.resolve(spec.getName());
ensureDir(featureDir);
specWriter.write(spec, featureDir.resolve(Constants.SPEC_XML));
}
}
if (!featureGroups.isEmpty()) {
final Path fgsDir = fpWorkDir.resolve(Constants.FEATURE_GROUPS);
ensureDir(fgsDir);
final FeatureGroupXmlWriter fgWriter = FeatureGroupXmlWriter.getInstance();
for (FeatureGroup fg : featureGroups.values()) {
fgWriter.write(fg, fgsDir.resolve(fg.getName() + ".xml"));
}
}
if (!classes.isEmpty()) {
createPluginJar(classes, services, fpWorkDir.resolve(Constants.PLUGINS).resolve(pluginFileName));
}
if (!plugins.isEmpty()) {
final Path pluginsDir = fpWorkDir.resolve(Constants.PLUGINS);
ensureDir(pluginsDir);
for (Path plugin : plugins) {
Files.copy(plugin, pluginsDir.resolve(plugin.getFileName()));
}
}
if (!layers.isEmpty()) {
for (Map.Entry<ConfigId, ConfigLayerSpec> entry : layers.entrySet()) {
final ConfigId id = entry.getKey();
final Path xml = LayoutUtils.getLayerSpecXml(fpWorkDir, id.getModel(), id.getName(), false);
if (Files.exists(xml)) {
throw new ProvisioningException("Failed to create feature-pack: " + xml + " already exists");
}
ConfigLayerXmlWriter.getInstance().write(entry.getValue(), xml);
}
}
if (!configs.isEmpty()) {
for (ConfigModel config : configs.values()) {
final Path modelXml = LayoutUtils.getConfigXml(fpWorkDir, config.getId(), false);
if (Files.exists(modelXml)) {
throw new ProvisioningException("Failed to create feature-pack: " + modelXml + " already exists");
}
ConfigXmlWriter.getInstance().write(config, modelXml);
}
}
fpSpec = fpBuilder.build();
final FeaturePackXmlWriter writer = FeaturePackXmlWriter.getInstance();
writer.write(fpSpec, fpWorkDir.resolve(Constants.FEATURE_PACK_XML));
if (tasks != null && !tasks.isEmpty()) {
tasks.execute(FsTaskContext.builder().setTargetRoot(fpWorkDir.resolve(Constants.RESOURCES)).build());
}
creator.install(fps.getFPID(), fpWorkDir);
} catch (ProvisioningDescriptionException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException(e);
} finally {
IoUtils.recursiveDelete(fpWorkDir);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackCreator method install.
void install(FeaturePackLocation.FPID fpid, Path fpContentDir) throws ProvisioningException {
Universe<?> universe = null;
UniverseFeaturePackInstaller ufpInstaller = null;
if (universeResolution) {
universe = universeResolver.getUniverse(fpid.getLocation().getUniverse());
ufpInstaller = ufpInstallers.get(universe.getFactoryId());
if (ufpInstaller == null) {
throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), ufpInstallers.keySet()));
}
}
final Path fpZip = getBuildDir().resolve(LayoutUtils.ensureValidFileName(fpid.toString()));
try {
ZipUtils.zip(fpContentDir, fpZip);
} catch (IOException e) {
throw new ProvisioningException("Failed to create feature-pack archive", e);
}
if (ufpInstaller != null) {
ufpInstaller.install(universe, fpid, fpZip);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackRuntimeBuilder method getFeatureSpec.
public ResolvedFeatureSpec getFeatureSpec(String name) throws ProvisioningException {
if (featureSpecs != null) {
final ResolvedFeatureSpec resolvedSpec = featureSpecs.get(name);
if (resolvedSpec != null) {
return resolvedSpec;
}
}
final Path specXml = dir.resolve(Constants.FEATURES).resolve(name).resolve(Constants.SPEC_XML);
if (!Files.exists(specXml)) {
return null;
}
try (BufferedReader reader = Files.newBufferedReader(specXml)) {
final FeatureSpec xmlSpec = FeatureSpecXmlParser.getInstance().parse(reader);
if (!xmlSpec.getName().equals(name)) {
throw new ProvisioningDescriptionException("Feature-pack " + getFPID() + " feature spec " + xmlSpec.getName() + " does not match the requested feature spec name " + name);
}
final ResolvedFeatureSpec resolvedSpec = new ResolvedFeatureSpec(new ResolvedSpecId(producer, xmlSpec.getName()), featureParamTypeProvider, xmlSpec);
if (featureSpecs == null) {
featureSpecs = new HashMap<>();
}
featureSpecs.put(name, resolvedSpec);
return resolvedSpec;
} catch (Exception e) {
throw new ProvisioningDescriptionException(Errors.parseXml(specXml), e);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackRuntimeBuilder method getConfig.
ConfigModel getConfig(ConfigId configId) throws ProvisioningException {
if (configs != null) {
final ConfigModel config = configs.get(configId);
if (config != null) {
return config;
}
}
final Path p = LayoutUtils.getConfigXml(dir, configId, false);
if (!Files.exists(p)) {
return null;
}
try (BufferedReader reader = Files.newBufferedReader(p)) {
final ConfigModel config = ConfigXmlParser.getInstance().parse(reader);
if (configs == null) {
configs = new HashMap<>();
}
configs.put(config.getId(), config);
return config;
} catch (Exception e) {
throw new ProvisioningException(Errors.parseXml(p), e);
}
}
Aggregations