Pre Instructor must be able to download all the File inserted by beneficiary in a ZIp
This commit is contained in:
@@ -200,6 +200,18 @@ public interface ApplicationApi {
|
||||
ResponseEntity<Response<ApplicationResponse>> validateApplication(HttpServletRequest request,
|
||||
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
|
||||
|
||||
|
||||
@Operation(summary = "Api to download all the File inserted by beneficiary in a ZIP file",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))
|
||||
})
|
||||
@GetMapping(value = "/{applicationId}/documents/zip")
|
||||
ResponseEntity<byte[]> downloadApplicationDocumentsAsZip(HttpServletRequest httpServletRequest,
|
||||
@Parameter(required = true) @PathVariable("applicationId") Long applicationId);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,5 +148,21 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<byte[]> downloadApplicationDocumentsAsZip(HttpServletRequest request, Long applicationId) {
|
||||
byte[] zipFile = applicationService.downloadApplicationDocumentsAsZip(request, applicationId);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
headers.setContentDispositionFormData("attachment", "documents.zip");
|
||||
|
||||
if (zipFile == null || zipFile.length == 0) {
|
||||
String notFoundMessage = Translator.toLocale(GepafinConstant.APPLICATION_DOCUMENTS_NOT_FOUND_MSG);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(notFoundMessage.getBytes());
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(zipFile, headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user