diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 0d28b300..85708f49 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -10,3 +10,7 @@ updates:
schedule:
interval: "daily"
target-branch: "grad-release"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
index ad579c75..2026371d 100644
--- a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
@@ -154,6 +154,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
diff --git a/.github/workflows/build.from.main.branch.deploy.to.dev.yml b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
index d192192d..80ad3870 100644
--- a/.github/workflows/build.from.main.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
@@ -141,6 +141,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
diff --git a/.github/workflows/build.from.release.branch.deploy.to.dev.yml b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
index 0375760b..e4296d52 100644
--- a/.github/workflows/build.from.release.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
@@ -149,6 +149,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
diff --git a/api/pom.xml b/api/pom.xml
index 0b45da9e..35c83805 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-batch-graduation-api
- 1.8.71
+ 1.8.72
educ-grad-batch-graduation-api
Ministry of Education GRAD BATCH GRADUATION API
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java
index 57804272..66c45ddb 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java
@@ -43,8 +43,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
// username
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- if (auth instanceof JwtAuthenticationToken) {
- JwtAuthenticationToken authenticationToken = (JwtAuthenticationToken) auth;
+ if (auth instanceof JwtAuthenticationToken authenticationToken) {
Jwt jwt = (Jwt) authenticationToken.getCredentials();
String username = JwtUtil.getName(jwt);
ThreadLocalStateUtil.setCurrentUser(username);
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
index aad3e8b0..39ec3b7c 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
@@ -234,9 +234,6 @@ public ResponseEntity launchRegGradSpecialJob(@RequestBody Stu
response.setTriggerBy(MANUAL);
response.setStartTime(LocalDateTime.now());
response.setStatus(BatchStatusEnum.STARTED.name());
- if(StringUtils.isBlank(studentSearchRequest.getActivityCode())) {
- studentSearchRequest.setActivityCode("USERDIST");
- }
validateInput(response, studentSearchRequest);
if(response.getException() != null) {
return ResponseEntity.status(400).body(response);
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java
index d5f0a2b4..c779304c 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java
@@ -3,7 +3,6 @@
import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity;
import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.ProcessError;
-import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj;
import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest;
import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils;
import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService;
@@ -84,7 +83,6 @@ protected void handleSummary(JobExecution jobExecution, String summaryDtoName, b
}
LOGGER.info(" --------------------------------------------------------------------------------------");
- ResponseObj obj = restUtils.getTokenResponseObject();
if (!isSpecialRun) {
updateBackStudentFlagForErroredStudents(summaryDTO.getErrors(), jobType);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java
index 44f09da8..a61da3b6 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java
@@ -1,22 +1,16 @@
package ca.bc.gov.educ.api.batchgraduation.listener;
-import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest;
import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils;
import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
-import org.springframework.batch.core.JobParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.ZoneId;
import java.util.Date;
-import java.util.List;
-
-import static ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants.SEARCH_REQUEST;
@Component
public class SpecialRunCompletionNotificationListener extends BaseRunCompletionNotificationListener {
@@ -29,8 +23,6 @@ public class SpecialRunCompletionNotificationListener extends BaseRunCompletionN
@Autowired
JsonTransformer jsonTransformer;
- private static final String RUN_BY = "runBy";
-
@Override
public void afterJob(JobExecution jobExecution) {
if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
@@ -38,22 +30,7 @@ public void afterJob(JobExecution jobExecution) {
LOGGER.info("=======================================================================================");
LOGGER.info("Special Job completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus());
handleSummary(jobExecution, "spcRunAlgSummaryDTO", true);
- processGradStudentRecordJobHistory(jobExecution);
LOGGER.info("=======================================================================================");
}
}
-
- private void processGradStudentRecordJobHistory(JobExecution jobExecution) {
-
- JobParameters jobParameters = jobExecution.getJobParameters();
- Long batchId = jobExecution.getId();
- String userName = jobParameters.getString(RUN_BY);
-
- String searchRequest = jobParameters.getString(SEARCH_REQUEST, "{}");
- StudentSearchRequest req = (StudentSearchRequest)jsonTransformer.unmarshall(searchRequest, StudentSearchRequest.class);
-
- restUtils.updateStudentGradRecordHistory(List.of(), batchId, userName, StringUtils.upperCase(req.getActivityCode()));
- }
-
-
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java
index 621570f7..7b8b344e 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java
@@ -26,7 +26,7 @@ public abstract class BasePartitioner extends SimplePartitioner {
private static final Logger LOGGER = LoggerFactory.getLogger(BasePartitioner.class);
private static final String RERUN_TYPE = "reRunType";
- private static final String RUN_BY = "runBy";
+ protected static final String RUN_BY = "runBy";
private static final String PREV_BATCH_ID = "previousBatchId";
private static final String RERUN_ALL = "RERUN_ALL";
private static final String RERUN_FAILED = "RERUN_FAILED";
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BaseStudentReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BaseStudentReader.java
index d37c999a..a97a75e6 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BaseStudentReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BaseStudentReader.java
@@ -3,6 +3,8 @@
import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj;
import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils;
+import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +22,9 @@ public abstract class BaseStudentReader implements ItemReader {
@Value("#{stepExecutionContext['index']}")
protected Integer nxtStudentForProcessing;
+ @Value("#{stepExecutionContext['runBy']}")
+ protected String runBy;
+
@Value("#{stepExecutionContext['data']}")
protected List studentList;
@@ -35,4 +40,10 @@ protected void fetchAccessToken() {
summaryDTO.setAccessToken(res.getAccess_token());
}
}
+
+ protected void setUserName() {
+ if (StringUtils.isNotBlank(runBy) && StringUtils.isBlank(ThreadLocalStateUtil.getCurrentUser())) {
+ ThreadLocalStateUtil.setCurrentUser(runBy);
+ }
+ }
}
\ No newline at end of file
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorReader.java
index 30e3966d..9293eb7d 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorReader.java
@@ -12,6 +12,7 @@ public class RecalculateProjectedGradRunErrorReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorRetryReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorRetryReader.java
index edd68426..e17cb48d 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorRetryReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunErrorRetryReader.java
@@ -12,6 +12,7 @@ public class RecalculateProjectedGradRunErrorRetryReader extends BaseStudentRead
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunReader.java
index 3cbca59d..d51253c2 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateProjectedGradRunReader.java
@@ -12,6 +12,7 @@ public class RecalculateProjectedGradRunReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorReader.java
index 6a2a3cc4..a74b5f9c 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorReader.java
@@ -12,6 +12,7 @@ public class RecalculateStudentErrorReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorRetryReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorRetryReader.java
index 64c2c31e..810d2249 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorRetryReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentErrorRetryReader.java
@@ -12,6 +12,7 @@ public class RecalculateStudentErrorRetryReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentReader.java
index ae887f4c..c5d8f2b9 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RecalculateStudentReader.java
@@ -12,6 +12,7 @@ public class RecalculateStudentReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
summaryDTO.setReadCount(studentList.size());
UUID nextStudent = null;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java
index be76349c..c5b15f73 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java
@@ -6,6 +6,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParameters;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Value;
@@ -31,6 +32,8 @@ public JobExecution getJobExecution() {
public Map partition(int gridSize) {
initializeRunType();
BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory();
+ JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
List studentList;
if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) {
studentList = restUtils.getStudentsForAlgorithm();
@@ -57,6 +60,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitionerRetry.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitionerRetry.java
index dad374d3..cebc76a1 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitionerRetry.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitionerRetry.java
@@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParameters;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Value;
@@ -30,6 +31,8 @@ public JobExecution getJobExecution() {
@Override
public Map partition(int gridSize) {
Long batchId = jobExecution.getId();
+ JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
List studentList = getInputDataForErroredStudents(batchId);
createTotalSummaryDTO("regGradAlgSummaryDTO");
@@ -48,6 +51,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java
index 82df4cc8..d9307e8f 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java
@@ -4,6 +4,7 @@
import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.RunTypeEnum;
import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest;
+import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
@@ -37,6 +38,7 @@ public Map partition(int gridSize) {
BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory();
List studentList;
JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
String searchRequest = jobParameters.getString(SEARCH_REQUEST, "{}");
StudentSearchRequest req = (StudentSearchRequest)jsonTransformer.unmarshall(searchRequest, StudentSearchRequest.class);
if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) {
@@ -64,6 +66,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitionerRetry.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitionerRetry.java
index e4eddd53..49d2c634 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitionerRetry.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitionerRetry.java
@@ -3,6 +3,7 @@
import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.RunTypeEnum;
import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest;
+import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
@@ -34,6 +35,8 @@ public JobExecution getJobExecution() {
@Override
public Map partition(int gridSize) {
Long batchId = jobExecution.getId();
+ JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
List studentList = getInputDataForErroredStudents(batchId);
createTotalSummaryDTO("spcRunAlgSummaryDTO");
@@ -52,6 +55,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialGradRunStudentReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialGradRunStudentReader.java
index ce051e9f..5d1f2884 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialGradRunStudentReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialGradRunStudentReader.java
@@ -12,6 +12,7 @@ public class SpecialGradRunStudentReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialProjectedGradRunReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialProjectedGradRunReader.java
index a12faff6..408035f1 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialProjectedGradRunReader.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpecialProjectedGradRunReader.java
@@ -12,6 +12,7 @@ public class SpecialProjectedGradRunReader extends BaseStudentReader {
@Override
public UUID read() throws Exception {
fetchAccessToken();
+ setUserName();
UUID nextStudent = null;
if (nxtStudentForProcessing < studentList.size()) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java
index 5f9d2b5f..a8a96458 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java
@@ -6,6 +6,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParameters;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Value;
@@ -31,6 +32,8 @@ public JobExecution getJobExecution() {
public Map partition(int gridSize) {
initializeRunType();
BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory();
+ JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
List studentList;
if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) {
studentList = restUtils.getStudentsForProjectedAlgorithm();
@@ -57,6 +60,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitionerRetry.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitionerRetry.java
index 6aba6575..a4bb0df8 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitionerRetry.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitionerRetry.java
@@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParameters;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Value;
@@ -30,6 +31,8 @@ public JobExecution getJobExecution() {
@Override
public Map partition(int gridSize) {
Long batchId = jobExecution.getId();
+ JobParameters jobParameters = jobExecution.getJobParameters();
+ String username = jobParameters.getString(RUN_BY);
List studentList = getInputDataForErroredStudents(batchId);
createTotalSummaryDTO("tvrRunSummaryDTO");
@@ -48,6 +51,7 @@ public Map partition(int gridSize) {
summaryDTO.setReadCount(data.size());
executionContext.put("summary", summaryDTO);
executionContext.put("index",0);
+ executionContext.put("runBy", username);
String key = "partition" + i;
map.put(key, executionContext);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java
index c5e128de..926d90c2 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java
@@ -71,7 +71,7 @@ public T get(String url, Class clazz, String accessToken) {
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
@@ -83,7 +83,10 @@ public T get(String url, Class clazz) {
obj = this.batchWebClient
.get()
.uri(url)
- .headers(h -> h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()))
+ .headers(h -> {
+ h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
+ h.set(EducGradBatchGraduationApiConstants.USERNAME, ThreadLocalStateUtil.getCurrentUser());
+ })
.retrieve()
// if 5xx errors, throw Service error
.onStatus(HttpStatusCode::is5xxServerError,
@@ -104,7 +107,7 @@ public T get(String url, Class clazz) {
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
@@ -143,7 +146,7 @@ public T post(String url, Object body, Class clazz, String accessToken) {
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
@@ -154,7 +157,10 @@ public T post(String url, Object body, Class clazz) {
try {
obj = this.batchWebClient.post()
.uri(url)
- .headers(h -> h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()))
+ .headers(h -> {
+ h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
+ h.set(EducGradBatchGraduationApiConstants.USERNAME, ThreadLocalStateUtil.getCurrentUser());
+ })
.body(BodyInserters.fromValue(body))
.retrieve()
.onStatus(HttpStatusCode::is5xxServerError,
@@ -171,7 +177,7 @@ public T post(String url, Object body, Class clazz) {
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
@@ -192,7 +198,10 @@ public T put(String url, Object body, Class clazz) {
try {
obj = this.batchWebClient.put()
.uri(url)
- .headers(h -> h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()))
+ .headers(h -> {
+ h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
+ h.set(EducGradBatchGraduationApiConstants.USERNAME, ThreadLocalStateUtil.getCurrentUser());
+ })
.body(BodyInserters.fromValue(body))
.retrieve()
.onStatus(HttpStatusCode::is5xxServerError,
@@ -209,7 +218,7 @@ public T put(String url, Object body, Class clazz) {
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
@@ -227,14 +236,17 @@ public T delete(String url, Class boundClass) {
T obj;
try {
obj = this.batchWebClient.delete().uri(url)
- .headers(h -> h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()))
+ .headers(h -> {
+ h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
+ h.set(EducGradBatchGraduationApiConstants.USERNAME, ThreadLocalStateUtil.getCurrentUser());
+ })
.retrieve().bodyToMono(boundClass).block();
} catch(Exception e) {
// catches IOExceptions and the like
throw new ServiceException(getErrorMessage(
url,
e.getLocalizedMessage()),
- (e instanceof WebClientResponseException) ? ((WebClientResponseException) e).getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
+ (e instanceof WebClientResponseException exception) ? exception.getStatusCode().value() : HttpStatus.SERVICE_UNAVAILABLE.value(),
e);
}
return obj;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java
index dd44be18..871d332b 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java
@@ -16,6 +16,7 @@ public class EducGradBatchGraduationApiConstants {
public static final String API_ROOT_MAPPING = "";
public static final String API_VERSION = "v1";
public static final String CORRELATION_ID = "correlationID";
+ public static final String USERNAME = "username";
public static final String GRAD_BATCH_API_ROOT_MAPPING = "/api/" + API_VERSION + "/batch";
// Manual Run