Skip to content
Snippets Groups Projects
Commit b9314f99 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Merge branch 'develop' into 113-add-dc-identifier-value-with-url-to-landing-pages

parents a4929b05 c3c15ca7
No related branches found
No related tags found
No related merge requests found
Pipeline #470723 passed
Showing
with 83 additions and 85 deletions
......@@ -27,11 +27,6 @@
<artifactId>httpclients</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>info.textgrid.middleware</groupId>
<artifactId>ltputils</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>info.textgrid.middleware.clients</groupId>
<artifactId>textgrid-clients</artifactId>
......
......@@ -123,7 +123,7 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD
public SearchResponse hitHandling(SearchResponse listFurtherValues, ListIdentifiersType lit,
String set, String resumptionToken, Map<String, Integer> cursorCollector) {
long size = listFurtherValues.getHits().totalHits;
long size = listFurtherValues.getHits().getTotalHits().value;
setResultSize(size);
for (SearchHit hit : listFurtherValues.getHits().getHits()) {
......@@ -147,7 +147,7 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD
// Check the need for a resumption token!
ResumptionTokenType responseToken = OaipmhUtilities.getResumptionToken(
listFurtherValues.getHits().getTotalHits(), resumptionToken, cursorCollector,
listFurtherValues.getHits().getTotalHits().value, resumptionToken, cursorCollector,
listFurtherValues.getScrollId(), this.searchResponseSize);
if (responseToken != null) {
lit.setResumptionToken(responseToken);
......
......@@ -135,7 +135,7 @@ public class IdentifierListDelivererIdiom extends IdentifierListDelivererAbstrac
String scrollID = scrollResp.getScrollId();
long completeListSize = scrollResp.getHits().totalHits;
long completeListSize = scrollResp.getHits().getTotalHits().value;
log.fine("complete list size: " + completeListSize);
......
......@@ -35,9 +35,8 @@ public class MetadataFormatListDelivererTG extends MetadataFormatListDelivererAb
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
GetRequest getRequest =
new GetRequest(this.oaiEsClient.getEsIndex(), this.oaiEsClient.getEsType(),
id.replace("textgrid:", "")).fetchSourceContext(fetchSourceContext);
new GetRequest(this.oaiEsClient.getEsIndex(), id.replace("textgrid:", ""))
.fetchSourceContext(fetchSourceContext);
GetResponse tgObject = null;
try {
tgObject = this.oaiEsClient.getEsClient().get(getRequest, RequestOptions.DEFAULT);
......
......@@ -13,16 +13,14 @@ import org.elasticsearch.client.RestHighLevelClient;
*
* @author Maximilian Brodhun, SUB Göttingen
* @author Stefan E. Funk, SUB Göttingen
* @version 2022-09-08
* @version 2023-09-06
* @since 2014-01-09
*/
public class OaipmhElasticSearchClient {
private String url;
private int[] ports;
private String esCluster;
private String esIndex;
private String esType;
private RestHighLevelClient esClient;
/**
......@@ -62,34 +60,6 @@ public class OaipmhElasticSearchClient {
this.esIndex = esIndex;
}
/**
* @return esType
*/
public String getEsType() {
return this.esType;
}
/**
* @param esType
*/
public void setEsType(String esType) {
this.esType = esType;
}
/**
* @return esCluster
*/
public String getClusterName() {
return this.esCluster;
}
/**
* @param esCluster
*/
public void setClusterName(String esCluster) {
this.esCluster = esCluster;
}
/**
* @return url
*/
......@@ -107,7 +77,7 @@ public class OaipmhElasticSearchClient {
/**
* @return port
*/
public int[] getPort() {
public int[] getPorts() {
return this.ports;
}
......
......@@ -445,9 +445,8 @@ public class OaipmhUtilities {
}
// Building the getRequest against the elastic search index.
GetRequest getRequest =
new GetRequest(theESClient.getEsIndex(), theESClient.getEsType(), idInElasticSearchIndex)
.fetchSourceContext(fetchSourceContext);
GetRequest getRequest = new GetRequest(theESClient.getEsIndex(), idInElasticSearchIndex)
.fetchSourceContext(fetchSourceContext);
log.fine("get request id: " + getRequest.id());
......
......@@ -9,7 +9,6 @@ import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.common.Strings;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import info.textgrid.middleware.common.LTPUtils;
import info.textgrid.middleware.common.RDFConstants;
import info.textgrid.middleware.common.TextGridMimetypes;
import info.textgrid.middleware.oaipmh.ContributorType;
......@@ -492,10 +491,10 @@ public class RecordDelivererDatacite extends RecordDelivererAbstract {
RelatedIdentifier relatedID = new RelatedIdentifier();
if (i.startsWith(RDFConstants.HDL_PREFIX)) {
relatedID.setRelatedIdentifierType(RelatedIdentifierType.HANDLE);
relatedID.setValue(LTPUtils.omitHdlPrefix(i));
relatedID.setValue(omitHdlPrefix(i));
} else if (i.startsWith(RDFConstants.DOI_PREFIX)) {
relatedID.setRelatedIdentifierType(RelatedIdentifierType.DOI);
relatedID.setValue(LTPUtils.omitDoiPrefix(i));
relatedID.setValue(omitDoiPrefix(i));
} else if (i.startsWith("http")) {
relatedID.setRelatedIdentifierType(RelatedIdentifierType.URL);
}
......@@ -685,10 +684,10 @@ public class RecordDelivererDatacite extends RecordDelivererAbstract {
AlternateIdentifier alternateID = new AlternateIdentifier();
if (i.startsWith(RDFConstants.HDL_PREFIX)) {
alternateID.setAlternateIdentifierType(ID_TYPE_HANDLE);
alternateID.setValue(LTPUtils.omitHdlPrefix(i));
alternateID.setValue(omitHdlPrefix(i));
} else if (i.startsWith(RDFConstants.DOI_PREFIX)) {
alternateID.setAlternateIdentifierType(ID_TYPE_DOI);
alternateID.setValue(LTPUtils.omitDoiPrefix(i));
alternateID.setValue(omitDoiPrefix(i));
} else {
alternateID.setAlternateIdentifierType(ID_TYPE_OTHER);
alternateID.setValue(i);
......@@ -859,7 +858,7 @@ public class RecordDelivererDatacite extends RecordDelivererAbstract {
// Datacite schema validation!
if (idValue != null && !idValue.isEmpty()) {
identifier.setIdentifierType(ID_TYPE_HANDLE);
identifier.setValue(LTPUtils.omitHdlPrefix(idValue));
identifier.setValue(omitHdlPrefix(idValue));
}
}
......@@ -870,7 +869,7 @@ public class RecordDelivererDatacite extends RecordDelivererAbstract {
else if (this.dariah) {
// We set DOI for DH, 'cause we HAVE it! :-D
identifier.setIdentifierType(ID_TYPE_DOI);
identifier.setValue(LTPUtils.omitDoiPrefix(idValue));
identifier.setValue(omitDoiPrefix(idValue));
}
return identifier;
......@@ -1009,6 +1008,51 @@ public class RecordDelivererDatacite extends RecordDelivererAbstract {
.getYear());
}
/**
* <p>
* Removes the "doi:" from the given DOI, if existing.
* </p>
*
* @param theDOI
* @return
*/
private static String omitDoiPrefix(final String theDOI) {
return omitPrefix(theDOI, RDFConstants.DOI_PREFIX);
}
/**
* <p>
* Removes the "hdl:" from the given PID, if existing.
* </p>
*
* @param theHDL
* @return
*/
private static String omitHdlPrefix(final String theHDL) {
return omitPrefix(theHDL, RDFConstants.HDL_PREFIX);
}
/**
* <p>
* Removes a prefix, including the ":" from the beginning of a string.
* </p>
*
* @param theURI
* @param thePrefix
* @return
*/
private static String omitPrefix(final String theURI, final String thePrefix) {
String result = theURI;
if (theURI != null && theURI.startsWith(thePrefix + ":")) {
result = theURI.replaceFirst(thePrefix + ":", "");
}
return result;
}
// **
// GETTERS & SETTERS
// **
......
......@@ -101,9 +101,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
String[] includes = this.workFields;
String[] excludes = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
GetRequest getRequest =
new GetRequest(this.oaiEsClient.getEsIndex(), this.oaiEsClient.getEsType(), identifier)
.fetchSourceContext(fetchSourceContext);
GetRequest getRequest = new GetRequest(this.oaiEsClient.getEsIndex(), identifier)
.fetchSourceContext(fetchSourceContext);
GetResponse responseWorkValues = null;
try {
......@@ -195,7 +194,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
scrollID = scrollResp.getScrollId();
long completeListSize = scrollResp.getHits().totalHits;
long completeListSize = scrollResp.getHits().getTotalHits().value;
setResultSize(completeListSize);
if (completeListSize > 0) {
......
......@@ -175,31 +175,27 @@ public class RecordListDelivererDatacite extends RecordListDelivererAbstract {
searchSourceBuilder.size(this.searchResponseSize);
searchRequest.source(searchSourceBuilder);
SearchResponse scrollResp = new SearchResponse();
if (resumptionToken != null) {
SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken);
scrollRequest.scroll(TimeValue.timeValueHours(24L));
try {
SearchResponse scrollResp = null;
// SearchResponse scrollResp = new SearchResponse(null);
try {
if (resumptionToken != null) {
SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken);
scrollRequest.scroll(TimeValue.timeValueHours(24L));
scrollResp = this.oaiEsClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
searchRequest.source(searchSourceBuilder);
searchRequest.scroll(TimeValue.timeValueHours(24L));
try {
} else {
searchRequest.source(searchSourceBuilder);
searchRequest.scroll(TimeValue.timeValueHours(24L));
scrollResp = this.oaiEsClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Check if scrollResp == null and what to do then!
String scrollID = scrollResp.getScrollId();
long completeListSize = scrollResp.getHits().totalHits;
long completeListSize = scrollResp.getHits().getTotalHits().value;
setResultSize(completeListSize);
if (completeListSize > 0) {
......@@ -223,6 +219,7 @@ public class RecordListDelivererDatacite extends RecordListDelivererAbstract {
} else {
id2add = hit.getId();
}
uriList.add(id2add);
}
}
......
......@@ -135,7 +135,7 @@ public class RecordListDelivererIdiom extends RecordListDelivererAbstract {
String scrollID = scrollResp.getScrollId();
long completeListSize = scrollResp.getHits().totalHits;
long completeListSize = scrollResp.getHits().getTotalHits().value;
log.fine("total hits: " + completeListSize);
......
......@@ -133,7 +133,6 @@ public class TestDHOaipmhLocally {
int[] ports = new int[] {9202};
oaiEsClient = new OaipmhElasticSearchClient("localhost", ports, 100);
oaiEsClient.setEsIndex("dariah-public");
oaiEsClient.setEsType("metadata");
record = new RecordDelivererDC(false, true);
record.setOaiEsClient(oaiEsClient);
......
......@@ -161,7 +161,6 @@ public class TestTGOaipmhLocally {
int[] ports = new int[] {9202};
oaiEsClient = new OaipmhElasticSearchClient("localhost", ports, 100);
oaiEsClient.setEsIndex("textgrid-public");
oaiEsClient.setEsType("metadata");
record = new RecordDelivererDC(true, false);
record.setOaiEsClient(oaiEsClient);
......
......@@ -41,7 +41,6 @@
<constructor-arg index="2"
value="${elasticSearch.itemLimit}" />
<property name="esIndex" value="${elasticSearch.index}" />
<property name="esType" value="${elasticSearch.type}" />
</bean>
<bean id="NonpublicElasticSearchClient"
......@@ -54,7 +53,6 @@
value="${elasticSearch.itemLimit}" />
<property name="esIndex"
value="${elasticSearch.nonpublicIndex}" />
<property name="esType" value="${elasticSearch.type}" />
</bean>
<!-- Main class bean -->
......
......@@ -11,7 +11,6 @@ RS_ENDPOINT = https://dev.textgridlab.org/1.0/tgoaipmh
elasticSearch.url = searchindex-main
elasticSearch.ports = 9200
elasticSearch.index = ***
elasticSearch.type = metadata
elasticSearch.itemLimit = 100
# NONPUBLIC index only TextGrid IDIOM queries!
elasticSearch.nonpublicIndex = ***
......
......@@ -13,10 +13,10 @@
<jdk.version>1.8</jdk.version>
<antlr-maven-plugin.version>3.2</antlr-maven-plugin.version>
<antlr-runtime.version>3.2</antlr-runtime.version>
<common.version>4.4.1</common.version>
<common.version>5.0.0</common.version>
<cxf.version>3.3.13</cxf.version>
<cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version>
<elasticsearch.version>6.5.4</elasticsearch.version>
<elasticsearch.version>7.9.3</elasticsearch.version>
<jaxb2-namespace-prefix.version>1.3</jaxb2-namespace-prefix.version>
<jetty-maven-plugin.version>9.4.12.v20180830</jetty-maven-plugin.version>
<junit.version>4.13.1</junit.version>
......@@ -26,7 +26,7 @@
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<maven-jaxb2-plugin.version>0.15.2</maven-jaxb2-plugin.version>
<mets-mods-mapping.version>2.4.1</mets-mods-mapping.version>
<mets-mods-mapping.version>2.4.2</mets-mods-mapping.version>
<package-info-maven-plugin.version>1.4.5</package-info-maven-plugin.version>
<properties-maven-plugin.version>1.0-alpha-2</properties-maven-plugin.version>
<rdf4j-repository-api.version>3.0.2</rdf4j-repository-api.version>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment