From fcdfc390b2d7c836d89d2c729226edc357a55730 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar <43202851+sowmya695@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:45:52 +0530 Subject: [PATCH] MOSIP-28185 Code fix for notification (#1782) Co-authored-by: Sowmya Ujjappa Banakar --- .../impl/MessageNotificationServiceImpl.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java b/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java index cd551b37bd3..f40c06d1fa9 100644 --- a/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java +++ b/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java @@ -7,6 +7,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -74,7 +75,6 @@ import io.mosip.registration.processor.message.sender.exception.TemplateNotFoundException; import io.mosip.registration.processor.message.sender.template.TemplateGenerator; import io.mosip.registration.processor.packet.manager.decryptor.Decryptor; -import io.mosip.registration.processor.packet.storage.dto.ConfigEnum; import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; @@ -560,7 +560,7 @@ private Map setAttributes(String idJsonString, Map setAttributesFromIdJson(String id, String process, M String regType, String lang, StringBuilder phoneNumber, StringBuilder emailId) throws IOException, ApisResourceAccessException, PacketManagerException, JsonProcessingException, JSONException, PacketDecryptionFailureException, JsonParseException, JsonMappingException, io.mosip.kernel.core.exception.IOException { - JSONObject mapperIdentity = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); - + if (mapperJsonKeys == null) { + String mapperJsonString = Utilities.getJson(utility.getConfigServerFileStorageURL(), + utility.getGetRegProcessorIdentityJson()); + JSONObject mapperJson = JsonUtil.objectMapperReadValue(mapperJsonString, JSONObject.class); + mapperIdentity = JsonUtil.getJSONObject(mapperJson, utility.getGetRegProcessorDemographicIdentity()); + mapperJsonKeys = new ArrayList<>(mapperIdentity.keySet()); + } List mapperJsonValues = new ArrayList<>(); - JsonUtil.getJSONValue(JsonUtil.getJSONObject(mapperIdentity, MappingJsonConstants.INDIVIDUAL_BIOMETRICS), VALUE); - mapperIdentity.keySet().forEach(key -> mapperJsonValues.add(JsonUtil.getJSONValue(JsonUtil.getJSONObject(mapperIdentity, key), VALUE))); - - String source = utility.getDefaultSource(process, ConfigEnum.READER); + for (String key : mapperJsonKeys) { + JSONObject jsonValue = JsonUtil.getJSONObject(mapperIdentity, key); + if (jsonValue.get(VALUE) != null && !jsonValue.get(VALUE).toString().isBlank()) { + String[] valueArray = jsonValue.get(VALUE).toString().split(","); + mapperJsonValues.addAll(new ArrayList(Arrays.asList(valueArray))); + } + } Map fieldMap =null; try { fieldMap = packetManagerService.getFields(id, mapperJsonValues, process, ProviderStageName.MESSAGE_SENDER); @@ -640,7 +648,7 @@ else if (json instanceof org.json.JSONArray) { Object obj = jsonArray.get(i); JsonValue jsonValue = mapper.readValue(obj.toString(), JsonValue.class); if(jsonValue.getLanguage().equalsIgnoreCase(lang)) { - attribute.putIfAbsent(e.getKey().toString(), jsonValue.getValue()); + attribute.putIfAbsent(e.getKey().toString() + "_" + lang, jsonValue.getValue()); } } } else