use of org.jboss.galleon.spec.FeatureId in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method resolveExcludedIds.
private Set<ResolvedFeatureId> resolveExcludedIds(Set<ResolvedFeatureId> resolvedIds, Map<FeatureId, String> features) throws ProvisioningException {
for (Map.Entry<FeatureId, String> excluded : features.entrySet()) {
final FeatureId excludedId = excluded.getKey();
final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(excludedId.getSpec().getName());
if (parentFeature != null) {
resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, excluded.getValue(), excludedId.getParams()));
} else {
resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveFeatureId(excludedId.getParams()));
}
}
return resolvedIds;
}
use of org.jboss.galleon.spec.FeatureId in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureGroupIncludeExclude.
static void addFeatureGroupIncludeExclude(FeatureGroupSupport dep, String ns, final ElementNode depE) {
if (dep.hasExcludedSpecs()) {
for (SpecId spec : dep.getExcludedSpecs()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasExcludedFeatures()) {
for (Map.Entry<FeatureId, String> excluded : dep.getExcludedFeatures().entrySet()) {
final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(excludeE, Attribute.FEATURE_ID, excluded.getKey().toString());
if (excluded.getValue() != null) {
addAttribute(excludeE, Attribute.PARENT_REF, excluded.getValue());
}
}
}
if (dep.hasIncludedSpecs()) {
for (SpecId spec : dep.getIncludedSpecs()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.SPEC, spec.toString());
}
}
if (dep.hasIncludedFeatures()) {
for (Map.Entry<FeatureId, FeatureConfig> entry : dep.getIncludedFeatures().entrySet()) {
final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
addAttribute(includeE, Attribute.FEATURE_ID, entry.getKey().toString());
final FeatureConfig fc = entry.getValue();
if (fc.getParentRef() != null) {
addAttribute(includeE, Attribute.PARENT_REF, fc.getParentRef());
}
if (fc != null) {
addFeatureConfigBody(includeE, entry.getKey(), fc, ns);
}
}
}
}
use of org.jboss.galleon.spec.FeatureId in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method resolveIncludedIds.
private Map<ResolvedFeatureId, FeatureConfig> resolveIncludedIds(Map<ResolvedFeatureId, FeatureConfig> includedFeatures, Map<FeatureId, FeatureConfig> features) throws ProvisioningException {
for (Map.Entry<FeatureId, FeatureConfig> included : features.entrySet()) {
final FeatureConfig fc = new FeatureConfig(included.getValue());
final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(fc.getSpecId().getName());
if (parentFeature != null) {
includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, fc.getParentRef(), fc.getParams()), fc);
} else {
includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveFeatureId(fc.getParams()), fc);
}
}
return includedFeatures;
}
use of org.jboss.galleon.spec.FeatureId in project galleon by wildfly.
the class ProvisioningDiffProvider method getFeatureId.
private static FeatureId getFeatureId(final ProvisionedFeature feature) throws ProvisioningDescriptionException, ProvisioningException {
final FeatureId.Builder id = FeatureId.builder(feature.getSpecId().getName());
final ResolvedFeatureId resolvedId = feature.getId();
for (String name : resolvedId.getParams().keySet()) {
id.setParam(name, feature.getConfigParam(name));
}
return id.build();
}
use of org.jboss.galleon.spec.FeatureId 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