diff --git a/pom.xml b/pom.xml
index ed73033..29b187b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
kangaroo-and-rabbit
archidata
- 0.7.0-dev
+ 0.7.1
3.1
21
diff --git a/src/org/kar/archidata/dataAccess/DataAccess.java b/src/org/kar/archidata/dataAccess/DataAccess.java
index f902cbb..bafb2ca 100644
--- a/src/org/kar/archidata/dataAccess/DataAccess.java
+++ b/src/org/kar/archidata/dataAccess/DataAccess.java
@@ -835,7 +835,8 @@ public class DataAccess {
UUID uuid = null;
if (generateUUID) {
firstField = false;
- uuid = UUID.randomUUID();
+ // uuid = UUID.randomUUID();
+ uuid = UuidUtils.nextUUID();
addElement(ps, uuid, iii);
iii.inc();
}
diff --git a/src/org/kar/archidata/tools/UuidUtils.java b/src/org/kar/archidata/tools/UuidUtils.java
index 2632356..4bab0fa 100644
--- a/src/org/kar/archidata/tools/UuidUtils.java
+++ b/src/org/kar/archidata/tools/UuidUtils.java
@@ -2,6 +2,10 @@ package org.kar.archidata.tools;
import java.math.BigInteger;
import java.nio.ByteBuffer;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
import java.util.UUID;
public class UuidUtils {
@@ -25,4 +29,41 @@ public class UuidUtils {
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
}
+
+ private static class Generator {
+ private long base;
+ private final long offset;
+ private long previous;
+
+ public Generator() {
+ this.offset = System.currentTimeMillis();
+ // The local method never generate new UUID in the past, then we use the creation function time to prevent 2038 error
+ final Instant startingUUID = LocalDate.of(2024, 03, 19).atStartOfDay(ZoneOffset.UTC).toInstant();
+ this.base = startingUUID.until(Instant.now(), ChronoUnit.SECONDS);
+ final String serveurBaseUUID = System.getenv("UUID_SERVER_ID");
+ if (serveurBaseUUID != null) {
+ long serverId = Long.valueOf(serveurBaseUUID);
+ serverId %= 0xFFFF;
+ this.base += (serverId << (64 - 16));
+ } else {
+ this.base += (1L << (64 - 16));
+ }
+ }
+
+ public synchronized UUID next() {
+ long tmp = System.currentTimeMillis();
+ if (this.previous >= tmp) {
+ tmp = this.previous + 1;
+ }
+ this.previous = tmp;
+ tmp -= this.offset;
+ return new UUID(Long.reverseBytes(tmp), this.base);
+ }
+ }
+
+ private static Generator generator = new Generator();
+
+ public static UUID nextUUID() {
+ return generator.next();
+ }
}
diff --git a/version.txt b/version.txt
index e1bde80..39e898a 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.7.0-dev
+0.7.1