From 214c06a34bd4718a7f1b9f680716d19bfcd89cdf Mon Sep 17 00:00:00 2001 From: Maximilian Brodhun <brodhun@sub.uni-goettingen.de> Date: Fri, 8 Mar 2019 12:09:06 +0100 Subject: [PATCH] correction in error and added class for idiom mets data --- oaipmh-core/pom.xml | 25 ++++++++++ .../info/textgrid/middleware/OAIPMHImpl.java | 23 ++++++--- .../middleware/RecordDelivererAbstract.java | 7 +-- .../middleware/RecordDelivererDC.java | 4 +- .../info/textgrid/middleware/OaiPmhTest.java | 47 +++++++++++++++++-- 5 files changed, 92 insertions(+), 14 deletions(-) diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 95385bbd..408d386d 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -86,6 +86,31 @@ <artifactId>metsModsMapping</artifactId> <version>1.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-core</artifactId> + <version>3.4.0</version> + </dependency> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-arq</artifactId> + <version>3.6.0</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + </dependency> + + + + </dependencies> <build> <pluginManagement> 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 efdb7d88..521dad77 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -35,6 +35,7 @@ public class OAIPMHImpl implements OAIPMHProducer { private RepIdentification rep; private RecordListDeliverer recordList; private RecordDelivererDC recDelivDC; + private RecordDelivererIDIOM recDelivIDIOM; private MetadataFormatListDeliverer metadataFormatList; private SetDeliverer setList; private IdentifierListDeliverer identifierList; @@ -52,11 +53,12 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param setList * @param identifierList */ - public OAIPMHImpl(RepIdentification rep, RecordDelivererDC recDelivDC, + public OAIPMHImpl(RepIdentification rep, RecordDelivererDC recDelivDC,RecordDelivererIDIOM recDelivIDIOM, RecordListDeliverer recordList, MetadataFormatListDeliverer metadataFormatList, SetDeliverer setList, IdentifierListDeliverer identifierList) { this.rep = rep; this.recDelivDC = recDelivDC; + this.recDelivIDIOM = recDelivIDIOM; this.recordList = recordList; this.metadataFormatList = metadataFormatList; this.setList = setList; @@ -159,12 +161,18 @@ public class OAIPMHImpl implements OAIPMHProducer { */ public JAXBElement<OAIPMHType> getRecordRequest(ObjectFactory obf, OAIPMHType oai, RequestType request) { - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - // Check request. - ErrorHandler requestErrors = RecordDelivererAbstract.requestChecker(request); - if (requestErrors != null) { + /** + * Check request. In GetRecord: + * allowed parameters: identifier, metadataPrefix, verb + * forbidden: resumptionToken, from, till, set + * optional: no one + */ + + ErrorHandler requestErrors = RecordDelivererAbstract.requestChecker(request); + + if (requestErrors.getError().getCode() != null) { oai.getError().add(requestErrors.getError()); } @@ -176,11 +184,14 @@ public class OAIPMHImpl implements OAIPMHProducer { // Take IDIOM if IDIOM prefix. if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { - // recDeliv = recDelivDC; + System.out.println("IDIOM"); + recDeliv = this.recDelivIDIOM; } // Finally start the QUERY! GetRecordType getRecord = new GetRecordType(); + System.out.println(request.getIdentifier()); + System.out.println(request.getMetadataPrefix()); getRecord = recDeliv.getRecordById(request.getIdentifier()); if (getRecord != null) { diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java index 98cf5612..8ffcb85d 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java @@ -51,7 +51,6 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac else { List<String> errorValues = new ArrayList<String>(); - if (request.getFrom() != null) { errorValues.add("from"); } @@ -70,9 +69,11 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac if (request.getIdentifier() == null) { errorValues.add("identifier"); } + if(errorValues.size()>0) { + result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments " + + "or is missing required arguments: " + errorValues); + } - result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments " - + "or is missing required arguments: " + errorValues); } return result; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java index 3a1b619b..d2f4e46a 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -90,14 +90,14 @@ public class RecordDelivererDC extends RecordDelivererAbstract { * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ public GetRecordType getRecordById(String id) { - + System.out.println("DC"); ObjectFactory of = new ObjectFactory(); OaiDcType odt = new OaiDcType(); GetRecordType grt = new GetRecordType(); RecordType record = new RecordType(); String changedId = id; DublinCoreBuilder dbc = new DublinCoreBuilder(odt, of); - + if (id.startsWith(this.repositoryObjectURIPrefix)) { changedId = changedId.replace(this.repositoryObjectURIPrefix, ""); // System.out.println("CHANGEDID: " + changedId); diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java index e1b1da7c..95f62914 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -35,7 +35,7 @@ public class OaiPmhTest { // false, true); private static RecordDelivererDC record; - + private static RecordDelivererIDIOM recordIDIOM; // private RecordListDeliverer recordList = new RecordListDeliverer(TGConstants.TGFields, // TGConstants.TGWorkFields, true, false); @@ -51,7 +51,7 @@ public class OaiPmhTest { // false, true); private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, true, false); - private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhTest.record, this.recordList, + private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, this.recordList, this.metadataFormatList, this.setListDARIAH, this.identifierList); /** @@ -73,6 +73,8 @@ public class OaiPmhTest { record = new RecordDelivererDC(true, false); record.setOaiEsClient(oaiEsClient); record.setWorkFields(TGConstants.TGWorkFields); + + recordIDIOM = new RecordDelivererIDIOM(true, false); } /** @@ -212,11 +214,50 @@ public class OaiPmhTest { System.out.println("Test for the verb \"GetRecord\" with succesfull response"); JAXBElement<OAIPMHType> p = - this.request.getRequest("GetRecord", "wr71.0", "oai_dc", "", "", "", ""); + this.request.getRequest("GetRecord", "vqn0.0", "oai_dc", "", "", "", ""); JAXB.marshal(p, System.out); System.out.println("-----------------------------------\n"); } + /** + * @throws ParseException + */ + @Test + //@Ignore + public void testGetRequestGetRecordIDIOM() throws ParseException { + + record.setContributor(TGConstants.CONTRIBUTOR_LIST); + record.setCoverage(TGConstants.COVERAGE_LIST); + record.setCreator(TGConstants.CREATOR_LIST); + record.setDates(TGConstants.DATE_LIST); + record.setDescriptions(TGConstants.DESCRIPTION_LIST); + record.setFormats(TGConstants.FORMAT_LIST); + record.setIdentifiers(TGConstants.IDENTIFIER_LIST); + record.setLanguages(TGConstants.LANGUAGE_LIST); + record.setPublishers(TGConstants.PUBLISHER_LIST); + record.setRelations(TGConstants.RELATIONS_LIST); + record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + record.setRights(TGConstants.RIGHTS_LIST); + record.setSources(TGConstants.SOURCE_LIST); + record.setSubjects(TGConstants.SUBJECT_LIST); + record.setTitles(TGConstants.TITLE_LIST); + record.setTypes(TGConstants.TYPE_LIST); + record.setFields(TGConstants.TGFields); + record.setFormatField(TGConstants.FORMAT); + record.setFormatToFilter(TextGridMimetypes.EDITION); + record.setDateOfObjectCreation(TGConstants.CREATED); + record.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); + record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + record.setIdentifierField("textgridUri"); + + System.out.println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> p = + this.request.getRequest("GetRecord", "2557q.0", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + } + + /** * @throws ParseException */ -- GitLab