Skip to content

Commit

Permalink
MCR-3038 MCRMETSDefaultGenerator.structureMets generates double logic…
Browse files Browse the repository at this point in the history
…al ids
  • Loading branch information
sebhofmann authored and kkrebs committed Feb 7, 2024
1 parent 4ee6a88 commit 6e80194
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -147,8 +149,7 @@ private Mets createMets() throws IOException {
}

private void structureMets(MCRPath dir, Set<MCRPath> 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<MCRPath, BasicFileAttributes> files = new TreeMap<>();
SortedMap<MCRPath, BasicFileAttributes> directories = new TreeMap<>();

Expand All @@ -160,11 +161,12 @@ private void structureMets(MCRPath dir, Set<MCRPath> ignoreNodes, FileSec fileSe
for (Map.Entry<MCRPath, BasicFileAttributes> 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);
}
}
}
Expand Down

0 comments on commit 6e80194

Please sign in to comment.