Search in sources :

Example 1 with RemoteEventData

use of org.xwiki.observation.remote.RemoteEventData in project xwiki-platform by xwiki.

the class DefaultJGroupsReceiver method receive.

@Override
public void receive(Message msg) {
    RemoteEventData remoteEvent = (RemoteEventData) msg.getObject();
    this.logger.debug("Received JGroups remote event [{}]", remoteEvent);
    getRemoteObservationManager().notify(remoteEvent);
}
Also used : RemoteEventData(org.xwiki.observation.remote.RemoteEventData)

Example 2 with RemoteEventData

use of org.xwiki.observation.remote.RemoteEventData in project xwiki-platform by xwiki.

the class DocumentEventConverterTest method testConvertWithOriginalDocNull.

@Test
public void testConvertWithOriginalDocNull() throws Exception {
    EventConverterManager eventConverterManager = getComponentManager().getInstance(EventConverterManager.class);
    // local -> remote
    LocalEventData localEvent = new LocalEventData();
    localEvent.setEvent(new DocumentUpdatedEvent(new DocumentReference("wiki", "space", "page")));
    localEvent.setSource(new XWikiDocument(new DocumentReference("wiki", "space", "page")));
    localEvent.setData(getContext());
    RemoteEventData remoteEvent = eventConverterManager.createRemoteEventData(localEvent);
    Assert.assertFalse(remoteEvent.getSource() instanceof XWikiDocument);
    Assert.assertFalse(remoteEvent.getData() instanceof XWikiContext);
    // serialize/unserialize
    ByteArrayOutputStream sos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(sos);
    oos.writeObject(remoteEvent);
    ByteArrayInputStream sis = new ByteArrayInputStream(sos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(sis);
    remoteEvent = (RemoteEventData) ois.readObject();
    // remote -> local
    LocalEventData localEvent2 = eventConverterManager.createLocalEventData(remoteEvent);
    Assert.assertTrue(localEvent2.getSource() instanceof XWikiDocument);
    Assert.assertTrue(localEvent2.getData() instanceof XWikiContext);
    Assert.assertEquals("wiki", ((XWikiDocument) localEvent2.getSource()).getWikiName());
    Assert.assertEquals("space", ((XWikiDocument) localEvent2.getSource()).getSpaceName());
    Assert.assertEquals("page", ((XWikiDocument) localEvent2.getSource()).getPageName());
    Assert.assertTrue(((XWikiDocument) localEvent2.getSource()).getOriginalDocument().isNew());
}
Also used : LocalEventData(org.xwiki.observation.remote.LocalEventData) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) RemoteEventData(org.xwiki.observation.remote.RemoteEventData) ByteArrayInputStream(java.io.ByteArrayInputStream) EventConverterManager(org.xwiki.observation.remote.converter.EventConverterManager) XWikiContext(com.xpn.xwiki.XWikiContext) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) DocumentReference(org.xwiki.model.reference.DocumentReference) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

RemoteEventData (org.xwiki.observation.remote.RemoteEventData)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Test (org.junit.Test)1 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 LocalEventData (org.xwiki.observation.remote.LocalEventData)1 EventConverterManager (org.xwiki.observation.remote.converter.EventConverterManager)1