Search in sources :

Example 1 with WikiNamespace

use of org.xwiki.model.namespace.WikiNamespace in project xwiki-platform by xwiki.

the class DefaultRecordableEventDescriptorManager method getDescriptorsFromWiki.

private List<RecordableEventDescriptor> getDescriptorsFromWiki(String wikiId) throws ComponentLookupException {
    Namespace namespace = new WikiNamespace(wikiId);
    ComponentManager wikiComponentManager = componentManagerManager.getComponentManager(namespace.serialize(), false);
    if (wikiComponentManager == null) {
        return Collections.emptyList();
    }
    List<RecordableEventDescriptor> descriptors = new ArrayList<>();
    descriptors.addAll(wikiComponentManager.getInstanceList(RecordableEventDescriptor.class));
    descriptors.addAll(wikiComponentManager.getInstanceList(UntypedRecordableEventDescriptor.class));
    return descriptors;
}
Also used : RecordableEventDescriptor(org.xwiki.eventstream.RecordableEventDescriptor) UntypedRecordableEventDescriptor(org.xwiki.eventstream.UntypedRecordableEventDescriptor) UntypedRecordableEventDescriptor(org.xwiki.eventstream.UntypedRecordableEventDescriptor) WikiNamespace(org.xwiki.model.namespace.WikiNamespace) ComponentManager(org.xwiki.component.manager.ComponentManager) ArrayList(java.util.ArrayList) WikiNamespace(org.xwiki.model.namespace.WikiNamespace) Namespace(org.xwiki.component.namespace.Namespace)

Example 2 with WikiNamespace

use of org.xwiki.model.namespace.WikiNamespace in project xwiki-platform by xwiki.

the class WikiDeletedListener method onEvent.

@Override
public void onEvent(Event event, Object o, Object context) {
    String wiki = ((WikiDeletedEvent) event).getWikiId();
    ComponentManager componentManager = this.componentManagerManager.getComponentManager(new WikiNamespace(wiki).serialize(), false);
    if (componentManager instanceof Disposable) {
        try {
            ((Disposable) componentManager).dispose();
        } catch (ComponentLifecycleException e) {
            this.logger.error(String.format("Failed to dispose component manager for wiki [%s]", wiki), e);
        }
    }
}
Also used : Disposable(org.xwiki.component.phase.Disposable) WikiNamespace(org.xwiki.model.namespace.WikiNamespace) ComponentManager(org.xwiki.component.manager.ComponentManager) ComponentLifecycleException(org.xwiki.component.manager.ComponentLifecycleException) WikiDeletedEvent(org.xwiki.bridge.event.WikiDeletedEvent)

Aggregations

ComponentManager (org.xwiki.component.manager.ComponentManager)2 WikiNamespace (org.xwiki.model.namespace.WikiNamespace)2 ArrayList (java.util.ArrayList)1 WikiDeletedEvent (org.xwiki.bridge.event.WikiDeletedEvent)1 ComponentLifecycleException (org.xwiki.component.manager.ComponentLifecycleException)1 Namespace (org.xwiki.component.namespace.Namespace)1 Disposable (org.xwiki.component.phase.Disposable)1 RecordableEventDescriptor (org.xwiki.eventstream.RecordableEventDescriptor)1 UntypedRecordableEventDescriptor (org.xwiki.eventstream.UntypedRecordableEventDescriptor)1