From 9906bdb772ce1f37b54d261b14f5065713e6e2f9 Mon Sep 17 00:00:00 2001 From: Sreenadh S <32409698+sree96@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:15:46 +0530 Subject: [PATCH] [INJIVER-587] - move vp-result to different controller Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com> --- .../verify/controller/VPResultController.java | 38 +++++++++++++++++++ .../controller/VPSubmissionController.java | 15 -------- 2 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 verify-service/src/main/java/io/inji/verify/controller/VPResultController.java diff --git a/verify-service/src/main/java/io/inji/verify/controller/VPResultController.java b/verify-service/src/main/java/io/inji/verify/controller/VPResultController.java new file mode 100644 index 00000000..49795636 --- /dev/null +++ b/verify-service/src/main/java/io/inji/verify/controller/VPResultController.java @@ -0,0 +1,38 @@ +package io.inji.verify.controller; + +import io.inji.verify.dto.submission.VPTokenResultDto; +import io.inji.verify.enums.ErrorCode; +import io.inji.verify.shared.Constants; +import io.inji.verify.spi.VerifiablePresentationRequestService; +import io.inji.verify.spi.VerifiablePresentationSubmissionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +@RestController +public class VPResultController { + @Autowired + VerifiablePresentationRequestService verifiablePresentationRequestService; + + @Autowired + VerifiablePresentationSubmissionService verifiablePresentationSubmissionService; + + @GetMapping(path = "/vp-result/{transactionId}") + public ResponseEntity getVPResult(@PathVariable String transactionId) { + List requestIds = verifiablePresentationRequestService.getLatestRequestIdFor(transactionId); + + if (requestIds.isEmpty()) { + return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_100, Constants.ERR_100), HttpStatus.OK); + } + + VPTokenResultDto result = verifiablePresentationSubmissionService.getVPResult(requestIds,transactionId); + if (result != null) { + return new ResponseEntity<>(result, HttpStatus.OK); + } + return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_101, Constants.ERR_101),HttpStatus.OK); + } +} diff --git a/verify-service/src/main/java/io/inji/verify/controller/VPSubmissionController.java b/verify-service/src/main/java/io/inji/verify/controller/VPSubmissionController.java index 3ac76c7a..cbcafbcb 100644 --- a/verify-service/src/main/java/io/inji/verify/controller/VPSubmissionController.java +++ b/verify-service/src/main/java/io/inji/verify/controller/VPSubmissionController.java @@ -31,21 +31,6 @@ public class VPSubmissionController { @Autowired Gson gson; - @GetMapping(path = "/result/{transactionId}") - public ResponseEntity getVPResult(@PathVariable String transactionId) { - List requestIds = verifiablePresentationRequestService.getLatestRequestIdFor(transactionId); - - if (requestIds.isEmpty()) { - return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_100, Constants.ERR_100),HttpStatus.OK); - } - - VPTokenResultDto result = verifiablePresentationSubmissionService.getVPResult(requestIds,transactionId); - if (result != null) { - return new ResponseEntity<>(result, HttpStatus.OK); - } - return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_101, Constants.ERR_101),HttpStatus.OK); - } - @PostMapping(path = Constants.RESPONSE_SUBMISSION_URI, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public ResponseEntity submitVP(@RequestParam(value = "vp_token") String vpToken, @RequestParam(value = "presentation_submission") String presentationSubmission, @RequestParam(value = "state") String state) { PresentationSubmissionDto presentationSubmissionDto = gson.fromJson(presentationSubmission, PresentationSubmissionDto.class);