diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java index ca8c1f03c9daa2136c3e06f4f086a34e70110178..8489a98505e961e141fe4347c34dcc27372fc633 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java @@ -52,6 +52,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); private int searchResponseSize; + private long resultSize; /** * In OAIPMH a ListIdentifiers request is answered by responding the datestamp and the identifier @@ -138,10 +139,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { searchRequest.source(searchSourceBuilder); searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); listListIdentiferValues = OAI_ESClient.getEsClient() - .search( - searchRequest, - RequestOptions.DEFAULT - ); + .search(searchRequest, RequestOptions.DEFAULT); } listListIdentiferValues = hitHandling(listListIdentiferValues, lit, set, listListIdentiferValues.getScrollId()); @@ -160,6 +158,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { String set, String resumptionToken) { int i = 0; + setResultSize(listFurtherValues.getHits().totalHits); for (SearchHit hit : listFurtherValues.getHits().getHits()) { i++; if (this.textgrid) { @@ -379,4 +378,16 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { this.oaiEsClient = oaiEsClient; } + + +public long getResultSize() { + return resultSize; +} + + + +public void setResultSize(long resultSize) { + this.resultSize = resultSize; +} + } 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 4d9e021b390d0b0c527f88bf60a75f163d3544db..173fe454ba6023886ca03329a3da7302f78044e2 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -266,21 +266,6 @@ public class OAIPMHImpl implements OAIPMHProducer { } } - // // Default is DC. - // - // IdentifierListDelivererInterface listDeliv = this.identifierListDC; - // - // this.log.info("Actual Value of IDIOM MetsMods Boolean is: " - // + IdentifierListDelivererAbstract.isIdiomMets()); - // this.log.info("Actual Value of DublinCore Boolean is: " - // + IdentifierListDelivererAbstract.isDublinCore()); - // - // if (IdentifierListDelivererAbstract.isIdiomMets()) { - // listDeliv = this.identifierListIDIOM; - // } else if (IdentifierListDelivererAbstract.isDublinCore()) { - // listDeliv = this.identifierListDC; - // } - ListIdentifiersType listIdentifiers=null; try { listIdentifiers = idListDeliv.processIdentifierList(request.getFrom(), @@ -291,13 +276,19 @@ public class OAIPMHImpl implements OAIPMHProducer { } if (listIdentifiers != null) { + if(identifierListDC.getResultSize()==0) { + requestErrors.setError("RecordMatchError", "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); + oai.getError().add(requestErrors.getError()); + }else { oai.setListIdentifiers(listIdentifiers); - } else { - ErrorHandler idError = new ErrorHandler(); + } + } + //} else { + /*ErrorHandler idError = new ErrorHandler(); idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(idError.getError()); - } + oai.getError().add(idError.getError());*/ + //} } return oaipmhRoot; @@ -427,11 +418,12 @@ public class OAIPMHImpl implements OAIPMHProducer { if (listRecords != null ) { if(recordListDC.getResultSize()==0) { - System.out.println(recordListDC.isFoundItems()); requestErrors.setError("RecordMatchError", "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); oai.getError().add(requestErrors.getError()); + }else { + oai.setListRecords(listRecords); } - oai.setListRecords(listRecords); + } } 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 e0cbfa6498acaf025e0a906626a287f9bd047959..b62aac56e9ab5dcb337f7463a649948f40b1f524 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -44,7 +44,7 @@ public class OaiPmhTest { private OAIPMHImpl request = new OAIPMHImpl( this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.recordList, OaiPmhTest.recordListIDIOM, this.metadataFormatList, - this.setListTextGrid, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM); + OaiPmhTest.setListTextGrid, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM); /** * @throws Exception @@ -249,7 +249,7 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setSearchResponseSize("100"); System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "oai_dc", - "project:TGPR-ed7c757e-1ead-69d4-7c17-554a3581925c", "", "", ""); + "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c", "", "", ""); JAXB.marshal(p, System.out); System.out.println("-----------------------------------\n"); } @@ -355,10 +355,10 @@ public class OaiPmhTest { System.out.println("Test for the verb \"ListRecords\" with sets with succesfull response"); JAXBElement<OAIPMHType> p = - this.request.getRequest("ListRecords", "", "oai_dc", "project:TGPR-bbac3e50-440c-e763-4749-5540cc8bb6aa", "", "", ""); + this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); JAXB.marshal(p, System.out); - /*String resToken =""; + String resToken =""; for(Map.Entry<String, Integer> entry : RecordListDelivererDC.cursorCollector.entrySet()) { resToken = entry.getKey(); } @@ -367,7 +367,7 @@ public class OaiPmhTest { "", "", "", resToken); JAXB.marshal(p2, System.out); System.out.println("HASH MAP AFTER: "); - System.out.println(RecordListDelivererDC.cursorCollector);*/ + System.out.println(RecordListDelivererDC.cursorCollector); System.out.println("-----------------------------------\n"); @@ -417,7 +417,7 @@ public class OaiPmhTest { * @throws ParseException */ @Test - @Ignore + //@Ignore public void testListRecords2() throws ParseException { OaiPmhTest.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST);