LOG.debug("Saved kycInfo in db: investorId: {}, kycUuid: {}, isKycComplete: {}", kycInfo.getInvestorId(), kycInfo.getKycUuid(), kycInfo.isKycComplete()); } catch (DataIntegrityViolationException e) { LOG.info("KycInfo for investor was already saved to database.", investorId);
/** * Completes the KYC process for the specified investor * @param investorId The id of the investor for whom the KYC should be completed * @param requestContext The context of the request that called this endpoint * @return A DTO containing the investor id and a boolean for success or failure * @throws NonexistentInvestorException if the specified investor does not exist * @throws KycAlreadyCompletedException if KYC was already completed for this investor */ @RequestMapping(value = "/kyc/{investorId}/complete", method = POST, produces = APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<CompleteSingleKycResponseDTO> setInvestorComplete(@PathVariable("investorId") Long investorId, @Context HttpServletRequest requestContext) throws NonexistentInvestorException, KycAlreadyCompletedException { String ipAddress = IPAddressUtil.getIPAddress(requestContext); LOG.info("/complete called from {} with investorId {}", ipAddress, investorId); try { KycInfo kycInfo = kycInfoService.getKycInfoByInvestorId(investorId); if(kycInfo.isKycComplete()) { throw new KycAlreadyCompletedException(); } else { // Complete KYC kycInfoService.setKycComplete(investorId, true); return ResponseEntity .status(HttpStatus.OK) .body(new CompleteSingleKycResponseDTO(investorId, true)); } } catch(InvestorNotFoundException e) { // KYC Process not yet started throw new NonexistentInvestorException(); } }
throw new KycNotYetStartedException(); if(kycInfo.isKycComplete()) { throw new KycAlreadyCompletedException();
boolean isKycComplete = kycInfo.isKycComplete(); if(!isKycComplete) {
private void assertKycInfo(KycInfo kycInfo, long investorId, boolean isKycStartEmailSent, int noOfRemindersSent, boolean isKycComplete, URI kycUri) { assertEquals(investorId, (long) kycInfo.getInvestorId()); assertEquals(isKycStartEmailSent, kycInfo.isStartKycEmailSent()); assertEquals(noOfRemindersSent, (int) kycInfo.getNoOfRemindersSent()); assertEquals(isKycComplete, kycInfo.isKycComplete()); assertEquals(kycUri.toASCIIString(), kycInfo.getKycUri()); }