From 6e59ff0c1d40bce8b8d94f27b09121907911c7e5 Mon Sep 17 00:00:00 2001
From: "Stefan E. Funk" <funk@sub.uni-goettingen.de>
Date: Wed, 6 Jul 2022 12:56:30 +0200
Subject: [PATCH] chore: fox logging

---
 .../textgrid/middleware/OAIPMHUtilities.java  |  5 +-
 .../middleware/RecordListDelivererDC.java     |  6 +-
 .../middleware/OaiPmhDariahdeOnlineTests.java | 61 +++++++++++++++++++
 3 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java
index 1e711d03..e197964d 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java
@@ -49,7 +49,8 @@ import info.textgrid.namespaces.middleware.tgauth.ProjectInfo;
  * </p>
  * 
  * @author Maximilian Brodhun, SUB Göttingen
- * @version 2021-10-21
+ * @author Stefan E. Funk, SUB Göttingen
+ * @version 2022-07-06
  * @since 2014-01-29
  */
 public class OAIPMHUtilities {
@@ -264,7 +265,7 @@ public class OAIPMHUtilities {
       final String resumptionToken, Map<String, Integer> cursorCollector, final String scrollID,
       final int searchResponseSize, final int i) {
 
-    log.info("Creating a ResumptionToken:\n " + "CompleteListSize: " + completeListSize + "\n"
+    log.debug("Creating a ResumptionToken:\n " + "CompleteListSize: " + completeListSize + "\n"
         + "ResumptionToken: " + resumptionToken + "\n" + "CursorCollector: " + cursorCollector
         + "\n" + "ScrollID: " + scrollID + "\n" + "SearchResponseSize: " + searchResponseSize + "\n"
         + "IterationStep: " + i);
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java
index 00d2b32a..8d8cc9d3 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java
@@ -260,14 +260,16 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
 
       // Check the need for a resumption token!
 
-      log.info("  ##  " + completeListSize + "\n  ##  " + resumptionToken + "\n  ##  " + scrollID);
+      System.out.println("  ##  completeListSize: " + completeListSize);
+      System.out.println("  ##  resumptionToken: " + resumptionToken);
+      System.out.println("  ##  scrollid: " + scrollID);
 
       ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken(completeListSize,
           resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i);
       if (resTokenForResponse != null) {
         recordList.setResumptionToken(resTokenForResponse);
 
-        log.info("  ##  resTokenForResponse: " + resTokenForResponse.getValue());
+        System.out.println("  ##  resTokenForResponse: " + resTokenForResponse.getValue());
       }
 
     } else {
diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java
index 764de98d..ba4132c9 100644
--- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java
+++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java
@@ -266,6 +266,67 @@ public class OaiPmhDariahdeOnlineTests {
     }
   }
 
+  /**
+   * @throws IOException
+   */
+  @Test
+  public void testListRecordsSetDCDifferentPrefixes() throws IOException {
+
+    String uri = checkListRecordsSet;
+
+    System.out.println(OaiPmhTestUtilities.TESTING + "#LISTRECORDS - HDL PREFIX");
+
+    if (!uri.startsWith("hdl:")) {
+      assertTrue("missing 'hdl:' prefix!", false);
+    }
+    System.out.println("uri: " + uri);
+    int pages1 = testList("ListRecords", "oai_dc", uri);
+    if (pages1 != checkListRecordsSetExpectedPages) {
+      System.out.println(pages1 + " != " + checkListRecordsSetExpectedPages);
+    }
+
+    System.out.println(OaiPmhTestUtilities.TESTING + "#LISTRECORDS - NO PREFIX");
+
+    if (checkListRecordsSet.startsWith("hdl:")) {
+      uri = checkListRecordsSet.substring(4);
+    }
+    System.out.println("uri: " + uri);
+    int pages4 = testList("ListRecords", "oai_dc", uri);
+    if (pages4 != checkListRecordsSetExpectedPages) {
+      System.out.println(pages4 + " != " + checkListRecordsSetExpectedPages);
+    }
+
+    System.out.println(OaiPmhTestUtilities.TESTING + "#LISTRECORDS - WRONG PREFIX");
+
+    if (checkListRecordsSet.startsWith("hdl:")) {
+      uri = "**" + checkListRecordsSet.substring(4);
+    }
+    System.out.println("uri: " + uri);
+    int pages2 = testList("ListRecords", "oai_dc", uri);
+    if (pages2 != checkListRecordsSetExpectedPages) {
+      System.out.println(pages2 + " != " + checkListRecordsSetExpectedPages);
+    }
+
+    System.out.println(OaiPmhTestUtilities.TESTING + "#LISTRECORDS - WRONG PREFIX");
+
+    if (checkListRecordsSet.startsWith("hdl:")) {
+      uri = "**" + checkListRecordsSet.substring(4);
+    }
+    System.out.println("uri: " + uri);
+    int pages3 = testList("ListRecords", "oai_dc", uri);
+    if (pages3 != checkListRecordsSetExpectedPages) {
+      System.out.println(pages3 + " != " + checkListRecordsSetExpectedPages);
+    }
+
+    // Check pages count.
+    if (pages1 != checkListRecordsSetExpectedPages
+        || pages2 != checkListRecordsSetExpectedPages
+        || pages3 != checkListRecordsSetExpectedPages
+        || pages4 != checkListRecordsSetExpectedPages) {
+      assertTrue("pages count does not match", false);
+    }
+  }
+
   /**
    * @throws IOException
    */
-- 
GitLab