diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml
index dc69ae1fa4..e2d980efda 100644
--- a/.github/workflows/push-trigger.yml
+++ b/.github/workflows/push-trigger.yml
@@ -43,7 +43,7 @@ jobs:
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
- OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }}
+ OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
diff --git a/commons-packet/commons-packet-manager/pom.xml b/commons-packet/commons-packet-manager/pom.xml
index 97ebce25a6..f6831f39e9 100644
--- a/commons-packet/commons-packet-manager/pom.xml
+++ b/commons-packet/commons-packet-manager/pom.xml
@@ -9,7 +9,7 @@
commons-packet-manager
Mosip commons project
https://github.com/mosip/commons
- 1.2.0.3
+ 1.2.0.4-SNAPSHOT
UTF-8
@@ -23,6 +23,7 @@
3.2.0
2.3
+ 0.7.0
2.0.2.RELEASE
@@ -46,7 +47,7 @@
1.2.0.1
1.2.0.1
2.0.2.RELEASE
- 1.2.0.1
+ 1.2.0.2-SNAPSHOT
**/constants/**,**/config/**,**/audit/**,**/util/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/**,**/*Utils.java,**/*Validator.java,**/*Helper.java,**/verticle/**,**/VidWriter.java/**,**/masterdata/utils/**,**/spi/**,**/core/http/**,"**/LocationServiceImpl.java","**/RegistrationCenterMachineServiceImpl.java","**/RegistrationCenterServiceImpl.java","**/pridgenerator/**","**/idgenerator/prid","**/proxy/**","**/cryptosignature/**"
**/dto/**,**/entity/**,**/config/**
@@ -154,18 +155,28 @@
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
+
+
+ ossrh
+ https://central.sonatype.com/repository/maven-snapshots/
+
+
+ ossrh
+ https://central.sonatype.com/api/v1/publisher
+
+
+
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ ${central.publishing.maven.plugin.version}
+ true
+
+ ossrh
+ false
+
+
org.apache.maven.plugins
maven-compiler-plugin
@@ -188,27 +199,6 @@
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
-
- default-deploy
- deploy
-
- deploy
-
-
-
-
- ossrh
- https://oss.sonatype.org/
- false
-
-
-
org.apache.maven.plugins
maven-source-plugin
diff --git a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/facade/PacketReader.java b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/facade/PacketReader.java
index 0c9632e556..8855daa203 100644
--- a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/facade/PacketReader.java
+++ b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/facade/PacketReader.java
@@ -114,12 +114,13 @@ public Document getDocument(String id, String documentName, String source, Strin
* @param process : the process
* @return BiometricRecord : the biometric record
*/
+
+ // The caching is removed from this method and moved to the implementation class as part of MOSIP-42180 JIRA. If we use the older implementation class logic (Customized Packet Reader Implementation) then caching logic will not work because of newly introduced getBiometric() method in IPacketReader interface i.e. we need to implement the caching logic in new getBiometric() method in implementation class.
@PreAuthorize("hasRole('BIOMETRIC_READ')")
- @Cacheable(value = "packets", key = "'biometrics'.concat('-').#id.concat('-').concat(#person).concat('-').concat(#modalities).concat('-').concat(#source).concat('-').concat(#process)", condition = "#bypassCache == false")
public BiometricRecord getBiometric(String id, String person, List modalities, String source, String process, boolean bypassCache) {
LOGGER.info(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
"getBiometric for source : " + source + " process : " + process);
- return getProvider(source, process).getBiometric(id, person, modalities, source, process);
+ return getProvider(source, process).getBiometric(id, person, modalities, source, process, bypassCache);
}
/**
@@ -147,6 +148,7 @@ public Map getMetaInfo(String id, String source, String process,
* @return
*/
@PreAuthorize("hasRole('DATA_READ')")
+ @Cacheable(value = "info", key = "{#id}")
public List info(String id) {
LOGGER.info(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
"info called");
diff --git a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/impl/PacketReaderImpl.java b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/impl/PacketReaderImpl.java
index c987c7e664..fb7da7236c 100644
--- a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/impl/PacketReaderImpl.java
+++ b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/impl/PacketReaderImpl.java
@@ -9,9 +9,7 @@
import static io.mosip.commons.packet.constants.PacketManagerConstants.TYPE;
import static io.mosip.commons.packet.constants.PacketManagerConstants.VALUE;
-import java.io.IOException;
import java.io.InputStream;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -29,32 +27,28 @@
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
-import io.mosip.commons.packet.constants.PacketManagerConstants;
import io.mosip.commons.packet.dto.Document;
import io.mosip.commons.packet.dto.Packet;
import io.mosip.commons.packet.dto.PacketInfo;
-import io.mosip.commons.packet.exception.ApiNotAccessibleException;
import io.mosip.commons.packet.exception.GetAllIdentityException;
import io.mosip.commons.packet.exception.GetAllMetaInfoException;
import io.mosip.commons.packet.exception.GetBiometricException;
import io.mosip.commons.packet.exception.GetDocumentException;
-import io.mosip.commons.packet.exception.PacketDecryptionFailureException;
-import io.mosip.commons.packet.exception.PacketKeeperException;
import io.mosip.commons.packet.exception.PacketValidationFailureException;
import io.mosip.commons.packet.keeper.PacketKeeper;
import io.mosip.commons.packet.spi.IPacketReader;
import io.mosip.commons.packet.util.IdSchemaUtils;
-import io.mosip.commons.packet.util.PacketManagerHelper;
import io.mosip.commons.packet.util.PacketManagerLogger;
import io.mosip.commons.packet.util.PacketValidator;
import io.mosip.commons.packet.util.ZipUtils;
@@ -91,6 +85,8 @@ public class PacketReaderImpl implements IPacketReader {
@Autowired
private PacketValidator packetValidator;
+ @Autowired
+ private CacheManager cacheManager;
/**
* Perform packet validations and audit errors. List of validations - 1. schema
* & idobject reference validation 2. files validation 3. decrypted packet
@@ -231,55 +227,18 @@ public Document getDocument(String id, String documentName, String source, Strin
}
@Override
- public BiometricRecord getBiometric(String id, String biometricFieldName, List modalities, String source,
- String process) {
+ public BiometricRecord getBiometric(String id, String biometricFieldName, List modalities, String source, String process, boolean byPassCache) {
LOGGER.info(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
- "getBiometric :: for - " + biometricFieldName);
+ "getBiometric :: for - " + biometricFieldName + " with byPassCache - " + byPassCache);
BiometricRecord biometricRecord = null;
- String packetName = null;
- String fileName = null;
- try {
- String bioString = packetReader.getField(id, biometricFieldName, source, process, false);//(String) idobjectMap.get(biometricFieldName);
- JSONObject biometricMap = null;
- if (bioString != null)
- biometricMap = new JSONObject(bioString);
- if (bioString == null || biometricMap == null || biometricMap.isNull(VALUE)) {
- // biometric file not present in idobject. Search in meta data.
- Map metadataMap = getMetaInfo(id, source, process);
- String operationsData = metadataMap.get(META_INFO_OPERATIONS_DATA);
- if (StringUtils.isNotEmpty(operationsData)) {
- JSONArray jsonArray = new JSONArray(operationsData);
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jsonObject = (JSONObject) jsonArray.get(i);
- if (jsonObject.has(LABEL)
- && jsonObject.get(LABEL).toString().equalsIgnoreCase(biometricFieldName)) {
- packetName = ID;
- fileName = jsonObject.isNull(VALUE) ? null : jsonObject.get(VALUE).toString();
- break;
- }
- }
- }
- } else {
- String idSchemaVersion = packetReader.getField(id,
- idSchemaUtils.getIdschemaVersionFromMappingJson(), source, process, false);
- Double schemaVersion = idSchemaVersion != null ? Double.valueOf(idSchemaVersion) : null;
- packetName = idSchemaUtils.getSource(biometricFieldName, schemaVersion);
- fileName = biometricMap.get(VALUE).toString();
- }
- if (packetName == null || fileName == null)
- return null;
-
- Packet packet = packetKeeper.getPacket(getPacketInfo(id, packetName, source, process));
- InputStream biometrics = ZipUtils.unzipAndGetFile(packet.getPacket(), fileName);
- if (biometrics == null)
- return null;
- BIR bir = CbeffValidator.getBIRFromXML(IOUtils.toByteArray(biometrics));
+ try {
+ BIR bir = loadBiometricsFromObjectStore(id, biometricFieldName, source, process, byPassCache);
biometricRecord = new BiometricRecord();
if(bir.getOthers() != null) {
HashMap others = new HashMap<>();
bir.getOthers().entrySet().forEach(e -> {
- others.put(e.getKey(), e.getValue());
+ others.put(e.getKey(), e.getValue());
});
biometricRecord.setOthers(others);
}
@@ -300,6 +259,88 @@ public BiometricRecord getBiometric(String id, String biometricFieldName, List modalities, String source, String process) {
+ return getBiometric(id, biometricFieldName, modalities, source, process, false);
+ }
+
+ private String generateKey(String id, String biometricFieldName, String source, String process) {
+ return String.format("%s-%s-%s-%s", id, biometricFieldName, source, process);
+ }
+
+ private BIR loadBiometricsFromObjectStore(String id, String biometricFieldName, String source, String process, boolean byPassCache) throws Exception {
+ String cacheKey = generateKey(id, biometricFieldName, source, process);
+ Cache cache = cacheManager.getCache("packets");
+
+ if(byPassCache || cache == null) {
+ LOGGER.debug(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
+ "Skipping Cache due to byPassCache : " + byPassCache + " or IsCachePresent : " + (cache != null));
+ return loadBiometricsFromObjectStore(id, biometricFieldName, source, process);
+ }
+
+ BIR cachedValue = cache.get(cacheKey, BIR.class);
+ if(cachedValue != null) {
+ LOGGER.debug(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
+ "Cache Found for the Key : " + cacheKey);
+ return cachedValue;
+ }
+
+ LOGGER.debug(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
+ "Cache not found for the Key : " + cacheKey + " Loading biometrics from ObjectStore");
+ BIR bir = loadBiometricsFromObjectStore(id, biometricFieldName, source, process);
+ if(bir != null) {
+ LOGGER.debug(PacketManagerLogger.SESSIONID, PacketManagerLogger.REGISTRATIONID, id,
+ "Adding cache the Key : " + cacheKey);
+ cache.put(cacheKey, bir);
+ }
+
+ return bir;
+ }
+
+ private BIR loadBiometricsFromObjectStore(String id, String biometricFieldName, String source, String process) throws Exception {
+ String packetName = null;
+ String fileName = null;
+
+ String bioString = packetReader.getField(id, biometricFieldName, source, process, false);//(String) idobjectMap.get(biometricFieldName);
+ JSONObject biometricMap = null;
+ if (bioString != null)
+ biometricMap = new JSONObject(bioString);
+ if (bioString == null || biometricMap == null || biometricMap.isNull(VALUE)) {
+ // biometric file not present in idobject. Search in meta data.
+ Map metadataMap = getMetaInfo(id, source, process);
+ String operationsData = metadataMap.get(META_INFO_OPERATIONS_DATA);
+ if (StringUtils.isNotEmpty(operationsData)) {
+ JSONArray jsonArray = new JSONArray(operationsData);
+ for (int i = 0; i < jsonArray.length(); i++) {
+ JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+ if (jsonObject.has(LABEL)
+ && jsonObject.get(LABEL).toString().equalsIgnoreCase(biometricFieldName)) {
+ packetName = ID;
+ fileName = jsonObject.isNull(VALUE) ? null : jsonObject.get(VALUE).toString();
+ break;
+ }
+ }
+ }
+ } else {
+ String idSchemaVersion = packetReader.getField(id,
+ idSchemaUtils.getIdschemaVersionFromMappingJson(), source, process, false);
+ Double schemaVersion = idSchemaVersion != null ? Double.valueOf(idSchemaVersion) : null;
+ packetName = idSchemaUtils.getSource(biometricFieldName, schemaVersion);
+ fileName = biometricMap.get(VALUE).toString();
+ }
+
+ if (packetName == null || fileName == null)
+ return null;
+
+ Packet packet = packetKeeper.getPacket(getPacketInfo(id, packetName, source, process));
+ InputStream biometrics = ZipUtils.unzipAndGetFile(packet.getPacket(), fileName);
+ if (biometrics == null)
+ return null;
+
+ return CbeffValidator.getBIRFromXML(IOUtils.toByteArray(biometrics));
+ }
+
@Override
public Map getMetaInfo(String id, String source, String process) {
Map finalMap = new LinkedHashMap<>();
diff --git a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/spi/IPacketReader.java b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/spi/IPacketReader.java
index 6926d004d3..c8721406c6 100644
--- a/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/spi/IPacketReader.java
+++ b/commons-packet/commons-packet-manager/src/main/java/io/mosip/commons/packet/spi/IPacketReader.java
@@ -29,4 +29,8 @@ public interface IPacketReader {
public Map getMetaInfo(String id, String source, String process);
public List
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
-
- default-deploy
- deploy
-
- deploy
-
-
-
-
- ossrh
- https://oss.sonatype.org/
- false
-
-
org.apache.maven.plugins
@@ -359,6 +343,16 @@
false
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ ${central.publishing.maven.plugin.version}
+ true
+
+ ossrh
+ false
+
+
diff --git a/commons-packet/pom.xml b/commons-packet/pom.xml
index 2f1031a49d..34e5d01851 100644
--- a/commons-packet/pom.xml
+++ b/commons-packet/pom.xml
@@ -7,7 +7,7 @@
io.mosip.commons
commons-packet
- 1.2.0.3
+ 1.2.0.4-SNAPSHOT
common-packet
Common packet manager for MOSIP
https://github.com/mosip/packet-manager
@@ -27,6 +27,7 @@
3.7.0.1746
3.2.0
2.3
+ 0.7.0
2.0.2.RELEASE
@@ -45,7 +46,7 @@
1.2.0.1
1.2.0.1
2.0.2.RELEASE
- 1.2.0.1
+ 1.2.0.2-SNAPSHOT
**/constant/**,**/config/**,**/httpfilter/**,**/cache/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/**,**/*Utils.java,**/*Validator.java,**/*Helper.java,**/verticle/**,**/VidWriter.java/**,**/masterdata/utils/**,**/spi/**,**/core/http/**,"**/LocationServiceImpl.java","**/RegistrationCenterMachineServiceImpl.java","**/RegistrationCenterServiceImpl.java","**/pridgenerator/**","**/idgenerator/prid","**/proxy/**","**/cryptosignature/**"
**/dto/**,**/entity/**,**/config/**
@@ -55,19 +56,28 @@
commons-packet-service
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
-
+
+
+ ossrh
+ https://central.sonatype.com/repository/maven-snapshots/
+
+
+ ossrh
+ https://central.sonatype.com/api/v1/publisher
+
+
+
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ ${central.publishing.maven.plugin.version}
+ true
+
+ ossrh
+ false
+
+
org.apache.maven.plugins
maven-surefire-plugin
@@ -155,27 +165,6 @@
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
-
- default-deploy
- deploy
-
- deploy
-
-
-
-
- ossrh
- https://oss.sonatype.org/
- false
-
-
-
org.apache.maven.plugins
maven-source-plugin