Merge pull request #73 from Kitzanos/s3-call-document-download-issue-prod

Fixed S3 call document download issue.
This commit is contained in:
rbonazzo-KZ
2024-10-29 17:14:56 +01:00
committed by GitHub
5 changed files with 18 additions and 16 deletions

View File

@@ -119,8 +119,8 @@ public class ApplicationDao {
@Autowired
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
@Value("${aws.s3.url.folder.signed.document}")
private String signedDocumentS3Folder;
// @Value("${aws.s3.url.folder.signed.document}")
// private String signedDocumentS3Folder;
@Value("${default.hub.uuid}")
private String defaultHubUuid;

View File

@@ -21,7 +21,6 @@ import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.Utils;
import org.h2.util.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -94,8 +93,8 @@ public class CallDao {
@Autowired
private FormDao formDao;
@Value("${aws.s3.url.folder}")
private String s3Folder;
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
@Autowired
private AmazonS3Service amazonS3Service;
@@ -103,6 +102,9 @@ public class CallDao {
@Autowired
private CriteriaFormFieldRepository criteriaFormFieldRepository;
@Autowired
private S3PathConfig s3PathConfig;
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
@@ -127,6 +129,7 @@ public class CallDao {
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
for (DocumentEntity document : documents) {
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L);
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
String fileName = Utils.extractFileName(document.getFilePath());
ZipEntry zipEntry = new ZipEntry(fileName);

View File

@@ -8,10 +8,10 @@ import java.util.Map;
import java.util.function.Function;
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -58,8 +58,8 @@ public class DelegationDao {
@Autowired
private S3PathConfig s3ConfigBean;
@Value("${aws.s3.url.folder.delegation}")
private String s3Folder;
// @Value("${aws.s3.url.folder.delegation}")
// private String s3Folder;
@Autowired
private UserCompanyDelegationRepository userCompanyDelegationRepository;
@@ -67,9 +67,9 @@ public class DelegationDao {
@Autowired
private Validator validator;
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
try {
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
XWPFDocument doc = loadTemplate(templateStream);
replacePlaceholders(doc, placeholders);

View File

@@ -7,7 +7,6 @@ import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -49,8 +48,8 @@ public class DocumentDao {
@Autowired
private ApplicationRepository applicationFormRepository;
@Value("${aws.s3.url.folder}")
private String s3Folder;
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
List<DocumentEntity> documentEntities = new ArrayList<>();
@@ -141,7 +140,7 @@ public class DocumentDao {
try {
Long callId;
Long applicationId;
if(type.equals("APPLICATION")){
if(type.equals(DocumentSourceTypeEnum.APPLICATION)){
callId = applicationFormRepository.findCallIdById(id);
applicationId = id;
}else{

View File

@@ -30,9 +30,9 @@ aws.secret.access.key=FtnkzF8E3vtqPrVnloqMyNSUSqg0f9Z9L0R7qQOu
aws.s3.region=eu-west-1
aws.s3.bucket.name=mementoresources
aws.s3.url = https://mementoresources.s3.eu-west-1.amazonaws.com/
aws.s3.url.folder=gepafin
aws.s3.url.folder.delegation=gepafin/delegation
aws.s3.url.folder.signed.document=gepafin/signed-document
#aws.s3.url.folder=gepafin
#aws.s3.url.folder.delegation=gepafin/delegation
#aws.s3.url.folder.signed.document=gepafin/signed-document
# JWT configuration
# Ensure these values match your expectations
security.authentication.jwt.secret=my-secret-token-to-change-in-prod-environment-your-super-secure-randomly-generated-key