From df8af6e6cd8a2a43c99144f9bc2c671aa9a560bf Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 30 Oct 2020 11:29:43 +0200 Subject: [PATCH] Trim time on Dataset's modified time in order to match with the Database --- .../main/java/eu/eudat/logic/managers/DatasetManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index c3f137c9f..c219dd9ea 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -83,6 +83,8 @@ import javax.xml.xpath.XPathFactory; import java.io.*; import java.math.BigInteger; import java.nio.file.Files; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -580,7 +582,10 @@ public class DatasetManager { if (datasetWizardModel.getId() != null) { tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId()); if (tempDataset != null) { - if (datasetWizardModel.getModified().getTime() != tempDataset.getModified().getTime()) { + + Instant dbTime = Instant.ofEpochMilli(tempDataset.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS); + Instant modelTime = Instant.ofEpochMilli(datasetWizardModel.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS); + if (modelTime.toEpochMilli() != dbTime.toEpochMilli()) { throw new Exception("Dataset has been modified already by another user."); } sendNotification = true;