Updated code
This commit is contained in:
@@ -1080,7 +1080,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,0L,0L);
|
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));
|
||||||
}
|
}
|
||||||
@@ -1244,7 +1244,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,0L,0L);
|
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());
|
||||||
@@ -1252,7 +1252,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signedDocument != null) {
|
if (signedDocument != null) {
|
||||||
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId,0L,0L);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1528,10 +1528,10 @@ public class ApplicationEvaluationDao {
|
|||||||
List<EvaluationDocumentRequest> docRequest) {
|
List<EvaluationDocumentRequest> docRequest) {
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional=applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
Optional<ApplicationEvaluationEntity> entityOptional=applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
||||||
ApplicationEvaluationEntity applicationEvaluationEntity =null;
|
ApplicationEvaluationEntity applicationEvaluationEntity =null;
|
||||||
if(entityOptional.isPresent()) {
|
ApplicationEvaluationEntity oldApplicationEvaluation = Utils.getClonedEntityForData(entityOptional.get());
|
||||||
applicationEvaluationEntity = entityOptional.get();
|
applicationEvaluationEntity = entityOptional.get();
|
||||||
|
|
||||||
if (docRequest != null) {
|
if (docRequest != null) {
|
||||||
// String existingEvaluationDocJson = applicationEvaluationEntity.getEvaluationDocument();
|
|
||||||
List<EvaluationDocumentRequest> existingDocs = new ArrayList<>();
|
List<EvaluationDocumentRequest> existingDocs = new ArrayList<>();
|
||||||
|
|
||||||
for (EvaluationDocumentRequest doc : docRequest) {
|
for (EvaluationDocumentRequest doc : docRequest) {
|
||||||
@@ -1544,8 +1544,10 @@ public class ApplicationEvaluationDao {
|
|||||||
String updatedEvaluationDocJson = Utils.convertObjectToJson(existingDocs);
|
String updatedEvaluationDocJson = Utils.convertObjectToJson(existingDocs);
|
||||||
applicationEvaluationEntity.setEvaluationDocument(updatedEvaluationDocJson);
|
applicationEvaluationEntity.setEvaluationDocument(updatedEvaluationDocJson);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(applicationEvaluationEntity);
|
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(applicationEvaluationEntity);
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Upload Document in Application Evaluation" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluation).newData(savedEntity).build());
|
||||||
return convertToResponse(savedEntity);
|
return convertToResponse(savedEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,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,0L,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);
|
||||||
|
|||||||
@@ -92,7 +92,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,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);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class DocumentDao {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ public class DocumentDao {
|
|||||||
callId = applicationEntity.getCall().getId();
|
callId = applicationEntity.getCall().getId();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String s3Path = generateS3Path(type, callId, applicationId, amendmentId, evaluationId);
|
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) {
|
||||||
@@ -166,9 +167,9 @@ public class DocumentDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId,Long evaluationId) {
|
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId) {
|
||||||
try {
|
try {
|
||||||
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId,evaluationId);
|
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));
|
||||||
}
|
}
|
||||||
@@ -218,8 +219,7 @@ public class DocumentDao {
|
|||||||
applicationId = applicationEntity.getId();
|
applicationId = applicationEntity.getId();
|
||||||
callId = applicationEntity.getCall().getId();
|
callId = applicationEntity.getCall().getId();
|
||||||
}
|
}
|
||||||
|
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId);
|
||||||
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId,evaluationId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ public class DocumentDao {
|
|||||||
callId = id;
|
callId = id;
|
||||||
applicationId = 0L;
|
applicationId = 0L;
|
||||||
}
|
}
|
||||||
String s3Path = generateS3Path(type, callId, applicationId,amendmentId,evaluationId);
|
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) {
|
||||||
@@ -290,12 +290,12 @@ public class DocumentDao {
|
|||||||
return callDao.convertToDocumentResponseBean(documentEntity);
|
return callDao.convertToDocumentResponseBean(documentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
|
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
DocumentEntity oldDocumentEntity = Utils.getClonedEntityForData(documentEntity);
|
DocumentEntity oldDocumentEntity = Utils.getClonedEntityForData(documentEntity);
|
||||||
String oldS3Path = documentEntity.getFilePath();
|
String oldS3Path = documentEntity.getFilePath();
|
||||||
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId,evaluationId);
|
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId);
|
||||||
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(documentEntity.getFileName(), oldS3Path, newS3Path);
|
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(documentEntity.getFileName(), oldS3Path, newS3Path);
|
||||||
documentEntity.setFileName(response.getFileName());
|
documentEntity.setFileName(response.getFileName());
|
||||||
documentEntity.setFilePath(response.getFilePath());
|
documentEntity.setFilePath(response.getFilePath());
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ public class S3PathConfig {
|
|||||||
@Autowired
|
@Autowired
|
||||||
S3ConfigRepository s3ConfigRepository;
|
S3ConfigRepository s3ConfigRepository;
|
||||||
|
|
||||||
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
|
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,amendmentId);
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
|
||||||
}
|
}
|
||||||
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
|
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,amendmentId);
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class S3ReUploadMigrationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId,evaluationId);
|
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId);
|
||||||
processDocuments++;
|
processDocuments++;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -219,10 +219,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,0L,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(),0L,0L);
|
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class UserSignedAndDelegationServiceImpl {
|
|||||||
|
|
||||||
private String generateNewS3PathForDelegationDoc() {
|
private String generateNewS3PathForDelegationDoc() {
|
||||||
|
|
||||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L,0l);
|
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
||||||
|
|||||||
Reference in New Issue
Block a user