@Test public void createsAuditEventsWithNoRequest() throws ComponentLookupException { Mockito.when(this.context.getRequest()).thenReturn(null); this.mocker.getComponentUnderTest().onEvent(new ActionExecutedEvent("action"), this.xdoc, null); ArgumentCaptor<AuditEvent> captor = ArgumentCaptor.forClass(AuditEvent.class); Mockito.verify(this.store).store(captor.capture()); AuditEvent e = captor.getValue(); Assert.assertNull(e.getIp()); }
@Override public void onEvent(Event event, Object source, Object data) { final ActionExecutedEvent aee = (ActionExecutedEvent) event; final XWikiDocument doc = (XWikiDocument) source; final XWikiRequest request = this.xcontextProvider.get().getRequest(); final String ip = request != null ? request.getRemoteAddr() : null; AuditEvent auditEvent = new AuditEvent(this.users.getCurrentUser(), ip, aee.getActionName(), null, doc.getDocumentReference(), Calendar.getInstance(Locale.ROOT)); for (AuditEventProcessor processor : this.processors.get()) { auditEvent = processor.process(auditEvent); } this.store.store(auditEvent); }
AuditEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { final ActionExecutedEvent aee = (ActionExecutedEvent) event; final XWikiDocument doc = (XWikiDocument) source; final XWikiRequest request = this.xcontextProvider.get().getRequest(); final String ip = request != null ? request.getRemoteAddr() : null; AuditEvent auditEvent = new AuditEvent(this.users.getCurrentUser(), ip, aee.getActionName(), null, doc.getDocumentReference(), Calendar.getInstance(Locale.ROOT)); for (AuditEventProcessor processor : this.processors.get()) { auditEvent = processor.process(auditEvent); } this.store.store(auditEvent); } }
AuditEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { final ActionExecutedEvent aee = (ActionExecutedEvent) event; final XWikiDocument doc = (XWikiDocument) source; final XWikiRequest request = this.xcontextProvider.get().getRequest(); final String ip = request != null ? request.getRemoteAddr() : null; AuditEvent auditEvent = new AuditEvent(this.users.getCurrentUser(), ip, aee.getActionName(), null, doc.getDocumentReference(), Calendar.getInstance(Locale.ROOT)); for (AuditEventProcessor processor : this.processors.get()) { auditEvent = processor.process(auditEvent); } this.store.store(auditEvent); } AuditEventListener(); }
AuditEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { final ActionExecutedEvent aee = (ActionExecutedEvent) event; final XWikiDocument doc = (XWikiDocument) source; final XWikiRequest request = this.xcontextProvider.get().getRequest(); final String ip = request != null ? request.getRemoteAddr() : null; AuditEvent auditEvent = new AuditEvent(this.users.getCurrentUser(), ip, aee.getActionName(), null, doc.getDocumentReference(), Calendar.getInstance(Locale.ROOT)); for (AuditEventProcessor processor : this.processors.get()) { auditEvent = processor.process(auditEvent); } this.store.store(auditEvent); } AuditEventListener(); @Override void onEvent(Event event, Object source, Object data); }
AuditEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { final ActionExecutedEvent aee = (ActionExecutedEvent) event; final XWikiDocument doc = (XWikiDocument) source; final XWikiRequest request = this.xcontextProvider.get().getRequest(); final String ip = request != null ? request.getRemoteAddr() : null; AuditEvent auditEvent = new AuditEvent(this.users.getCurrentUser(), ip, aee.getActionName(), null, doc.getDocumentReference(), Calendar.getInstance(Locale.ROOT)); for (AuditEventProcessor processor : this.processors.get()) { auditEvent = processor.process(auditEvent); } this.store.store(auditEvent); } AuditEventListener(); @Override void onEvent(Event event, Object source, Object data);  }