Search in sources :

Example 1 with ExtensionInstallFailedEvent

use of org.xwiki.extension.event.ExtensionInstallFailedEvent in project xwiki-platform by xwiki.

the class RepairXarJob method repairExtension.

/**
 * @param localExtension the local extension to install
 * @param namespace the namespace where to install extension
 * @param dependency indicate of the extension is installed as a dependency of another
 * @param managedDependencies the managed dependencies
 * @throws InstallException failed to repair extension
 */
private void repairExtension(LocalExtension localExtension, String namespace, boolean dependency, Map<String, ExtensionDependency> managedDependencies) throws InstallException {
    this.progressManager.pushLevelProgress(2, this);
    this.observationManager.notify(new ExtensionInstallingEvent(localExtension.getId(), namespace), localExtension);
    InstalledExtension installedExtension = null;
    try {
        this.progressManager.startStep(this);
        Collection<? extends ExtensionDependency> dependencies = localExtension.getDependencies();
        if (!dependencies.isEmpty()) {
            this.progressManager.pushLevelProgress(dependencies.size(), dependencies);
            try {
                for (ExtensionDependency extensionDependency : dependencies) {
                    this.progressManager.startStep(dependencies);
                    // Replace with managed dependency if any
                    ExtensionDependency resolvedDependency = ExtensionUtils.getDependency(extensionDependency, managedDependencies, localExtension);
                    repairDependency(resolvedDependency, namespace, ExtensionUtils.append(managedDependencies, localExtension));
                    this.progressManager.endStep(dependencies);
                }
            } finally {
                this.progressManager.popLevelProgress(dependencies);
            }
        }
        this.progressManager.endStep(this);
        this.progressManager.startStep(this);
        installedExtension = this.installedRepository.installExtension(localExtension, namespace, dependency);
    } finally {
        if (installedExtension != null) {
            this.observationManager.notify(new ExtensionInstalledEvent(installedExtension.getId(), namespace), installedExtension);
        } else {
            this.observationManager.notify(new ExtensionInstallFailedEvent(localExtension.getId(), namespace), localExtension);
        }
        this.progressManager.popLevelProgress(this);
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionInstallingEvent(org.xwiki.extension.event.ExtensionInstallingEvent) ExtensionInstallFailedEvent(org.xwiki.extension.event.ExtensionInstallFailedEvent) ExtensionDependency(org.xwiki.extension.ExtensionDependency) ExtensionInstalledEvent(org.xwiki.extension.event.ExtensionInstalledEvent)

Aggregations

ExtensionDependency (org.xwiki.extension.ExtensionDependency)1 InstalledExtension (org.xwiki.extension.InstalledExtension)1 ExtensionInstallFailedEvent (org.xwiki.extension.event.ExtensionInstallFailedEvent)1 ExtensionInstalledEvent (org.xwiki.extension.event.ExtensionInstalledEvent)1 ExtensionInstallingEvent (org.xwiki.extension.event.ExtensionInstallingEvent)1