airajena opened a new pull request, #5497:
URL: https://github.com/apache/fineract/pull/5497
## Summary
This PR fixes `FINERACT-2028` by ensuring manual scheduler job execution is
audited.
## Problem
Manual job trigger (`POST /v1/jobs/{jobId}?command=executeJob`) executed
jobs directly via `JobRegisterService` and bypassed command processing, so no
`m_portfolio_command_source` audit entry was created.
## Root Cause
`SchedulerJobApiResource.executeJob(...)` called:
- `jobRegisterService.executeJobWithParameters(jobId, jsonRequestBody)`
directly,
instead of routing through
`PortfolioCommandSourceWritePlatformService.logCommandSource(...)`.
## Changes
1. Added scheduler execute command wrapper
-
`fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java`
- New builder method: `executeSchedulerJob(Long jobId)` with:
- `actionName = "EXECUTE"`
- `entityName = "SCHEDULER"`
- `href = "/jobs/{jobId}?command=executeJob"`
2. Routed job execution through command source logging
-
`fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/api/SchedulerJobApiResource.java`
- Replaced direct service invocation with:
- build command wrapper (`executeSchedulerJob(jobId)`)
- `commandsSourceWritePlatformService.logCommandSource(commandRequest)`
3. Added command handler for scheduler execute
-
`fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/handler/ExecuteJobCommandHandler.java`
- New handler annotated with:
- `@CommandType(entity = "SCHEDULER", action = "EXECUTE")`
- Executes the scheduler job and returns `CommandProcessingResult`.
4. Added unit test for new handler
-
`fineract-provider/src/test/java/org/apache/fineract/infrastructure/jobs/handler/ExecuteJobCommandHandlerTest.java`
- Verifies:
- `JobRegisterService.executeJobWithParameters(...)` is called
- command/resource IDs are returned in result
5. Added integration test for audit behavior
-
`integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java`
- New test: `executeSchedulerJobShouldCreateAuditEntry()`
- Verifies triggering a scheduler job creates a new audit entry with:
- `actionName = EXECUTE`
- `entityName = SCHEDULER`
## Tests Executed
- `:fineract-provider:test --tests
"org.apache.fineract.infrastructure.jobs.handler.ExecuteJobCommandHandlerTest"`
- `:integration-tests:test --tests
"org.apache.fineract.integrationtests.AuditIntegrationTest.executeSchedulerJobShouldCreateAuditEntry"
-PcargoDisabled`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]