Added signed documents in Zip
This commit is contained in:
@@ -1008,7 +1008,9 @@ public class ApplicationDao {
|
||||
}
|
||||
});
|
||||
List<DocumentEntity> documents = documentRepository.findAllById(documentIds);
|
||||
if (documents.isEmpty()) {
|
||||
ApplicationSignedDocumentEntity signedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
if (documents.isEmpty() && signedDocument == null) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
|
||||
@@ -1025,6 +1027,17 @@ public class ApplicationDao {
|
||||
throw new RuntimeException("Error downloading or adding document to ZIP: " + document.getFileName(), e);
|
||||
}
|
||||
}
|
||||
if (signedDocument != null) {
|
||||
String s3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId);
|
||||
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, signedDocument.getFilePath())) {
|
||||
String fileName = signedDocument.getFileName();
|
||||
zos.putNextEntry(new ZipEntry(fileName));
|
||||
IOUtils.copy(fileInputStream, zos);
|
||||
zos.closeEntry();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Error downloading or adding signed document to ZIP: " + signedDocument.getFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
zos.finish();
|
||||
return zipOutputStream.toByteArray();
|
||||
|
||||
Reference in New Issue
Block a user