use of org.xwiki.extension.UninstallException in project xwiki-platform by xwiki.
the class WikiEventListener method onWikiDeleted.
private void onWikiDeleted(WikiDeletedEvent event) {
String namespace = "wiki:" + event.getWikiId();
Collection<InstalledExtension> installedExtensions = this.installedRepository.getInstalledExtensions(namespace);
for (InstalledExtension installedExtension : installedExtensions) {
if (!installedExtension.isInstalled(null)) {
try {
this.installedRepository.uninstallExtension(installedExtension, namespace);
} catch (UninstallException e) {
this.logger.error("Failed to uninstall extension [{}] from namespace [{}]", installedExtension, namespace, e);
}
}
}
}
use of org.xwiki.extension.UninstallException in project xwiki-platform by xwiki.
the class XarExtensionHandler method uninstall.
@Override
public void uninstall(InstalledExtension installedExtension, String namespace, Request request) throws UninstallException {
try {
initializePagesIndex(request);
initJobPackageConfiguration(request, false);
} catch (Exception e) {
throw new UninstallException("Failed to initialize extension plan index", e);
}
// probably not be in an expected state)
if (!request.isRemote()) {
Job currentJob;
try {
currentJob = this.componentManager.<JobContext>getInstance(JobContext.class).getCurrentJob();
} catch (ComponentLookupException e) {
currentJob = null;
}
if (currentJob == null) {
String wiki;
try {
wiki = XarHandlerUtils.getWikiFromNamespace(namespace);
} catch (UnsupportedNamespaceException e) {
throw new UninstallException("Failed to extract wiki id from namespace", e);
}
PackageConfiguration configuration = createPackageConfiguration(null, request, wiki);
try {
XarInstalledExtension xarLocalExtension = (XarInstalledExtension) this.xarRepository.resolve(installedExtension.getId());
Collection<XarEntry> pages = xarLocalExtension.getXarPackage().getEntries();
this.packager.unimportPages(pages, configuration);
} catch (Exception e) {
// Not supposed to be possible
throw new UninstallException("Failed to get xar extension [" + installedExtension.getId() + "] from xar repository", e);
}
} else {
// The actual delete of pages is done in XarExtensionJobFinishedListener
}
}
}
Aggregations