From 6e801942803f088b967ff201f248a9007a55e45a Mon Sep 17 00:00:00 2001 From: Sebastian Hofmann Date: Tue, 6 Feb 2024 13:28:51 +0100 Subject: [PATCH] MCR-3038 MCRMETSDefaultGenerator.structureMets generates double logical ids --- .../mycore/mets/model/MCRMETSDefaultGenerator.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mycore-mets/src/main/java/org/mycore/mets/model/MCRMETSDefaultGenerator.java b/mycore-mets/src/main/java/org/mycore/mets/model/MCRMETSDefaultGenerator.java index df01e8dc66..c045f9c617 100644 --- a/mycore-mets/src/main/java/org/mycore/mets/model/MCRMETSDefaultGenerator.java +++ b/mycore-mets/src/main/java/org/mycore/mets/model/MCRMETSDefaultGenerator.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -132,7 +133,8 @@ private Mets createMets() throws IOException { StructLink structLink = new StructLink(); // create internal structure - structureMets(getDerivatePath(), getIgnorePaths(), fileSec, physicalDiv, logicalDiv, structLink, 0); + structureMets(getDerivatePath(), getIgnorePaths(), fileSec, physicalDiv, logicalDiv, structLink, + new AtomicInteger(0)); hrefIdMap.clear(); // add to mets @@ -147,8 +149,7 @@ private Mets createMets() throws IOException { } private void structureMets(MCRPath dir, Set ignoreNodes, FileSec fileSec, PhysicalDiv physicalDiv, - LogicalDiv logicalDiv, StructLink structLink, int logOrder) throws IOException { - int lOrder = logOrder; + LogicalDiv logicalDiv, StructLink structLink, AtomicInteger logCounter) throws IOException { SortedMap files = new TreeMap<>(); SortedMap directories = new TreeMap<>(); @@ -160,11 +161,12 @@ private void structureMets(MCRPath dir, Set ignoreNodes, FileSec fileSe for (Map.Entry directory : directories.entrySet()) { String dirName = directory.getKey().getFileName().toString(); if (isInExcludedRootFolder(directory.getKey())) { - structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, logicalDiv, structLink, lOrder); + structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, logicalDiv, structLink, + logCounter); } else { - LogicalDiv section = new LogicalDiv("log_" + ++lOrder, "section", dirName); + LogicalDiv section = new LogicalDiv("log_" + logCounter.incrementAndGet(), "section", dirName); logicalDiv.add(section); - structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, section, structLink, lOrder); + structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, section, structLink, logCounter); } } }