Merge pull request #73 from Kitzanos/s3-call-document-download-issue-prod
Fixed S3 call document download issue.
This commit is contained in:
@@ -119,8 +119,8 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder.signed.document}")
|
// @Value("${aws.s3.url.folder.signed.document}")
|
||||||
private String signedDocumentS3Folder;
|
// private String signedDocumentS3Folder;
|
||||||
|
|
||||||
@Value("${default.hub.uuid}")
|
@Value("${default.hub.uuid}")
|
||||||
private String defaultHubUuid;
|
private String defaultHubUuid;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import net.gepafin.tendermanagement.util.DateTimeUtil;
|
|||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import org.h2.util.IOUtils;
|
import org.h2.util.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -94,14 +93,17 @@ public class CallDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FormDao formDao;
|
private FormDao formDao;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder}")
|
// @Value("${aws.s3.url.folder}")
|
||||||
private String s3Folder;
|
// private String s3Folder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AmazonS3Service amazonS3Service;
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private S3PathConfig s3PathConfig;
|
||||||
|
|
||||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||||
@@ -127,6 +129,7 @@ public class CallDao {
|
|||||||
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
||||||
|
|
||||||
for (DocumentEntity document : documents) {
|
for (DocumentEntity document : documents) {
|
||||||
|
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L);
|
||||||
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
|
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
|
||||||
String fileName = Utils.extractFileName(document.getFilePath());
|
String fileName = Utils.extractFileName(document.getFilePath());
|
||||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import java.util.Map;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ public class DelegationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private S3PathConfig s3ConfigBean;
|
private S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder.delegation}")
|
// @Value("${aws.s3.url.folder.delegation}")
|
||||||
private String s3Folder;
|
// private String s3Folder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||||
@@ -67,9 +67,9 @@ public class DelegationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
|
||||||
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
||||||
try {
|
try {
|
||||||
|
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
|
||||||
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
|
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
|
||||||
XWPFDocument doc = loadTemplate(templateStream);
|
XWPFDocument doc = loadTemplate(templateStream);
|
||||||
replacePlaceholders(doc, placeholders);
|
replacePlaceholders(doc, placeholders);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
|||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -49,8 +48,8 @@ public class DocumentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationRepository applicationFormRepository;
|
private ApplicationRepository applicationFormRepository;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder}")
|
// @Value("${aws.s3.url.folder}")
|
||||||
private String s3Folder;
|
// private String s3Folder;
|
||||||
|
|
||||||
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||||
List<DocumentEntity> documentEntities = new ArrayList<>();
|
List<DocumentEntity> documentEntities = new ArrayList<>();
|
||||||
@@ -141,7 +140,7 @@ public class DocumentDao {
|
|||||||
try {
|
try {
|
||||||
Long callId;
|
Long callId;
|
||||||
Long applicationId;
|
Long applicationId;
|
||||||
if(type.equals("APPLICATION")){
|
if(type.equals(DocumentSourceTypeEnum.APPLICATION)){
|
||||||
callId = applicationFormRepository.findCallIdById(id);
|
callId = applicationFormRepository.findCallIdById(id);
|
||||||
applicationId = id;
|
applicationId = id;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ aws.secret.access.key=FtnkzF8E3vtqPrVnloqMyNSUSqg0f9Z9L0R7qQOu
|
|||||||
aws.s3.region=eu-west-1
|
aws.s3.region=eu-west-1
|
||||||
aws.s3.bucket.name=mementoresources
|
aws.s3.bucket.name=mementoresources
|
||||||
aws.s3.url = https://mementoresources.s3.eu-west-1.amazonaws.com/
|
aws.s3.url = https://mementoresources.s3.eu-west-1.amazonaws.com/
|
||||||
aws.s3.url.folder=gepafin
|
#aws.s3.url.folder=gepafin
|
||||||
aws.s3.url.folder.delegation=gepafin/delegation
|
#aws.s3.url.folder.delegation=gepafin/delegation
|
||||||
aws.s3.url.folder.signed.document=gepafin/signed-document
|
#aws.s3.url.folder.signed.document=gepafin/signed-document
|
||||||
# JWT configuration
|
# JWT configuration
|
||||||
# Ensure these values match your expectations
|
# Ensure these values match your expectations
|
||||||
security.authentication.jwt.secret=my-secret-token-to-change-in-prod-environment-your-super-secure-randomly-generated-key
|
security.authentication.jwt.secret=my-secret-token-to-change-in-prod-environment-your-super-secure-randomly-generated-key
|
||||||
|
|||||||
Reference in New Issue
Block a user