From e8ba8bdbfe842368a3b21cceeb09bf4f846473ff Mon Sep 17 00:00:00 2001
From: mbrodhu <behnert-brodhun@sub.uni-goettingen.de>
Date: Mon, 16 Nov 2020 11:07:04 +0100
Subject: [PATCH] enable recordList

---
 oaipmh-core/pom.xml                           |  7 ++-
 .../info/textgrid/middleware/OAIPMHImpl.java  |  4 +-
 .../middleware/RecordDelivererIDIOM.java      |  3 +
 .../middleware/RecordListDelivererIDIOM.java  | 61 +++----------------
 oaipmh-webapp/pom.xml                         |  1 +
 pom.xml                                       | 25 +++++++-
 6 files changed, 43 insertions(+), 58 deletions(-)

diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml
index 274ddc11..b5512554 100644
--- a/oaipmh-core/pom.xml
+++ b/oaipmh-core/pom.xml
@@ -12,8 +12,9 @@
 	<packaging>jar</packaging>
 	<name>DARIAHDE :: OAI-PMH DataProvider :: Core</name>
 	<url>http://maven.apache.org</url>
-	<dependencies>
-		<dependency>
+		
+<dependencies>
+<dependency>
 			<groupId>info.textgrid.middleware</groupId>
 			<artifactId>crud-common</artifactId>
 			<version>${tgcrud.version}</version>
@@ -84,7 +85,7 @@
 		<dependency>
 			<groupId>org.classicmayan.tools</groupId>
 			<artifactId>metsModsMapping</artifactId>
-			<version>1.1.9</version>
+			<version>1.1.11</version>
 		</dependency>
 		<dependency>
 			<groupId>de.shadowhunt.maven.plugins</groupId>
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
index bb82e4a4..366343d3 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
@@ -418,11 +418,11 @@ public class OAIPMHImpl implements OAIPMHProducer {
             && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken());
         boolean restokIDIOMExisting = RecordListDelivererIDIOM.cursorCollector != null
             && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken());
-        System.out.println("OAIIMPL: " + request.getResumptionToken());
+        
         if (restokDCExisting) {
           recListDeliv = this.recordListDC;
         } else if (restokIDIOMExisting) {
-        	System.out.println("DUMDIDUM");
+       
           recListDeliv = this.recordListIDIOM;
         }
       }
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java
index e0bc710c..781f3e2a 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java
@@ -14,6 +14,7 @@ import info.textgrid.middleware.oaipmh.GetRecordType;
 import info.textgrid.middleware.oaipmh.HeaderType;
 import info.textgrid.middleware.oaipmh.MetadataType;
 import info.textgrid.middleware.oaipmh.RecordType;
+import info.textgrid.middleware.oaipmh.StatusType;
 
 /**
  * 
@@ -162,6 +163,8 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract {
     recordHeader.setIdentifier(identifier);
     recordHeader.setDatestamp(OAIPMHUtilities.datestampAsString(dateOfCreation));
     this.record.setHeader(recordHeader);
+    
+    //recordHeader.setStatus(StatusType.DELETED);
     // return recordHeader;
   }
 
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java
index 20213d67..039f8235 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java
@@ -61,48 +61,6 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract {
    * @see info.textgrid.middleware.RecordListDelivererInterface#getRecords(java.lang.String,
    * java.lang.String, java.lang.String, java.lang.String)
    */
- /* @Override
-  public ListRecordsType getRecords(final String from, final String to, final String set,
-      final String resumptionToken) {
-
-    String resTokenValue = resumptionToken;
-
-    log.info("Started List Records with booleans for DARIAH:  " + this.dariah + " and TextGrid: "
-        + this.textgrid);
-
-    ListRecordsType recordList = new ListRecordsType();
-    List<String> artefactURIs;
-    Queries queries = new Queries();
-    if (resumptionToken == null) {
-      artefactURIs = queries.getArtefactList(0);
-      // Create resumption token for every request only (we do need the same token for resuming
-      // because we are using a hash map for counting the calls).
-      resTokenValue = UUID.randomUUID().toString();
-    } else {
-      // Use given resumption token here.
-      artefactURIs = queries.getArtefactList(cursorCollector.get(resumptionToken));
-    }
-
-    long listSize = Queries.getAmountOfArtefacts();
-    int i = 0;
-
-    for (String artefactURI : artefactURIs) {
-      RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false);
-
-      recordList.getRecord().add(idiomRecord.getRecordById(artefactURI).getRecord());
-      i++;
-    }
-
-    // Check the need for a resumption token!
-    ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken(listSize,
-        resumptionToken, cursorCollector, resTokenValue, 30, i);
-
-    if (resTokenForResponse != null) {
-      recordList.setResumptionToken(resTokenForResponse);
-    }
-
-    return recordList;
-  }*/
 
   @Override
   public ListRecordsType getRecords(final String from, final String to, final String set,
@@ -113,9 +71,9 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract {
 	  QueryBuilder recordFilterForClassicMayan;
 	  QueryBuilder rangeQuery;
 	  Queries queries = new Queries();
-	  List<String> artefactURIs = queries.getArtefactList();;
+	  //List<String> artefactURIs = queries.getArtefactList();
 	  
-	  rangeQuery = QueryBuilders.rangeQuery("created").from(from).to(to);
+	  rangeQuery = QueryBuilders.rangeQuery("lastModified").from(from).to(to);
 	  recordFilterForClassicMayan = QueryBuilders.boolQuery().must(rangeQuery)
 			  .must(QueryBuilders.matchPhraseQuery("project.id", "TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318"))
 			  .must(QueryBuilders.matchPhraseQuery("format", "text/tg.inputform+rdf+xml"))
@@ -127,7 +85,7 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract {
 		  
 	      scrollResp = OAI_ESClient.getOaiESClient()
 	              .prepareSearch("textgrid-nonpublic")
-	              .setScroll(new TimeValue(60000))
+	              .setScroll(TimeValue.timeValueHours(24L))
 	              .setTypes(OAI_ESClient.getEsType())
 	              .addFields("lastModified", "textgridUri", "project.id")
 	              .setQuery(recordFilterForClassicMayan)
@@ -135,9 +93,8 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract {
 	              .execute()
 	              .actionGet();
 	  }else {
-		  System.out.println("resumptionToken for res: " + resumptionToken);
 	      scrollResp = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken)
-	              .setScroll(new TimeValue(60000)).execute().actionGet();
+	              .setScroll(TimeValue.timeValueHours(24L)).execute().actionGet();
 	  }
 	  
 	  String scrollID = scrollResp.getScrollId();
@@ -150,16 +107,16 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract {
 	        int i = 0;
 	        //System.out.println("inside ");
 	        for (SearchHit hit : scrollResp.getHits().getHits()) {
+	          
 	          i++;
 	          String textgridURI = hit.getFields().get("textgridUri").getValue().toString().replace(".0", "");
-	          if(artefactURIs.contains(textgridURI)) {
-	        	  RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false);
-	        	  recordList.getRecord().add(idiomRecord.getRecordById(textgridURI).getRecord());
-	          }
+	          System.out.println("Processing: " + textgridURI);
+        	  RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false);
+        	  recordList.getRecord().add(idiomRecord.getRecordById(textgridURI).getRecord());
+
 	        }
 
 		   // Check the need for a resumption token!
-	       System.out.println("resumptionToken: " + resumptionToken);
 		   ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken(
 		          completeListSize, resumptionToken, cursorCollector, scrollID, 30, i);
 		   if (resTokenForResponse != null) {
diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml
index 620d51a2..4aff4e37 100644
--- a/oaipmh-webapp/pom.xml
+++ b/oaipmh-webapp/pom.xml
@@ -77,6 +77,7 @@
 			<artifactId>oaipmh-core</artifactId>
 			<version>${project.version}</version>
 		</dependency>
+
 	</dependencies>
 	<build>
 		<finalName>oaipmh</finalName>
diff --git a/pom.xml b/pom.xml
index 9dc7a6d2..aaf89181 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,12 +22,13 @@
 		<maven-antrun-plugin.version>1.3</maven-antrun-plugin.version>
 		<jaxb2-maven-plugin.version>2.5.0</jaxb2-maven-plugin.version>
 		<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
-		<maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
+		<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
 		<jetty-maven-plugin.version>9.4.12.v20180830</jetty-maven-plugin.version>
 		<maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version>
 		<properties-maven-plugin.version>1.0-alpha-2</properties-maven-plugin.version>
 	</properties>
 	<url>https://projects.gwdg.de/projects/oai-pmh</url>
+
 	<scm>
 		<connection>scm:git@git.projects.gwdg.de:oai-pmh.git</connection>
 		<developerConnection>scm:git@git.projects.gwdg.de:oai-pmh.git</developerConnection>
@@ -78,6 +79,28 @@
 				<artifactId>maven-deploy-plugin</artifactId>
 				<version>${maven-deploy-plugin.version}</version>
 			</plugin>
+
+
+       <!--plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>chronos-jmeter-maven-plugin</artifactId>
+            <version>1.1.0</version>
+            <dependencies>
+                <dependency>
+                    <groupId>org.codehaus.plexus</groupId>
+                    <artifactId>plexus-utils</artifactId>
+                    <version>3.0.15</version>
+                </dependency>
+            </dependencies>
+            <executions>
+                <execution>
+                    <goals>
+                        <goal>jmeter</goal>
+                    </goals>
+                </execution>
+            </executions>
+        </plugin-->
+
 		</plugins>
 	</build>
 	<modules>
-- 
GitLab