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