From ccfc561235a3844a366e23866505893fbf367f1d Mon Sep 17 00:00:00 2001 From: yashmsonkusare Date: Wed, 5 Apr 2023 16:22:36 +0530 Subject: [PATCH 1/2] Updated the digital card service --- .../io/mosip/admin/packetstatusupdater/util/EventEnum.java | 3 +++ .../admin/service/impl/ApplicantDetailServiceImpl.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/admin-service/src/main/java/io/mosip/admin/packetstatusupdater/util/EventEnum.java b/admin/admin-service/src/main/java/io/mosip/admin/packetstatusupdater/util/EventEnum.java index 33d37ee0df2..305a82b7be2 100644 --- a/admin/admin-service/src/main/java/io/mosip/admin/packetstatusupdater/util/EventEnum.java +++ b/admin/admin-service/src/main/java/io/mosip/admin/packetstatusupdater/util/EventEnum.java @@ -76,6 +76,9 @@ public enum EventEnum { "successfully return the applicantPhoto and dob", "ADM-AVD", "admin service", "NO_ID", "NO_ID_TYPE", AuditConstant.APPLICATION_ID, AuditConstant.APPLICATION_NAME), APPLICANT_VERIFICATION_ERROR("ADM-AVD-503",AuditConstant.AUDIT_SYSTEM,"Request for Applicant Verification","Failed to call Rest api - %s","ADM-AVD","admin service","NO_ID","NO_ID_TYPE",AuditConstant.APPLICATION_ID,AuditConstant.APPLICATION_NAME), + APPLICANT_RID_NOT_FOUND("ADM-AVD-509",AuditConstant.AUDIT_SYSTEM,"Request for Applicant Verification","RID not found","ADM-AVD","admin service","NO_ID","NO_ID_TYPE",AuditConstant.APPLICATION_ID,AuditConstant.APPLICATION_NAME), + APPLICANT_LIMIT_EXCEEDED("ADM-AVD-510",AuditConstant.AUDIT_SYSTEM,"Request for Applicant Verification","Applicant search limit exceeded","ADM-AVD","admin service","NO_ID","NO_ID_TYPE",AuditConstant.APPLICATION_ID,AuditConstant.APPLICATION_NAME), + REQ_ID_NOT_FOUND("ADM-AVD-511",AuditConstant.AUDIT_SYSTEM,"Request for Applicant Verification","Request id not found","ADM-AVD","admin service","NO_ID","NO_ID_TYPE",AuditConstant.APPLICATION_ID,AuditConstant.APPLICATION_NAME), RID_DIGITAL_CARD_REQ_EXCEPTION("ADM-AVD-504",AuditConstant.AUDIT_SYSTEM,"Request for Digital Card","Downloading digital card based on RID failed - %s","ADM-AVD","admin service","NO_ID","NO_ID_TYPE",AuditConstant.APPLICATION_ID,AuditConstant.APPLICATION_NAME), RID_DIGITAL_CARD_REQ("ADM-AVD-505", AuditConstant.AUDIT_SYSTEM, "Request for Digital Card", "API called for Digital card", "ADM-AVD", "Admin service", "NO_ID", "NO_ID_TYPE", diff --git a/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java b/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java index f2399cecbe6..7c5ec683a27 100644 --- a/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java +++ b/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java @@ -91,12 +91,14 @@ public ApplicantDetailsDto getApplicantDetails(String rid) throws Exception { String userId = ((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername(); long count=applicantUserDetailsRepository.countByUserIdAndLoginDate(userId, LocalDate.now()); if((int)count>=maxcount){ + auditUtil.setAuditRequestDto(EventEnum.APPLICANT_LIMIT_EXCEEDED,null); throw new RequestException(ApplicantDetailErrorCode.LIMIT_EXCEEDED.getErrorCode(), ApplicantDetailErrorCode.LIMIT_EXCEEDED.getErrorMessage()); } String response = restClient.getApi(ApiName.RETRIEVE_IDENTITY_API,pathsegments,"type","bio",String.class); JSONObject responseObj= objectMapper.readValue(response,JSONObject.class); if(response!=null && responseObj.get("response")==null) { + auditUtil.setAuditRequestDto(EventEnum.APPLICANT_RID_NOT_FOUND,null); throw new RequestException(ApplicantDetailErrorCode.RID_NOT_FOUND.getErrorCode(), ApplicantDetailErrorCode.RID_NOT_FOUND.getErrorMessage()); } @@ -123,7 +125,7 @@ public ApplicantDetailsDto getApplicantDetails(String rid) throws Exception { throw new RequestException(ApplicantDetailErrorCode.UNABLE_TO_RETRIEVE_RID_DETAILS.getErrorCode(), ApplicantDetailErrorCode.UNABLE_TO_RETRIEVE_RID_DETAILS.getErrorMessage(),e); }catch (InvalidIDException | DataNotFoundException e){ - auditUtil.setAuditRequestDto(EventEnum.APPLICANT_VERIFICATION_ERROR); + auditUtil.setAuditRequestDto(EventEnum.APPLICANT_RID_NOT_FOUND,null); throw new RequestException(e.getErrorCode(), e.getErrorText()); } return applicantDetailsDto; @@ -164,6 +166,7 @@ private DigitalCardStatusResponseDto getDigitialCardStatus(String rid) String response = restClient.getApi(ApiName.DIGITAL_CARD_STATUS_URL,pathsegments,"","",String.class); JSONObject responseObj= objectMapper.readValue(response,JSONObject.class); if(responseObj.containsKey("response") && responseObj.get("response")==null) { + auditUtil.setAuditRequestDto(EventEnum.APPLICANT_VERIFICATION_ERROR,null); throw new MasterDataServiceException(ApplicantDetailErrorCode.REQ_ID_NOT_FOUND.getErrorCode(), ApplicantDetailErrorCode.REQ_ID_NOT_FOUND.getErrorMessage()); } @@ -187,6 +190,7 @@ private void getImageData(JSONArray documents, Map applicantData String imageData = "data:image/png;base64," + encodedBytes; applicantDataMap.put(ApplicantPhoto, imageData); } else { + auditUtil.setAuditRequestDto(EventEnum.APPLICANT_VERIFICATION_ERROR,null); throw new DataNotFoundException(ApplicantDetailErrorCode.DATA_NOT_FOUND.getErrorCode(), ApplicantDetailErrorCode.DATA_NOT_FOUND.getErrorMessage()); } } From 60239339b417aa78da00417d4f9b80ccef1ee43c Mon Sep 17 00:00:00 2001 From: Yash S <119652212+yashmsonkusare@users.noreply.github.com> Date: Wed, 3 May 2023 15:50:29 +0530 Subject: [PATCH 2/2] Updated the condition if the `photoByte` is empty --- .../io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java b/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java index 7c5ec683a27..43e19730611 100644 --- a/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java +++ b/admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java @@ -182,7 +182,7 @@ private void getImageData(JSONArray documents, Map applicantData String individualBiometrics = utility.getJSONValue(documentObj, VALUE); List subtype = new ArrayList<>(); byte[] photoByte = cbeffToBiometricUtil.getImageBytes(individualBiometrics, FACE, subtype); - if (photoByte != null) { + if (photoByte != null && photoByte.length > 0) { convertRequestDto.setVersion("ISO19794_5_2011"); convertRequestDto.setInputBytes(photoByte); byte[] data = FaceDecoder.convertFaceISOToImageBytes(convertRequestDto);