Search in sources :

Example 31 with ProvisioningDescriptionException

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

the class LayoutUtils method getConfigXml.

public static Path getConfigXml(Path fpDir, ConfigId configId, boolean existing) throws ProvisioningDescriptionException {
    final String model = configId.getModel();
    final String name = configId.getName();
    final Path p;
    if (name == null) {
        if (model == null) {
            throw new ProvisioningDescriptionException("Anonymous configs are included in feature-pack.xml");
        }
        p = fpDir.resolve(Constants.CONFIGS).resolve(model).resolve(Constants.MODEL_XML);
    } else if (model == null) {
        p = fpDir.resolve(Constants.CONFIGS).resolve(name).resolve(Constants.CONFIG_XML);
    } else {
        p = fpDir.resolve(Constants.CONFIGS).resolve(model).resolve(name).resolve(Constants.CONFIG_XML);
    }
    if (existing && !Files.exists(p)) {
        throw new ProvisioningDescriptionException("Failed to locate XML file describing configuration " + configId + " at " + p);
    }
    return p;
}
Also used : Path(java.nio.file.Path) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 32 with ProvisioningDescriptionException

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

the class ProvisioningXmlParser30 method readUniverse.

private static void readUniverse(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> fpBuilder) throws XMLStreamException {
    String name = null;
    String factory = null;
    String 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 FACTORY:
                factory = reader.getAttributeValue(i);
                break;
            case NAME:
                name = reader.getAttributeValue(i);
                break;
            case LOCATION:
                location = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    ParsingUtils.parseNoContent(reader);
    try {
        fpBuilder.addUniverse(name, factory, location);
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException("Failed to parse universe declaration", e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 33 with ProvisioningDescriptionException

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

the class FeatureGroupXml method readExclude.

private static void readExclude(XMLExtendedStreamReader reader, String dependency, FeatureGroupBuilderSupport<?> depBuilder) throws XMLStreamException {
    String spec = null;
    String featureIdStr = null;
    String parentRef = null;
    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:
                featureIdStr = reader.getAttributeValue(i);
                break;
            case SPEC:
                spec = reader.getAttributeValue(i);
                break;
            case PARENT_REF:
                parentRef = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (spec != null) {
        if (featureIdStr != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.FEATURE_ID, reader);
        }
        if (parentRef != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.PARENT_REF, reader);
        }
        try {
            depBuilder.excludeSpec(dependency, spec);
        } catch (ProvisioningDescriptionException e) {
            throw new XMLStreamException("Failed to parse config", e);
        }
    } else if (featureIdStr != null) {
        try {
            depBuilder.excludeFeature(dependency, parseFeatureId(featureIdStr), parentRef);
        } catch (ProvisioningDescriptionException e) {
            throw new XMLStreamException("Failed to parse config", e);
        }
    } else {
        throw new XMLStreamException("Either " + Attribute.SPEC + " or " + Attribute.FEATURE_ID + " has to be present", reader.getLocation());
    }
    ParsingUtils.parseNoContent(reader);
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 34 with ProvisioningDescriptionException

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

the class FeatureGroupXml method readFeatureConfig.

public static void readFeatureConfig(XMLExtendedStreamReader reader, FeatureConfig config) throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case SPEC:
                try {
                    config.setSpecName(reader.getAttributeValue(i));
                } catch (ProvisioningDescriptionException e) {
                    throw new XMLStreamException("Failed to parse config", e);
                }
                break;
            case PARENT_REF:
                config.setParentRef(reader.getAttributeValue(i));
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (config.getSpecId() == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.SPEC));
    }
    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 DEPENDS:
                        readFeatureDependency(reader, config);
                        break;
                    case PARAM:
                        readParameter(reader, config);
                        break;
                    case FEATURE:
                        final FeatureConfig child = new FeatureConfig();
                        readFeatureConfig(reader, child);
                        config.addFeature(child);
                        break;
                    case FEATURE_GROUP:
                        config.addFeatureGroup(readFeatureGroupDependency(null, reader));
                        break;
                    case ORIGIN:
                        readOrigin(reader, config);
                        break;
                    case RESET_PARAM:
                        config.resetParam(readParamAttr(reader));
                        break;
                    case UNSET_PARAM:
                        config.unsetParam(readParamAttr(reader));
                        break;
                    default:
                        throw ParsingUtils.unexpectedContent(reader);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 35 with ProvisioningDescriptionException

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

the class FeatureGroupXml method readInclude.

private static void readInclude(XMLExtendedStreamReader reader, String origin, FeatureGroupBuilderSupport<?> depBuilder) throws XMLStreamException {
    String spec = null;
    String featureIdStr = null;
    String parentRef = null;
    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:
                featureIdStr = reader.getAttributeValue(i);
                break;
            case SPEC:
                spec = reader.getAttributeValue(i);
                break;
            case PARENT_REF:
                parentRef = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (spec != null) {
        if (featureIdStr != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.FEATURE_ID, reader);
        }
        if (parentRef != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.PARENT_REF, reader);
        }
        try {
            depBuilder.includeSpec(origin, spec);
        } catch (ProvisioningDescriptionException e) {
            throw new XMLStreamException("Failed to parse config", e);
        }
        ParsingUtils.parseNoContent(reader);
        return;
    }
    if (featureIdStr == null) {
        throw new XMLStreamException("Either " + Attribute.SPEC + " or " + Attribute.FEATURE_ID + " has to be present", reader.getLocation());
    }
    final FeatureId featureId = parseFeatureId(featureIdStr);
    final FeatureConfig fc = new FeatureConfig();
    fc.setOrigin(origin);
    fc.setParentRef(parentRef);
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                try {
                    depBuilder.includeFeature(featureId, fc);
                } catch (ProvisioningDescriptionException e) {
                    throw new XMLStreamException("Failed to parse config", e);
                }
                return;
            case XMLStreamConstants.START_ELEMENT:
                final Element element = Element.of(reader.getName().getLocalPart());
                switch(element) {
                    case DEPENDS:
                        readFeatureDependency(reader, fc);
                        break;
                    case PARAM:
                        readParameter(reader, fc);
                        break;
                    case FEATURE:
                        final FeatureConfig nested = new FeatureConfig();
                        readFeatureConfig(reader, nested);
                        fc.addFeature(nested);
                        break;
                    case RESET_PARAM:
                        fc.resetParam(readParamAttr(reader));
                        break;
                    case UNSET_PARAM:
                        fc.unsetParam(readParamAttr(reader));
                        break;
                    default:
                        throw ParsingUtils.unexpectedContent(reader);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) XMLStreamException(javax.xml.stream.XMLStreamException) FeatureConfig(org.jboss.galleon.config.FeatureConfig) 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