use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class ProvisionedStateXmlParser30 method parseSource.
private static FeaturePackLocation parseSource(XMLExtendedStreamReader reader) throws XMLStreamException {
final int count = reader.getAttributeCount();
FeaturePackLocation fps = null;
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
switch(attribute) {
case LOCATION:
try {
fps = FeaturePackLocation.fromString(reader.getAttributeValue(i));
} catch (IllegalArgumentException e) {
throw new XMLStreamException("Failed to parse feature-pack location", e);
}
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (fps == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
}
return fps;
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class ProvisioningXmlParser30 method readPatch.
private static FPID readPatch(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> depsBuilder) throws XMLStreamException {
FeaturePackLocation fpl = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case ID:
fpl = parseFpl(reader, i);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (fpl == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.ID));
}
ParsingUtils.parseNoContent(reader);
fpl = resolveUniverse(depsBuilder, fpl);
return fpl.getFPID();
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class FeaturePackXmlParser20 method readFpl.
private FeaturePackLocation readFpl(XMLExtendedStreamReader reader) throws XMLStreamException {
FeaturePackLocation 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 LOCATION:
try {
location = FeaturePackLocation.fromString(reader.getAttributeValue(i));
} catch (IllegalArgumentException e) {
throw new XMLStreamException(ParsingUtils.error("Failed to parse feature-pack location", reader.getLocation()), e);
}
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (location == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
}
return location;
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class FeaturePackXmlParser20 method parsePatchFor.
private void parsePatchFor(final XMLExtendedStreamReader reader, FeaturePackSpec.Builder builder) throws XMLStreamException {
final int count = reader.getAttributeCount();
FPID patchFor = null;
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case FOR:
final FeaturePackLocation location;
try {
location = FeaturePackLocation.fromString(reader.getAttributeValue(i));
} catch (IllegalArgumentException e) {
throw new XMLStreamException("Failed to parse patch for FPID '" + reader.getAttributeValue(i) + "'", e);
}
patchFor = ProvisioningXmlParser30.resolveUniverse(builder, location).getFPID();
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (patchFor == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.FOR));
}
ParsingUtils.parseNoContent(reader);
if (patchFor.getBuild() == null) {
throw new XMLStreamException("Build number is missing for the version the patch is applied to: " + patchFor);
}
builder.setPatchFor(patchFor);
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class FeaturePackDepsConfigBuilder method addFeaturePackDep.
@SuppressWarnings("unchecked")
public B addFeaturePackDep(int index, FeaturePackConfig dependency) throws ProvisioningDescriptionException {
if (index >= fpDeps.size()) {
addFeaturePackDep(dependency);
return (B) this;
}
FeaturePackLocation fpl = dependency.getLocation();
final UniverseSpec resolvedUniverse = getConfiguredUniverse(fpl);
if (resolvedUniverse != null) {
fpl = fpl.replaceUniverse(resolvedUniverse);
dependency = FeaturePackConfig.builder(fpl).init(dependency).build();
}
if (fpDeps.containsKey(fpl.getProducer())) {
throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(fpl.getProducer()));
}
// reconstruct the linkedMap.
Map<ProducerSpec, FeaturePackConfig> tmp = Collections.emptyMap();
int i = 0;
for (Entry<ProducerSpec, FeaturePackConfig> entry : fpDeps.entrySet()) {
if (i == index) {
tmp = CollectionUtils.putLinked(tmp, fpl.getProducer(), dependency);
}
tmp = CollectionUtils.putLinked(tmp, entry.getKey(), entry.getValue());
i += 1;
}
fpDeps = tmp;
return (B) this;
}
Aggregations