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")));
}
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")));
}
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;
}
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;
}
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");
}
}
Aggregations