Search in sources :

Example 1 with UnsatisfiedPackageDependencyException

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

the class FeaturePackRuntimeBuilder method resolvePackage.

boolean resolvePackage(String pkgName, ProvisioningRuntimeBuilder rt, PackageRuntime.Builder parent, int type) throws ProvisioningException {
    PackageRuntime.Builder pkgBuilder = pkgBuilders.get(pkgName);
    if (pkgBuilder == null) {
        final Path pkgDir = LayoutUtils.getPackageDir(dir, pkgName, false);
        if (!Files.exists(pkgDir)) {
            return false;
        }
        final Path pkgXml = pkgDir.resolve(Constants.PACKAGE_XML);
        if (!Files.exists(pkgXml)) {
            throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(pkgXml));
        }
        try (BufferedReader reader = Files.newBufferedReader(pkgXml)) {
            pkgBuilder = PackageRuntime.builder(this, PackageXmlParser.getInstance().parse(reader), pkgDir, ++rt.pkgsTotal);
        } catch (IOException | XMLStreamException e) {
            throw new ProvisioningException(Errors.parseXml(pkgXml), e);
        }
        if (!pkgBuilder.spec.getName().equals(pkgName)) {
            throw new ProvisioningDescriptionException("Feature-pack " + getFPID() + " package spec name " + pkgBuilder.spec.getName() + " does not match the requested package name " + pkgName);
        }
        pkgBuilders = CollectionUtils.put(pkgBuilders, pkgName, pkgBuilder);
    }
    pkgBuilder.referencedAs(type);
    if (parent == null) {
        pkgBuilder.setFlag(PackageRuntime.ROOT);
        if (type == PackageDependencySpec.REQUIRED) {
            pkgBuilder.include();
        }
    } else if (!parent.isFlagOn(PackageRuntime.SCHEDULED)) {
        parent.addPackageDep(pkgBuilder, type, rt.includedPkgDeps);
    }
    if (!rt.addToPkgDepBranch(pkgBuilder)) {
        // to avoid stack overflow processing circular dependencies
        return true;
    }
    if (pkgBuilder.spec.hasPackageDeps()) {
        final FeaturePackRuntimeBuilder currentOrigin = rt.setOrigin(this);
        try {
            rt.processPackageDeps(pkgBuilder.spec, pkgBuilder);
        } catch (UnsatisfiedPackageDependencyException e) {
            throw new UnsatisfiedPackageDependencyException(getFPID(), pkgName, e);
        } catch (ProvisioningException e) {
            throw new ProvisioningException(Errors.resolvePackage(getFPID(), pkgName), e);
        } finally {
            rt.setOrigin(currentOrigin);
        }
    }
    return true;
}
Also used : Path(java.nio.file.Path) XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningException(org.jboss.galleon.ProvisioningException) UnsatisfiedPackageDependencyException(org.jboss.galleon.UnsatisfiedPackageDependencyException) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 UnsatisfiedPackageDependencyException (org.jboss.galleon.UnsatisfiedPackageDependencyException)1