Search in sources :

Example 36 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeatureGroupXml method readFeatureDependency.

private static void readFeatureDependency(XMLExtendedStreamReader reader, FeatureConfig config) throws XMLStreamException {
    String id = null;
    String origin = null;
    boolean include = false;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case FEATURE_ID:
                id = reader.getAttributeValue(i);
                break;
            case ORIGIN:
                origin = reader.getAttributeValue(i);
                break;
            case INCLUDE:
                include = Boolean.parseBoolean(reader.getAttributeValue(i));
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (id == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.FEATURE_ID));
    }
    ParsingUtils.parseNoContent(reader);
    try {
        config.addFeatureDep(FeatureDependencySpec.create(parseFeatureId(id), origin, include));
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException(e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 37 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeatureSpecXmlParser10 method parseCapabilityName.

private CapabilitySpec parseCapabilityName(XMLExtendedStreamReader reader) throws XMLStreamException {
    String name = null;
    boolean optional = false;
    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 OPTIONAL:
                optional = Boolean.parseBoolean(reader.getAttributeValue(i));
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
    }
    ParsingUtils.parseNoContent(reader);
    try {
        return CapabilitySpec.fromString(name, optional);
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException("Failed to parse capability '" + name + "'", reader.getLocation(), e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 38 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeatureSpecXmlParser10 method parseDependency.

private FeatureDependencySpec parseDependency(XMLExtendedStreamReader reader) throws XMLStreamException {
    String dependency = null;
    boolean include = false;
    String featureId = null;
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case DEPENDENCY:
                dependency = reader.getAttributeValue(i);
                break;
            case FEATURE_ID:
                featureId = reader.getAttributeValue(i);
                break;
            case INCLUDE:
                include = Boolean.parseBoolean(reader.getAttributeValue(i));
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (featureId == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.FEATURE_ID));
    }
    ParsingUtils.parseNoContent(reader);
    try {
        return FeatureDependencySpec.create(FeatureId.fromString(featureId), dependency, include);
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException("Failed to parse feature dependency", reader.getLocation(), e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 39 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeatureGroupBuilderSupport method excludeSpec.

@SuppressWarnings("unchecked")
public B excludeSpec(String spec) throws ProvisioningDescriptionException {
    final SpecId specId = SpecId.fromString(spec);
    if (includedSpecs.contains(specId)) {
        throw new ProvisioningDescriptionException(specId + " spec has been inplicitly excluded");
    }
    excludedSpecs = CollectionUtils.add(excludedSpecs, specId);
    return (B) this;
}
Also used : SpecId(org.jboss.galleon.spec.SpecId) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 40 with ProvisioningDescriptionException

use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.

the class FeatureGroupBuilderSupport method includeSpec.

@SuppressWarnings("unchecked")
public B includeSpec(String spec) throws ProvisioningDescriptionException {
    final SpecId specId = SpecId.fromString(spec);
    if (excludedSpecs.contains(specId)) {
        throw new ProvisioningDescriptionException(specId + " spec has been explicitly excluded");
    }
    includedSpecs = CollectionUtils.addLinked(includedSpecs, specId);
    return (B) this;
}
Also used : SpecId(org.jboss.galleon.spec.SpecId) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)41 XMLStreamException (javax.xml.stream.XMLStreamException)19 Path (java.nio.file.Path)12 IOException (java.io.IOException)9 ProvisioningException (org.jboss.galleon.ProvisioningException)8 BufferedReader (java.io.BufferedReader)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)5 HashMap (java.util.HashMap)4 FeatureGroup (org.jboss.galleon.config.FeatureGroup)4 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 UnsatisfiedPackageDependencyException (org.jboss.galleon.UnsatisfiedPackageDependencyException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)3 Reader (java.io.Reader)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 FeatureConfig (org.jboss.galleon.config.FeatureConfig)2