From 3d11e39c8edd8bc94d933b4bc7bac336df737b9e Mon Sep 17 00:00:00 2001 From: VitorLelis Date: Thu, 30 Jul 2026 12:09:40 +0100 Subject: [PATCH] fix: original filename of external lobs on doc indexes --- .../com/databasepreservation/model/data/BinaryCell.java | 4 ++++ .../modules/externalLobs/ExternalLOBSFilter.java | 4 ++++ .../siard/out/content/SIARDDKContentExportStrategy.java | 7 +++++++ .../siard/out/output/SIARDDKDatabaseExportModule.java | 3 ++- .../services/conversion/model/report/ConversionReport.java | 5 +++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dbptk-model/src/main/java/com/databasepreservation/model/data/BinaryCell.java b/dbptk-model/src/main/java/com/databasepreservation/model/data/BinaryCell.java index 63f8fbf3..a5a02831 100644 --- a/dbptk-model/src/main/java/com/databasepreservation/model/data/BinaryCell.java +++ b/dbptk-model/src/main/java/com/databasepreservation/model/data/BinaryCell.java @@ -139,4 +139,8 @@ public long getLength() { public String getMimeType() { return mimeType; } + + public void setFile(String file) { + this.file = file; + } } diff --git a/dbptk-modules/dbptk-filter-external-lobs/src/main/java/com/databasepreservation/modules/externalLobs/ExternalLOBSFilter.java b/dbptk-modules/dbptk-filter-external-lobs/src/main/java/com/databasepreservation/modules/externalLobs/ExternalLOBSFilter.java index 50a99a33..b64d47e6 100644 --- a/dbptk-modules/dbptk-filter-external-lobs/src/main/java/com/databasepreservation/modules/externalLobs/ExternalLOBSFilter.java +++ b/dbptk-modules/dbptk-filter-external-lobs/src/main/java/com/databasepreservation/modules/externalLobs/ExternalLOBSFilter.java @@ -20,6 +20,7 @@ import com.databasepreservation.managers.ExportModuleContextManager; import com.databasepreservation.managers.ModuleConfigurationManager; +import com.databasepreservation.model.data.BinaryCell; import com.databasepreservation.model.data.Cell; import com.databasepreservation.model.data.NullCell; import com.databasepreservation.model.data.Row; @@ -167,6 +168,9 @@ public void handleDataRow(Row row) throws ModuleException { .get(currentTable.getId() + index); Cell newCell = getExternalLOBSCellHandler(externalLobsConfiguration).handleCell(cell.getId(), simpleCell.getSimpleData()); + if (newCell instanceof BinaryCell binaryCell) { + binaryCell.setFile(simpleCell.getSimpleData()); + } rowCells.set(index, newCell); } else { reporter.ignored("Cell " + cell.getId(), "reference to external LOB is null"); diff --git a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/content/SIARDDKContentExportStrategy.java b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/content/SIARDDKContentExportStrategy.java index d5f22716..0a497a3c 100644 --- a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/content/SIARDDKContentExportStrategy.java +++ b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/content/SIARDDKContentExportStrategy.java @@ -20,6 +20,7 @@ import java.util.zip.ZipInputStream; import org.apache.commons.codec.binary.Hex; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.jdom2.Document; import org.jdom2.Element; @@ -367,6 +368,12 @@ private void processConvertedLobArchive(BinaryCell binaryCell, long rowIndex, in throw new ModuleException().withMessage("Missing conversion_report.json in cell archive."); } + String fileFromCell = binaryCell.getFile(); + if (fileFromCell != null) { + String filename = FilenameUtils.getName(fileFromCell).stripTrailing(); + report = report.withOriginalFilename(filename); + } + List siardPhysicalPaths = new ArrayList<>(); int fileCount = 0; String processedFilesExtension = "tif"; diff --git a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/output/SIARDDKDatabaseExportModule.java b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/output/SIARDDKDatabaseExportModule.java index 9fd917c1..d750ca8c 100644 --- a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/output/SIARDDKDatabaseExportModule.java +++ b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/out/output/SIARDDKDatabaseExportModule.java @@ -360,8 +360,9 @@ private ProcessedRowContext processRowAsync(Row row) throws ModuleException { // TODO: Handle multiple files per cell if needed. Currently assumes single file // output. - Cell newCell = new BinaryCell(cell.getId(), new PathInputStreamProvider(result.zipFile()), + BinaryCell newCell = new BinaryCell(cell.getId(), new PathInputStreamProvider(result.zipFile()), "application/zip"); + newCell.setFile(binCell.getFile()); cells.set(i, newCell); // Track extracted parts to clean them individually later diff --git a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/services/conversion/model/report/ConversionReport.java b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/services/conversion/model/report/ConversionReport.java index 4deafef2..32aaec45 100644 --- a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/services/conversion/model/report/ConversionReport.java +++ b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/services/conversion/model/report/ConversionReport.java @@ -19,4 +19,9 @@ public ConversionReport withContext(DbptkContext context) { return new ConversionReport(jobId, status, originalFilename, totalArtifactsProduced, artifacts, errorMessage, context); } + + public ConversionReport withOriginalFilename(String newFilename) { + return new ConversionReport(jobId, status, newFilename, totalArtifactsProduced, artifacts, errorMessage, + dbptkContext); + } }