Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the digital card service #851

Open
wants to merge 2 commits into
base: 1.1.5.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
yashmsonkusare marked this conversation as resolved.
Show resolved Hide resolved
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
Expand All @@ -179,14 +182,15 @@ private void getImageData(JSONArray documents, Map<String, String> applicantData
String individualBiometrics = utility.getJSONValue(documentObj, VALUE);
List<String> 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);
String encodedBytes = StringUtils.newStringUtf8(Base64.encodeBase64(data, false));
String imageData = "data:image/png;base64," + encodedBytes;
applicantDataMap.put(ApplicantPhoto, imageData);
} else {
auditUtil.setAuditRequestDto(EventEnum.APPLICANT_VERIFICATION_ERROR,null);
yashmsonkusare marked this conversation as resolved.
Show resolved Hide resolved
throw new DataNotFoundException(ApplicantDetailErrorCode.DATA_NOT_FOUND.getErrorCode(), ApplicantDetailErrorCode.DATA_NOT_FOUND.getErrorMessage());
}
}
Expand Down