diff --git a/.github/workflows/push_trigger.yml b/.github/workflows/push_trigger.yml
index bec5436b1ea..e77cc908bfe 100644
--- a/.github/workflows/push_trigger.yml
+++ b/.github/workflows/push_trigger.yml
@@ -126,7 +126,7 @@ jobs:
- name: Publish the maven package
run: |
- cd admin && mvn deploy -DaltDeploymentRepository=ossrh::default::${{ secrets.OSSRH_SNAPSHOT_URL }} -s $GITHUB_WORKSPACE/settings.xml -f pom.xml
+ cd admin && mvn deploy -DaltDeploymentRepository=ossrh::default::${{ secrets.RELEASE_URL }} -s $GITHUB_WORKSPACE/settings.xml -f pom.xml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GPG_TTY: $(tty)
diff --git a/.github/workflows/release_changes.yml b/.github/workflows/release_changes.yml
index cc9c2956d9e..5d8e1a32989 100644
--- a/.github/workflows/release_changes.yml
+++ b/.github/workflows/release_changes.yml
@@ -27,6 +27,11 @@ jobs:
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
+ - name: update Branch name in badges
+ run: |
+ sed -i 's/branch=.*)]/branch=${{ env.BRANCH_NAME }}\)]/g' README.md
+ sed -i 's/branch=.*\&/branch=${{ env.BRANCH_NAME }}\&/g' README.md
+
- name: Mannualy changing the pom versions
run: find . -type f -name "*pom.xml" -print0 | xargs -0 sed -i "s/${{ github.event.inputs.snapshotTags }}/${{ github.event.inputs.releaseTags }}/g"
@@ -48,7 +53,7 @@ jobs:
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.ACTION_PAT }}
- commit-message: Updated Pom versions for release changes
+ commit-message: Release Bot Pre-release changes
title: Release changes
body: Automated PR for ${{ github.event.inputs.releaseTags }} release.
branch: release-branch
diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml
new file mode 100644
index 00000000000..e9bba0e65a0
--- /dev/null
+++ b/.github/workflows/tag.yaml
@@ -0,0 +1,43 @@
+name: Tagging of repos
+
+env:
+ tag: v1.2.3
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'Tag to be published'
+ required: true
+ default: 'v1.2.3'
+ type: string
+ body:
+ description: 'Release body message'
+ required: true
+ default: 'Changes in this Release'
+ type: string
+ pre-release:
+ description: 'Pre-release? True/False'
+ required: true
+ default: False
+ type: string
+
+jobs:
+ build:
+ name: Create Release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
+ with:
+ tag_name: ${{ github.event.inputs.tag }}
+ release_name: ${{ github.event.inputs.tag }}
+ body: |
+ ${{ github.event.inputs.body }}
+ draft: false
+ prerelease: ${{fromJSON(github.event.inputs.pre-release)}}
diff --git a/README.md b/README.md
index 863f5707507..168f14bccf5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Maven Package upon a push](https://github.com/mosip/admin-services/actions/workflows/push_trigger.yml/badge.svg?branch=develop)](https://github.com/mosip/admin-services/actions/workflows/push_trigger.yml)
+[![Maven Package upon a push](https://github.com/mosip/admin-services/actions/workflows/push_trigger.yml/badge.svg?branch=release-1.2.0.1)](https://github.com/mosip/admin-services/actions/workflows/push_trigger.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mosip_admin-services&id=mosip_admin-services&metric=alert_status)](https://sonarcloud.io/dashboard?id=mosip_admin-services)
diff --git a/admin/admin-service/pom.xml b/admin/admin-service/pom.xml
index 2510e13704c..c4ee4b51a60 100644
--- a/admin/admin-service/pom.xml
+++ b/admin/admin-service/pom.xml
@@ -7,18 +7,18 @@
io.mosip.admin
admin-parent
- 1.2.0.1-SNAPSHOT
+ 1.2.0.1-B1
admin-service
admin-service
- 1.2.0.1-SNAPSHOT
+ 1.2.0.1-B1
http://maven.apache.org
jar
UTF-8
2.0.4.RELEASE
1.5.10
- 1.2.0.1-SNAPSHOT
+ 1.2.0.1-B1
@@ -147,13 +147,7 @@
org.digibooster.spring.batch
spring-batch-security
- 1.0.0
-
-
- org.slf4j
- slf4j-api
-
-
+ 1.1.0-RELEASE
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/CustomLineMapper.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/CustomLineMapper.java
index 63fbdb38e5d..a1bd8dedd7f 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/CustomLineMapper.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/CustomLineMapper.java
@@ -7,10 +7,13 @@
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
public class CustomLineMapper implements LineMapper, InitializingBean {
@@ -41,6 +44,10 @@ public T mapLine(String line, int lineNumber) throws Exception {
throw new Exception("Invalid language code provided");
}
}
+ Set> violations = validator.validate(fieldSetMapper.mapFieldSet(tokenizer.tokenize(line)));
+ if (!violations.isEmpty()) {
+ throw new ConstraintViolationException(violations);
+ }
return fieldSetMapper.mapFieldSet(tokenizer.tokenize(line));
}
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/JobResultListener.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/JobResultListener.java
index c38d07789d2..a4f2a53f0d7 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/JobResultListener.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/JobResultListener.java
@@ -3,51 +3,33 @@
import io.mosip.admin.bulkdataupload.repositories.BulkUploadTranscationRepository;
import io.mosip.admin.packetstatusupdater.util.AuditUtil;
import io.mosip.admin.packetstatusupdater.util.EventEnum;
-import org.digibooster.spring.batch.security.listener.JobExecutionSecurityContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
-import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.file.FlatFileParseException;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.List;
+import javax.validation.ConstraintViolationException;
+
public class JobResultListener implements JobExecutionListener {
private static final Logger logger = LoggerFactory.getLogger(JobResultListener.class);
private static String STATUS_MESSAGE = "
STATUS: %s, MESSAGE: %s";
private AuditUtil auditUtil;
- private JobExecutionSecurityContextListener jobExecutionSecurityContextListener;
private BulkUploadTranscationRepository bulkUploadTranscationRepository;
- private static final String SECURITY_PARAM_NAME = "security-param";
- private static final ThreadLocal ORIGINAL_CONTEXT = new ThreadLocal<>();
public JobResultListener(BulkUploadTranscationRepository bulkUploadTranscationRepository,
- AuditUtil auditUtil, JobExecutionSecurityContextListener jobExecutionSecurityContextListener) {
+ AuditUtil auditUtil) {
this.bulkUploadTranscationRepository = bulkUploadTranscationRepository;
this.auditUtil = auditUtil;
- this.jobExecutionSecurityContextListener = new JobExecutionSecurityContextListener();
}
@Override
public void beforeJob(JobExecution jobExecution) {
- logger.info("Job started : {}", jobExecution.getJobParameters().getString("transactionId"));
- this.jobExecutionSecurityContextListener.fillJobExecutionContext(jobExecution);
-
- if(jobExecution.getStepExecutions().isEmpty()) {
- restoreContext(jobExecution);
- }
- else {
- for(StepExecution stepExecution : jobExecution.getStepExecutions()) {
- this.jobExecutionSecurityContextListener.restoreContext(stepExecution);
- }
- }
-
+ // TODO Nothing
}
@Override
@@ -58,9 +40,13 @@ public void afterJob(JobExecution jobExecution) {
List failures = new ArrayList();
jobExecution.getStepExecutions().forEach(step -> {
step.getFailureExceptions().forEach(failure -> {
- if (failure instanceof FlatFileParseException) {
+ if (failure instanceof FlatFileParseException && failure.getCause() instanceof ConstraintViolationException) {
+ failures.add("Line --> " + ((FlatFileParseException) failure).getLineNumber() + " --> "+
+ ((FlatFileParseException) failure).getCause().getMessage());
+ }
+ else if(failure instanceof FlatFileParseException){
failures.add("Line --> " + ((FlatFileParseException) failure).getLineNumber() +
- " --> Datatype mismatch / Failed to write into object");
+ " --> Datatype mismatch/ Validation error / Failed to write into object");
} else
failures.add(failure.getCause() != null ? failure.getCause().getMessage() : failure.getMessage());
});
@@ -75,33 +61,6 @@ public void afterJob(JobExecution jobExecution) {
} catch (Throwable t) {
logger.error("Failed to update job status {}", jobId, t);
- } finally {
- clearContext();
- this.jobExecutionSecurityContextListener.removeFromJobExecutionContext(jobExecution);
- }
- }
-
-
- private void restoreContext(JobExecution jobExecution) {
- if (jobExecution.getExecutionContext().containsKey(SECURITY_PARAM_NAME)) {
- logger.debug("Restore the security context");
- Authentication authentication = (Authentication) jobExecution.getExecutionContext()
- .get(SECURITY_PARAM_NAME);
- SecurityContext securityContext = SecurityContextHolder.getContext();
- ORIGINAL_CONTEXT.set(securityContext.getAuthentication());
- securityContext.setAuthentication(authentication);
- } else {
- logger.error("Could not find key {} in the job execution context", SECURITY_PARAM_NAME);
- }
- }
-
- private void clearContext() {
- logger.debug("Clear the security context");
- SecurityContextHolder.clearContext();
- Authentication originalAuth = ORIGINAL_CONTEXT.get();
- if (originalAuth != null) {
- SecurityContextHolder.getContext().setAuthentication(originalAuth);
- ORIGINAL_CONTEXT.remove();
}
}
}
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/PacketJobResultListener.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/PacketJobResultListener.java
index b917752b7b6..838534c8cc3 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/PacketJobResultListener.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/batch/PacketJobResultListener.java
@@ -2,20 +2,14 @@
import io.mosip.admin.bulkdataupload.repositories.BulkUploadTranscationRepository;
import io.mosip.admin.packetstatusupdater.util.AuditUtil;
import io.mosip.admin.packetstatusupdater.util.EventEnum;
-import org.digibooster.spring.batch.security.listener.JobExecutionSecurityContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.file.FlatFileParseException;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-import javax.sql.DataSource;
-import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -24,31 +18,18 @@ public class PacketJobResultListener implements JobExecutionListener {
private static final Logger logger = LoggerFactory.getLogger(JobResultListener.class);
private static String STATUS_MESSAGE = "
READ: %d, STATUS: %s, MESSAGE: %s";
private AuditUtil auditUtil;
- private JobExecutionSecurityContextListener jobExecutionSecurityContextListener;
private BulkUploadTranscationRepository bulkUploadTranscationRepository;
private static final String SECURITY_PARAM_NAME = "security-param";
private static final ThreadLocal ORIGINAL_CONTEXT = new ThreadLocal<>();
public PacketJobResultListener(BulkUploadTranscationRepository bulkUploadTranscationRepository,
- AuditUtil auditUtil, JobExecutionSecurityContextListener jobExecutionSecurityContextListener) {
+ AuditUtil auditUtil) {
this.bulkUploadTranscationRepository = bulkUploadTranscationRepository;
this.auditUtil = auditUtil;
- this.jobExecutionSecurityContextListener = new JobExecutionSecurityContextListener();
}
@Override
public void beforeJob(JobExecution jobExecution) {
- logger.info("Job started : {}", jobExecution.getJobParameters().getString("transactionId"));
- this.jobExecutionSecurityContextListener.fillJobExecutionContext(jobExecution);
-
- if(jobExecution.getStepExecutions().isEmpty()) {
- restoreContext(jobExecution);
- }
- else {
- for(StepExecution stepExecution : jobExecution.getStepExecutions()) {
- this.jobExecutionSecurityContextListener.restoreContext(stepExecution);
- }
- }
}
@Override
@@ -80,33 +61,7 @@ public void afterJob(JobExecution jobExecution) {
} catch (Throwable t) {
logger.error("Failed to update job status {}", jobId, t);
- } finally {
- clearContext();
- this.jobExecutionSecurityContextListener.removeFromJobExecutionContext(jobExecution);
}
}
-
- private void restoreContext(JobExecution jobExecution) {
- if (jobExecution.getExecutionContext().containsKey(SECURITY_PARAM_NAME)) {
- logger.debug("Restore the security context");
- Authentication authentication = (Authentication) jobExecution.getExecutionContext()
- .get(SECURITY_PARAM_NAME);
- SecurityContext securityContext = SecurityContextHolder.getContext();
- ORIGINAL_CONTEXT.set(securityContext.getAuthentication());
- securityContext.setAuthentication(authentication);
- } else {
- logger.error("Could not find key {} in the job execution context", SECURITY_PARAM_NAME);
- }
- }
-
- private void clearContext() {
- logger.debug("Clear the security context");
- SecurityContextHolder.clearContext();
- Authentication originalAuth = ORIGINAL_CONTEXT.get();
- if (originalAuth != null) {
- SecurityContextHolder.getContext().setAuthentication(originalAuth);
- ORIGINAL_CONTEXT.remove();
- }
- }
}
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/BlocklistedWords.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/BlocklistedWords.java
index d61b7bcc94f..2095f95ab0a 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/BlocklistedWords.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/BlocklistedWords.java
@@ -7,6 +7,7 @@
import javax.persistence.Id;
import javax.persistence.Table;
+import io.mosip.admin.validator.AlphabeticValidator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -37,6 +38,7 @@ public class BlocklistedWords extends BaseEntity implements Serializable {
*/
@Id
@Column(name = "word", length = 128)
+ @AlphabeticValidator(message = "Blocklisted word can only contain Alphabets")
private String word;
/**
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/ModuleDetail.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/ModuleDetail.java
index 08a226d0f94..15b6c69ce08 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/ModuleDetail.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/ModuleDetail.java
@@ -5,8 +5,11 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
+import javax.persistence.IdClass;
import javax.persistence.Table;
+import io.mosip.admin.bulkdataupload.entity.id.CodeAndLanguageCodeID;
+import io.mosip.admin.bulkdataupload.entity.id.IdAndLanguageCodeID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,6 +21,7 @@
@AllArgsConstructor
@Entity
@Table(name = "module_detail", schema = "master")
+@IdClass(IdAndLanguageCodeID.class)
public class ModuleDetail extends BaseEntity implements Serializable {
/**
@@ -29,6 +33,7 @@ public class ModuleDetail extends BaseEntity implements Serializable {
@Column(name = "id", nullable = false, length = 36)
private String id;
+ @Id
@Column(name = "lang_code", nullable = false, length = 3)
private String langCode;
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/Template.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/Template.java
index 1e63bc7b68f..06bfc02fdac 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/Template.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/Template.java
@@ -71,7 +71,8 @@ public class Template extends BaseEntity implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
- @JoinColumn(name = "module_id", referencedColumnName = "id", insertable = false, updatable = false) })
+ @JoinColumn(name = "module_id", referencedColumnName = "id", insertable = false, updatable = false),
+ @JoinColumn(name = "lang_code", referencedColumnName = "lang_code", insertable = false, updatable = false) })
private ModuleDetail moduleDetail;
@ManyToOne(fetch = FetchType.LAZY)
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/id/HolidayID.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/id/HolidayID.java
index d21290b1c48..8477a649eaf 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/id/HolidayID.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/entity/id/HolidayID.java
@@ -33,7 +33,5 @@ public class HolidayID implements Serializable {
@Column(name = "lang_code", nullable = false, length = 3)
private String langCode;
- @Column(name = "holiday_name", nullable = false, length = 64)
- private String holidayName;
}
diff --git a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/service/impl/BulkDataUploadServiceImpl.java b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/service/impl/BulkDataUploadServiceImpl.java
index 0ded34be383..0662a77bfcc 100644
--- a/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/service/impl/BulkDataUploadServiceImpl.java
+++ b/admin/admin-service/src/main/java/io/mosip/admin/bulkdataupload/service/impl/BulkDataUploadServiceImpl.java
@@ -14,6 +14,7 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
+import javax.validation.Validator;
import io.mosip.admin.bulkdataupload.batch.CustomLineMapper;
import io.mosip.admin.bulkdataupload.batch.JobResultListener;
@@ -24,7 +25,7 @@
import io.mosip.admin.bulkdataupload.batch.CustomChunkListener;
import io.mosip.admin.bulkdataupload.service.PacketUploadService;
import io.mosip.kernel.core.util.*;
-import org.digibooster.spring.batch.security.listener.JobExecutionSecurityContextListener;
+import org.digibooster.spring.batch.listener.JobExecutionListenerContextSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.*;
@@ -108,6 +109,9 @@ public class BulkDataUploadServiceImpl implements BulkDataService {
@Autowired
private RestTemplate restTemplate;
+
+ @Autowired
+ private Validator validator;
@Autowired
private BulkUploadTranscationRepository bulkTranscationRepo;
@@ -144,6 +148,9 @@ public class BulkDataUploadServiceImpl implements BulkDataService {
@Autowired
private PacketJobResultListener packetJobResultListener;
+ @Autowired
+ private JobExecutionListenerContextSupport jobExecutionListenerContextSupport;
+
@Value("${mosip.mandatory-languages}")
private String mandatoryLanguages;
@@ -408,6 +415,7 @@ private Job getJob(MultipartFile file, String operation, String repositoryName,
.build();
return jobBuilderFactory.get("ETL-Load")
+ .listener(jobExecutionListenerContextSupport)
.listener(jobResultListener)
.incrementer(new RunIdIncrementer())
.start(step)
@@ -474,7 +482,7 @@ public void handleLine(String s) {
fieldSetMapper.setTargetType(clazz);
fieldSetMapper.setConversionService(customConversionService());
- CustomLineMapper