Trim time on Dataset's modified time in order to match with the Database

This commit is contained in:
George Kalampokis 2020-10-30 11:29:43 +02:00
parent ba5c295187
commit df8af6e6cd
1 changed files with 6 additions and 1 deletions

View File

@ -83,6 +83,8 @@ import javax.xml.xpath.XPathFactory;
import java.io.*; import java.io.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -580,7 +582,10 @@ public class DatasetManager {
if (datasetWizardModel.getId() != null) { if (datasetWizardModel.getId() != null) {
tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId()); tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
if (tempDataset != null) { 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."); throw new Exception("Dataset has been modified already by another user.");
} }
sendNotification = true; sendNotification = true;