-
Notifications
You must be signed in to change notification settings - Fork 6
Add audit logs for approval tasks #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| String workflowRequestId = approvalTaskDAO.getWorkflowRequestIdByApprovalTaskId(approvalTaskId); | ||
| String workflowId = approvalTaskDAO.getWorkflowID(approvalTaskId); | ||
|
|
||
| handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 2
| handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED); | |
| handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED); | |
| log.info("Approval task completed. TaskId: " + approvalTaskId + ", WorkflowRequestId: " + workflowRequestId); |
| .workflowRequestId(workflowRequestId) | ||
| .newStatus(WorkflowEngineConstants.TaskStatus.REJECTED.toString()); | ||
| auditLogger.printAuditLog(auditBuilder); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 6
| completeWorkflowRequest(workflowRequestId, REJECTED); | |
| log.info("Workflow request rejected and completed. WorkflowRequestId: " + workflowRequestId); |
|
|
||
| for (String existingApprovalTaskId : existingApprovalTasks) { | ||
| if (existingApprovalTaskId.equals(updatedApprovalTaskId)) { | ||
| if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 8
| if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) { | |
| if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) { | |
| log.debug("Claiming task for user approver type. TaskId: " + updatedApprovalTaskId); |
| .workflowId(workflowId) | ||
| .newStatus(reservedStatus); | ||
| auditLogger.printAuditLog(auditBuilder); | ||
| } else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 9
| } else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) { | |
| } else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) { | |
| log.debug("Claiming task for role approver type. TaskId: " + updatedApprovalTaskId); |
| .workflowId(workflowId) | ||
| .newStatus(blockedStatus); | ||
| auditLogger.printAuditLog(blockedApprovalBuilder); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 10
| } | |
| } else { | |
| log.debug("Blocking all existing tasks for workflow request: " + workflowRequestID); |
| */ | ||
| public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) { | ||
|
|
||
| if (operation == null) { | ||
| log.warn("Operation is null. Cannot trigger audit log."); | ||
| return; | ||
| } | ||
| if (StringUtils.isBlank(targetId)) { | ||
| log.warn("Target ID is blank. Cannot trigger audit log."); | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 11
| */ | |
| public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) { | |
| if (operation == null) { | |
| log.warn("Operation is null. Cannot trigger audit log."); | |
| return; | |
| } | |
| if (StringUtils.isBlank(targetId)) { | |
| log.warn("Target ID is blank. Cannot trigger audit log."); | |
| return; | |
| public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) { | |
| if (operation == null) { | |
| log.warn("Operation is null. Cannot trigger audit log."); | |
| return; | |
| } | |
| if (StringUtils.isBlank(targetId)) { | |
| log.warn("Target ID is blank. Cannot trigger audit log."); | |
| return; | |
| } | |
| if (log.isDebugEnabled()) { | |
| log.debug("Triggering audit log for operation: " + operation.getLogAction() + ", targetId: " + targetId); | |
| } |
| LoggerUtils.getInitiatorType(initiatorId), | ||
| targetId, | ||
| LoggerUtils.Target.ApprovalTask.name(), | ||
| operation.getLogAction()). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 12
| operation.getLogAction()). | |
| LoggerUtils.triggerAuditLogEvent(auditLogBuilder); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Audit log triggered successfully for operation: " + operation.getLogAction()); | |
| } |
| * | ||
| * @return Initiator id despite masking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 13
| * | |
| * @return Initiator id despite masking. | |
| private String getInitiatorId() { | |
| if (log.isDebugEnabled()) { | |
| log.debug("Getting initiator ID for audit log"); | |
| } |
| if (!isV2AuditLogsEnabled()) { | ||
| if (log.isDebugEnabled()) { | ||
| log.debug("V2 audit logs are disabled. Skipping audit log for operation: " + | ||
| (builder.operation != null ? builder.operation.getLogAction() : "unknown")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 14
| (builder.operation != null ? builder.operation.getLogAction() : "unknown")); | |
| Map<String, Object> dataMap = builder.buildDataMap(); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Printing audit log for task: " + builder.taskId + ", operation: " + builder.operation.getLogAction()); | |
| } |
| /** | ||
| * Validate required fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 15
| /** | |
| * Validate required fields. | |
| private void validate() { | |
| if (log.isDebugEnabled()) { | |
| log.debug("Validating audit log builder data"); | |
| } |
| * @throws IllegalArgumentException if validation fails | ||
| */ | ||
| private void validate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 16
| * @throws IllegalArgumentException if validation fails | |
| */ | |
| private void validate() { | |
| if (operation == null) { | |
| log.error("Failed to validate audit log builder: Operation is required"); | |
| throw new IllegalArgumentException("Operation is required for audit logging"); | |
| } |
|
|
||
| if (operation == null) { | ||
| throw new IllegalArgumentException("Operation is required for audit logging"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 17
| if (operation == null) { | |
| throw new IllegalArgumentException("Operation is required for audit logging"); | |
| if (StringUtils.isBlank(taskId)) { | |
| log.error("Failed to validate audit log builder: Task ID is required"); | |
| throw new IllegalArgumentException("Task ID is required for audit logging"); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
|
Integration test runner |

Purpose
$subject
Related Issues
Related PRs
Todo: