Search in sources :

Example 1 with ProvisioningDescriptionException

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

the class LayoutUtils method getFeaturePackDir.

public static Path getFeaturePackDir(Path fpLayoutDir, FPID fpid, boolean existing) throws ProvisioningDescriptionException {
    final FeaturePackLocation fps = fpid.getLocation();
    final UniverseSpec universe = fps.getUniverse();
    Path fpPath = fpLayoutDir.resolve(universe.getFactory());
    if (universe.getLocation() != null) {
        fpPath = fpPath.resolve(ensureValidFileName(universe.getLocation()));
    }
    fpPath = fpPath.resolve(ensureValidFileName(fps.getProducerName()));
    if (fps.getChannelName() != null) {
        fpPath = fpPath.resolve(fps.getChannelName());
    }
    fpPath = fpPath.resolve(ensureValidFileName(fpid.getBuild()));
    if (existing && !Files.exists(fpPath)) {
        throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpPath));
    }
    return fpPath;
}
Also used : Path(java.nio.file.Path) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 2 with ProvisioningDescriptionException

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

the class LayoutUtils method getLayerSpecXml.

public static Path getLayerSpecXml(Path fpDir, String model, String name, boolean existing) throws ProvisioningDescriptionException {
    Path p = fpDir.resolve(Constants.LAYERS);
    if (model != null) {
        p = p.resolve(model);
    }
    p = p.resolve(name).resolve(Constants.LAYER_SPEC_XML);
    if (existing && !Files.exists(p)) {
        throw new ProvisioningDescriptionException("Failed to locate XML file describing configuration layer " + name + " at " + p);
    }
    return p;
}
Also used : Path(java.nio.file.Path) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 3 with ProvisioningDescriptionException

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

the class UnknownDefaultPackageTestCase method testMain.

@Test
public void testMain() throws Exception {
    final FPID fp1Gav = LegacyGalleon1Universe.newFPID("org.pm.test:fp-install", "1", "1.0.0.Beta1");
    try {
        FeaturePackDescription.builder(FeaturePackSpec.builder(fp1Gav).addDefaultPackage("default")).addPackage(PackageSpec.forName("a")).build();
        Assert.fail("Non-existing default package");
    } catch (ProvisioningDescriptionException e) {
        Assert.assertEquals(Errors.unknownPackage(fp1Gav, "default"), e.getMessage());
    }
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException) Test(org.junit.Test)

Example 4 with ProvisioningDescriptionException

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

the class FeaturePackDepsConfigBuilder method addFeaturePackDepResolved.

@SuppressWarnings("unchecked")
private B addFeaturePackDepResolved(String origin, FeaturePackConfig dependency, boolean replaceExistingVersion) throws ProvisioningDescriptionException {
    String existingOrigin = null;
    final ProducerSpec producer = dependency.getLocation().getProducer();
    if (dependency.isTransitive()) {
        if (fpDeps.containsKey(producer)) {
            throw new ProvisioningDescriptionException(producer + " has been already added as a direct dependency");
        }
        if (transitiveDeps.containsKey(producer)) {
            if (!replaceExistingVersion) {
                throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(producer));
            }
            existingOrigin = producerOrigins.get(producer);
        }
        transitiveDeps = CollectionUtils.putLinked(transitiveDeps, producer, dependency);
    } else {
        if (transitiveDeps.containsKey(producer)) {
            throw new ProvisioningDescriptionException(producer + " has been already added as a transitive dependency");
        }
        if (fpDeps.containsKey(producer)) {
            if (!replaceExistingVersion) {
                throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(producer));
            }
            existingOrigin = producerOrigins.get(producer);
        }
        fpDeps = CollectionUtils.putLinked(fpDeps, producer, dependency);
    }
    if (origin != null) {
        if (existingOrigin != null) {
            if (!existingOrigin.equals(origin)) {
                fpDepsByOrigin = CollectionUtils.remove(fpDepsByOrigin, existingOrigin);
                producerOrigins = CollectionUtils.put(producerOrigins, producer, origin);
            }
        } else if (fpDepsByOrigin.containsKey(origin)) {
            throw new ProvisioningDescriptionException(Errors.duplicateDependencyName(origin));
        } else {
            producerOrigins = CollectionUtils.put(producerOrigins, producer, origin);
        }
        fpDepsByOrigin = CollectionUtils.put(fpDepsByOrigin, origin, dependency);
    }
    return (B) this;
}
Also used : ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 5 with ProvisioningDescriptionException

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

the class ProvisioningLayout method doBuild.

private void doBuild(boolean cleanupTransitive, boolean trackProgress) throws ProvisioningException {
    buildTracker = getBuildTracker(trackProgress);
    buildTracker.starting(-1);
    final Map<ProducerSpec, FPID> depBranch = new HashMap<>();
    layout(config, depBranch, FeaturePackLayout.DIRECT_DEP);
    if (!conflicts.isEmpty()) {
        throw new ProvisioningDescriptionException(Errors.fpVersionCheckFailed(conflicts.values()));
    }
    if (transitiveDeps != null) {
        ProvisioningConfig.Builder newConfig = null;
        List<ProducerSpec> notUsedTransitive = Collections.emptyList();
        for (ProducerSpec producer : transitiveDeps) {
            if (featurePacks.containsKey(producer)) {
                continue;
            }
            if (cleanupTransitive && config.hasTransitiveDep(producer)) {
                if (newConfig == null) {
                    newConfig = ProvisioningConfig.builder(config);
                }
                newConfig.removeTransitiveDep(producer.getLocation().getFPID());
                continue;
            }
            notUsedTransitive = CollectionUtils.add(notUsedTransitive, producer);
        }
        if (!notUsedTransitive.isEmpty()) {
            throw new ProvisioningDescriptionException(Errors.transitiveDependencyNotFound(notUsedTransitive.toArray(new ProducerSpec[notUsedTransitive.size()])));
        }
        if (newConfig != null) {
            config = newConfig.build();
        }
        transitiveDeps = null;
    }
    if (resolvedVersions != null) {
        final ProvisioningConfig.Builder builder = ProvisioningConfig.builder().addOptions(config.getOptions()).initUniverses(config).initConfigs(config);
        addFpDeps(builder, config.getFeaturePackDeps());
        if (config.hasTransitiveDeps()) {
            addFpDeps(builder, config.getTransitiveDeps());
        }
        if (!resolvedVersions.isEmpty()) {
            for (FeaturePackLocation fpl : resolvedVersions.values()) {
                final FeaturePackConfig existing = builder.getTransitiveFeaturePackDep(fpl.getProducer());
                if (existing == null) {
                    builder.addTransitiveDep(fpl);
                } else if (!existing.getLocation().hasBuild()) {
                    builder.updateFeaturePackDep(FeaturePackConfig.builder(fpl).init(existing).build());
                }
            }
        }
        config = builder.build();
        resolvedVersions = null;
    }
    // apply patches
    if (!fpPatches.isEmpty()) {
        for (F f : ordered) {
            final List<F> patches = fpPatches.get(f.getFPID());
            if (patches == null) {
                if (f.getSpec().hasPlugins()) {
                    pluginLocations = CollectionUtils.putAll(pluginLocations, f.getSpec().getPlugins());
                }
                final Path fpResources = f.getDir().resolve(Constants.RESOURCES);
                if (Files.exists(fpResources)) {
                    patchDir(getResources(), fpResources);
                }
                final Path fpPlugins = f.getDir().resolve(Constants.PLUGINS);
                if (Files.exists(fpPlugins)) {
                    patchDir(getPluginsDir(), fpPlugins);
                }
                continue;
            }
            final Path fpDir = LayoutUtils.getFeaturePackDir(handle.getPatchedDir(), f.getFPID(), false);
            try {
                Files.createDirectories(fpDir);
                IoUtils.copy(f.getDir(), fpDir);
            } catch (IOException e) {
                throw new ProvisioningException("Failed to patch feature-pack dir for " + f.getFPID(), e);
            }
            f.dir = fpDir;
            for (F patch : patches) {
                final Path patchDir = patch.getDir();
                patchFpDir(fpDir, patchDir, Constants.PACKAGES);
                patchFpDir(fpDir, patchDir, Constants.FEATURES);
                patchFpDir(fpDir, patchDir, Constants.FEATURE_GROUPS);
                patchFpDir(fpDir, patchDir, Constants.CONFIGS);
                patchFpDir(fpDir, patchDir, Constants.LAYERS);
                Path patchContent = patchDir.resolve(Constants.PLUGINS);
                if (Files.exists(patchContent)) {
                    patchDir(fpDir.resolve(Constants.PLUGINS), patchContent);
                    patchDir(getPluginsDir(), patchContent);
                }
                patchContent = patchDir.resolve(Constants.RESOURCES);
                if (Files.exists(patchContent)) {
                    patchDir(fpDir.resolve(Constants.RESOURCES), patchContent);
                    patchDir(getResources(), patchContent);
                }
                if (patch.getSpec().hasPlugins()) {
                    pluginLocations = CollectionUtils.putAll(pluginLocations, patch.getSpec().getPlugins());
                }
            }
        }
    }
    if (!pluginLocations.isEmpty()) {
        handle.addPlugins(pluginLocations.values());
    }
    buildTracker.complete();
}
Also used : Path(java.nio.file.Path) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) IOException(java.io.IOException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)41 XMLStreamException (javax.xml.stream.XMLStreamException)19 Path (java.nio.file.Path)12 IOException (java.io.IOException)9 ProvisioningException (org.jboss.galleon.ProvisioningException)8 BufferedReader (java.io.BufferedReader)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)5 HashMap (java.util.HashMap)4 FeatureGroup (org.jboss.galleon.config.FeatureGroup)4 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 UnsatisfiedPackageDependencyException (org.jboss.galleon.UnsatisfiedPackageDependencyException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)3 Reader (java.io.Reader)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 FeatureConfig (org.jboss.galleon.config.FeatureConfig)2