diff --git a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java index f14ab575f90..5de2fcca709 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java @@ -162,4 +162,7 @@ private ResidentConstants() { public static final String CHECK_STATUS_ID = "resident.checkstatus.id"; public static final String CHECK_STATUS_VERSION = "resident.checkstatus.version"; + public static final String CHECK_STATUS_INDIVIDUAL_ID = "mosip.resident.checkstatus.individualid.id"; + public static final String CHECKSTATUS_INDIVIDUALID_VERSION = "mosip.resident.checkstatus.individualid.version"; + } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index 6d15baf57f0..1e4e90cba9c 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -35,6 +35,7 @@ import reactor.util.function.Tuple3; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.Objects; /** @@ -71,10 +72,6 @@ public ResponseEntity downloadCard(@Validated @RequestBody MainRequestDT Tuple3> tupleResponse = (Tuple3>) downloadCardService.getDownloadCardPDF(downloadCardRequestDTOMainRequestDTO); - ResponseWrapper checkStatusResponse = tupleResponse.getT3(); - if(checkStatusResponse.getResponse() != null){ - return ResponseEntity.badRequest().body(checkStatusResponse); - } InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(tupleResponse.getT1())); if(tupleResponse.getT1().length==0){ throw new CardNotReadyException(); @@ -117,4 +114,11 @@ public ResponseEntity requestVidCard(@PathVariable("VID") String vid) th .header(ResidentConstants.EVENT_ID, tupleResponse.getT2()) .body(tupleResponse.getT1()); } + + @GetMapping("/status/individualId/{individualId}") + public ResponseEntity getStatus(@PathVariable("individualId") String individualId) throws BaseCheckedException, IOException { + ResponseWrapper responseWrapper = downloadCardService.getIndividualIdStatus(individualId); + return ResponseEntity.ok() + .body(responseWrapper); + } } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/dto/CheckStatusResponseDTO.java b/resident/resident-service/src/main/java/io/mosip/resident/dto/CheckStatusResponseDTO.java index d19b4b36517..f57b7c45f0c 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/dto/CheckStatusResponseDTO.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/dto/CheckStatusResponseDTO.java @@ -11,8 +11,6 @@ @Data public class CheckStatusResponseDTO { - private String individualId; - private String transactionID; private String transactionStage; private String aidStatus; } \ No newline at end of file diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java index 15663a3ccfd..fd6120f3335 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java @@ -7,9 +7,12 @@ import io.mosip.resident.dto.MainRequestDTO; import io.mosip.resident.dto.ResponseWrapper; import io.mosip.resident.dto.VidDownloadCardResponseDto; +import io.mosip.resident.exception.ApisResourceAccessException; import reactor.util.function.Tuple2; import reactor.util.function.Tuple3; +import java.io.IOException; + /** * This class is used to create service class to download uin card. * @Author Kamesh Shekhar Prasad @@ -20,4 +23,6 @@ public interface DownloadCardService { Tuple2 downloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO); Tuple2, String> getVidCardEventId(String vid) throws BaseCheckedException; + + ResponseWrapper getIndividualIdStatus(String vid) throws ApisResourceAccessException, IOException; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java index e56e81c0d11..4bcacf8a356 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Map; -import io.mosip.resident.constant.TransactionStage; import io.mosip.resident.dto.CheckStatusResponseDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -130,17 +129,7 @@ public Tuple3> getDownlo String idType = identityService.getIndividualIdType(individualId); if (idType.equalsIgnoreCase(AID)) { rid = individualId; - HashMap packetStatusMap = utilities.getPacketStatus(rid); - String aidStatus = packetStatusMap.get(ResidentConstants.AID_STATUS); - String transactionStage = packetStatusMap.get(ResidentConstants.TRANSACTION_TYPE_CODE); - if(aidStatus.equalsIgnoreCase(EventStatus.SUCCESS.name()) && - transactionStage.equalsIgnoreCase(CARD_READY_TO_DOWNLOAD)){ - pdfBytes = residentService.getUINCard(rid); - } else{ - checkStatusResponseDTOResponseWrapper = - getCheckStatusResponse(packetStatusMap, - downloadCardRequestDTOMainRequestDTO); - } + pdfBytes = residentService.getUINCard(rid); } else if (idType.equalsIgnoreCase(VID)) { ResidentTransactionEntity residentTransactionEntity = residentTransactionRepository.findTopByAidOrderByCrDtimesDesc(individualId); if(residentTransactionEntity !=null ){ @@ -187,20 +176,16 @@ public Tuple3> getDownlo return Tuples.of(pdfBytes, eventId, checkStatusResponseDTOResponseWrapper); } - private ResponseWrapper getCheckStatusResponse(HashMap packetStatusMap, - MainRequestDTO - downloadCardRequestDTOMainRequestDTO) { + private ResponseWrapper getCheckStatusResponse(HashMap packetStatusMap) { ResponseWrapper checkStatusResponseDTOResponseWrapper = new ResponseWrapper<>(); CheckStatusResponseDTO checkStatusResponseDTO = new CheckStatusResponseDTO(); String aidStatus = packetStatusMap.get(ResidentConstants.AID_STATUS); String transactionStage = packetStatusMap.get(ResidentConstants.TRANSACTION_TYPE_CODE); checkStatusResponseDTO.setAidStatus(aidStatus); - checkStatusResponseDTO.setTransactionID(downloadCardRequestDTOMainRequestDTO.getRequest().getTransactionId()); checkStatusResponseDTO.setTransactionStage(transactionStage); - checkStatusResponseDTO.setIndividualId(downloadCardRequestDTOMainRequestDTO.getRequest().getIndividualId()); checkStatusResponseDTOResponseWrapper.setResponse(checkStatusResponseDTO); - checkStatusResponseDTOResponseWrapper.setId(this.environment.getProperty(ResidentConstants.CHECK_STATUS_ID)); - checkStatusResponseDTOResponseWrapper.setVersion(this.environment.getProperty(ResidentConstants.CHECK_STATUS_VERSION)); + checkStatusResponseDTOResponseWrapper.setId(this.environment.getProperty(ResidentConstants.CHECK_STATUS_INDIVIDUAL_ID)); + checkStatusResponseDTOResponseWrapper.setVersion(this.environment.getProperty(ResidentConstants.CHECKSTATUS_INDIVIDUALID_VERSION)); return checkStatusResponseDTOResponseWrapper; } @@ -397,6 +382,12 @@ public Tuple2, String> getVidCardEve return Tuples.of(responseWrapper, eventId); } + @Override + public ResponseWrapper getIndividualIdStatus(String individualId) throws ApisResourceAccessException, IOException { + HashMap packetStatusMap = utilities.getPacketStatus(individualId); + return getCheckStatusResponse(packetStatusMap); + } + private ResidentTransactionEntity insertDataForVidCard(String vid) throws ApisResourceAccessException, IOException { ResidentTransactionEntity residentTransactionEntity = utilitiy.createEntity(); String uin = utilities.getUinByVid(vid); diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java index 8858b3ef454..6090381ef81 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java @@ -168,7 +168,6 @@ public void testGetDownloadCardPdfAID() throws ApisResourceAccessException, IOEx HashMap hashMap = new HashMap<>(); hashMap.put(ResidentConstants.AID_STATUS, "SUCCESS"); hashMap.put(ResidentConstants.TRANSACTION_TYPE_CODE, "SUCCESS"); - Mockito.when(utilities.getPacketStatus(Mockito.anyString())).thenReturn(hashMap); Mockito.when(identityService.getIndividualIdType(Mockito.anyString())).thenReturn("AID"); Tuple2 actualResult = downloadCardService.getDownloadCardPDF(downloadCardRequestDTOMainRequestDTO); assertNotNull(actualResult.getT1());