Search in sources :

Example 21 with DocumentCreatedEvent

use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.

the class DefaultWikiComponentManagerEventListenerTest method onDocumentCreated.

@Test
public void onDocumentCreated() throws Exception {
    onDocumentCreatedOrUpdated(new DocumentCreatedEvent(DOC_REFERENCE));
    verify(this.wikiComponentManagerEventListenerHelper, times(2)).registerComponentList(Arrays.asList(this.wikiComponent));
    verify(this.wikiComponentManagerEventListenerHelper, times(1)).unregisterComponents(any());
}
Also used : DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) Test(org.junit.Test)

Example 22 with DocumentCreatedEvent

use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.

the class DefaultWikiComponentManagerEventListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    if (source instanceof DocumentModelBridge) {
        // Get the document reference
        DocumentModelBridge document = (DocumentModelBridge) source;
        DocumentReference documentReference = document.getDocumentReference();
        if (event instanceof DocumentCreatedEvent || event instanceof DocumentUpdatedEvent) {
            registerDocumentComponents(document.getDocumentReference());
        } else if (event instanceof DocumentDeletedEvent) {
            // Unregister components from the deleted document, if any
            this.wikiComponentManagerEventListenerHelper.unregisterComponents(documentReference);
        }
    /* If we are at application startup time, we have to instanciate every document or object that we can find
         * in the wiki */
    } else if (event instanceof ApplicationReadyEvent || event instanceof WikiReadyEvent) {
        // These 2 events are created when the database is ready. We register all wiki components.
        registerAllDocumentComponents();
    }
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentModelBridge(org.xwiki.bridge.DocumentModelBridge) ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) WikiReadyEvent(org.xwiki.bridge.event.WikiReadyEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 23 with DocumentCreatedEvent

use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.

the class ColorThemeListenerTest method getEvents.

@Test
public void getEvents() throws Exception {
    List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
    assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Event(org.xwiki.observation.event.Event) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Test(org.junit.Test)

Example 24 with DocumentCreatedEvent

use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.

the class SSXListenerTest method getEvents.

@Test
public void getEvents() throws Exception {
    List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
    assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Event(org.xwiki.observation.event.Event) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Test(org.junit.Test)

Example 25 with DocumentCreatedEvent

use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.

the class SkinListenerTest method getEvents.

@Test
public void getEvents() throws Exception {
    List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
    assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Event(org.xwiki.observation.event.Event) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Test(org.junit.Test)

Aggregations

DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)26 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)18 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)17 Test (org.junit.Test)11 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)10 DocumentReference (org.xwiki.model.reference.DocumentReference)10 XWikiContext (com.xpn.xwiki.XWikiContext)8 Event (org.xwiki.observation.event.Event)5 ArrayList (java.util.ArrayList)4 DocumentCreatingEvent (org.xwiki.bridge.event.DocumentCreatingEvent)4 Date (java.util.Date)3 ActionExecutedEvent (org.xwiki.bridge.event.ActionExecutedEvent)3 XWiki (com.xpn.xwiki.XWiki)2 XWikiException (com.xpn.xwiki.XWikiException)2 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)2 AttachmentAddedEvent (com.xpn.xwiki.internal.event.AttachmentAddedEvent)2 AttachmentDeletedEvent (com.xpn.xwiki.internal.event.AttachmentDeletedEvent)2 AttachmentUpdatedEvent (com.xpn.xwiki.internal.event.AttachmentUpdatedEvent)2 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)2 DocumentUpdatingEvent (org.xwiki.bridge.event.DocumentUpdatingEvent)2