use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningXmlParser30 method parseConfigModelRef.
private static void parseConfigModelRef(XMLExtendedStreamReader reader, ConfigCustomizationsBuilder<?> fpBuilder, boolean include) throws XMLStreamException {
String name = null;
String model = null;
Boolean namedConfigsOnly = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
case MODEL:
model = reader.getAttributeValue(i);
break;
case NAMED_MODELS_ONLY:
namedConfigsOnly = Boolean.parseBoolean(reader.getAttributeValue(i));
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
try {
if (include) {
if (name == null) {
fpBuilder.includeConfigModel(model);
} else {
fpBuilder.includeDefaultConfig(new ConfigId(model, name));
}
} else if (name == null) {
if (namedConfigsOnly != null) {
fpBuilder.excludeConfigModel(model, namedConfigsOnly);
} else {
fpBuilder.excludeConfigModel(model);
}
} else {
fpBuilder.excludeDefaultConfig(model, name);
}
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException(e);
}
ParsingUtils.parseNoContent(reader);
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningXmlParser30 method doReadFeaturePackDep.
private static void doReadFeaturePackDep(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> builder, boolean transitive) throws XMLStreamException {
FeaturePackLocation location = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case LOCATION:
location = parseFpl(reader, i);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (location == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
}
location = resolveUniverse(builder, location);
String origin = null;
final FeaturePackConfig.Builder depBuilder = transitive ? FeaturePackConfig.transitiveBuilder(location) : FeaturePackConfig.builder(location);
while (reader.hasNext()) {
switch(reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT:
{
try {
builder.addFeaturePackDep(origin, depBuilder.build());
} catch (ProvisioningDescriptionException e) {
final StringBuilder buf = new StringBuilder();
buf.append("Failed to add ").append(location).append(" as a ");
if (transitive) {
buf.append("transitive ");
}
buf.append(" feature-pack dependency");
throw new XMLStreamException(ParsingUtils.error(buf.toString(), reader.getLocation()), e);
}
return;
}
case XMLStreamConstants.START_ELEMENT:
{
final Element element = Element.of(reader.getName().getLocalPart());
switch(element) {
case PACKAGES:
try {
FeaturePackPackagesConfigParser10.readPackages(reader, depBuilder);
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException("Failed to parse " + Element.PACKAGES.getLocalName() + ": " + e.getLocalizedMessage(), reader.getLocation(), e);
}
break;
case ORIGIN:
origin = reader.getElementText();
break;
case DEFAULT_CONFIGS:
ProvisioningXmlParser30.parseDefaultConfigs(reader, depBuilder);
break;
case CONFIG:
final ConfigModel.Builder config = ConfigModel.builder();
ConfigXml.readConfig(reader, config);
try {
depBuilder.addConfig(config.build());
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException("Failed to parse config element", reader.getLocation(), e);
}
break;
case PATCHES:
readPatches(reader, depBuilder, builder);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
break;
}
default:
{
throw ParsingUtils.unexpectedContent(reader);
}
}
}
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class FeatureGroupXml method readFeatureGroupDependency.
private static FeatureGroup readFeatureGroupDependency(String origin, XMLExtendedStreamReader reader) throws XMLStreamException {
String name = null;
Boolean inheritFeatures = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
switch(attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
case INHERIT_FEATURES:
inheritFeatures = Boolean.parseBoolean(reader.getAttributeValue(i));
break;
default:
throw ParsingUtils.unexpectedAttribute(reader, i);
}
}
if (name == null && inheritFeatures != null) {
throw new XMLStreamException(Attribute.INHERIT_FEATURES + " attribute can't be used w/o attribute " + Attribute.NAME);
}
final FeatureGroup.Builder depBuilder = FeatureGroup.builder(name).setOrigin(origin);
if (inheritFeatures != null) {
depBuilder.setInheritFeatures(inheritFeatures);
}
readFeatureGroupConfigBody(reader, depBuilder);
try {
return depBuilder.build();
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException("Failed to parse feature group dependency", reader.getLocation(), e);
}
}
use of org.jboss.galleon.ProvisioningDescriptionException 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.ProvisioningDescriptionException 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;
}
Aggregations