document code updation.
This commit is contained in:
@@ -80,7 +80,7 @@ public class S3ReUploadMigrationService {
|
||||
File localFile = downloadFileFromS3(oldUrl);
|
||||
String newKey = generateNewS3Path(document); // Make sure this generates the correct new path
|
||||
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||
updateDocumentPathAndDeleteOldEntry(document, uploadedPath);
|
||||
updateDocumentPathAndNameEntry(document, uploadedPath);
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing document {}: {}", document.getId(), e.getMessage());
|
||||
}
|
||||
@@ -178,20 +178,12 @@ public class S3ReUploadMigrationService {
|
||||
}
|
||||
|
||||
|
||||
private void updateDocumentPathAndDeleteOldEntry(DocumentEntity document, String newPath) {
|
||||
private void updateDocumentPathAndNameEntry(DocumentEntity document, String newPath) {
|
||||
|
||||
String fileName = extractFileName(newPath);
|
||||
DocumentEntity newDocument = new DocumentEntity();
|
||||
newDocument.setFilePath(newPath);
|
||||
newDocument.setSource(document.getSource());
|
||||
newDocument.setType(document.getType());
|
||||
newDocument.setIsDeleted(false);
|
||||
newDocument.setSourceId(document.getSourceId());
|
||||
newDocument.setFileName(fileName);
|
||||
|
||||
documentRepository.save(newDocument);
|
||||
documentRepository.delete(document);
|
||||
|
||||
document.setFilePath(newPath);
|
||||
document.setFileName(fileName);
|
||||
documentRepository.save(document);
|
||||
log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user