diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java index e08db81e6a8baf71a979fa6dfe99c98fa86f887a..e72dce17d87e975bc2f4f3b97b7130e9cd404ae6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java @@ -53,7 +53,7 @@ import info.textgrid.middleware.oaipmh.TitleType; /** * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2021-07-06 + * @version 2021-07-09 * @since 2020-06-13 */ @Component @@ -106,10 +106,10 @@ public class RecordDelivererDATACITE extends RecordDelivererAbstract { */ public GetRecordType getRecordById(String idInElasticSearchIndex) throws ParseException, DatatypeConfigurationException, IOException { + this.jsonObj = new JSONObject(OAIPMHUtilities .getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), - idInElasticSearchIndex.replace("textgrid:", ""), this.fields, - Strings.EMPTY_ARRAY) + idInElasticSearchIndex.replace("textgrid:", ""), this.fields, Strings.EMPTY_ARRAY) .getSource()); HeaderType header = new HeaderType(); diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java index 2c5f96a6987c658f5090448d20457c33057e9a2f..628a9d24b2a4a5560701312b73e7315c9c5ebdc2 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java @@ -248,20 +248,43 @@ public class OaiPmhTextgridOnlineTests { host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + OAI_DC_PREFIX; - if (!host.contains("dev.textgridlab.org")) { - TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); - int status = httpResponse.getStatusCode(); - String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); - System.out.println("\tresponse: " + response); + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); - if (!response.contains(shouldContain)) { - assertTrue(false); - } + if (!response.contains(shouldContain)) { + assertTrue(false); + } - System.out.println(OK); - } else { - System.out.println(NOT_TESTED); + System.out.println(OK); + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordOAIDCNoPrefix() throws IOException { + + System.out.println(TESTING + "testGetRecordOAIDCNoPrefix()"); + + String identifier = "mq05.0"; + String shouldContain = "tvitt@textgrid.de"; + + String url = + host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + + OAI_DC_PREFIX; + + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); + + if (!response.contains(shouldContain)) { + assertTrue(false); } + + System.out.println(OK); } /** @@ -272,27 +295,104 @@ public class OaiPmhTextgridOnlineTests { System.out.println(TESTING + "testGetRecordIDIOMMETS()"); - String identifier = "textgrid:254w6"; - String shouldContain = "Tikal"; + String identifier = "textgrid:2sg18.0"; + String shouldContain = "Aguateca"; String url = host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + OAI_IDIOMMETS_PREFIX; - if (!host.contains("dev.textgridlab.org")) { - TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); - int status = httpResponse.getStatusCode(); - String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); - System.out.println("\tresponse: " + response); + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); - if (!response.contains(shouldContain)) { - assertTrue(false); - } + if (!response.contains(shouldContain)) { + assertTrue(false); + } - System.out.println(OK); - } else { - System.err.println(NOT_TESTED); + System.out.println(OK); + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordIDIOMMETSNoPrefix() throws IOException { + + System.out.println(TESTING + "testGetRecordIDIOMMETSNoPrefix()"); + + String identifier = "2sg18.0"; + String shouldContain = "Aguateca"; + + String url = + host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + + OAI_IDIOMMETS_PREFIX; + + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); + + if (!response.contains(shouldContain)) { + assertTrue(false); } + + System.out.println(OK); + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordDATACITE() throws IOException { + + System.out.println(TESTING + "testGetRecordDATACITE()"); + + String identifier = "textgrid:mq05.0"; + String shouldContain = "Wer dich kennt - der kaufft dich nit"; + + String url = + host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + + OAI_DATACITE_PREFIX; + + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); + + if (!response.contains(shouldContain)) { + assertTrue(false); + } + + System.out.println(OK); + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordDATACITENoPrefix() throws IOException { + + System.out.println(TESTING + "testGetRecordDATACITENoPrefix()"); + + String identifier = "mq05.0"; + String shouldContain = "Wer dich kennt - der kaufft dich nit"; + + String url = + host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" + + OAI_DATACITE_PREFIX; + + TGHttpResponse httpResponse = getHttpResponse(url, NO_THREAD_NAME); + int status = httpResponse.getStatusCode(); + String response = IOUtils.readStringFromStream(httpResponse.getInputstream()); + System.out.println("\tresponse: " + response); + + if (!response.contains(shouldContain)) { + assertTrue(false); + } + + System.out.println(OK); } /** diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/TestOAIPMHUtilities.java b/oaipmh-core/src/test/java/info/textgrid/middleware/TestOAIPMHUtilities.java new file mode 100644 index 0000000000000000000000000000000000000000..6d711f51fcdf0bf24aee23a57cc591a6117f7665 --- /dev/null +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/TestOAIPMHUtilities.java @@ -0,0 +1,63 @@ +package info.textgrid.middleware; + +import static org.junit.Assert.assertTrue; +import java.text.ParseException; +import org.junit.Test; + +/** + */ +public class TestOAIPMHUtilities { + + /** + * @throws ParseException + */ + @Test + public void testOmitPrefixFromIdentifier() { + + // Check Handle IDs (dhrep). + String id1 = "hdl:21.11113/0000-000B-C8EF-7"; + String exp1 = "21.11113/0000-000B-C8EF-7"; + String res1 = OAIPMHUtilities.omitPrefixFromIdentifier(id1); + if (!res1.equals(exp1)) { + System.out.println(res1 + "!=" + exp1); + assertTrue(false); + } + + // Check tgrep set IDs. + String id2 = "project:TGPR-2c283391-6ed5-70b4-2e5e-5501c856bca9"; + String exp2 = "TGPR-2c283391-6ed5-70b4-2e5e-5501c856bca9"; + String res2 = OAIPMHUtilities.omitPrefixFromIdentifier(id2); + if (!res2.equals(exp2)) { + System.out.println(res2 + "!=" + exp2); + assertTrue(false); + } + + // Check tgrep identifier. + String id3 = "textgrid:24gv8.0"; + String exp3 = "24gv8.0"; + String res3 = OAIPMHUtilities.omitPrefixFromIdentifier(id3); + if (!res3.equals(exp3)) { + System.out.println(res3 + "!=" + exp3); + assertTrue(false); + } + + // Check unknown prefix. + String id4 = "urgli:furgli"; + String exp4 = "urgli:furgli"; + String res4 = OAIPMHUtilities.omitPrefixFromIdentifier(id4); + if (!res4.equals(exp4)) { + System.out.println(res4 + "!=" + exp4); + assertTrue(false); + } + + // Check no prefix. + String id5 = "URGLARGLAUA"; + String exp5 = "URGLARGLAUA"; + String res5 = OAIPMHUtilities.omitPrefixFromIdentifier(id5); + if (!res5.equals(exp5)) { + System.out.println(res5 + "!=" + exp5); + assertTrue(false); + } + } + +} diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties index f8caf3dbcfbf0b23a2e5c1dea1c7b52fcfcdfd97..07b19be2bbcc0ca05e84ea844042018a3bbed397 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties @@ -59,10 +59,10 @@ oar.formatFields = administrativeMetadata.dcterms:format oar.rightsFields = descriptiveMetadata.dc:rights oar.descriptionFields = descriptiveMetadata.dc:decsription oar.relatedIdentifierFields = descriptiveMetadata.dc:relation -oar.relationToWorkObject = +oar.relationToWorkObject = na oar.geoLocationFields = descriptiveMetadata.dc:coverage oar.handle = administrativeMetadata.dcterms:identifier -oar.versionFields = +oar.versionFields = na oar.subjectFields = descriptiveMetadata.dc:subject oar.sizeField = administrativeMetadata.dcterms:extent