Search in sources :

Example 16 with ProvisioningDescriptionException

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

the class ProvisioningRuntimeBuilder method processConfig.

private void processConfig(ConfigModelStack configStack, ConfigModel config) throws ProvisioningException {
    this.configStack = configStack;
    configStack.overwriteProps(config.getProperties());
    configStack.overwriteConfigDeps(config.getConfigDeps());
    try {
        if (config.hasPackageDeps()) {
            if (currentOrigin == null) {
                throw new ProvisioningDescriptionException(Errors.topConfigsCantDefinePackageDeps(config.getId()));
            }
            processPackageDeps(config, null);
        }
        processConfigItemContainer(config);
        this.configStack = null;
    } catch (ProvisioningException e) {
        throw new ProvisioningException(Errors.failedToResolveConfigSpec(config.getModel(), config.getName()), e);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 17 with ProvisioningDescriptionException

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

the class ResolvedFeature method setParam.

void setParam(String name, Object value, boolean overwrite) throws ProvisioningException {
    if (id != null) {
        final Object idValue = id.params.get(name);
        if (idValue != null) {
            if (!idValue.equals(value)) {
                throw new ProvisioningDescriptionException("ID parameter " + name + "=" + idValue + " can't be reset to " + value);
            }
            return;
        }
    }
    if (!spec.xmlSpec.hasParam(name)) {
        throw new ProvisioningDescriptionException(Errors.unknownFeatureParameter(spec.id, name));
    }
    if (unsetParams.contains(name)) {
        if (!overwrite) {
            return;
        }
        unsetParams = CollectionUtils.remove(unsetParams, name);
        params.put(name, value);
        return;
    }
    if (resetParams.contains(name)) {
        if (!overwrite) {
            return;
        }
        resetParams = CollectionUtils.remove(resetParams, name);
        params.put(name, value);
        return;
    }
    final Object prevValue = params.get(name);
    if (prevValue == null) {
        params.put(name, value);
        return;
    }
    final FeatureParameterType valueType = spec.getTypeForParameter(name);
    if (valueType.isMergeable()) {
        params.put(name, overwrite ? valueType.merge(prevValue, value) : valueType.merge(value, prevValue));
        return;
    }
    if (overwrite) {
        params.put(name, value);
    }
}
Also used : FeatureParameterType(org.jboss.galleon.type.FeatureParameterType) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 18 with ProvisioningDescriptionException

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

the class FeaturePackDescriber method processPackage.

private static PackageSpec processPackage(Path pkgDir, String encoding) throws ProvisioningDescriptionException {
    assertDirectory(pkgDir);
    final Path pkgXml = pkgDir.resolve(Constants.PACKAGE_XML);
    if (!Files.exists(pkgXml)) {
        throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(pkgXml));
    }
    try (Reader in = Files.newBufferedReader(pkgXml, Charset.forName(encoding))) {
        return PackageXmlParser.getInstance().parse(in);
    } catch (IOException e) {
        throw new ProvisioningDescriptionException(Errors.openFile(pkgXml), e);
    } catch (XMLStreamException e) {
        throw new ProvisioningDescriptionException(Errors.parseXml(pkgXml), e);
    }
}
Also used : Path(java.nio.file.Path) XMLStreamException(javax.xml.stream.XMLStreamException) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 19 with ProvisioningDescriptionException

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

the class FeatureSpecXmlParser10 method parseParameter.

private FeatureParameterSpec parseParameter(XMLExtendedStreamReader reader) throws XMLStreamException {
    final FeatureParameterSpec.Builder builder = FeatureParameterSpec.builder();
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case NAME:
                builder.setName(reader.getAttributeValue(i));
                break;
            case FEATURE_ID:
                if (Boolean.parseBoolean(reader.getAttributeValue(i))) {
                    builder.setFeatureId();
                }
                break;
            case DEFAULT:
                builder.setDefaultValue(reader.getAttributeValue(i));
                break;
            case NILLABLE:
                if (Boolean.parseBoolean(reader.getAttributeValue(i))) {
                    builder.setNillable();
                }
                break;
            case TYPE:
                builder.setType(reader.getAttributeValue(i));
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (builder.getName() == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
    }
    ParsingUtils.parseNoContent(reader);
    try {
        return builder.build();
    } catch (ProvisioningDescriptionException e) {
        throw new XMLStreamException("Failed to create feature parameter", reader.getLocation(), e);
    }
}
Also used : FeatureParameterSpec(org.jboss.galleon.spec.FeatureParameterSpec) XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 20 with ProvisioningDescriptionException

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

the class ProvisionedConfigXmlParser30 method readFeature.

private static void readFeature(XMLExtendedStreamReader reader, ResolvedSpecId specId, ProvisionedConfigBuilder config) throws XMLStreamException {
    ResolvedFeatureId id = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case ID:
                try {
                    id = ResolvedFeatureId.fromString(reader.getAttributeValue(i));
                } catch (ProvisioningDescriptionException e) {
                    throw new XMLStreamException(Errors.parseXml(), e);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    final ProvisionedFeatureBuilder featureBuilder = id == null ? ProvisionedFeatureBuilder.builder(specId) : ProvisionedFeatureBuilder.builder(id);
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                {
                    try {
                        config.addFeature(featureBuilder.build());
                    } catch (ProvisioningDescriptionException e) {
                        throw new XMLStreamException("Failed to instantiate provisioned feature", reader.getLocation(), e);
                    }
                    return;
                }
            case XMLStreamConstants.START_ELEMENT:
                {
                    final Element element = Element.of(reader.getName());
                    switch(element) {
                        case PARAM:
                            readParam(reader, featureBuilder);
                            break;
                        default:
                            throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
            default:
                {
                    throw ParsingUtils.unexpectedContent(reader);
                }
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException) ResolvedFeatureId(org.jboss.galleon.runtime.ResolvedFeatureId)

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