Search in sources :

Example 91 with FeaturePackLocation

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;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 92 with FeaturePackLocation

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();
}
Also used : FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 93 with FeaturePackLocation

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;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 94 with FeaturePackLocation

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);
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) XMLStreamException(javax.xml.stream.XMLStreamException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 95 with FeaturePackLocation

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;
}
Also used : ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)111 Test (org.junit.Test)46 Path (java.nio.file.Path)23 ProvisioningException (org.jboss.galleon.ProvisioningException)18 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)18 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)16 ArrayList (java.util.ArrayList)13 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)13 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)12 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)9 XMLStreamException (javax.xml.stream.XMLStreamException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)8 IOException (java.io.IOException)7 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)7 HashMap (java.util.HashMap)6 CommandException (org.aesh.command.CommandException)6 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)6 FeatureConfig (org.jboss.galleon.config.FeatureConfig)6 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)6 Set (java.util.Set)5