Search in sources :

Example 31 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method popLayer.

private FeatureGroupSupport popLayer(ConfigModelStack layerStack) throws ProvisioningException {
    final FeatureGroupSupport fg = layerStack.peekAtGroup();
    if (!(fg instanceof ConfigLayerSpec)) {
        throw new ProvisioningException("Expected config layer but got " + fg);
    }
    final ConfigLayerSpec layer = (ConfigLayerSpec) fg;
    if (layer.hasLayerDeps()) {
        for (ConfigLayerDependency dep : layer.getLayerDeps()) {
            layerStack.addLayerDep(dep);
        }
    }
    layerStack.popGroup();
    return fg;
}
Also used : FeatureGroupSupport(org.jboss.galleon.config.FeatureGroupSupport) ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigLayerSpec(org.jboss.galleon.spec.ConfigLayerSpec) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency)

Example 32 with ProvisioningException

use of org.jboss.galleon.ProvisioningException 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);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 33 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class CapabilityResolver method resolve.

List<String> resolve(CapabilitySpec capSpec, ResolvedFeature feature) throws ProvisioningException {
    if (capSpec.isStatic()) {
        return Collections.singletonList(capSpec.toString());
    }
    if (capBuf == null) {
        capBuf = new StringBuilder();
    }
    this.feature = feature;
    this.capSpec = capSpec;
    try {
        if (!capSpec.resolve(this)) {
            return Collections.emptyList();
        }
        if (capList == null) {
            return capBuf.length() == 0 ? Collections.emptyList() : Collections.singletonList(capBuf.toString());
        }
        List<String> resolved = new ArrayList<>(capList.size());
        for (int i = 0; i < capList.size(); ++i) {
            resolved.add(capList.get(i).toString());
        }
        return resolved;
    } catch (ProvisioningException e) {
        throw new ProvisioningException(Errors.failedToResolveCapability(feature, capSpec), e);
    } finally {
        reset();
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ArrayList(java.util.ArrayList)

Example 34 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class DefaultBranchedConfigArranger method orderCapabilityProviders.

private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException {
    for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) {
        final List<String> resolvedCaps = capResolver.resolve(capSpec, feature);
        if (resolvedCaps.isEmpty()) {
            continue;
        }
        for (String resolvedCap : resolvedCaps) {
            final CapabilityProviders providers;
            try {
                providers = getProviders(resolvedCap, false);
            } catch (ProvisioningException e) {
                throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap));
            }
            circularRefs = CollectionUtils.addAll(circularRefs, orderProviders(providers));
            if (providers.isProvided()) {
                feature.addBranchDep(providers.branches.iterator().next(), false);
            // System.out.println("added branch dep on cap provider " + feature.getId() + " -> " + providers.branches);
            } else {
                providers.addBranchDependee(feature);
            }
        }
    }
    return circularRefs;
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 35 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.

the class DefaultBranchedConfigArranger method orderFeatures.

List<ResolvedFeature> orderFeatures() throws ProvisioningException {
    try {
        doOrder(configStack.rt);
    } catch (ProvisioningException e) {
        throw new ProvisioningException(Errors.failedToBuildConfigSpec(configStack.id.getModel(), configStack.id.getName()), e);
    }
    orderedFeatures = new ArrayList<>(features.size());
    if (getBooleanProp(configStack.props, ConfigModel.MERGE_SAME_DEPS_BRANCHES, false)) {
        this.branchesByDeps = new LinkedHashMap<>(featureBranches.size());
        for (ConfigFeatureBranch branch : featureBranches) {
            orderAndMergeBranchesWithSameDeps(branch);
        }
        for (List<ResolvedFeature> features : branchesByDeps.values()) {
            if (features.size() == 1) {
                final ResolvedFeature feature = features.get(0);
                if (feature.isBatchStart()) {
                    feature.clearBatchStart();
                    feature.clearBatchEnd();
                }
                orderedFeatures.add(feature);
            } else {
                orderedFeatures.addAll(features);
            }
        }
        return orderedFeatures;
    }
    for (ConfigFeatureBranch branch : featureBranches) {
        orderBranches(branch);
    }
    if (!mergeIndependentBranches) {
        return orderedFeatures;
    }
    List<ResolvedFeature> result = new ArrayList<>(features.size());
    if (!independentNonBatchBranch.isEmpty()) {
        result.addAll(independentNonBatchBranch);
    }
    if (!independentBatchBranch.isEmpty()) {
        if (independentBatchBranch.size() == 1) {
            final ResolvedFeature firstFeature = independentBatchBranch.get(0);
            firstFeature.clearBatchStart();
            firstFeature.clearBatchEnd();
        } else {
            independentBatchBranch.get(0).startBatch();
            independentBatchBranch.get(independentBatchBranch.size() - 1).endBatch();
        }
        result.addAll(independentBatchBranch);
    }
    result.addAll(orderedFeatures);
    return result;
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ArrayList(java.util.ArrayList)

Aggregations

ProvisioningException (org.jboss.galleon.ProvisioningException)101 IOException (java.io.IOException)45 Path (java.nio.file.Path)35 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)24 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)15 XMLStreamException (javax.xml.stream.XMLStreamException)13 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)10 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)10 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)9 ProvisioningManager (org.jboss.galleon.ProvisioningManager)9 BufferedReader (java.io.BufferedReader)8 HashMap (java.util.HashMap)8 ConfigId (org.jboss.galleon.config.ConfigId)8 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)7 BufferedWriter (java.io.BufferedWriter)6