@Test public void listEventsForwardsCalls() { Calendar from = Calendar.getInstance(); from.clear(); from.set(2010, 0, 1, 0, 0, 0); Calendar to = Calendar.getInstance(); to.clear(); to.set(2011, 0, 1, 0, 0, 0); AuditEvent template = new AuditEvent(this.user, "ip", "action", null, this.doc, null); when(this.store.getEvents(template, from, to, 20, 10)).thenReturn(this.events); when(this.auth.hasAccess(this.user, Right.ADMIN, this.xwikiPreferences)).thenReturn(true); JSONObject response = (JSONObject) this.resource .listEvents(20, 10, "action", "user", "ip", "Space.Page", "01/01/2010", "01/01/2011").getEntity(); Mockito.verify(this.store).getEvents(template, from, to, 20, 10); JSONArray data = (JSONArray) response.get("data"); Assert.assertSame(this.events.get(0).toJSON(), data.opt(0)); }
@Override @SuppressWarnings("checkstyle:ParameterNumber") public Response listEvents(int start, int number, String action, String userId, String ip, String entityId, String fromTime, String toTime) { if (!this.auth.hasAccess(this.users.getCurrentUser(), Right.ADMIN, this.resolver.resolve(Constants.XWIKI_SPACE_REFERENCE))) { this.slf4Jlogger.debug("Activity logs access denied to user [{}]", this.users.getCurrentUser()); return Response.status(Status.FORBIDDEN).build(); } JSONArray eventsList = new JSONArray(); AuditEvent eventTemplate = setTemplate(action, userId, ip, entityId); List<AuditEvent> results = getResults(eventTemplate, fromTime, toTime, start, number); for (AuditEvent event : results) { eventsList.put(event.toJSON()); } JSONObject response = new JSONObject(); response.put("data", eventsList); return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build(); }
DefaultAuditResource extends XWikiResource implements AuditResource { @Override @SuppressWarnings("checkstyle:ParameterNumber") public Response listEvents(int start, int number, String action, String userId, String ip, String entityId, String fromTime, String toTime) { if (!this.auth.hasAccess(this.users.getCurrentUser(), Right.ADMIN, this.resolver.resolve(Constants.XWIKI_SPACE_REFERENCE))) { this.slf4Jlogger.debug("Activity logs access denied to user [{}]", this.users.getCurrentUser()); return Response.status(Status.FORBIDDEN).build(); } JSONArray eventsList = new JSONArray(); AuditEvent eventTemplate = setTemplate(action, userId, ip, entityId); List<AuditEvent> results = getResults(eventTemplate, fromTime, toTime, start, number); for (AuditEvent event : results) { eventsList.put(event.toJSON()); } JSONObject response = new JSONObject(); response.put("data", eventsList); return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build(); } }
DefaultAuditResource extends XWikiResource implements AuditResource { @Override @SuppressWarnings("checkstyle:ParameterNumber") public Response listEvents(int start, int number, String action, String userId, String ip, String entityId, String fromTime, String toTime) { if (!this.auth.hasAccess(this.users.getCurrentUser(), Right.ADMIN, this.resolver.resolve(Constants.XWIKI_SPACE_REFERENCE))) { this.slf4Jlogger.debug("Activity logs access denied to user [{}]", this.users.getCurrentUser()); return Response.status(Status.FORBIDDEN).build(); } JSONArray eventsList = new JSONArray(); AuditEvent eventTemplate = setTemplate(action, userId, ip, entityId); List<AuditEvent> results = getResults(eventTemplate, fromTime, toTime, start, number); for (AuditEvent event : results) { eventsList.put(event.toJSON()); } JSONObject response = new JSONObject(); response.put("data", eventsList); return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build(); }  }
DefaultAuditResource extends XWikiResource implements AuditResource { @Override @SuppressWarnings("checkstyle:ParameterNumber") public Response listEvents(int start, int number, String action, String userId, String ip, String entityId, String fromTime, String toTime) { if (!this.auth.hasAccess(this.users.getCurrentUser(), Right.ADMIN, this.resolver.resolve(Constants.XWIKI_SPACE_REFERENCE))) { this.slf4Jlogger.debug("Activity logs access denied to user [{}]", this.users.getCurrentUser()); return Response.status(Status.FORBIDDEN).build(); } JSONArray eventsList = new JSONArray(); AuditEvent eventTemplate = setTemplate(action, userId, ip, entityId); List<AuditEvent> results = getResults(eventTemplate, fromTime, toTime, start, number); for (AuditEvent event : results) { eventsList.put(event.toJSON()); } JSONObject response = new JSONObject(); response.put("data", eventsList); return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build(); }  @Override @SuppressWarnings("checkstyle:ParameterNumber") Response listEvents(int start, int number, String action, String userId, String ip, String entityId,
        String fromTime, String toTime); }
DefaultAuditResource extends XWikiResource implements AuditResource { @Override @SuppressWarnings("checkstyle:ParameterNumber") public Response listEvents(int start, int number, String action, String userId, String ip, String entityId, String fromTime, String toTime) { if (!this.auth.hasAccess(this.users.getCurrentUser(), Right.ADMIN, this.resolver.resolve(Constants.XWIKI_SPACE_REFERENCE))) { this.slf4Jlogger.debug("Activity logs access denied to user [{}]", this.users.getCurrentUser()); return Response.status(Status.FORBIDDEN).build(); } JSONArray eventsList = new JSONArray(); AuditEvent eventTemplate = setTemplate(action, userId, ip, entityId); List<AuditEvent> results = getResults(eventTemplate, fromTime, toTime, start, number); for (AuditEvent event : results) { eventsList.put(event.toJSON()); } JSONObject response = new JSONObject(); response.put("data", eventsList); return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build(); }  @Override @SuppressWarnings("checkstyle:ParameterNumber") Response listEvents(int start, int number, String action, String userId, String ip, String entityId,
        String fromTime, String toTime);  }