Search in sources :

Example 1 with ExtensionException

use of org.xwiki.extension.ExtensionException in project xwiki-platform by xwiki.

the class WikiEventListener method copyInstalledExtension.

private void copyInstalledExtension(InstalledExtension installedExtension, String sourceNamespace, String targetNamespace) {
    if (!installedExtension.isInstalled(targetNamespace) && !installedExtension.isInstalled(null)) {
        // Copy dependencies first
        for (ExtensionDependency dependency : installedExtension.getDependencies()) {
            InstalledExtension installedDependency = this.installedRepository.getInstalledExtension(dependency.getId(), sourceNamespace);
            if (installedDependency != null) {
                copyInstalledExtension(installedDependency, sourceNamespace, targetNamespace);
            }
        }
        // Copy extension
        try {
            // Installed extension
            this.extensionHandlerManager.initialize(installedExtension, targetNamespace);
            // Register extension as installed
            this.installedRepository.installExtension(installedExtension, targetNamespace, installedExtension.isDependency(sourceNamespace));
        } catch (ExtensionException e) {
            this.logger.error("Failed to copy extension [{}] from namespace [{}] to namespace [{}]", installedExtension, sourceNamespace, targetNamespace, e);
        }
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionException(org.xwiki.extension.ExtensionException) ExtensionDependency(org.xwiki.extension.ExtensionDependency)

Aggregations

ExtensionDependency (org.xwiki.extension.ExtensionDependency)1 ExtensionException (org.xwiki.extension.ExtensionException)1 InstalledExtension (org.xwiki.extension.InstalledExtension)1