Search in sources :

Example 1 with ActionExecutingEvent

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

the class ActionExecutedEventTest method testDoesntEqualDifferentTypeOfAction.

@Test
public void testDoesntEqualDifferentTypeOfAction() {
    ActionExecutedEvent event = new ActionExecutedEvent("something");
    Assert.assertFalse("Same object isn't matched!", event.equals(new ActionExecutingEvent("something")));
}
Also used : ActionExecutedEvent(org.xwiki.bridge.event.ActionExecutedEvent) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 2 with ActionExecutingEvent

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

the class ActionExecutedEventTest method testDoesntMatchDifferentTypeOfAction.

@Test
public void testDoesntMatchDifferentTypeOfAction() {
    ActionExecutedEvent event = new ActionExecutedEvent("something");
    Assert.assertFalse("A different type of action was matched!", event.matches(new ActionExecutingEvent("something")));
}
Also used : ActionExecutedEvent(org.xwiki.bridge.event.ActionExecutedEvent) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 3 with ActionExecutingEvent

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

the class ActionExecutionEventConverter method toRemote.

@Override
public boolean toRemote(LocalEventData localEvent, RemoteEventData remoteEvent) {
    if (localEvent.getEvent() instanceof ActionExecutedEvent || localEvent.getEvent() instanceof ActionExecutingEvent) {
        AbstractActionExecutionEvent event = (AbstractActionExecutionEvent) localEvent.getEvent();
        if (this.actions.contains(event.getActionName())) {
            // fill the remote event
            remoteEvent.setEvent(event);
            remoteEvent.setSource(serializeXWikiDocument((XWikiDocument) localEvent.getSource()));
            remoteEvent.setData(serializeXWikiContext((XWikiContext) localEvent.getData()));
        }
        return true;
    }
    return false;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) AbstractActionExecutionEvent(org.xwiki.bridge.event.AbstractActionExecutionEvent) ActionExecutedEvent(org.xwiki.bridge.event.ActionExecutedEvent) XWikiContext(com.xpn.xwiki.XWikiContext) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent)

Example 4 with ActionExecutingEvent

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

the class ActionExecutionEventConverter method fromRemote.

@Override
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) {
    if (remoteEvent.getEvent() instanceof ActionExecutedEvent || remoteEvent.getEvent() instanceof ActionExecutingEvent) {
        // fill the local event
        XWikiContext xcontext = unserializeXWikiContext(remoteEvent.getData());
        try {
            if (xcontext != null) {
                localEvent.setSource(unserializeDocument(remoteEvent.getSource()));
                localEvent.setData(xcontext);
                localEvent.setEvent((Event) remoteEvent.getEvent());
            }
        } catch (XWikiException e) {
            this.logger.error("Failed to convert remote event [{}]", remoteEvent, e);
        }
        return true;
    }
    return false;
}
Also used : ActionExecutedEvent(org.xwiki.bridge.event.ActionExecutedEvent) XWikiContext(com.xpn.xwiki.XWikiContext) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) XWikiException(com.xpn.xwiki.XWikiException)

Example 5 with ActionExecutingEvent

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

the class LegacyNotificationDispatcher method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    XWikiDocument document = (XWikiDocument) source;
    XWikiDocument originalDocument = document.getOriginalDocument();
    XWikiContext context = (XWikiContext) data;
    XWikiNotificationManager manager = getNotificationManager((XWikiContext) data);
    if (manager != null) {
        if (event instanceof DocumentCreatedEvent) {
            manager.verify(document, originalDocument, XWikiDocChangeNotificationInterface.EVENT_NEW, context);
        } else if (event instanceof DocumentUpdatedEvent) {
            manager.verify(document, originalDocument, XWikiDocChangeNotificationInterface.EVENT_CHANGE, context);
        } else if (event instanceof DocumentCreatingEvent) {
            manager.preverify(document, originalDocument, XWikiDocChangeNotificationInterface.EVENT_NEW, context);
        } else if (event instanceof DocumentUpdatingEvent) {
            manager.preverify(document, originalDocument, XWikiDocChangeNotificationInterface.EVENT_CHANGE, context);
        } else if (event instanceof DocumentDeletedEvent) {
            manager.verify(new XWikiDocument(document.getDocumentReference()), document, XWikiDocChangeNotificationInterface.EVENT_DELETE, context);
        } else if (event instanceof DocumentDeletingEvent) {
            manager.preverify(document, new XWikiDocument(document.getDocumentReference()), XWikiDocChangeNotificationInterface.EVENT_DELETE, context);
        } else if (event instanceof ActionExecutedEvent) {
            manager.verify(document, ((ActionExecutedEvent) event).getActionName(), context);
        } else if (event instanceof ActionExecutingEvent) {
            manager.preverify(document, ((ActionExecutingEvent) event).getActionName(), context);
        }
    } else {
        this.logger.error("Can't find old [XWikiNotificationManager] system");
    }
}
Also used : DocumentUpdatingEvent(org.xwiki.bridge.event.DocumentUpdatingEvent) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentDeletingEvent(org.xwiki.bridge.event.DocumentDeletingEvent) ActionExecutedEvent(org.xwiki.bridge.event.ActionExecutedEvent) XWikiContext(com.xpn.xwiki.XWikiContext) XWikiNotificationManager(com.xpn.xwiki.notify.XWikiNotificationManager) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) DocumentCreatingEvent(org.xwiki.bridge.event.DocumentCreatingEvent)

Aggregations

ActionExecutingEvent (org.xwiki.bridge.event.ActionExecutingEvent)37 Test (org.junit.Test)32 ActionExecutedEvent (org.xwiki.bridge.event.ActionExecutedEvent)9 XWikiContext (com.xpn.xwiki.XWikiContext)5 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)3 XWikiException (com.xpn.xwiki.XWikiException)2 XWikiRequest (com.xpn.xwiki.web.XWikiRequest)2 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)2 DocumentCreatingEvent (org.xwiki.bridge.event.DocumentCreatingEvent)2 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)2 DocumentDeletingEvent (org.xwiki.bridge.event.DocumentDeletingEvent)2 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)2 DocumentUpdatingEvent (org.xwiki.bridge.event.DocumentUpdatingEvent)2 LESSContext (org.xwiki.lesscss.internal.LESSContext)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 ObservationManager (org.xwiki.observation.ObservationManager)2 XWiki (com.xpn.xwiki.XWiki)1 MonitorPlugin (com.xpn.xwiki.monitor.api.MonitorPlugin)1 XWikiNotificationManager (com.xpn.xwiki.notify.XWikiNotificationManager)1 FileUploadPlugin (com.xpn.xwiki.plugin.fileupload.FileUploadPlugin)1