From c7dfd2ffe37547f8afbb07d3277f05eec817788b Mon Sep 17 00:00:00 2001 From: teleivo Date: Fri, 17 Jan 2025 09:38:11 +0100 Subject: [PATCH] chore: adapt signature --- .../audit/DefaultTrackedEntityAuditService.java | 4 ++-- .../dhis/tracker/audit/TrackedEntityAuditService.java | 4 ++-- .../dhis/tracker/export/OperationsParamsValidator.java | 2 +- .../trackedentity/DefaultTrackedEntityService.java | 10 +++------- .../DefaultTrackerObjectsDeletionService.java | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/DefaultTrackedEntityAuditService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/DefaultTrackedEntityAuditService.java index 4084f3c35ce..90f363a9acb 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/DefaultTrackedEntityAuditService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/DefaultTrackedEntityAuditService.java @@ -58,7 +58,7 @@ public class DefaultTrackedEntityAuditService implements TrackedEntityAuditServi @Async @Transactional public void addTrackedEntityAudit( - TrackedEntity trackedEntity, String username, AuditOperationType type) { + AuditOperationType type, String username, TrackedEntity trackedEntity) { if (username != null && trackedEntity != null && trackedEntity.getTrackedEntityType() != null @@ -73,7 +73,7 @@ public void addTrackedEntityAudit( @Async @Transactional public void addTrackedEntityAudit( - @Nonnull List trackedEntities, String username, AuditOperationType type) { + AuditOperationType type, String username, @Nonnull List trackedEntities) { List audits = trackedEntities.stream() .filter(te -> te.getTrackedEntityType().isAllowAuditLog()) diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/TrackedEntityAuditService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/TrackedEntityAuditService.java index c33cc797109..72aa24a0f8d 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/TrackedEntityAuditService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/audit/TrackedEntityAuditService.java @@ -41,11 +41,11 @@ public interface TrackedEntityAuditService { String ID = TrackedEntityAuditService.class.getName(); - void addTrackedEntityAudit(TrackedEntity trackedEntity, String username, AuditOperationType type); + void addTrackedEntityAudit(AuditOperationType type, String username, TrackedEntity trackedEntity); /** Adds multiple tracked entity audit */ void addTrackedEntityAudit( - @Nonnull List trackedEntity, String username, AuditOperationType type); + AuditOperationType type, String username, @Nonnull List trackedEntity); /** * Returns tracked entity audits matching query params diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/OperationsParamsValidator.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/OperationsParamsValidator.java index 03ebb230516..a4b20a86b20 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/OperationsParamsValidator.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/OperationsParamsValidator.java @@ -186,7 +186,7 @@ public TrackedEntity validateTrackedEntity(UID uid, UserDetails user) if (trackedEntity == null) { throw new BadRequestException("Tracked entity is specified but does not exist: " + uid); } - trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), READ); + trackedEntityAuditService.addTrackedEntityAudit(READ, user.getUsername(), trackedEntity); if (trackedEntity.getTrackedEntityType() != null && !aclService.canDataRead(user, trackedEntity.getTrackedEntityType())) { diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityService.java index 0d2d6bcb882..d66ba875d5b 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityService.java @@ -250,7 +250,7 @@ private TrackedEntity getTrackedEntity( throw new NotFoundException(TrackedEntity.class, uid); } - trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), READ); + trackedEntityAuditService.addTrackedEntityAudit(READ, user.getUsername(), trackedEntity); if (program != null) { List errors = @@ -391,7 +391,7 @@ private List getTrackedEntities( trackedEntity.setTrackedEntityAttributeValues( getTrackedEntityAttributeValues(trackedEntity, queryParams.getProgram())); } - addSearchAudit(trackedEntities, user); + trackedEntityAuditService.addTrackedEntityAudit(SEARCH, user.getUsername(), trackedEntities); return trackedEntities; } @@ -570,16 +570,12 @@ private RelationshipItem getTrackedEntityInRelationshipItem(String uid) throws N return null; } - trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), SEARCH); + trackedEntityAuditService.addTrackedEntityAudit(SEARCH, user.getUsername(), trackedEntity); relationshipItem.setTrackedEntity(trackedEntity); return relationshipItem; } - private void addSearchAudit(List trackedEntities, UserDetails user) { - trackedEntityAuditService.addTrackedEntityAudit(trackedEntities, user.getUsername(), SEARCH); - } - @Override public Set getOrderableFields() { return trackedEntityStore.getOrderableFields(); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/DefaultTrackerObjectsDeletionService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/DefaultTrackerObjectsDeletionService.java index 25234e5bea7..99e2ff14daf 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/DefaultTrackerObjectsDeletionService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/DefaultTrackerObjectsDeletionService.java @@ -180,7 +180,7 @@ public TrackerTypeReport deleteTrackedEntities(List trackedEntities) if (entity == null) { throw new NotFoundException(TrackedEntity.class, uid); } - trackedEntityAuditService.addTrackedEntityAudit(entity, getCurrentUsername(), DELETE); + trackedEntityAuditService.addTrackedEntityAudit(DELETE, getCurrentUsername(), entity); entity.setLastUpdatedByUserInfo(userInfoSnapshot);