protected void doExecute()

in src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java [299:345]


        protected void doExecute(final InstallationContext ctx, final JcrPackageManager pkgMgr, final TaskResource resource)
                throws RepositoryException, PackageException, IOException {

            // open package
            try (JcrPackage pkg = pkgMgr.open(pkgId))  {
                if (pkg == null) {
                    String message = MessageFormat.format("Error during installation of {0}: Package {1} missing.", resource, pkgId);
                    logger.error(message);
                    this.setFinishedState(ResourceState.IGNORED, null, message);
                    return;
                }

                // check if package was installed previously by some other means (or even by a previous run of the installer)
                if (pkg.isInstalled()) {
                    String message = MessageFormat.format("Package {0} was installed externally. Marking as installed.", pkgId);
                    logger.info(message);
                    this.setFinishedState(ResourceState.INSTALLED, null, message);
                    return;
                }

                // is dependency checking necessary?
                if (configuration.dependencyHandling() == DependencyHandling.REQUIRED || configuration.dependencyHandling() == DependencyHandling.STRICT) {
                    // check if dependencies are installed/available
                    for (final Dependency d : pkg.getDefinition().getDependencies()) {
                        if (pkgMgr.resolve(d, configuration.dependencyHandling() == DependencyHandling.STRICT ? true : false) == null) {
                            logger.info("Delaying installation of {} due to missing dependency {}.", pkgId, d);
                            return;
                        }
                    }
                }

                // finally, install package
                final ImportOptions opts = new ImportOptions();
                opts.setDependencyHandling(configuration.dependencyHandling());
                if (configuration.shouldCreateSnapshots()) {
                    pkg.install(opts);
                    ctx.log("Content package installed: {}", resource);
                } else {
                    pkg.extract(opts);
                    ctx.log("Content package extracted: {}", resource);
                }

                setFinishedState(ResourceState.INSTALLED);

                // notify retry handler to install dependent packages happens in the onPackageEvent
            }
        }