diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 8ca010824f0b9d93c803307abcdda52d6c11347e..c5fdba3e5539873b923b5327b508cba83a2ca392 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -5,15 +5,16 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.1.12</version> + <version>3.1.13</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> <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 030e4abfb8a79dfda9910c85e4516c5d9e736ef3..366343d31e1bc83c394e1651680487c610e43b48 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -418,9 +418,11 @@ public class OAIPMHImpl implements OAIPMHProducer { && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); boolean restokIDIOMExisting = RecordListDelivererIDIOM.cursorCollector != null && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken()); + if (restokDCExisting) { recListDeliv = this.recordListDC; } else if (restokIDIOMExisting) { + 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 e0bc710c7abef9029e265dbfbef6931dec58e31d..781f3e2a7898ae9c5f3af12bdf55ccf865e1584e 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 3f9453d92d9ee281432fe4e5de0ba99e6a7e90aa..039f823526302a33ca8c8524489fe26f925ac9c7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java @@ -6,6 +6,12 @@ import java.util.Map; import java.util.UUID; import org.apache.commons.logging.LogFactory; import org.classicmayan.tools.Queries; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; + import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListRecordsType; import info.textgrid.middleware.oaipmh.MetadataType; @@ -21,12 +27,14 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract { static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); private OAI_ESClient oaiEsClient; + private boolean foundItems; /** * @param textgrid * @param dariah */ public RecordListDelivererIDIOM(boolean textgrid, boolean dariah) { + super(textgrid, dariah); } @@ -53,48 +61,74 @@ 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; + final String resumptionToken) { + System.out.println("BUFF"); + ListRecordsType recordList = new ListRecordsType(); + + QueryBuilder recordFilterForClassicMayan; + QueryBuilder rangeQuery; + Queries queries = new Queries(); + //List<String> artefactURIs = queries.getArtefactList(); + + 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")) + .must(QueryBuilders.matchPhraseQuery("notes", "ARTEFACT")); + + SearchResponse scrollResp; + + if (resumptionToken == null) { + + scrollResp = OAI_ESClient.getOaiESClient() + .prepareSearch("textgrid-nonpublic") + .setScroll(TimeValue.timeValueHours(24L)) + .setTypes(OAI_ESClient.getEsType()) + .addFields("lastModified", "textgridUri", "project.id") + .setQuery(recordFilterForClassicMayan) + .setSize(30) + .execute() + .actionGet(); + }else { + scrollResp = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken) + .setScroll(TimeValue.timeValueHours(24L)).execute().actionGet(); + } + + String scrollID = scrollResp.getScrollId(); + + long completeListSize = scrollResp.getHits().totalHits(); + //System.out.println(completeListSize); + //System.out.println(completeListSize + " || " + artefactURIs.size()); + if (completeListSize > 0) { + setFoundItems(true); + int i = 0; + //System.out.println("inside "); + for (SearchHit hit : scrollResp.getHits().getHits()) { + + i++; + String textgridURI = hit.getFields().get("textgridUri").getValue().toString().replace(".0", ""); + 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! + ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken( + completeListSize, resumptionToken, cursorCollector, scrollID, 30, i); + if (resTokenForResponse != null) { + recordList.setResumptionToken(resTokenForResponse); + } + }else { + setFoundItems(false); + } + + return recordList; } - + /* * (non-Javadoc) * @@ -120,4 +154,12 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract { this.oaiEsClient = oaiEsClient; } +public boolean isFoundItems() { + return foundItems; +} + +public void setFoundItems(boolean foundItems) { + this.foundItems = foundItems; +} + } diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index ba83578d8284c1f50edfd84584f2253915846934..f56ef5c935c96cc68705397e144cc2b637f4c84a 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.1.12</version> + <version>3.1.13</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> @@ -77,6 +77,7 @@ <artifactId>oaipmh-core</artifactId> <version>${project.version}</version> </dependency> + </dependencies> <build> <finalName>oaipmh</finalName> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index 58fc35dfa03945d96eab35d472ab0039abf56b42..22f28676a32fd6ec035a0309a58d1939a451adc9 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -22,7 +22,7 @@ <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> - <value>file:/etc/dhrep/oaipmh/oaipmh.properties</value> + <value>file:/home/max/dev/oai-pmh/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties</value> </list> </property> <property name="ignoreResourceNotFound" value="true" /> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties index b5404bc7f0767fdcf8e2376bffae6b65e1a883c1..0e733f528141eb0b7b09fef86df5b2e5143f1cf5 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties @@ -1,8 +1,8 @@ -############################## -## ElasticSearch Endpoint ## -############################## +############################################################################### +## OAI-PMH Configuration File ## +############################################################################### -RS_ENDPOINT = http://textgrid-esx1.gwdg.de/tgoaipmh +RS_ENDPOINT = https://textgridlab.org/1.0/tgoaipmh ############################ ## ElasticSearch Config ## @@ -10,13 +10,13 @@ RS_ENDPOINT = http://textgrid-esx1.gwdg.de/tgoaipmh elasticSearch.url = 127.0.0.1 elasticSearch.port = 9302 -elasticSearch.clusterName = tg-esx1-dev-instance +elasticSearch.clusterName = tg-esx2-instance elasticSearch.index = textgrid-public elasticSearch.type = metadata ######################## ## Project Choosing ## -######################## +########################1 textgrid = true dariah = false @@ -26,12 +26,12 @@ dariah = false ############################# RepositoryName = TextGrid Repository -BaseUrl = http://textgrid-esx1.gwdg.de +BaseUrl = https://textgridlab.org/1.0/tgoaipmh/oai DeletedRecordInfo = NO EarliestDateStamp = 2011-06-11T02:32:40Z Granularity = YYYY_MM_DD_THH_MM_SS_Z ProtocolVersion = 2.0 -AdminMail = funk@sub.uni-goettingen.de +AdminMail = support@de.dariah.eu ###################### ## Field Settings ## @@ -40,6 +40,23 @@ AdminMail = funk@sub.uni-goettingen.de fields = created, format, identifier, dataContributor, textgridUri, project.id, relations.isDerivedFrom, title, pid.value, edition.isEditionOf, edition.agent.value, edition.license.licenseUri, edition.language, edition.source.bibliographicCitation.author.value, edition.source.bibliographicCitation.editor.value, edition.source.bibliographicCitation.editionTitle, edition.source.bibliographicCitation.placeOfPublication.value, edition.source.bibliographicCitation.publisher.value, edition.source.bibliographicCitation.editionNo, edition.source.bibliographicCitation.series, edition.source.bibliographicCitation.volume, edition.source.bibliographicCitation.issue, edition.source.bibliographicCitation.epage, edition.source.bibliographicCitation.spage, edition.source.bibliographicCitation.bibidentifier, work.abstract, work.genre, work.type, work.spatial.value, work.temporal.value, work.agent.value, work.subject.id.value, lastModified workFields = created, work.abstract, relations.isDerivedFrom, textgridUri, work.genre, title, work.type, work.spatial.value, work.temporal.spatial, work.agent.value, work.subject.id.value +###################### +## OpenAireRecords ### +###################### + +oar.titleFields = title,edition.source.bibliographicCitation.editionTitle +oar.dateFields = created,issued,lastModified +oar.contributorFields = dataContributor +oar.languageFields = edition.language +oar.alternateIdentifierFields = textgridUri +oar.formatFields = format +oar.rightsFields = edition.license +oar.descriptionFields = work.abstract +oar.relatedIdentifierFields = edition.isEditionOf +oar.relationToWorkObject = edition.isEditionOf + + + ########################## ## Dublin Core Fields ## ########################## @@ -68,7 +85,7 @@ typeList = work.genre, work.type rangeField = created identifierListFields = textgridUri, created, format formatField = format -formatToFilter = text/vnd.dariah.dhrep.collection+turtle +formatToFilter = text/tg.edition+tg.aggregation+xml dateOfObjectCreation = created relationToFurtherMetadataObject = edition.isEditionOf repositoryObjectURIPrefix = textgrid: diff --git a/pom.xml b/pom.xml index 5bb5d095e333f43621648dc0ca6e5a38aa3ecb9c..55aba0ca6fca9a6dac787c93af2e55b30a0ab6fb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh</artifactId> - <version>3.1.12</version> + <version>3.1.13</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties> @@ -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>