| Line 627... |
Line 627... |
| 627 |
return "response";
|
627 |
return "response";
|
| 628 |
}
|
628 |
}
|
| 629 |
|
629 |
|
| 630 |
@RequestMapping(value = "/admin/policy/certificate", method = RequestMethod.GET)
|
630 |
@RequestMapping(value = "/admin/policy/certificate", method = RequestMethod.GET)
|
| 631 |
public ResponseEntity<byte[]> downloadPolicyCertificate(HttpServletRequest request,
|
631 |
public ResponseEntity<byte[]> downloadPolicyCertificate(HttpServletRequest request,
|
| - |
|
632 |
@RequestParam(required = false) String policyNumber,
|
| 632 |
@RequestParam String policyNumber) throws Exception {
|
633 |
@RequestParam(required = false) String proposalNumber) throws Exception {
|
| 633 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
634 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 634 |
if (!roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
635 |
if (!roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
| 635 |
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
636 |
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
| 636 |
}
|
637 |
}
|
| 637 |
|
638 |
|
| - |
|
639 |
if ((policyNumber == null || policyNumber.isEmpty())
|
| - |
|
640 |
&& (proposalNumber == null || proposalNumber.isEmpty())) {
|
| - |
|
641 |
return ResponseEntity.badRequest().build();
|
| - |
|
642 |
}
|
| - |
|
643 |
|
| - |
|
644 |
// If policyNumber wasn't given, resolve it from proposalNumber first.
|
| - |
|
645 |
if (policyNumber == null || policyNumber.isEmpty()) {
|
| - |
|
646 |
policyNumber = iciciLombardService.recoverPolicyNumberByProposalNumber(proposalNumber);
|
| - |
|
647 |
}
|
| - |
|
648 |
|
| 638 |
String filePath = iciciLombardService.fetchPolicyCertificateByPolicyNumber(policyNumber);
|
649 |
String filePath = iciciLombardService.fetchPolicyCertificateByPolicyNumber(policyNumber);
|
| 639 |
byte[] pdfBytes = Files.readAllBytes(new File(filePath).toPath());
|
650 |
byte[] pdfBytes = Files.readAllBytes(new File(filePath).toPath());
|
| 640 |
|
651 |
|
| 641 |
String safeName = "policy-" + policyNumber.replace("/", "-") + ".pdf";
|
652 |
String safeName = "policy-" + policyNumber.replace("/", "-") + ".pdf";
|
| 642 |
HttpHeaders headers = new HttpHeaders();
|
653 |
HttpHeaders headers = new HttpHeaders();
|