AUDIT-36: Add REST endpoint for audit log queries with user/action/date filtering#17
AUDIT-36: Add REST endpoint for audit log queries with user/action/date filtering#17AshThe25 wants to merge 1 commit into
Conversation
|
JIRA issue: https://issues.openmrs.org/browse/AUDIT-36 The module has no REST API, uses old DWR instead. GET /module/auditlog/rest/auditlogs is added.
Frontend workspace using this endpoint: |
|
Frontend workspace that consumes this endpoint: |
|
Added unit tests in the latest commit covering:
|
There was a problem hiding this comment.
If types is null we match all; if it is an empty list we pass an empty Restrictions.in, which Hibernate turns into 1=0. Worth adding an isEmpty guard so the caller does not accidentally get zero rows
There was a problem hiding this comment.
Good catch — added isEmpty() guard on both types and actions lists. An empty collection now behaves the same as null instead of generating 1=0. Pushed the fix.
…pagination Exposes GET /module/auditlog/rest/auditlogs with query parameters: user - filter by user UUID action - comma-separated: CREATED, UPDATED, DELETED startDate - inclusive lower bound (yyyy-MM-dd) endDate - inclusive upper bound (yyyy-MM-dd) startIndex - zero-based pagination offset (default 0) limit - page size capped at 100 (default 25) Changes: - AuditLogDAO: new getAuditLogs(userUuid, actions, dates, ...) method with isEmpty guards to avoid Hibernate 1=0 on empty list args - HibernateAuditLogDAO: Criteria-based implementation with user alias join - AuditLogService: new method declaration with PRIV_GET_AUDITLOGS guard - AuditLogServiceImpl: delegates to DAO - AuditLogRestController: Spring MVC @responsebody controller returning JSON - AuditLogDTO / AuditLogPageResponse: lightweight serialisable response types - Unit tests for AuditLogRestController and AuditLogServiceImpl
23d75c1 to
f0179df
Compare
|
Hi @ibacher, I see these PRs were closed. Could you share what was wrong so I can learn from it? Happy to rework any of them based on your feedback. |
Problem
This module does not have any REST API, but rather only uses the old DWR API. The OpenMRS O3 Frontend dashboard needs an endpoint that returns JSON data for the audit log.
Solution
Introduce a new GET request on /module/auditlog/rest/auditlogs with these parameters:
Changes
Testing
Manual testing with curl on the OpenMRS server. Unit tests coming in a different pull request.
JIRA
AUDIT-36