Search in sources :

Example 31 with FeatureConfig

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());
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Example 32 with FeatureConfig

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());
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Example 33 with FeatureConfig

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);
            }
        }
    }
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ElementNode(org.jboss.galleon.xml.util.ElementNode) SpecId(org.jboss.galleon.spec.SpecId) Map(java.util.Map)

Example 34 with FeatureConfig

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());
}
Also used : HashMap(java.util.HashMap) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Example 35 with FeatureConfig

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());
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Aggregations

FeatureConfig (org.jboss.galleon.config.FeatureConfig)76 StateDiffPlugin (org.jboss.galleon.plugin.StateDiffPlugin)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)5 Test (org.junit.Test)4 Map (java.util.Map)3 FeatureId (org.jboss.galleon.spec.FeatureId)3 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)2 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)2 HashMap (java.util.HashMap)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigId (org.jboss.galleon.config.ConfigId)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)1 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)1 SpecId (org.jboss.galleon.spec.SpecId)1 BasicStateDiffPlugin (org.jboss.galleon.userchanges.persist.test.BasicStateDiffPlugin)1