Search in sources :

Example 1 with UnsupportedNamespaceException

use of org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException 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 UnsupportedNamespaceException

use of org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException in project xwiki-platform by xwiki.

the class DiffXarJob method diff.

private void diff(InstalledExtension installedExtension, String namespace, Set<LocalDocumentReference> alreadydone) {
    Collection<ExtensionId> excludedExtensions = getRequest().getExcludedExtensions();
    if (XarExtensionHandler.TYPE.equals(installedExtension.getType()) && (excludedExtensions == null || !excludedExtensions.contains(installedExtension.getId()))) {
        if (getRequest().isVerbose()) {
            this.logger.info("Computing differences for [{}] on namespace [{}]", installedExtension.getId(), namespace);
        }
        try {
            WikiReference wikiReference = new WikiReference(XarHandlerUtils.getWikiFromNamespace(namespace));
            diff(new XarFile(new File(installedExtension.getFile().getAbsolutePath())), wikiReference, installedExtension.getId(), alreadydone);
        } catch (UnsupportedNamespaceException e) {
            this.logger.error("Failed to extract the wiki id from the namespace [{}].", namespace, e);
        } catch (IOException e) {
            this.logger.error("Failed to read the XAR file of the extension [{}].", installedExtension.getId(), e);
        } catch (XarException e) {
            this.logger.error("Failed to parse the XAR file of the extension [{}].", installedExtension.getId(), e);
        }
    }
}
Also used : UnsupportedNamespaceException(org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException) XarFile(org.xwiki.xar.XarFile) XarException(org.xwiki.xar.XarException) ExtensionId(org.xwiki.extension.ExtensionId) IOException(java.io.IOException) WikiReference(org.xwiki.model.reference.WikiReference) XarFile(org.xwiki.xar.XarFile) File(java.io.File)

Aggregations

UnsupportedNamespaceException (org.xwiki.extension.xar.internal.handler.UnsupportedNamespaceException)2 File (java.io.File)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 ExtensionId (org.xwiki.extension.ExtensionId)1 InstalledExtension (org.xwiki.extension.InstalledExtension)1 ExtensionEvent (org.xwiki.extension.event.ExtensionEvent)1 ExtensionUninstalledEvent (org.xwiki.extension.event.ExtensionUninstalledEvent)1 WikiReference (org.xwiki.model.reference.WikiReference)1 XarException (org.xwiki.xar.XarException)1 XarFile (org.xwiki.xar.XarFile)1