Search in sources :

Example 1 with ExtensionUninstalledEvent

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

the class InstalledExtensionSynchronizer method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    ExtensionEvent extensionEvent = (ExtensionEvent) event;
    try {
        if (extensionEvent instanceof ExtensionUninstalledEvent) {
            // Update documents index
            getXarRepository().pagesRemoved(extensionEvent.getExtensionId(), extensionEvent.getNamespace());
            // Update extension cache
            getXarRepository().updateCachedXarExtension(extensionEvent.getExtensionId());
        } else {
            if (data != null) {
                for (InstalledExtension installedExtension : (Collection<InstalledExtension>) data) {
                    // Update documents index
                    getXarRepository().pagesRemoved(installedExtension.getId(), extensionEvent.getNamespace());
                    // Update extension cache
                    getXarRepository().updateCachedXarExtension(installedExtension.getId());
                }
            }
            // New extension
            // Update extension cache
            getXarRepository().updateCachedXarExtension(extensionEvent.getExtensionId());
            // Update documents index
            getXarRepository().pagesAdded(extensionEvent.getExtensionId(), extensionEvent.getNamespace());
        }
    } catch (UnsupportedNamespaceException e) {
        logger.error("Failed to extract wiki from namespace [{}]", extensionEvent.getNamespace());
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) UnsupportedNamespaceException(org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException) ExtensionUninstalledEvent(org.xwiki.extension.event.ExtensionUninstalledEvent) Collection(java.util.Collection) ExtensionEvent(org.xwiki.extension.event.ExtensionEvent)

Example 2 with ExtensionUninstalledEvent

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

the class JARTranslationBundleFactoryTest method mockUninstallExtension.

private void mockUninstallExtension(ExtensionId extensionId, String namespace) throws ComponentLookupException {
    DefaultInstalledExtension installedExtension = mockInstalledExtension(extensionId, namespace);
    getObservationManager().notify(new ExtensionUninstalledEvent(extensionId, namespace), installedExtension);
}
Also used : ExtensionUninstalledEvent(org.xwiki.extension.event.ExtensionUninstalledEvent) DefaultInstalledExtension(org.xwiki.extension.repository.internal.installed.DefaultInstalledExtension)

Example 3 with ExtensionUninstalledEvent

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

the class JARTranslationBundleFactoryListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    ExtensionEvent extensionEvent = (ExtensionEvent) event;
    InstalledExtension extension = (InstalledExtension) source;
    if (extension.getType().equals(EXTENSION_TYPE)) {
        if (event instanceof ExtensionInstalledEvent) {
            extensionAdded(extension, extensionEvent.getNamespace());
        } else if (event instanceof ExtensionUninstalledEvent) {
            extensionDeleted(extension, extensionEvent.getNamespace());
        } else {
            extensionUpgraded(extension, (Collection<InstalledExtension>) data, extensionEvent.getNamespace());
        }
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionUninstalledEvent(org.xwiki.extension.event.ExtensionUninstalledEvent) Collection(java.util.Collection) ExtensionEvent(org.xwiki.extension.event.ExtensionEvent) ExtensionInstalledEvent(org.xwiki.extension.event.ExtensionInstalledEvent)

Aggregations

ExtensionUninstalledEvent (org.xwiki.extension.event.ExtensionUninstalledEvent)3 Collection (java.util.Collection)2 InstalledExtension (org.xwiki.extension.InstalledExtension)2 ExtensionEvent (org.xwiki.extension.event.ExtensionEvent)2 ExtensionInstalledEvent (org.xwiki.extension.event.ExtensionInstalledEvent)1 DefaultInstalledExtension (org.xwiki.extension.repository.internal.installed.DefaultInstalledExtension)1 UnsupportedNamespaceException (org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException)1