use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class FeatureGroupXml method readOriginIncludeExclude.
private static void readOriginIncludeExclude(XMLExtendedStreamReader reader, FeatureGroupBuilderSupport<?> builder) throws XMLStreamException {
String origin = 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:
origin = reader.getAttributeValue(i);
break;
default:
throw ParsingUtils.unexpectedAttribute(reader, i);
}
}
if (origin == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
}
while (reader.hasNext()) {
switch(reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT:
return;
case XMLStreamConstants.START_ELEMENT:
final Element element = Element.of(reader.getName().getLocalPart());
switch(element) {
case INCLUDE:
readInclude(reader, origin, builder);
break;
case EXCLUDE:
readExclude(reader, origin, builder);
break;
case FEATURE_GROUP:
builder.addFeatureGroup(readFeatureGroupDependency(origin, reader));
break;
case FEATURE:
final FeatureConfig nested = new FeatureConfig();
nested.setOrigin(origin);
readFeatureConfig(reader, nested);
builder.addFeature(nested);
break;
case PACKAGES:
PackageDepsSpecXmlParser.parsePackageDeps(Element.PACKAGES, reader, builder);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
throw ParsingUtils.endOfDocument(reader.getLocation());
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class FeatureGroupXml method readFeatureGroupSpec.
public static void readFeatureGroupSpec(XMLExtendedStreamReader reader, FeatureGroup.Builder groupBuilder) throws XMLStreamException {
final int count = reader.getAttributeCount();
String name = null;
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
switch(attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
default:
throw ParsingUtils.unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
}
groupBuilder.setName(name);
while (reader.hasNext()) {
switch(reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT:
{
return;
}
case XMLStreamConstants.START_ELEMENT:
{
final Element element = Element.of(reader.getName().getLocalPart());
switch(element) {
case FEATURE_GROUP:
groupBuilder.addFeatureGroup(readFeatureGroupDependency(null, reader));
break;
case ORIGIN:
readOrigin(reader, groupBuilder);
break;
case FEATURE:
final FeatureConfig nested = new FeatureConfig();
readFeatureConfig(reader, nested);
groupBuilder.addFeature(nested);
break;
case PACKAGES:
PackageDepsSpecXmlParser.parsePackageDeps(Element.PACKAGES, reader, groupBuilder);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
break;
}
default:
{
throw ParsingUtils.unexpectedContent(reader);
}
}
}
throw ParsingUtils.endOfDocument(reader.getLocation());
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureGroupIncludeExclude.
static void addFeatureGroupIncludeExclude(FeatureGroupSupport dep, String ns, final ElementNode depE) {
if (dep.hasExcludedSpecs()) {
for (SpecId spec : dep.getExcludedSpecs()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasExcludedFeatures()) {
for (Map.Entry<FeatureId, String> excluded : dep.getExcludedFeatures().entrySet()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.FEATURE_ID, excluded.getKey().toString());
if (excluded.getValue() != null) {
addAttribute(excludeE, Attribute.PARENT_REF, excluded.getValue());
}
}
}
if (dep.hasIncludedSpecs()) {
for (SpecId spec : dep.getIncludedSpecs()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasIncludedFeatures()) {
for (Map.Entry<FeatureId, FeatureConfig> entry : dep.getIncludedFeatures().entrySet()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.FEATURE_ID, entry.getKey().toString());
final FeatureConfig fc = entry.getValue();
if (fc.getParentRef() != null) {
addAttribute(includeE, Attribute.PARENT_REF, fc.getParentRef());
}
if (fc != null) {
addFeatureConfigBody(includeE, entry.getKey(), fc, ns);
}
}
}
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class OverwriteInitializedChildIdParamWhileNestingTestCase method pmFailure.
@Override
protected void pmFailure(Throwable e) throws ProvisioningDescriptionException {
Assert.assertEquals(Errors.failedToResolveConfigSpec(null, "main"), e.getMessage());
e = e.getCause();
Assert.assertNotNull(e);
Assert.assertEquals(Errors.failedToProcess(FP_GAV, new FeatureConfig("specA").setParam("id", "a1").addFeatureGroup(FeatureGroup.forGroup("groupC"))), e.getLocalizedMessage());
e = e.getCause();
Assert.assertNotNull(e);
Assert.assertEquals(Errors.failedToProcess(FP_GAV, "groupC"), e.getLocalizedMessage());
e = e.getCause();
Assert.assertNotNull(e);
Assert.assertEquals(Errors.failedToProcess(FP_GAV, new FeatureConfig("specC").setParam("id", "c1").setParam("a", "a2")), e.getLocalizedMessage());
e = e.getCause();
Assert.assertNotNull(e);
final Map<String, String> params = new HashMap<>();
params.put("id", "c1");
params.put("a", "a2");
Assert.assertEquals(Errors.failedToInitializeForeignKeyParams(new ResolvedSpecId(FP_GAV.getProducer(), "specC"), ResolvedFeatureId.create(new ResolvedSpecId(FP_GAV.getProducer(), "specA"), "id", "a1"), params), e.getLocalizedMessage());
e = e.getCause();
Assert.assertNotNull(e);
Assert.assertEquals(Errors.idParamForeignKeyInitConflict(new ResolvedSpecId(FP_GAV.getProducer(), "specC"), "a", "a2", "a1"), e.getLocalizedMessage());
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class FeatureDependsOnNonExistingPackageTestCase method pmFailure.
@Override
protected void pmFailure(Throwable e) throws ProvisioningDescriptionException {
Assert.assertEquals(Errors.failedToResolveConfigSpec(null, "main"), e.getLocalizedMessage());
Throwable t = e.getCause();
Assert.assertNotNull(t);
Assert.assertEquals(Errors.failedToProcess(FP_GAV, new FeatureConfig("specA").setParam("name", "a")), t.getLocalizedMessage());
t = e.getCause();
Assert.assertNotNull(t);
Assert.assertEquals(Errors.packageNotFound(FP_GAV, "specA.pkg"), t.getCause().getLocalizedMessage());
}
Aggregations