diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 769303600c7a9274211a447910df7083a8adc560..8d2b6ed11f868ad6acde62d29edfd3269869aa42 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -4,7 +4,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>2.7.2-SNAPSHOT</version> + <version>2.7.3-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java index 79cfc0fe6a8b7f9640254a4058c9e4e303571867..a6f15360b2703a8f264e68149dd86d040a6f0242 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java @@ -239,9 +239,10 @@ public class DublinCoreFieldLoader { public static List<String> setIdentifier(GetResponse responseWorkValues, String[] values) { if(responseWorkValues.isExists()){ - for (String field : values) { - List<Object> entireIdentifier = responseWorkValues.getField(field).getValues(); + for (String field : values) { + if (responseWorkValues.getField(field) != null) { + List<Object> entireIdentifier = responseWorkValues.getField(field).getValues(); for (int i = 0; i < responseWorkValues.getField(field).getValues().size(); i++) { identifiers.add(entireIdentifier.get(i).toString()); } 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 eaaf1ad471fe215a2dc723d3dc1a02e61c2be687..4b3cd822bfec2b30b1937b11617262d8f6dbfce8 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -447,51 +447,28 @@ public class OAIPMHImpl implements OAIPMHProducer { // RecordListDeliverer(oaiEsClient,// TGConstants.TGFields); JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - if (request.getResumptionToken() != null - && request.getMetadataPrefix() != null) { + if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( - "The request includes illegal arguments or missing requiered arguments:" - + errorValues); + error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue("The request includes illegal arguments or missing requiered arguments:" + errorValues); oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); - } else if (request.getResumptionToken() != null - && request.getSet() != null) { + } else if (request.getResumptionToken() != null&& request.getSet() != null) { errorValues.add("Set"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( - "The request includes illegal arguments or missing requiered arguments:" - + errorValues); + error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue("The request includes illegal arguments or missing requiered arguments:" + errorValues); oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); - } else if (request.getResumptionToken() == null - && request.getMetadataPrefix() == null) { + } else if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( - "The request includes illegal arguments or missing requiered arguments:" - + errorValues); + error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue("The request includes illegal arguments or missing requiered arguments:" + errorValues); oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); - } else if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals( - TGConstants.METADATA_DC_PREFIX)) { - error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR) - .setValue( - "The value of the metadataPrefix: " - + request.getMetadataPrefix() - + " is not supported by the item identified by the value of: " - + request.getIdentifier()); - oai.getError().add( - error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR)); + } else if (request.getMetadataPrefix() != null && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { + error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR).setValue("The value of the metadataPrefix: " + request.getMetadataPrefix() + " is not supported by the item identified by the value of: " + request.getIdentifier()); + oai.getError().add(error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR)); } else { - listRecords = recordList.getRecords(request.getFrom(), - request.getUntil(), request.getSet(), - request.getResumptionToken()); + listRecords = recordList.getRecords(request.getFrom(), request.getUntil(), request.getSet(), request.getResumptionToken()); if (listRecords != null) { oai.setListRecords(listRecords); } else { - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue( - "The combination of the values " + request.getFrom() - + " and " + request.getUntil() - + " results in an empty list"); - oai.getError().add( - error.setError(TGConstants.OAI_NO_RECORD_MATCH)); + error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue( "The combination of the values " + request.getFrom() + " and " + request.getUntil() + " results in an empty list"); + oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java index a84e7e67b29f3db2c3cc7a93fb9830d3f1be0cfa..792ccbde40e34a468126753cfc35ef263b57f165 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java @@ -127,7 +127,7 @@ public class RecordDeliverer { GetResponse tgObject = recordById.execute().actionGet(); - System.out.println(tgObject.getField("administrativeMetadata.dcterms:identifier").getValue()); + //System.out.println(tgObject.getField("administrativeMetadata.dcterms:identifier").getValue()); if (tgObject.isExists()) { @@ -236,6 +236,9 @@ public class RecordDeliverer { public void putContentIntoDCFieldLists(GetResponse responseWorkValues, GetResponse relatedWorkObject) { this.contributors = DublinCoreFieldLoader.setContributor(responseWorkValues, this.contributorList); this.formats = DublinCoreFieldLoader.setFormat(responseWorkValues,this.formatList); + for(String bla : identifierList){ + System.out.println("BLA: " + bla); + } this.identifiers = DublinCoreFieldLoader.setIdentifier(responseWorkValues, this.identifierList); this.languages = DublinCoreFieldLoader.setLanguage(responseWorkValues,this.languageList); this.publishers = DublinCoreFieldLoader.setPublisher(responseWorkValues, this.publisherList); diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java index a844642619625069f7e102c221f7bbe3deba1e40..cf6ef1e4050fd04312e3c77d93401571322b8327 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java @@ -157,9 +157,6 @@ public class RecordListDeliverer { */ public void fetchFields(QueryBuilder query, ListRecordsType recordList, String resumptionToken, String set) throws UnsupportedEncodingException { - -// System.out.println("RESTOKEN: "+ resumptionToken); - //SearchResponse getRecordList = null; String scrollID = ""; SearchResponse scrollResp; QueryBuilder recordFilter; @@ -169,9 +166,7 @@ public class RecordListDeliverer { }else { recordFilter = QueryBuilders.boolQuery().must(query).must(QueryBuilders.matchPhraseQuery(formatField, formatToFilter)); } - -// System.out.println("QUERY: " + recordFilter); - + if (resumptionToken == null) { scrollResp = OAI_ESClient.getOaiESClient().prepareSearch(OAI_ESClient.getEsIndex()) .setScroll(new TimeValue(lifeTimeResToken)) @@ -181,56 +176,37 @@ public class RecordListDeliverer { .setSize(searchResponseSize) .execute() .actionGet(); - //System.out.println(scrollResp); -// System.out.println("Clustername: " + OAI_ESClient.getEsIndex()); } else { scrollResp = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken).setScroll(new TimeValue(lifeTimeResToken)).execute().actionGet(); } - - //System.out.println("QUERY: " + scrollResp); scrollID = scrollResp.getScrollId(); long completeListSize = scrollResp.getHits().totalHits(); + System.out.println("LISTSIZE: " + completeListSize); -// System.out.println("COMPLETELISTESIZE: " + completeListeSize); if (completeListSize > 0) { setFoundItems(true); -// System.out.println("ÃœBER IF"); - - //resTokenForResponse.setCursor((BigInteger.valueOf(searchResposeSize))); - //resTokenForResponse.setValue(scrollID); int i =0; - -// System.out.println("YEAH"); - + for (SearchHit hit : scrollResp.getHits().getHits()) { - -// System.out.println("YEAH FOR EACH"); - + i++; -// System.out.println("TADA"); - if (hit != null && hit.getFields() != null) { - //System.out.println("SROLL_ID" + scrollID ); try { if(hit.getFields().get(this.dateOfObjectCreation)!=null){ String datestamp = hit.getFields().get(this.dateOfObjectCreation).getValue().toString(); datestamp = OAIPMHUtillities.convertDateFormat(datestamp).toXMLFormat(); - //System.out.println("DATESTAMP: " + datestamp); } } catch (ParseException e1) { log.debug(e1); } catch (DatatypeConfigurationException e1) { log.debug(e1); } - //System.out.println("MODIFIEDFIELD: " + modifiedField); modifiedValue = hit.getFields().get(this.modifiedField).getValue().toString(); - //System.out.println("MODIEFED: " + modifiedValue); - // TextGrid search! String workUri = ""; if (this.textgrid == true && hit.getFields().get(formatField).values().get(0).toString().equals(formatToFilter)) { @@ -250,19 +226,15 @@ public class RecordListDeliverer { if (this.dariah == true) { putContentIntoDCFieldLists2(hit, furtherDCElements(hit.getId(), OAI_ESClient.getOaiESClient())); - //System.out.println("IDENTFIER: " + this.identifierField); buildRecord(recordList, set, hit.getFields().get(this.identifierField).getValue().toString()); listClearer(); } } } - -// System.out.println("BLABLABLABLA"); // Check the need for a resumption token! - ResumptionTokenType resTokenForResponse = OAIPMHUtillities.getResumptionToken( - completeListSize, resumptionToken, cursorCollector, scrollID, searchResponseSize, i); + ResumptionTokenType resTokenForResponse = OAIPMHUtillities.getResumptionToken(completeListSize, resumptionToken, cursorCollector, scrollID, searchResponseSize, i); if (resTokenForResponse != null) { recordList.setResumptionToken(resTokenForResponse); } @@ -360,14 +332,12 @@ public class RecordListDeliverer { * @return */ public ListRecordsType getRecords(String from, String to, String set, String resumptionToken) { - //System.out.println("RECOGNIZED SET WITH NAME: " + set); + ListRecordsType recordList = new ListRecordsType(); QueryBuilder query; QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(to); if (set != null) { - //this.set = set; -// System.out.println("SET IS HERE: " + set); String queryField = ""; String valueField = ""; @@ -386,9 +356,8 @@ public class RecordListDeliverer { QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); - //System.out.println(boolQuery); query = boolQuery; - + System.out.println(query); } else { query = rangeQuery; @@ -434,12 +403,8 @@ public class RecordListDeliverer { } else header.setIdentifier(headerIdentifier); - //System.out.println("identifiers: " + this.identifiers.get(0)); if (set != null) { header.getSetSpec().add(set); -// System.out.println("BLABLUBB"); - // header.getSetSpec().add(this.collectionTitle); - //} } return header; } @@ -467,9 +432,6 @@ public class RecordListDeliverer { dbc.setSource(this.sources); dbc.setSubject(this.subjects); dbc.setTitle(this.titles); - for(String title : titles){ - System.out.println("LISTRECORDS TITLES: " + title); - } dbc.setType(this.types); return dbc; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java index e6c0effbc7a35d540b800921d94905a5c9f0b364..0275dc6cc56422d3793d42d21227d9b5f325c480 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java @@ -102,9 +102,8 @@ public final class TGConstants { public static final String[] CREATOR_LIST = { WORK_AGENT }; public static final String[] DATE_LIST = { CREATED }; public static final String[] DESCRIPTION_LIST = { WORK_ABSTRACT }; - public static final String[] FORMAT_LIST = { FORMAT }; - public static final String[] IDENTIFIER_LIST = { URI, - PID, IDENTIFIER }; + public static final String[] FORMAT_LIST = { FORMAT }; + public static final String[] IDENTIFIER_LIST = { URI,PID, IDENTIFIER}; public static final String[] LANGUAGE_LIST = { EDITION_LANGUAGE }; public static final String[] PUBLISHER_LIST = { BIBCIT_PUBLISHER }; public static final String[] RELATIONS_LIST = { 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 23280207666811eede0804de550af902f2152f33..371c17a4fc0f78e03ee0d2fceca198f8e666c502 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -36,9 +36,9 @@ public class OaiPmhTest { // oaiEsClient, // TGConstants.TGWorkFields, // true, false); - private RecordDeliverer record = new RecordDeliverer(oaiEsClient, DARIAHConstants.DARIAHFields, false, true); + //private RecordDeliverer record = new RecordDeliverer(oaiEsClient, DARIAHConstants.DARIAHFields, false, true); - //private RecordDeliverer record = new RecordDeliverer(oaiEsClient, TGConstants.TGFields, true, false); + private RecordDeliverer record = new RecordDeliverer(oaiEsClient, TGConstants.TGFields, true, false); //private RecordListDeliverer recordList = new RecordListDeliverer(TGConstants.TGFields, TGConstants.TGWorkFields, true, false); @@ -60,8 +60,8 @@ public class OaiPmhTest { public static void setUp() throws Exception { //sc = new SesameClient("http://localhost:9091/openrdf-workbench/repositories/textgrid-public"); - //oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx1-dev-instance"); - oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); + oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); + //oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); OAI_ESClient.setEsIndex("textgrid-public"); OAI_ESClient.setEsType("metadata"); //oaiEsClient.setEsIndex("dariahreptest"); @@ -204,7 +204,7 @@ public class OaiPmhTest { this.record.setIdentifierField("textgridUri"); System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord","textgrid:m90c.0", "oai_dc", "", "", "", ""); + JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord","wr71.0", "oai_dc", "", "", "", ""); JAXB.marshal(p, System.out); System.out.println("-----------------------------------\n"); } @@ -373,7 +373,7 @@ public class OaiPmhTest { * @throws ParseException */ @Test - @Ignore + //@Ignore public void testListRecordsDariah() throws ParseException { //System.out.println("BUJA"); @@ -398,16 +398,12 @@ public class OaiPmhTest { this.recordList.setFieldForRange(DARIAHConstants.MODIFIED_FIELD); this.recordList.setDateOfObjectCreation(DARIAHConstants.RANGE_FIELD); this.recordList.setIdentifierField(DARIAHConstants.IDENTIFIER); - //this.recordList.setFormatField("descriptiveMetadata.dc:format"); this.recordList.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); this.recordList.setModifiedField(DARIAHConstants.MODIFIED_FIELD); - // this.recordList.setFormatToFilter("image/png"); this.recordList.setRelationToFurtherMetadataObject("descriptiveMetadata.dc:relation"); this.recordList.setSearchResponseSize("100"); - // cregId:hdl:6607/0000-0000-26A5-B - // dariah:collection:6607/0000-0000-26A5-B - JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "hdl:21.T11991/0000-0003-5666-A", "", "", ""); + JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "21.T11991/0000-0003-718E-E", "", "", ""); JAXB.marshal(r, System.out); System.out.println("-----------------------------------\n"); } diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index ce108ffeaf1c5dfb1c93a4a9aea1819325e35e1f..4998779a2b4abe86f1ba8a17a7ec5cd9e5d16e6d 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -4,7 +4,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>2.7.2-SNAPSHOT</version> + <version>2.7.3-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> diff --git a/pom.xml b/pom.xml index e5ffe7de4052afd644b9d0cb1f49205fe10d5da3..2e6d1b87be4037537e1ca0492424241dda4e56ea 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>2.7.2-SNAPSHOT</version> + <version>2.7.3-SNAPSHOT</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties>