Amendment Documents
This commit is contained in:
@@ -983,7 +983,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
private String generateS3PathForDelegation(Long callId, Long applicationId) {
|
private String generateS3PathForDelegation(Long callId, Long applicationId) {
|
||||||
try {
|
try {
|
||||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId);
|
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId,0L);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||||
}
|
}
|
||||||
@@ -1125,7 +1125,7 @@ public class ApplicationDao {
|
|||||||
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
|
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
||||||
|
|
||||||
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, applicationEntity.getCall().getId(), applicationId);
|
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, applicationEntity.getCall().getId(), applicationId,0L);
|
||||||
|
|
||||||
for (DocumentEntity document : documents) {
|
for (DocumentEntity document : documents) {
|
||||||
String fileName = Utils.extractFileName(document.getFilePath());
|
String fileName = Utils.extractFileName(document.getFilePath());
|
||||||
@@ -1133,7 +1133,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signedDocument != null) {
|
if (signedDocument != null) {
|
||||||
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId);
|
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId,0L);
|
||||||
String signedDocFileName = signedDocument.getFileName();
|
String signedDocFileName = signedDocument.getFileName();
|
||||||
addDocumentToZip(zos, signedDocS3Folder, signedDocument.getFilePath(), signedDocFileName);
|
addDocumentToZip(zos, signedDocS3Folder, signedDocument.getFilePath(), signedDocFileName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,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);
|
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L,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);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class DelegationDao {
|
|||||||
|
|
||||||
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.TEMPLATE, 0L, 0L);
|
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 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);
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
|||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
|
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
@@ -50,11 +52,16 @@ public class DocumentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
ApplicationService applicationService;
|
ApplicationService applicationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ApplicationAmendmentRequestService applicationAmendmentRequestService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||||
|
|
||||||
@Value("${aws.s3.bucket.name}")
|
@Value("${aws.s3.bucket.name}")
|
||||||
private String bucketName;
|
private String bucketName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Value("${aws.s3.url.folder}")
|
// @Value("${aws.s3.url.folder}")
|
||||||
// private String s3Folder;
|
// private String s3Folder;
|
||||||
|
|
||||||
@@ -77,30 +84,38 @@ public class DocumentDao {
|
|||||||
documentRepository.saveAll(documentEntities);
|
documentRepository.saveAll(documentEntities);
|
||||||
return documentEntities.stream().map(callDao::convertToDocumentResponseBean).collect(Collectors.toList());
|
return documentEntities.stream().map(callDao::convertToDocumentResponseBean).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long sourceId) {
|
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long sourceId) {
|
||||||
|
|
||||||
Long applicationId = 0L;
|
Long applicationId = 0L;
|
||||||
|
Long amendmentId = 0L;
|
||||||
Long callId = sourceId;
|
Long callId = sourceId;
|
||||||
if (type == DocumentSourceTypeEnum.APPLICATION) {
|
if (type == DocumentSourceTypeEnum.APPLICATION) {
|
||||||
applicationId = sourceId;
|
applicationId = sourceId;
|
||||||
callId = applicationFormRepository.findCallIdById(applicationId);
|
callId = applicationFormRepository.findCallIdById(applicationId);
|
||||||
|
} else if (type == DocumentSourceTypeEnum.AMENDMENT) {
|
||||||
|
amendmentId = sourceId;
|
||||||
|
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||||
|
applicationId = applicationEntity.getId();
|
||||||
|
callId = applicationEntity.getCall().getId();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String s3Path = generateS3Path(type, callId, applicationId);
|
String s3Path = generateS3Path(type, callId, applicationId, amendmentId);
|
||||||
log.info("Generated S3 path {}", s3Path);
|
log.info("Generated S3 path {}", s3Path);
|
||||||
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId) {
|
|
||||||
|
|
||||||
|
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId) {
|
||||||
try {
|
try {
|
||||||
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId);
|
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long resolveSourceId(Long sourceId, DocumentSourceTypeEnum sourceType) {
|
private Long resolveSourceId(Long sourceId, DocumentSourceTypeEnum sourceType) {
|
||||||
if (sourceType == DocumentSourceTypeEnum.CALL) {
|
if (sourceType == DocumentSourceTypeEnum.CALL) {
|
||||||
CallEntity callEntity = callService.validateCall(sourceId);
|
CallEntity callEntity = callService.validateCall(sourceId);
|
||||||
@@ -119,16 +134,23 @@ public class DocumentDao {
|
|||||||
DocumentEntity documentEntity = validateDocument(documentId);
|
DocumentEntity documentEntity = validateDocument(documentId);
|
||||||
Long callId = null;
|
Long callId = null;
|
||||||
Long applicationId = null;
|
Long applicationId = null;
|
||||||
|
Long amendmentId = null;
|
||||||
|
|
||||||
if ("CALL".equalsIgnoreCase(documentEntity.getSource())) {
|
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(documentEntity.getSource())) {
|
||||||
callId = documentEntity.getSourceId();
|
callId = documentEntity.getSourceId();
|
||||||
} else if ("APPLICATION".equalsIgnoreCase(documentEntity.getSource())) {
|
} else if (DocumentSourceTypeEnum.APPLICATION.getValue().equalsIgnoreCase(documentEntity.getSource())) {
|
||||||
applicationId = documentEntity.getSourceId();
|
applicationId = documentEntity.getSourceId();
|
||||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||||
callId = applicationEntity.getCall().getId();
|
callId = applicationEntity.getCall().getId();
|
||||||
}
|
}
|
||||||
|
else if(DocumentSourceTypeEnum.AMENDMENT.getValue().equalsIgnoreCase(documentEntity.getSource())){
|
||||||
|
amendmentId = documentEntity.getSourceId();
|
||||||
|
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||||
|
applicationId = applicationEntity.getId();
|
||||||
|
callId = applicationEntity.getCall().getId();
|
||||||
|
}
|
||||||
|
|
||||||
amazonS3Service.deleteFileFromS3(documentEntity,callId,applicationId);
|
amazonS3Service.deleteFileFromS3(documentEntity, callId, applicationId,amendmentId);
|
||||||
documentEntity.setIsDeleted(true);
|
documentEntity.setIsDeleted(true);
|
||||||
documentRepository.save(documentEntity);
|
documentRepository.save(documentEntity);
|
||||||
}
|
}
|
||||||
@@ -152,19 +174,28 @@ public class DocumentDao {
|
|||||||
}
|
}
|
||||||
return callDao.convertToDocumentResponseBean(documentEntity);
|
return callDao.convertToDocumentResponseBean(documentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UploadFileOnAmazonS3Response updateFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long id) {
|
private UploadFileOnAmazonS3Response updateFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long id) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Long callId;
|
Long callId=null;
|
||||||
Long applicationId;
|
Long applicationId=null;
|
||||||
if(type.equals(DocumentSourceTypeEnum.APPLICATION)){
|
Long amendmentId=null;
|
||||||
|
if (type.equals(DocumentSourceTypeEnum.APPLICATION)) {
|
||||||
callId = applicationFormRepository.findCallIdById(id);
|
callId = applicationFormRepository.findCallIdById(id);
|
||||||
applicationId = id;
|
applicationId = id;
|
||||||
}else{
|
}
|
||||||
|
else if(type.equals(DocumentSourceTypeEnum.AMENDMENT)){
|
||||||
|
amendmentId = id;
|
||||||
|
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||||
|
applicationId = applicationEntity.getId();
|
||||||
|
callId = applicationEntity.getCall().getId();
|
||||||
|
}
|
||||||
|
else {
|
||||||
callId = id;
|
callId = id;
|
||||||
applicationId = 0L;
|
applicationId = 0L;
|
||||||
}
|
}
|
||||||
String s3Path = generateS3Path(type, callId, applicationId);
|
String s3Path = generateS3Path(type, callId, applicationId,amendmentId);
|
||||||
log.info("Generated S3 path {}", s3Path);
|
log.info("Generated S3 path {}", s3Path);
|
||||||
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -13,25 +13,28 @@ public class S3PathConfig {
|
|||||||
@Autowired
|
@Autowired
|
||||||
S3ConfigRepository s3ConfigRepository;
|
S3ConfigRepository s3ConfigRepository;
|
||||||
|
|
||||||
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId) {
|
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
|
||||||
|
|
||||||
S3ConfigEntity config = getDocumentPath(type);
|
S3ConfigEntity config = getDocumentPath(type);
|
||||||
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
|
||||||
}
|
}
|
||||||
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId) {
|
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
|
||||||
|
|
||||||
S3ConfigEntity config = getDocumentPathForOther(type);
|
S3ConfigEntity config = getDocumentPathForOther(type);
|
||||||
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
|
||||||
}
|
|
||||||
private String buildS3Path(String pathTemplate, Long callId, Long applicationId) {
|
|
||||||
|
|
||||||
return pathTemplate.replace("{call_id}", callId != null && callId != 0L ? "call_" + callId : "").replace("{application_id}", applicationId != null && applicationId != 0L ? "application_" + applicationId : "");
|
|
||||||
}
|
}
|
||||||
public String generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum type) {
|
public String generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum type) {
|
||||||
|
|
||||||
S3ConfigEntity config = getDocumentPathForOther(type);
|
S3ConfigEntity config = getDocumentPathForOther(type);
|
||||||
return config.getParentFolder() + "/" + config.getPath();
|
return config.getParentFolder() + "/" + config.getPath();
|
||||||
}
|
}
|
||||||
|
private String buildS3Path(String pathTemplate, Long callId, Long applicationId, Long amendmentId) {
|
||||||
|
return pathTemplate
|
||||||
|
.replace("{call_id}", callId != null && callId != 0L ? "call_" + callId : "")
|
||||||
|
.replace("{application_id}", applicationId != null && applicationId != 0L ? "application_" + applicationId : "")
|
||||||
|
.replace("{amendment_id}", amendmentId != null && amendmentId != 0L ? "amendment_" + amendmentId : "");
|
||||||
|
}
|
||||||
|
|
||||||
private S3ConfigEntity getDocumentPath(DocumentSourceTypeEnum type) {
|
private S3ConfigEntity getDocumentPath(DocumentSourceTypeEnum type) {
|
||||||
|
|
||||||
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ public enum DocOtherSourceTypeEnum {
|
|||||||
TEMPLATE("TEMPLATE"),
|
TEMPLATE("TEMPLATE"),
|
||||||
DELETED_USER_DELEGATION("DELETED_USER_DELEGATION"),
|
DELETED_USER_DELEGATION("DELETED_USER_DELEGATION"),
|
||||||
DELETED_APPLICATION("DELETED_APPLICATION"),
|
DELETED_APPLICATION("DELETED_APPLICATION"),
|
||||||
DELETED_CALL("DELETED_CALL");
|
DELETED_CALL("DELETED_CALL"),
|
||||||
|
DELETED_AMENDMENT("DELETED_AMENDMENT");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package net.gepafin.tendermanagement.enums;
|
|||||||
public enum DocumentSourceTypeEnum {
|
public enum DocumentSourceTypeEnum {
|
||||||
CALL("CALL"),
|
CALL("CALL"),
|
||||||
|
|
||||||
APPLICATION("APPLICATION");
|
APPLICATION("APPLICATION"),
|
||||||
|
|
||||||
|
AMENDMENT("AMENDMENT");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@@ -34,4 +35,12 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
|||||||
|
|
||||||
List<ApplicationAmendmentRequestEntity> findByApplicationIdAndStatusInAndIsDeletedFalse(Long applicationId, List<String> statuses);
|
List<ApplicationAmendmentRequestEntity> findByApplicationIdAndStatusInAndIsDeletedFalse(Long applicationId, List<String> statuses);
|
||||||
|
|
||||||
|
@Query("SELECT app " +
|
||||||
|
"FROM ApplicationEntity app " +
|
||||||
|
"WHERE app.id = (SELECT aar.applicationId " +
|
||||||
|
"FROM ApplicationAmendmentRequestEntity aar " +
|
||||||
|
"WHERE aar.id = :amendmentId)")
|
||||||
|
ApplicationEntity findApplicationByAmendmentId(Long amendmentId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package net.gepafin.tendermanagement.service;
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||||
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
@@ -21,7 +20,7 @@ AmazonS3Service {
|
|||||||
|
|
||||||
InputStream getFile(String s3Folder, String filePath) throws IOException;
|
InputStream getFile(String s3Folder, String filePath) throws IOException;
|
||||||
|
|
||||||
String generateS3PathForDeletedDocument(DocOtherSourceTypeEnum typeOfDocument, Long callId, Long applicationId);
|
String generateS3PathForDeletedDocument(DocOtherSourceTypeEnum typeOfDocument, Long callId, Long applicationId,Long amendmentId);
|
||||||
|
|
||||||
String generateS3PathForDeletedDocumentForOther();
|
String generateS3PathForDeletedDocumentForOther();
|
||||||
|
|
||||||
@@ -29,6 +28,6 @@ AmazonS3Service {
|
|||||||
|
|
||||||
void deleteDelegationfromS3(UserCompanyDelegationEntity userCompanyDelegationEntity);
|
void deleteDelegationfromS3(UserCompanyDelegationEntity userCompanyDelegationEntity);
|
||||||
|
|
||||||
void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId);
|
void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -146,9 +146,9 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateS3PathForDeletedDocument(DocOtherSourceTypeEnum typeOfDocument, Long callId, Long applicationId) {
|
public String generateS3PathForDeletedDocument(DocOtherSourceTypeEnum typeOfDocument, Long callId, Long applicationId,Long amendmentId) {
|
||||||
try {
|
try {
|
||||||
return s3ConfigBean.generateDocumentPathForOther(typeOfDocument, callId, applicationId);
|
return s3ConfigBean.generateDocumentPathForOther(typeOfDocument, callId, applicationId,amendmentId);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new CustomValidationException(
|
throw new CustomValidationException(
|
||||||
Status.VALIDATION_ERROR,
|
Status.VALIDATION_ERROR,
|
||||||
@@ -207,10 +207,10 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId) {
|
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId) {
|
||||||
try {
|
try {
|
||||||
String oldS3Path = documentEntity.getFilePath();
|
String oldS3Path = documentEntity.getFilePath();
|
||||||
String newS3Path = generateS3PathForDeletedDocument(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId)
|
String newS3Path = generateS3PathForDeletedDocument(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId)
|
||||||
+ "/" + oldS3Path.substring(oldS3Path.lastIndexOf("/") + 1);
|
+ "/" + oldS3Path.substring(oldS3Path.lastIndexOf("/") + 1);
|
||||||
String bucketUrlPrefix = getBucketUrlPrefix();
|
String bucketUrlPrefix = getBucketUrlPrefix();
|
||||||
if (oldS3Path.startsWith(bucketUrlPrefix)) {
|
if (oldS3Path.startsWith(bucketUrlPrefix)) {
|
||||||
@@ -224,6 +224,4 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
throw new CustomValidationException(Status.VALIDATION_ERROR, "Error occurred while moving file to deleted folder.");
|
throw new CustomValidationException(Status.VALIDATION_ERROR, "Error occurred while moving file to deleted folder.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -164,10 +164,10 @@ public class S3ReUploadMigrationService {
|
|||||||
Long callId;
|
Long callId;
|
||||||
|
|
||||||
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
|
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
|
||||||
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L);
|
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L);
|
||||||
} else {
|
} else {
|
||||||
callId = applicationRepository.findCallIdById(document.getSourceId());
|
callId = applicationRepository.findCallIdById(document.getSourceId());
|
||||||
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId());
|
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class UserSignedAndDelegationServiceImpl {
|
|||||||
|
|
||||||
private String generateNewS3PathForDelegationDoc() {
|
private String generateNewS3PathForDelegationDoc() {
|
||||||
|
|
||||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
|
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
||||||
|
|||||||
@@ -1803,4 +1803,52 @@
|
|||||||
<column name="MOTIVATION" type="TEXT"></column>
|
<column name="MOTIVATION" type="TEXT"></column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="28-10-2024_1" author="Nisha Kashyap">
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="DELETED_CALL"/>
|
||||||
|
<column name="path" value="call/{call_id}/deleted"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/local"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="DELETED_APPLICATION"/>
|
||||||
|
<column name="path" value="call/{call_id}/application/{application_id}/deleted"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/local"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="DELETED_USER_DELEGATION"/>
|
||||||
|
<column name="path" value="user_delegation/deleted"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/local"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="AMENDMENT"/>
|
||||||
|
<column name="path" value="call/{call_id}/application/{application_id}/amendment/{amendment_id}"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/local"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="DELETED_AMENDMENT"/>
|
||||||
|
<column name="path" value="call/{call_id}/application/{application_id}/amendment/{amendment_id}/deleted"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/local"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
Reference in New Issue
Block a user