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);
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
Aggregations