diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index da21578a329329b3c4175b1d8e14e43f95696f3f..ca53bd66e98ebad7d26855d9ab64b5e679edc598 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.4-SNAPSHOT</version> + <version>3.4.1-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java index baac2e476146ebe56f9c622ff8d81f73271e6ac8..4ca6df2f63eea5a067684e31b97e86b8df5187cd 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java @@ -6,18 +6,22 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.Map; -// import javax.swing.plaf.synth.SynthSpinnerUI; +import javax.xml.datatype.DatatypeConfigurationException; import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.json.JSONObject; import info.textgrid.middleware.common.TextGridMimetypes; +import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.RequestType; import info.textgrid.middleware.oaipmh.ResumptionTokenType; @@ -27,18 +31,40 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; */ public abstract class IdentifierListDelivererAbstract implements IdentifierListDelivererInterface { - protected boolean textgrid; - protected boolean dariah; - private boolean foundItems; - private long resultSize; - private int searchResponseSize; - public String rangeField; + // ** + // FINALS + // ** - protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - public ResumptionTokenType resTokenForResponse; + protected static final int lifeTimeResToken = 100; + + // ** + // STATIC + // ** private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordListDelivererAbstract.class); + protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + + // ** + // CLASS + // ** + + protected boolean textgrid; + protected boolean dariah; + protected boolean foundItems; + protected long resultSize; + protected int searchResponseSize; + protected ResumptionTokenType resTokenForResponse; + protected String datestamp; + protected boolean idExist = true; + protected OAI_ESClient oaiEsClient; + protected String[] identifierListFields; // Fields for the elasticsearch request + protected String rangeField; // Field for the optional range query + protected String dateOfObjectCreation; // Field for the object creation in the repository + protected String repositoryObjectURIPrefix; // + protected String identifierField; + protected String formatField; + protected String formatToFilter; /** * @param textgrid @@ -49,16 +75,218 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD this.dariah = dariah; } - /* - * (non-Javadoc) + // ** + // PUBLIC METHODS + // ** + + /** + * @param request + * @return + */ + public static ErrorHandler requestChecker(RequestType request) { + + ErrorHandler result = new ErrorHandler(); + + // Check if metadata prefix is existing and valid. + if (request.getMetadataPrefix() != null + && !request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { + result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, + "The value of the metadataPrefix: " + request.getMetadataPrefix() + + " is not supported by the item identified by the value of: " + + request.getIdentifier()); + } + + // Check if resumptionToken is invalid or existing. + if (request.getResumptionToken() != null) { + boolean restokDCExisting = IdentifierListDelivererDC.cursorCollector != null + && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); + boolean restokIDIOMExisting = IdentifierListDelivererIDIOM.cursorCollector != null + && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); + boolean restok = cursorCollector != null + && cursorCollector.containsKey(request.getResumptionToken()); + + if (!restokDCExisting && !restokIDIOMExisting && !restok) { + + result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " + + request.getResumptionToken() + " argument is invalid or expired."); + } + } + + List<String> errorValues = new ArrayList<String>(); + + if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { + errorValues.add("metadataPrefix"); + } + 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); + } + + return result; + } + + /** + * <p> + * To get the required values for the ListIdentifiers request this function will ask ElasticSearch + * for a specific textgridUri the values "created" and "textgridUri". + * </p> * - * @see info.textgrid.middleware.IdentifierListDelivererInterface#processIdentifierList(java.lang. - * String, java.lang.String, java.lang.String, java.lang.String) + * <p> + * Since the ListIdentifiers request enables the possibility the limit the request in a specific + * time interval, it is necessary to perform a range query on the ElasticSearch index.</p + * + * @param from : start value for the range query + * @param to : end value to the range query + * @return after calling the function "setListIdentifierHeader" the return value is the whole + * ListIdentifiers element + * @throws IOException */ - @Override - public ListIdentifiersType processIdentifierList(String from, String until, String set, + public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) throws IOException, ParseException { - return null; + + // FIXME combine it with with getIdentifierListWithSet and check for empty set + + ListIdentifiersType lit = new ListIdentifiersType(); + QueryBuilder query = setOrNot(set, from, to); + SearchResponse listListIdentiferValues; + + String[] includes = this.identifierListFields; + String[] excludes = Strings.EMPTY_ARRAY; + // TODO: necessary? + // FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + + SearchRequest searchRequest = + new SearchRequest(OAI_ESClient.getEsIndex()).searchType(SearchType.QUERY_THEN_FETCH); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(query); + searchSourceBuilder.size(this.searchResponseSize); + searchSourceBuilder.fetchSource(includes, excludes); + + if (resumptionToken != null) { + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueSeconds(lifeTimeResToken)); + listListIdentiferValues = + OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); + } else { + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); + listListIdentiferValues = + OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); + } + + listListIdentiferValues = + hitHandling(listListIdentiferValues, lit, set, listListIdentiferValues.getScrollId()); + + return lit; + } + + /** + * @param listFurtherValues + * @param lit + * @param set + * @param resumptionToken + * @return + */ + public SearchResponse hitHandling(SearchResponse listFurtherValues, ListIdentifiersType lit, + String set, String resumptionToken) { + + int i = 0; + long size = listFurtherValues.getHits().totalHits; + setResultSize(size); + + log.debug("hits: " + size); + + for (SearchHit hit : listFurtherValues.getHits().getHits()) { + i++; + + log.debug("hit " + i + ": " + hit.getId()); + + // Handle TextGrid. + if (this.textgrid) { + String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); + try { + datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat(); + } catch (ParseException e) { + log.error(e.getMessage()); + } catch (DatatypeConfigurationException e) { + log.error(e.getMessage()); + } + String identifier = hit.getSourceAsMap().get(this.identifierField).toString(); + lit = setListIdentifierHeader(datestamp, identifier, lit, set); + } + + // Handle DARIAH. + else if (this.dariah) { + + log.debug("dateOfObjectCreation: " + this.dateOfObjectCreation); + + JSONObject json = new JSONObject(hit.getSourceAsMap()); + + // Get modifiedDate field and convert datestamp. + this.datestamp = OAIPMHUtilities.fieldLoader(json, this.dateOfObjectCreation); + try { + log.debug("datestamp: " + this.datestamp); + + this.datestamp = OAIPMHUtilities.convertDateFormat(this.datestamp).toXMLFormat(); + + log.debug("datestamp converted: " + this.datestamp); + + } catch (ParseException e) { + log.error(e.getMessage()); + // FIXME Go to ERROR state! + } catch (DatatypeConfigurationException e) { + log.error(e.getMessage()); + // FIXME Go to ERROR state! + } + + // Get identifier field. + String identifier = OAIPMHUtilities.fieldLoader(json, this.identifierField); + + log.debug("identifier: " + identifier); + + lit = setListIdentifierHeader(this.datestamp, identifier, lit, set); + } + } + + // Check the need for a resumption token! + ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken( + listFurtherValues.getHits().getTotalHits(), resumptionToken, cursorCollector, + listFurtherValues.getScrollId(), this.searchResponseSize, i); + if (resTokenForResponse != null) { + lit.setResumptionToken(resTokenForResponse); + } + + return listFurtherValues; + } + + /** + * @param datestamp + * @param identifier + * @param lit + * @param set + * @return + */ + private static ListIdentifiersType setListIdentifierHeader(String datestamp, String identifier, + ListIdentifiersType lit, String set) { + + // FIXME Delete this function and check for empty set string in setListIdentifierHeaderWithSet + + HeaderType header = new HeaderType(); + header.setDatestamp(datestamp); + header.setIdentifier(identifier); + + if (set != null) { + header.getSetSpec().add(set); + } + lit.getHeader().add(header); + + return lit; } /** @@ -72,6 +300,8 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD public List<String> getUriListOfAllEditions(String from, String until, String set, String resumptionToken) throws IOException { + // NOTE Used by OpenAireIdentifierList + /* * InputStream input = null; try { input = new * FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); } catch (FileNotFoundException e) { @@ -112,6 +342,10 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD return getContentFromESIndex(query, resumptionToken, set); } + // ** + // PRIVATE METHODS + // ** + /** * @param query * @param resumptionToken @@ -201,58 +435,56 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD return uriList; } - /** - * @param request + * @param set + * @param from + * @param until * @return */ - public static ErrorHandler requestChecker(RequestType request) { - - ErrorHandler result = new ErrorHandler(); + public QueryBuilder setOrNot(String set, String from, String until) { - // Check if metadata prefix is existing and valid. - if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX) - && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX) - && !request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { - result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, - "The value of the metadataPrefix: " + request.getMetadataPrefix() - + " is not supported by the item identified by the value of: " - + request.getIdentifier()); - } + QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(until); + QueryBuilder formatQuery = QueryBuilders.matchPhrasePrefixQuery("format", this.formatToFilter); + QueryBuilder query; - // Check if resumptionToken is invalid or existing. - if (request.getResumptionToken() != null) { - boolean restokDCExisting = IdentifierListDelivererDC.cursorCollector != null - && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); - boolean restokIDIOMExisting = IdentifierListDelivererIDIOM.cursorCollector != null - && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); - boolean restok = cursorCollector != null - && cursorCollector.containsKey(request.getResumptionToken()); + if (set != null) { + String queryField = ""; + String valueField = ""; - if (!restokDCExisting && !restokIDIOMExisting && !restok) { + if (this.dariah == true) { + queryField = "descriptiveMetadata.dc:relation"; + valueField = set; + } - result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " - + request.getResumptionToken() + " argument is invalid or expired."); + if (this.textgrid == true) { + String[] setParts = set.split(":"); + if (setParts[0].equals("project")) { + queryField = "project.id"; + valueField = setParts[1]; + } } - } - List<String> errorValues = new ArrayList<String>(); + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); + if (this.dariah) { + query = matchQuery; + } else { + query = QueryBuilders.boolQuery().must(matchQuery).must(formatQuery).must(rangeQuery); + } - if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { - errorValues.add("metadataPrefix"); - } - 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); + } else { + if (this.dariah == true) + query = rangeQuery; + else + query = QueryBuilders.boolQuery().must(rangeQuery).must(formatQuery); } - return result; + return query; } + // ** + // GETTERS & SETTERS + // ** + /** * @return */ @@ -298,15 +530,149 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD /** * @return */ - public String getRangeField() { + public String getFieldForRange() { return this.rangeField; } /** - * @param rangeField + * @param fieldForRange + */ + public void setFieldForRange(String fieldForRange) { + this.rangeField = fieldForRange; + } + + /** + * @return + */ + public OAI_ESClient getOaiEsClient() { + return this.oaiEsClient; + } + + /** + * @param oaiEsClient + */ + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } + + /** + * @param lit + * @return + */ + public ListIdentifiersType getLit(ListIdentifiersType lit) { + return lit; + } + + /** + * @return + */ + public String getDateOfObjectCreation() { + return this.dateOfObjectCreation; + } + + /** + * @param dateOfObjectCreation + */ + public void setDateOfObjectCreation(String dateOfObjectCreation) { + this.dateOfObjectCreation = dateOfObjectCreation; + } + + /** + * @param repositoryObjectURIPrefix + */ + public void setRepositoryObjectURIPrefix(String repositoryObjectURIPrefix) { + this.repositoryObjectURIPrefix = repositoryObjectURIPrefix; + } + + /** + * @return + */ + public String getRepositoryObjectURIPrefix() { + return this.repositoryObjectURIPrefix; + } + + /** + * @param validItem + */ + public void setIdExist(boolean validItem) { + this.idExist = validItem; + } + + /** + * @return + */ + public boolean getIdExist() { + return this.idExist; + } + + /** + * @return + */ + public String[] getIdentifierListFields() { + return this.identifierListFields; + } + + /** + * @param identifierListFields + */ + public void setIdentifierListFields(String[] identifierListFields) { + this.identifierListFields = identifierListFields; + } + + /** + * @return + */ + public String getFormatField() { + return this.formatField; + } + + /** + * @param formatField + */ + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + /** + * @return + */ + public String getFormatToFilter() { + return this.formatToFilter; + } + + /** + * @param formatToFilter + */ + public void setFormatToFilter(String formatToFilter) { + this.formatToFilter = formatToFilter; + } + + /** + * @return + */ + public String getIdentifierField() { + return this.identifierField; + } + + /** + * @param identifierPrefix + */ + public void setIdentifierField(String identifierPrefix) { + this.identifierField = identifierPrefix; + } + + /** + * @return + */ + public int getSearchResponseSize() { + return this.searchResponseSize; + } + + /** + * @param searchResponseSize */ - public void setRangeField(String rangeField) { - this.rangeField = rangeField; + public void setSearchResponseSize(String searchResponseSize) { + this.searchResponseSize = Integer.parseInt(searchResponseSize); } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDATACITE.java new file mode 100644 index 0000000000000000000000000000000000000000..ea7a7535dc074de0b842c06f6c3b332a8102a5ce --- /dev/null +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDATACITE.java @@ -0,0 +1,24 @@ +package info.textgrid.middleware; + +/** + * <p> + * Class to build the Element for a ListIdentifiers request. + * </p> + * + * @author Stefan E. Funk, SUB Göttingen + * @version 2021-07-06 + * @since 2014-02-20 + */ + +public class IdentifierListDelivererDATACITE extends IdentifierListDelivererAbstract { + + /** + * @param datestamp taken from the elasticSearch index (created element) + * @param identifier taken from the elasticSearch index (textgridUri) + * @return the ListIdentifierElement with the responded header element + */ + public IdentifierListDelivererDATACITE(boolean textgrid, boolean dariah) { + super(textgrid, dariah); + } + +} 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 3e37efdc4a782a24b82445a30911f60aeb702555..6aad6aaa70261e0f106e49c816ec1f0b3f82f8a6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java @@ -1,29 +1,5 @@ package info.textgrid.middleware; -import java.io.IOException; -import java.text.ParseException; -import java.util.Hashtable; -import java.util.Map; -import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.client.RequestOptions; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.json.JSONObject; -import info.textgrid.middleware.common.TextGridMimetypes; -import info.textgrid.middleware.oaipmh.HeaderType; -import info.textgrid.middleware.oaipmh.ListIdentifiersType; -import info.textgrid.middleware.oaipmh.ResumptionTokenType; - /** * <p> * Class to build the Element for a ListIdentifiers request. @@ -31,32 +7,12 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2021-06-18 + * @version 2021-07-06 * @since 2014-02-20 */ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { - private static Log log = LogFactory.getLog(IdentifierListDelivererDC.class); - - private static final int lifeTimeResToken = 100; - - // private static org.apache.commons.logging.Log log = - // LogFactory.getLog(IdentifierListDelivererDC.class); - public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - - private String datestamp; - private boolean idExist = true; - private OAI_ESClient oaiEsClient; - - private String[] identifierListFields; // Fields for the elasticsearch request - private String rangeField; // Field for the optional range query - private String dateOfObjectCreation; // Field for the object creation in the repository - private String repositoryObjectURIPrefix; // - private String identifierField; - private int searchResponseSize; - private long resultSize; - /** * <p> * In OAIPMH a ListIdentifiers request is answered by responding the datestamp and the identifier @@ -72,349 +28,4 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { super(textgrid, dariah); } - /** - * @param datestamp - * @param identifier - * @param lit - * @param set - * @return - */ - private static ListIdentifiersType setListIdentifierHeader(String datestamp, String identifier, - ListIdentifiersType lit, String set) { - - // FIXME Delete this function and check for empty set string in setListIdentifierHeaderWithSet - - HeaderType header = new HeaderType(); - header.setDatestamp(datestamp); - header.setIdentifier(identifier); - - if (set != null) { - header.getSetSpec().add(set); - } - lit.getHeader().add(header); - - return lit; - } - - /** - * <p> - * To get the required values for the ListIdentifiers request this function will ask ElasticSearch - * for a specific textgridUri the values "created" and "textgridUri". - * </p> - * - * <p> - * Since the ListIdentifiers request enables the possibility the limit the request in a specific - * time interval, it is necessary to perform a range query on the ElasticSearch index.</p - * - * @param from : start value for the range query - * @param to : end value to the range query - * @return after calling the function "setListIdentifierHeader" the return value is the whole - * ListIdentifiers element - * @throws IOException - */ - public ListIdentifiersType processIdentifierList(String from, String to, String set, - String resumptionToken) throws IOException { - - // FIXME combine it with with getIdentifierListWithSet and check for empty set - - ListIdentifiersType lit = new ListIdentifiersType(); - QueryBuilder query = setOrNot(set, from, to); - SearchResponse listListIdentiferValues; - - String[] includes = this.identifierListFields; - String[] excludes = Strings.EMPTY_ARRAY; - // TODO: necessary? - // FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); - - SearchRequest searchRequest = - new SearchRequest(OAI_ESClient.getEsIndex()).searchType(SearchType.QUERY_THEN_FETCH); - - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - searchSourceBuilder.query(query); - searchSourceBuilder.size(this.searchResponseSize); - searchSourceBuilder.fetchSource(includes, excludes); - - if (resumptionToken != null) { - SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); - scrollRequest.scroll(TimeValue.timeValueSeconds(lifeTimeResToken)); - listListIdentiferValues = - OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); - } else { - searchRequest.source(searchSourceBuilder); - searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); - listListIdentiferValues = - OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); - } - listListIdentiferValues = - hitHandling(listListIdentiferValues, lit, set, listListIdentiferValues.getScrollId()); - - return lit; - } - - /** - * @param listFurtherValues - * @param lit - * @param set - * @param resumptionToken - * @return - */ - public SearchResponse hitHandling(SearchResponse listFurtherValues, ListIdentifiersType lit, - String set, String resumptionToken) { - - int i = 0; - long size = listFurtherValues.getHits().totalHits; - setResultSize(size); - - log.debug("hits: " + size); - - for (SearchHit hit : listFurtherValues.getHits().getHits()) { - i++; - - log.debug("hit " + i + ": " + hit.getId()); - - // Handle TextGrid. - if (this.textgrid) { - String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); - try { - datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat(); - } catch (ParseException e) { - log.error(e.getMessage()); - } catch (DatatypeConfigurationException e) { - log.error(e.getMessage()); - } - String identifier = hit.getSourceAsMap().get(this.identifierField).toString(); - lit = setListIdentifierHeader(datestamp, identifier, lit, set); - } - - // Handle DARIAH. - else if (this.dariah) { - - log.debug("dateOfObjectCreation: " + this.dateOfObjectCreation); - - JSONObject json = new JSONObject(hit.getSourceAsMap()); - - // Get modifiedDate field and convert datestamp. - this.datestamp = OAIPMHUtilities.fieldLoader(json, this.dateOfObjectCreation); - try { - log.debug("datestamp: " + this.datestamp); - - this.datestamp = OAIPMHUtilities.convertDateFormat(this.datestamp).toXMLFormat(); - - log.debug("datestamp converted: " + this.datestamp); - - } catch (ParseException e) { - log.error(e.getMessage()); - // FIXME Go to ERROR state! - } catch (DatatypeConfigurationException e) { - log.error(e.getMessage()); - // FIXME Go to ERROR state! - } - - // Get identifier field. - String identifier = OAIPMHUtilities.fieldLoader(json, this.identifierField); - - log.debug("identifier: " + identifier); - - lit = setListIdentifierHeader(this.datestamp, identifier, lit, set); - } - } - - // Check the need for a resumption token! - ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken( - listFurtherValues.getHits().getTotalHits(), resumptionToken, cursorCollector, - listFurtherValues.getScrollId(), this.searchResponseSize, i); - if (resTokenForResponse != null) { - lit.setResumptionToken(resTokenForResponse); - } - - return listFurtherValues; - } - - /** - * @param set - * @param from - * @param until - * @return - */ - public QueryBuilder setOrNot(String set, String from, String until) { - - String filterFormat = ""; - if (this.textgrid == true) { - filterFormat = TextGridMimetypes.EDITION; - } else { - filterFormat = TextGridMimetypes.DARIAH_COLLECTION; - } - - QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(until); - QueryBuilder formatQuery = QueryBuilders.matchPhrasePrefixQuery("format", filterFormat); - QueryBuilder query; - - if (set != null) { - String queryField = ""; - String valueField = ""; - - if (this.dariah == true) { - queryField = "descriptiveMetadata.dc:relation"; - valueField = set; - } - - if (this.textgrid == true) { - String[] setParts = set.split(":"); - if (setParts[0].equals("project")) { - queryField = "project.id"; - valueField = setParts[1]; - } - } - - QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); - if (this.dariah) { - query = matchQuery; - } else { - query = QueryBuilders.boolQuery().must(matchQuery).must(formatQuery).must(rangeQuery); - } - - } else { - if (this.dariah == true) - query = rangeQuery; - else - query = QueryBuilders.boolQuery().must(rangeQuery).must(formatQuery); - } - - return query; - } - - /** - * @param lit - * @return - */ - public ListIdentifiersType getLit(ListIdentifiersType lit) { - return lit; - } - - /** - * @return - */ - public String getDateOfObjectCreation() { - return this.dateOfObjectCreation; - } - - /** - * @param dateOfObjectCreation - */ - public void setDateOfObjectCreation(String dateOfObjectCreation) { - this.dateOfObjectCreation = dateOfObjectCreation; - } - - /** - * @param repositoryObjectURIPrefix - */ - public void setRepositoryObjectURIPrefix(String repositoryObjectURIPrefix) { - this.repositoryObjectURIPrefix = repositoryObjectURIPrefix; - } - - /** - * @return - */ - public String getRepositoryObjectURIPrefix() { - return this.repositoryObjectURIPrefix; - } - - /** - * @param validItem - */ - public void setIdExist(boolean validItem) { - this.idExist = validItem; - } - - /** - * @return - */ - public boolean getIdExist() { - return this.idExist; - } - - /** - * @return - */ - public String[] getIdentifierListFields() { - return this.identifierListFields; - } - - /** - * @param identifierListFields - */ - public void setIdentifierListFields(String[] identifierListFields) { - this.identifierListFields = identifierListFields; - } - - /** - * @return - */ - public String getFieldForRange() { - return this.rangeField; - } - - /** - * @param fieldForRange - */ - public void setFieldForRange(String fieldForRange) { - this.rangeField = fieldForRange; - } - - /** - * @return - */ - public String getIdentifierField() { - return this.identifierField; - } - - /** - * @param identifierPrefix - */ - public void setIdentifierField(String identifierPrefix) { - this.identifierField = identifierPrefix; - } - - /** - * @return - */ - public int getSearchResponseSize() { - return this.searchResponseSize; - } - - /** - * @param searchResponseSize - */ - public void setSearchResponseSize(String searchResponseSize) { - this.searchResponseSize = Integer.parseInt(searchResponseSize); - } - - /** - * @return - */ - public OAI_ESClient getOaiEsClient() { - return this.oaiEsClient; - } - - /** - * @param oaiEsClient - */ - public void setOaiEsClient(OAI_ESClient oaiEsClient) { - this.oaiEsClient = oaiEsClient; - } - - /** - * @return - */ - public long getResultSize() { - return this.resultSize; - } - - /** - * @param resultSize - */ - public void setResultSize(long resultSize) { - this.resultSize = resultSize; - } - } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java index 0277f24de1bc9a9f2e734a430ae71918696db8a6..43804bc51bc9e0fdaf77e83fd0f5854282d138d7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java @@ -2,8 +2,6 @@ package info.textgrid.middleware; import java.io.IOException; import java.text.ParseException; -import java.util.Hashtable; -import java.util.Map; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; @@ -15,7 +13,6 @@ import org.elasticsearch.index.query.RangeQueryBuilder; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.json.JSONObject; - import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.ResumptionTokenType; @@ -24,9 +21,6 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; */ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstract { - static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - private boolean foundItems; - /** * @param textgrid * @param dariah @@ -44,10 +38,10 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac public ListIdentifiersType processIdentifierList(final String from, final String to, final String set, final String resumptionToken) throws ParseException, IOException { - //String resTokenValue = resumptionToken; - - ListIdentifiersType identifierList = new ListIdentifiersType(); - + // String resTokenValue = resumptionToken; + + ListIdentifiersType identifierList = new ListIdentifiersType(); + BoolQueryBuilder recordFilterForClassicMayan; RangeQueryBuilder rangeQuery; @@ -60,7 +54,7 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac .must(QueryBuilders.matchPhraseQuery("notes", "ARTEFACT")); - // List<String> artefactURIs = new ArrayList<String>(); + // List<String> artefactURIs = new ArrayList<String>(); // Queries queries = new Queries(); SearchResponse scrollResp; @@ -88,12 +82,12 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac searchRequest.source(searchSourceBuilder); searchRequest.scroll(TimeValue.timeValueHours(24L)); try { - scrollResp = OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // scrollResp = OAI_ESClient.getEsClient().prepareSearchScroll(resumptionToken) + scrollResp = OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // scrollResp = OAI_ESClient.getEsClient().prepareSearchScroll(resumptionToken) // .setScroll(TimeValue.timeValueHours(24L)).execute().actionGet(); } @@ -108,11 +102,12 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac for (SearchHit hit : scrollResp.getHits().getHits()) { i++; - String textgridURI = OAIPMHUtilities.fieldLoader(new JSONObject(hit.getSourceAsMap()), "textgridUri"); - //hit.getFields().get("textgridUri").getValue().toString().replace(".0", ""); + String textgridURI = + OAIPMHUtilities.fieldLoader(new JSONObject(hit.getSourceAsMap()), "textgridUri"); + // hit.getFields().get("textgridUri").getValue().toString().replace(".0", ""); System.out.println(textgridURI); RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false); - + identifierList.getHeader() .add(idiomRecord.getRecordById(textgridURI.replace(".0", "")).getRecord().getHeader()); } @@ -134,22 +129,4 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac return identifierList; } - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.IdentifierListDelivererAbstract#isFoundItems() - */ - public boolean isFoundItems() { - return this.foundItems; - } - - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.IdentifierListDelivererAbstract#setFoundItems(boolean) - */ - public void setFoundItems(boolean foundItems) { - this.foundItems = foundItems; - } - } 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 471f4fad6708264bfa4b7367838aecdf7243c11c..8f025ca5a5d73e0fb3627f30432de1e2c7624ab7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -32,11 +32,13 @@ import info.textgrid.middleware.oaipmh.VerbType; * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2019-10-29 + * @version 2021-07-06 * @since 2014-01-29 */ public class OAIPMHImpl implements OAIPMHProducer { + // NOTE Changed OpenAireIdentifierList into IdentifierListDelivererDATACITE! + // ** // STATICS // ** @@ -52,14 +54,15 @@ public class OAIPMHImpl implements OAIPMHProducer { private RepIdentification rep; private RecordListDelivererDC recordListDC; private RecordListDelivererIDIOM recordListIDIOM; - private OpenAireRecord openAireRecord; + // private OpenAireRecord openAireRecord; private OpenAireRecordList openAireRecordList; - private OpenAireIdentifierList openAireIdentifierList; + // private OpenAireIdentifierList openAireIdentifierList; private RecordDelivererDC recDelivDC; private RecordDelivererIDIOM recDelivIDIOM; - + private RecordDelivererDATACITE recDelivDATACITE; private IdentifierListDelivererDC identifierListDC; private IdentifierListDelivererIDIOM identifierListIDIOM; + private IdentifierListDelivererDATACITE identifierListDATACITE; private MetadataFormatListDelivererInterface metadataFormatList; private SetDeliverer setList; @@ -86,7 +89,8 @@ public class OAIPMHImpl implements OAIPMHProducer { RepIdentification rep, // 0 RecordDelivererDC recDelivDC, // 1 RecordDelivererIDIOM recDelivIDIOM, // 2 - OpenAireRecord openAireRecord, // 3 + // OpenAireRecord openAireRecord, // 3 + RecordDelivererDATACITE recDelivDATACITE, // 3 RecordListDelivererDC recordListDC, // 4 RecordListDelivererIDIOM recordListIDIOM, // 5 OpenAireRecordList openAireRecordList, // 6 @@ -94,12 +98,14 @@ public class OAIPMHImpl implements OAIPMHProducer { SetDeliverer setList, // 8 IdentifierListDelivererDC identifierList, // 9 IdentifierListDelivererIDIOM identifierListIDIOM, // 10 - OpenAireIdentifierList openAireIdentifierList // 11 + // OpenAireIdentifierList openAireIdentifierList // 11 + IdentifierListDelivererDATACITE identifierListDATACITE // 11 ) { this.rep = rep; this.recDelivDC = recDelivDC; this.recDelivIDIOM = recDelivIDIOM; - this.openAireRecord = openAireRecord; + // this.openAireRecord = openAireRecord; + this.recDelivDATACITE = recDelivDATACITE; this.recordListDC = recordListDC; this.recordListIDIOM = recordListIDIOM; this.openAireRecordList = openAireRecordList; @@ -111,7 +117,8 @@ public class OAIPMHImpl implements OAIPMHProducer { this.setList = setList; this.identifierListDC = identifierList; this.identifierListIDIOM = identifierListIDIOM; - this.openAireIdentifierList = openAireIdentifierList; + // this.openAireIdentifierList = openAireIdentifierList; + this.identifierListDATACITE = identifierListDATACITE; } /* @@ -261,7 +268,7 @@ public class OAIPMHImpl implements OAIPMHProducer { recDeliv = this.recDelivIDIOM; } if (request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { - recDeliv = this.openAireRecord; + recDeliv = this.recDelivDATACITE; } // Finally start the QUERY! @@ -321,7 +328,8 @@ public class OAIPMHImpl implements OAIPMHProducer { } else if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { idListDeliv = this.identifierListIDIOM; } else if (request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { - idListDeliv = this.openAireIdentifierList; + // idListDeliv = this.openAireIdentifierList; + idListDeliv = this.identifierListDATACITE; } } @@ -341,7 +349,8 @@ public class OAIPMHImpl implements OAIPMHProducer { } else if (restokIDIOMExisting) { idListDeliv = this.identifierListIDIOM; } else if (restokOpenAireExisting) { - idListDeliv = this.openAireIdentifierList; + // idListDeliv = this.openAireIdentifierList; + idListDeliv = this.identifierListDATACITE; } } 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 4249d47aef2f9a280e84a4783e7b10c2f57b1282..09504b04e7b0ff3c2af3db556c8d018cc433c66a 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java @@ -5,11 +5,9 @@ import java.util.List; import info.textgrid.middleware.oaipmh.RequestType; /** - * FIXME - * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2019-03-07 + * @version 2021-07-06 * @since 2019-03-07 */ @@ -18,6 +16,38 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac protected boolean textgrid; protected boolean dariah; + protected OAI_ESClient oaiEsClient; + + protected String[] fields; + protected String[] workFields; + + protected String formatField; + protected String formatToFilter; + protected String dateOfObjectCreation; + protected String relationToFurtherMetadataObject; + protected String repositoryObjectURIPrefix; + protected String identifierField; + + // Lists for the Dublin Core elements. Lists are needed since each DC fields is possible to occur + // several times. + protected String[] contributorList; + protected String[] coverageList; + protected String[] creatorList; + protected String[] dateList; + protected String[] descriptionList; + protected String[] formatList; + protected String[] identifierList; + protected String[] languageList; + protected String[] publisherList; + protected String[] relationList; + // FIXME Why is this commented out? I just adapted beans.xml file. + // protected String[] relationsForWorkList; + protected String[] rightList; + protected String[] sourceList; + protected String[] subjectList; + protected String[] titleList; + protected String[] typeList; + /** * @param textgrid * @param dariah @@ -79,4 +109,239 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac return result; } + // ** + // GETTERS AND SETTERS + // ** + + /** + * @param formatToFilter + */ + public void setFormatToFilter(String formatToFilter) { + this.formatToFilter = formatToFilter; + } + + /** + * @param formatField + */ + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + /** + * @return + */ + public String getDateOfObjectCreation() { + return this.dateOfObjectCreation; + } + + /** + * @param dateOfObjectCreation + */ + public void setDateOfObjectCreation(String dateOfObjectCreation) { + this.dateOfObjectCreation = dateOfObjectCreation; + } + + /** + * @return + */ + public String getRelationToFurtherMetadataObject() { + return this.relationToFurtherMetadataObject; + } + + /** + * @param relationToFurtherMetadataObject + */ + public void setRelationToFurtherMetadataObject(String relationToFurtherMetadataObject) { + this.relationToFurtherMetadataObject = relationToFurtherMetadataObject; + } + + /** + * @return + */ + public String getRepositoryObjectURIPrefix() { + return this.repositoryObjectURIPrefix; + } + + /** + * @param repositoryObjectURIPrefix + */ + public void setRepositoryObjectURIPrefix(String repositoryObjectURIPrefix) { + this.repositoryObjectURIPrefix = repositoryObjectURIPrefix; + } + + /** + * @return + */ + public String getIdentifierField() { + return this.identifierField; + } + + /** + * @param identifierPrefix + */ + public void setIdentifierField(String identifierPrefix) { + this.identifierField = identifierPrefix; + } + + /** + * @param contributorList + */ + public void setContributor(String[] contributorList) { + this.contributorList = contributorList; + } + + /** + * @return + */ + public String[] getContributor() { + return this.contributorList; + } + + /** + * @param coveragesList + */ + public void setCoverage(String[] coveragesList) { + this.coverageList = coveragesList; + } + + /** + * @param creatorsList + */ + public void setCreator(String[] creatorsList) { + this.creatorList = creatorsList; + } + + /** + * @param datesList + */ + public void setDates(String[] datesList) { + this.dateList = datesList; + } + + /** + * @param descriptionsList + */ + public void setDescriptions(String[] descriptionsList) { + this.descriptionList = descriptionsList; + } + + /** + * @param formatsList + */ + public void setFormats(String[] formatsList) { + this.formatList = formatsList; + } + + /** + * @param identifiersList + */ + public void setIdentifiers(String[] identifiersList) { + this.identifierList = identifiersList; + } + + /** + * @param languagesList + */ + public void setLanguages(String[] languagesList) { + this.languageList = languagesList; + } + + /** + * @param publishersList + */ + public void setPublishers(String[] publishersList) { + this.publisherList = publishersList; + } + + /** + * @param relationsList + */ + public void setRelations(String[] relationsList) { + this.relationList = relationsList; + } + + // /** + // * @param relationsForWorkList + // */ + // public void setRelationsForWork(String[] relationsForWorkList) { + // this.relationsForWorkList = relationsForWorkList; + // } + + /** + * @param rightsList + */ + public void setRights(String[] rightsList) { + this.rightList = rightsList; + } + + /** + * @param sourcesList + */ + public void setSources(String[] sourcesList) { + this.sourceList = sourcesList; + } + + /** + * @param subjectsList + */ + public void setSubjects(String[] subjectsList) { + this.subjectList = subjectsList; + } + + /** + * @param titlesList + */ + public void setTitles(String[] titlesList) { + this.titleList = titlesList; + } + + /** + * @param typesList + */ + public void setTypes(String[] typesList) { + this.typeList = typesList; + } + + /** + * @return + */ + public OAI_ESClient getOaiEsClient() { + return this.oaiEsClient; + } + + /** + * @param oaiEsClient + */ + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } + + /** + * @return + */ + public String[] getWorkFields() { + return this.workFields; + } + + /** + * @param workFields + */ + public void setWorkFields(String[] workFields) { + this.workFields = workFields; + } + + /** + * @param fields + */ + public void setFields(String[] fields) { + this.fields = fields; + } + + /** + * @return + */ + public String[] getFields() { + return this.fields; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java new file mode 100644 index 0000000000000000000000000000000000000000..270c6ba2b82abb42c57892dcd7732806239d8509 --- /dev/null +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java @@ -0,0 +1,827 @@ +package info.textgrid.middleware; + +import java.io.IOException; +import java.text.ParseException; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.elasticsearch.common.Strings; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.stereotype.Component; +import info.textgrid.middleware.oaipmh.ContributorType; +import info.textgrid.middleware.oaipmh.DateType; +import info.textgrid.middleware.oaipmh.GetRecordType; +import info.textgrid.middleware.oaipmh.HeaderType; +import info.textgrid.middleware.oaipmh.OAIPMHtype; +import info.textgrid.middleware.oaipmh.ObjectFactory; +import info.textgrid.middleware.oaipmh.OpenaireDescriptionType; +import info.textgrid.middleware.oaipmh.RelatedIdentifierType; +import info.textgrid.middleware.oaipmh.RelationType; +import info.textgrid.middleware.oaipmh.Resource; +import info.textgrid.middleware.oaipmh.Resource.AlternateIdentifiers; +import info.textgrid.middleware.oaipmh.Resource.AlternateIdentifiers.AlternateIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Contributors; +import info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor; +// import info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Creators; +import info.textgrid.middleware.oaipmh.Resource.Creators.Creator; +import info.textgrid.middleware.oaipmh.Resource.Creators.Creator.NameIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Dates; +import info.textgrid.middleware.oaipmh.Resource.Dates.Date; +import info.textgrid.middleware.oaipmh.Resource.Descriptions; +import info.textgrid.middleware.oaipmh.Resource.Descriptions.Description; +import info.textgrid.middleware.oaipmh.Resource.Formats; +import info.textgrid.middleware.oaipmh.Resource.GeoLocations; +import info.textgrid.middleware.oaipmh.Resource.GeoLocations.GeoLocation; +import info.textgrid.middleware.oaipmh.Resource.Identifier; +import info.textgrid.middleware.oaipmh.Resource.RelatedIdentifiers; +import info.textgrid.middleware.oaipmh.Resource.RelatedIdentifiers.RelatedIdentifier; +import info.textgrid.middleware.oaipmh.Resource.ResourceType; +import info.textgrid.middleware.oaipmh.Resource.RightsList; +import info.textgrid.middleware.oaipmh.Resource.RightsList.Rights; +import info.textgrid.middleware.oaipmh.Resource.Sizes; +import info.textgrid.middleware.oaipmh.Resource.Subjects; +import info.textgrid.middleware.oaipmh.Resource.Subjects.Subject; +import info.textgrid.middleware.oaipmh.Resource.Titles; +import info.textgrid.middleware.oaipmh.Resource.Titles.Title; +import info.textgrid.middleware.oaipmh.TitleType; +// import info.textgrid.middleware.oaipmh.ResourceType; + +/** + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2021-07-06 + * @since 2020-06-13 + */ +@Component +public class RecordDelivererDATACITE extends RecordDelivererAbstract { + + // Logger for errors and info + private static Log log = LogFactory.getLog(RecordDelivererDATACITE.class); + + // Container object for the result of the elasticsearch request. This object contains the source + // of the response + private JSONObject jsonObj = new JSONObject(); + + // This variables contains the field requested in the ElasticSearch Index. The content will be + // given by a configuration file + private String[] oarTitleFields; + private String[] oarDateFields; + private String[] oarContributorFields; + private String[] oarLanguageFields; + private String[] oarAlternateIdentifierFields; + private String[] oarFormatFields; + private String[] oarRightsFields; + private String[] oarDescriptionFields; + private String[] oarRelatedIdentifierFields; + private String[] oarWorkFields; + private String[] oarGeoLocationFields; + private String[] oarVersionFields; + private String[] oarSubjectFields; + + private String relationToWorkObject; + private String handle; + private String sizeField; + + // This variable contains the XML-content for a whole OpenAire file + private Resource resource = new Resource(); + + /** + * @param textgrid flag to indicate that the content of the record is context of the TextGrid repo + * @param dariah flag to indicate that the content of the record is context of the DARIAH repo + * @throws IOException + */ + public RecordDelivererDATACITE(boolean textgrid, boolean dariah) throws IOException { + super(textgrid, dariah); + } + + /** + * building the record XML object for the OAI-PMH response + * + * @throws ParseException + * @throws IOException + */ + 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) + .getSource()); + + HeaderType header = new HeaderType(); + header.setDatestamp(OAIPMHUtilities + .datestampAsString(OAIPMHUtilities.fieldLoader(this.jsonObj, TGConstants.CREATED))); + + if (!idInElasticSearchIndex.startsWith(TGConstants.ITEM_IDENTIFIER_PREFIX)) { + header.setIdentifier(TGConstants.ITEM_IDENTIFIER_PREFIX + idInElasticSearchIndex); + } else { + header.setIdentifier(idInElasticSearchIndex); + } + + GetRecordType grt = OAIPMHUtilities.getRecordType(this.setOpenAireRecord(), header); + + return grt; + } + + /** + * Put the record from open-aire into the JAXBElement container to add it to an oai-pmh object + * + * @param idInElasticSearchIndex + * @return + * @throws ParseException + * @throws JAXBException + * @throws DatatypeConfigurationException + * @throws IOException + */ + public JAXBElement<OAIPMHtype> getRecord(String idInElasticSearchIndex) + throws ParseException, JAXBException, DatatypeConfigurationException, IOException { + + ObjectFactory obf = new ObjectFactory(); + JAXBElement<OAIPMHtype> oaijaxb; + OAIPMHtype oai = new OAIPMHtype(); + HeaderType header = new HeaderType(); + + this.jsonObj = + new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), + idInElasticSearchIndex, this.fields, Strings.EMPTY_ARRAY).getSource()); + + // Setting the header for the oaipmh response + header.setDatestamp(OAIPMHUtilities + .datestampAsString(OAIPMHUtilities.fieldLoader(this.jsonObj, TGConstants.CREATED))); + // The id for the response has to be starts with "textgrid:". The id in elasticsearch is + // missing. In consequence is optional in oaipmh request to write textgrid:1233.0 or just + // 1233.0. For the response the prefix has to be added + if (!idInElasticSearchIndex.startsWith(TGConstants.ITEM_IDENTIFIER_PREFIX)) { + header.setIdentifier(TGConstants.ITEM_IDENTIFIER_PREFIX + idInElasticSearchIndex); + } else { + header.setIdentifier(idInElasticSearchIndex); + } + // It is necessary to add the GetRecordType to the OAIPMH object. + GetRecordType grt = OAIPMHUtilities.getRecordType(this.setOpenAireRecord(), header); + oai.setGetRecord(grt); + oaijaxb = obf.createOAIPMH(oai); + oaijaxb.setValue(oai); + + return oaijaxb; + } + + /** + * Adding the open aire record fields to the openaire record object + * + * @return + * @throws ParseException + * @throws DatatypeConfigurationException + * @throws IOException + */ + private Resource setOpenAireRecord() + throws ParseException, DatatypeConfigurationException, IOException { + + this.resource.setTitles(this.addTitles()); + this.resource.setPublisher(addPublisher()); + this.resource.setPublicationYear(this.addPublicationYear()); + this.resource.setDates(this.addDates()); + this.resource.setContributors(this.addContributors()); + this.resource.setLanguage(this.addLanguae()); + this.resource.setAlternateIdentifiers(this.addAlternateIdentifier()); + this.resource.setFormats(this.addFormats()); + this.resource.setRightsList(this.addRights()); + this.resource.setDescriptions(this.addDescriptions()); + this.resource.setRelatedIdentifiers(this.addRelatedIdentifiers()); + this.resource.setIdentifier(this.addIdentifier()); + this.resource.setCreators(this.addCreators()); + this.addGeoLocation(); + this.resource.setResourceType(addResourceType()); + this.resource.setVersion(this.addVersion()); + + if (addSubjects().getSubject().get(0).getValue() != null) { + this.resource.setSubjects(this.addSubjects()); // TODO what if subjects == null? + } + + this.resource.setSizes(this.addSize()); + + return this.resource; + } + + /** + * @return + */ + private Sizes addSize() { + Sizes sizes = new Sizes(); + sizes.getSize().add(OAIPMHUtilities.fieldLoader(this.jsonObj, this.sizeField) + " Bytes"); + return sizes; + } + + /** + * @return + */ + private Subjects addSubjects() { + + Subjects subjects = new Subjects(); + + for (String subjectField : this.oarSubjectFields) { + Subject subject = new Subject(); + subject.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, subjectField + ".value")); + subject.setSchemeURI(OAIPMHUtilities.fieldLoader(this.jsonObj, subjectField + ".id.type")); + subject + .setSubjectScheme(OAIPMHUtilities.fieldLoader(this.jsonObj, subjectField + ".id.value")); + subjects.getSubject().add(subject); + } + if (subjects.getSubject().get(0) != null) { + return subjects; + } else { + return null; + } + } + + /** + * @return + */ + private String addVersion() { + + String version = ""; + for (String versionField : this.oarVersionFields) { + version = OAIPMHUtilities.fieldLoader(this.jsonObj, versionField); + } + + return version; + } + + /** + * @return + */ + private static ResourceType addResourceType() { + + ResourceType resourceType = new ResourceType(); + resourceType.setResourceTypeGeneral(info.textgrid.middleware.oaipmh.ResourceType.DATASET); + + return resourceType; + } + + /** + * + */ + private void addGeoLocation() { + + GeoLocations geoLocations = new GeoLocations(); + + for (String geoLocationField : this.oarGeoLocationFields) { + GeoLocation geoLocation = new GeoLocation(); + geoLocation.setGeoLocationPlace( + OAIPMHUtilities.fieldLoader(this.jsonObj, geoLocationField + ".value")); + geoLocations.getGeoLocation().add(geoLocation); + } + if (geoLocations.getGeoLocation().get(0).getGeoLocationPlace() != null) { + this.resource.setGeoLocations(geoLocations); + } + + // return geoLocations; + } + + /** + * @return + * @throws IOException + */ + private RelatedIdentifiers addRelatedIdentifiers() throws IOException { + + RelatedIdentifiers relatedIdentifiers = new RelatedIdentifiers(); + + for (String relatedIdentifierField : this.oarRelatedIdentifierFields) { + String[] workFields = {this.handle}; + RelatedIdentifier relatedIdentifier = new RelatedIdentifier(); + relatedIdentifier.setRelatedIdentifierType(RelatedIdentifierType.HANDLE); + // relatedIdentifier.setRelatedMetadataScheme(TGConstants.TEXTGRID_METADATASCHEME); + relatedIdentifier.setRelationType(RelationType.IS_PART_OF); + // relatedIdentifier.setSchemeType("XSD"); + // relatedIdentifier.setSchemeURI(TGConstants.TEXTGRID_METADATASCHEME_URI); + + String uriForWork = OAIPMHUtilities.fieldLoader(this.jsonObj, relatedIdentifierField) + .replace("textgrid:", ""); + relatedIdentifier + .setValue( + OAIPMHUtilities + .fieldLoader( + new JSONObject( + OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), + uriForWork, workFields, Strings.EMPTY_ARRAY).getSource()), + this.handle)); + relatedIdentifiers.getRelatedIdentifier().add(relatedIdentifier); + } + + return relatedIdentifiers; + } + + /** + * @return + * @throws IOException + */ + private Descriptions addDescriptions() throws IOException { + + Descriptions descriptions = new Descriptions(); + + for (String descriptionField : this.oarDescriptionFields) { + Description description = new Description(); + // description.setOpenaireDescriptionType(OpenaireDescriptionType.ABSTRACT); + // description.setOpenaireDescriptionType(OpenaireDescriptionType.ABSTRACT); + description.setDescriptionType(OpenaireDescriptionType.ABSTRACT); + String idForWorkObject = OAIPMHUtilities.fieldLoader(this.jsonObj, this.relationToWorkObject) + .replace("textgrid:", ""); + JSONObject resultOfFurtherObject = + new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), + idForWorkObject, this.workFields, Strings.EMPTY_ARRAY).getSource()); + String abstractFoFWork = OAIPMHUtilities.fieldLoader(resultOfFurtherObject, descriptionField); + description.setLang(abstractFoFWork); + descriptions.getDescription().add(description); + } + + return descriptions; + } + + /** + * @return + */ + private RightsList addRights() { + + RightsList rightsList = new RightsList(); + + for (String rightsField : this.oarRightsFields) { + Rights rights = new Rights(); + rights.setRightsURI(OAIPMHUtilities.fieldLoader(this.jsonObj, rightsField + ".licenseUri")); + rights.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, rightsField + ".value")); + rightsList.getRights().add(rights); + } + if (rightsList.getRights().get(0).getValue() != null) { + Rights openAccesRight = new Rights(); + openAccesRight.setRightsURI("info:eu-repo/semantics/openAccess"); + rightsList.getRights().add(openAccesRight); + } + + return rightsList; + } + + /** + * @return + */ + private Formats addFormats() { + + Formats formats = new Formats(); + + for (String formatField : this.oarFormatFields) { + formats.getFormat().add(OAIPMHUtilities.fieldLoader(this.jsonObj, formatField)); + } + + return formats; + } + + /** + * @return + */ + private AlternateIdentifiers addAlternateIdentifier() { + + AlternateIdentifiers alternateIdentifiers = new AlternateIdentifiers(); + + for (String alternateIdentifierField : this.oarAlternateIdentifierFields) { + AlternateIdentifier alternateIdentifier = new AlternateIdentifier(); + alternateIdentifier + .setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, alternateIdentifierField)); + alternateIdentifier.setAlternateIdentifierType(TGConstants.TEXTGRIDURI_IDENTIIER_TYPE); + alternateIdentifiers.getAlternateIdentifier().add(alternateIdentifier); + } + + return alternateIdentifiers; + } + + /** + * @return + */ + private String addLanguae() { + + String language = null; + + for (String languageField : this.oarLanguageFields) { + language = OAIPMHUtilities.fieldLoader(this.jsonObj, languageField); + } + + return language; + } + + /** + * @return + */ + private Contributors addContributors() { + + Contributors contributors = new Contributors(); + + for (String contributorField : this.oarContributorFields) { + Contributor contributorInOpenAireRecord = new Contributor(); + if (contributorField.equals("project")) { + contributorInOpenAireRecord.setContributorName( + OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".value")); + contributorInOpenAireRecord.setContributorType(ContributorType.OTHER); + info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name = + new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier(); + name.setNameIdentifierScheme("textgrid"); + name.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".id")); + name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd"); + contributorInOpenAireRecord.setNameIdentifier(name); + } else { + contributorInOpenAireRecord + .setContributorName(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField)); + contributorInOpenAireRecord.setContributorType(ContributorType.DATA_MANAGER); + /* + * info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name = + * new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier(); + * name.setNameIdentifierScheme("textgrid"); name.setValue(""); + * name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd"); + * contributorInOpenAireRecord.setNameIdentifier(name); + */ + } + + contributors.getContributor().add(contributorInOpenAireRecord); + } + + return contributors; + } + + /** + * @return + */ + private Dates addDates() { + + Dates dates = new Dates(); + + for (String dateField : this.oarDateFields) { + Date dateInOpenAireRecord = new Date(); + // System.out.println(dateField); + try { + dateInOpenAireRecord.setValue(OAIPMHUtilities + .datestampAsString(OAIPMHUtilities.fieldLoader(this.jsonObj, dateField))); + } catch (ParseException e) { + // TODO Auto-generated catch block + log.error("Could not parse date field"); + } + if (dateField.equals("created")) { + dateInOpenAireRecord.setDateType(DateType.CREATED); + } + if (dateField.equals("issued")) { + dateInOpenAireRecord.setDateType(DateType.ISSUED); + } + if (dateField.equals("lastModified")) { + dateInOpenAireRecord.setDateType(DateType.UPDATED); + } + dates.getDate().add(dateInOpenAireRecord); + } + + return dates; + } + + /** + * @return + */ + private Identifier addIdentifier() { + + Identifier identifier = new Identifier(); + + identifier.setIdentifierType("Handle"); + // System.out.println(jsonObj.get("textgridUri").toString()); + try { + identifier.setValue(this.jsonObj.getJSONObject("pid").get("value").toString()); + } catch (JSONException fieldNotFound) { + identifier.setValue(this.jsonObj.get("textgridUri").toString()); + } + + return identifier; + } + + /** + * @return + */ + private Creators addCreators() { + + Creators creators = new Creators(); + + /** + * Creators Field + */ + + // TODO: Fields from configFile + Creator creator = new Creator(); + + creator.setCreatorName(OAIPMHUtilities.fieldLoader(this.jsonObj, "edition.agent.value")); + NameIdentifier nameIdentifier = new NameIdentifier(); + // TODO: creatorID Field from config file + String creatorID = + OAIPMHUtilities.fieldLoader(this.jsonObj, "edition.source.bibliographicCitation.author.id"); + + if (creatorID != null && creatorID.contains(":")) { + nameIdentifier.setValue(creatorID.split(":")[1]); + nameIdentifier.setNameIdentifierScheme(creatorID.split(":")[0]); + /* + * TODO Check if the scheme URI is correct + */ + nameIdentifier.setSchemeURI("https://ref.de.dariah.eu/pndsearch/pndquery.xql?id="); + } else { + nameIdentifier.setValue(creatorID); + } + creator.setNameIdentifier(nameIdentifier); + nameIdentifier.setSchemeURI("https://ref.de.dariah.eu/pndsearch/pndquery.xql?id="); + creators.getCreator().add(creator); + + return creators; + } + + /** + * @return + */ + private Titles addTitles() { + + Titles titles = new Titles(); + + for (String titleField : this.oarTitleFields) { + Title tileInOpenAireRecord = new Title(); + tileInOpenAireRecord.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, titleField)); + tileInOpenAireRecord.setTitleType(TitleType.OTHER); + titles.getTitle().add(tileInOpenAireRecord); + } + + return titles; + } + + /** + * @return + */ + private static String addPublisher() { + + /** + * Publisher fields + */ + // TODO: fields from config file + // TODO: for each field + // return OAIPMHUtilities.fieldLoader(jsonObj, + // "edition.source.bibliographicCitation.publisher.value"); + + return "TextGrid"; + } + + /** + * @return + * @throws ParseException + * @throws DatatypeConfigurationException + */ + private String addPublicationYear() throws ParseException, DatatypeConfigurationException { + + /** + * Publication Year fields + */ + // TODO: fields from config file + + return Integer.toString(OAIPMHUtilities + .convertDateFormat(OAIPMHUtilities.fieldLoader(this.jsonObj, "created")).getYear()); + } + + // ** + // GETTERS & SETTERS + // ** + + /** + * @return + */ + public String[] getOarTitleFields() { + return this.oarTitleFields; + } + + /** + * @param oarTitleFields + */ + public void setOarTitleFields(String[] oarTitleFields) { + this.oarTitleFields = oarTitleFields; + } + + /** + * @return + */ + public Resource getResource() { + return this.resource; + } + + /** + * @param resource + */ + public void setResource(Resource resource) { + this.resource = resource; + } + + /** + * @return + */ + public String[] getOarDateFields() { + return this.oarDateFields; + } + + /** + * @param oarDateFields + */ + public void setOarDateFields(String[] oarDateFields) { + this.oarDateFields = oarDateFields; + } + + /** + * @return + */ + public String[] getOarContributorFields() { + return this.oarContributorFields; + } + + /** + * @param oarContributorFields + */ + public void setOarContributorFields(String[] oarContributorFields) { + this.oarContributorFields = oarContributorFields; + } + + /** + * @return + */ + public String[] getOarLanguageFields() { + return this.oarLanguageFields; + } + + /** + * @param oarLanguageFields + */ + public void setOarLanguageFields(String[] oarLanguageFields) { + this.oarLanguageFields = oarLanguageFields; + } + + /** + * @return + */ + public String[] getOarAlternateIdentifierFields() { + return this.oarAlternateIdentifierFields; + } + + /** + * @param oarAlternateIdentifierFields + */ + public void setOarAlternateIdentifierFields(String[] oarAlternateIdentifierFields) { + this.oarAlternateIdentifierFields = oarAlternateIdentifierFields; + } + + /** + * @return + */ + public String[] getOarFormatFields() { + return this.oarFormatFields; + } + + /** + * @param oarFormatFields + */ + public void setOarFormatFields(String[] oarFormatFields) { + this.oarFormatFields = oarFormatFields; + } + + /** + * @return + */ + public String[] getOarRightsFields() { + return this.oarRightsFields; + } + + /** + * @param oarRightsFields + */ + public void setOarRightsFields(String[] oarRightsFields) { + this.oarRightsFields = oarRightsFields; + } + + /** + * @return + */ + public String[] getOarDescriptionFields() { + return this.oarDescriptionFields; + } + + /** + * @param oarDescriptionFields + */ + public void setOarDescriptionFields(String[] oarDescriptionFields) { + this.oarDescriptionFields = oarDescriptionFields; + } + + /** + * @return + */ + public String[] getOarRelatedIdentifierFields() { + return this.oarRelatedIdentifierFields; + } + + /** + * @param oarRelatedIdentifierFields + */ + public void setOarRelatedIdentifierFields(String[] oarRelatedIdentifierFields) { + this.oarRelatedIdentifierFields = oarRelatedIdentifierFields; + } + + /** + * @return + */ + public String getRelationToWorkObject() { + return this.relationToWorkObject; + } + + /** + * @param relationToWorkObject + */ + public void setRelationToWorkObject(String relationToWorkObject) { + this.relationToWorkObject = relationToWorkObject; + } + + /** + * @return + */ + public String[] getOarWorkFields() { + return this.oarWorkFields; + } + + /** + * @param oarWorkFields + */ + public void setOarWorkFields(String[] oarWorkFields) { + this.oarWorkFields = oarWorkFields; + } + + /** + * @return + */ + public String[] getOarGeoLocationFields() { + return this.oarGeoLocationFields; + } + + /** + * @param oarGeoLocationFields + */ + public void setOarGeoLocationFields(String[] oarGeoLocationFields) { + this.oarGeoLocationFields = oarGeoLocationFields; + } + + /** + * @return + */ + public String getHandle() { + return this.handle; + } + + /** + * @param handle + */ + public void setHandle(String handle) { + this.handle = handle; + } + + /** + * @return + */ + public String[] getOarVersionFields() { + return this.oarVersionFields; + } + + /** + * @param oarVersionFields + */ + public void setOarVersionFields(String[] oarVersionFields) { + this.oarVersionFields = oarVersionFields; + } + + /** + * @return + */ + public String[] getOarSubjectFields() { + return this.oarSubjectFields; + } + + /** + * @param oarSubjectFields + */ + public void setOarSubjectFields(String[] oarSubjectFields) { + this.oarSubjectFields = oarSubjectFields; + } + + /** + * @return + */ + public String getSizeField() { + return this.sizeField; + } + + /** + * @param size + */ + public void setSizeField(String size) { + this.sizeField = size; + } + +} 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 0967d391c9d9555c52363997015c2b35fb11c23e..1f9cf00623a0b5857db0be73598ea8ee4f6134fd 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -21,47 +21,14 @@ import info.textgrid.middleware.oaipmh.RecordType; * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2021-05-20 + * @version 2021-07-06 * @since 2014-02-17 */ @Component public class RecordDelivererDC extends RecordDelivererAbstract { - private String[] fields; - private String[] workFields; - private String formatField; - private String formatToFilter; - private String dateOfObjectCreation; - private String relationToFurtherMetadataObject; - private String repositoryObjectURIPrefix; - private String identifierField; - - /* - * Lists for the Dublin Core elements. Lists are needed since each DC fields is possible to occur - * several times - */ - - private String[] contributorList; - private String[] coverageList; - private String[] creatorList; - private String[] dateList; - private String[] descriptionList; - private String[] formatList; - private String[] identifierList; - private String[] languageList; - private String[] publisherList; - private String[] relationList; - // FIXME Why is this commented out? I just adapted beans.xml file. - // private String[] relationsForWorkList; - private String[] rightList; - private String[] sourceList; - private String[] subjectList; - private String[] titleList; - private String[] typeList; - private static Log log = LogFactory.getLog(RecordDelivererDC.class); - private OAI_ESClient oaiEsClient; /** * @param textgrid @@ -95,7 +62,8 @@ public class RecordDelivererDC extends RecordDelivererAbstract { String[] includes = this.fields; String[] excludes = Strings.EMPTY_ARRAY; - esResultObject = OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(),id, includes, excludes); + esResultObject = OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), id, + includes, excludes); } catch (IOException e1) { // TODO Auto-generated catch block @@ -212,7 +180,8 @@ public class RecordDelivererDC extends RecordDelivererAbstract { String[] includes = this.workFields; String[] excludes = Strings.EMPTY_ARRAY; - responseWorkValues = OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), id, includes, excludes); + responseWorkValues = OAIPMHUtilities.getRcordByIDFromElasticSearch(OAI_ESClient.getEsIndex(), + id, includes, excludes); } catch (IOException e) { // TODO Auto-generated catch block @@ -297,239 +266,4 @@ public class RecordDelivererDC extends RecordDelivererAbstract { return result; } - // ** - // GETTERS AND SETTERS - // ** - - /** - * @param formatToFilter - */ - public void setFormatToFilter(String formatToFilter) { - this.formatToFilter = formatToFilter; - } - - /** - * @param formatField - */ - public void setFormatField(String formatField) { - this.formatField = formatField; - } - - /** - * @return - */ - public String getDateOfObjectCreation() { - return this.dateOfObjectCreation; - } - - /** - * @param dateOfObjectCreation - */ - public void setDateOfObjectCreation(String dateOfObjectCreation) { - this.dateOfObjectCreation = dateOfObjectCreation; - } - - /** - * @return - */ - public String getRelationToFurtherMetadataObject() { - return this.relationToFurtherMetadataObject; - } - - /** - * @param relationToFurtherMetadataObject - */ - public void setRelationToFurtherMetadataObject(String relationToFurtherMetadataObject) { - this.relationToFurtherMetadataObject = relationToFurtherMetadataObject; - } - - /** - * @return - */ - public String getRepositoryObjectURIPrefix() { - return this.repositoryObjectURIPrefix; - } - - /** - * @param repositoryObjectURIPrefix - */ - public void setRepositoryObjectURIPrefix(String repositoryObjectURIPrefix) { - this.repositoryObjectURIPrefix = repositoryObjectURIPrefix; - } - - /** - * @return - */ - public String getIdentifierField() { - return this.identifierField; - } - - /** - * @param identifierPrefix - */ - public void setIdentifierField(String identifierPrefix) { - this.identifierField = identifierPrefix; - } - - /** - * @param contributorList - */ - public void setContributor(String[] contributorList) { - this.contributorList = contributorList; - } - - /** - * @return - */ - public String[] getContributor() { - return this.contributorList; - } - - /** - * @param coveragesList - */ - public void setCoverage(String[] coveragesList) { - this.coverageList = coveragesList; - } - - /** - * @param creatorsList - */ - public void setCreator(String[] creatorsList) { - this.creatorList = creatorsList; - } - - /** - * @param datesList - */ - public void setDates(String[] datesList) { - this.dateList = datesList; - } - - /** - * @param descriptionsList - */ - public void setDescriptions(String[] descriptionsList) { - this.descriptionList = descriptionsList; - } - - /** - * @param formatsList - */ - public void setFormats(String[] formatsList) { - this.formatList = formatsList; - } - - /** - * @param identifiersList - */ - public void setIdentifiers(String[] identifiersList) { - this.identifierList = identifiersList; - } - - /** - * @param languagesList - */ - public void setLanguages(String[] languagesList) { - this.languageList = languagesList; - } - - /** - * @param publishersList - */ - public void setPublishers(String[] publishersList) { - this.publisherList = publishersList; - } - - /** - * @param relationsList - */ - public void setRelations(String[] relationsList) { - this.relationList = relationsList; - } - - // /** - // * @param relationsForWorkList - // */ - // public void setRelationsForWork(String[] relationsForWorkList) { - // this.relationsForWorkList = relationsForWorkList; - // } - - /** - * @param rightsList - */ - public void setRights(String[] rightsList) { - this.rightList = rightsList; - } - - /** - * @param sourcesList - */ - public void setSources(String[] sourcesList) { - this.sourceList = sourcesList; - } - - /** - * @param subjectsList - */ - public void setSubjects(String[] subjectsList) { - this.subjectList = subjectsList; - } - - /** - * @param titlesList - */ - public void setTitles(String[] titlesList) { - this.titleList = titlesList; - } - - /** - * @param typesList - */ - public void setTypes(String[] typesList) { - this.typeList = typesList; - } - - /** - * @return - */ - public OAI_ESClient getOaiEsClient() { - return this.oaiEsClient; - } - - /** - * @param oaiEsClient - */ - public void setOaiEsClient(OAI_ESClient oaiEsClient) { - this.oaiEsClient = oaiEsClient; - } - - /** - * @return - */ - public String[] getWorkFields() { - return this.workFields; - } - - /** - * @param workFields - */ - public void setWorkFields(String[] workFields) { - this.workFields = workFields; - } - - /** - * @param fields - */ - public void setFields(String[] fields) { - this.fields = fields; - } - - /** - * @return - */ - public String[] getFields() { - return this.fields; - } - } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java index 98da2c68b3645b7fe169d18c92da989c7087f027..ac211b341000ea03d444b78d3e9a5057db209762 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java @@ -31,15 +31,13 @@ import info.textgrid.middleware.oaipmh.RecordType; @Component public class RecordDelivererIDIOM extends RecordDelivererAbstract { - private String dateOfObjectCreation; + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererIDIOM.class); + private String dateOfLastOblectModification; - private OAI_ESClient oaiEsClient; RecordType record = new RecordType(); ClassicMayanMetsMods metsmods; - private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererIDIOM.class); - /** * @param textgrid * @param dariah @@ -89,7 +87,8 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { JSONObject json = new JSONObject(); String[] fields = {TGConstants.CREATED, TGConstants.MODIFIED_FIELD}; json = new JSONObject(OAIPMHUtilities - .getRcordByIDFromElasticSearch("textgrid-nonpublic", changedId, fields, Strings.EMPTY_ARRAY).getSource()); + .getRcordByIDFromElasticSearch("textgrid-nonpublic", changedId, fields, Strings.EMPTY_ARRAY) + .getSource()); log.debug("id in elasticsearch is: " + OAIPMHUtilities .datestampAsString(OAIPMHUtilities.fieldLoader(json, TGConstants.CREATED))); @@ -181,30 +180,16 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { HeaderType recordHeader = new HeaderType(); recordHeader.setIdentifier(identifier); - if(OAIPMHUtilities.isThisDateValid(dateOfCreation)) { - recordHeader.setDatestamp(OAIPMHUtilities.datestampAsString(dateOfCreation)); - }else { - recordHeader.setDatestamp(dateOfCreation); + if (OAIPMHUtilities.isThisDateValid(dateOfCreation)) { + recordHeader.setDatestamp(OAIPMHUtilities.datestampAsString(dateOfCreation)); + } else { + recordHeader.setDatestamp(dateOfCreation); } - + this.record.setHeader(recordHeader); // recordHeader.setStatus(StatusType.DELETED); // return recordHeader; } - /** - * @return - */ - public OAI_ESClient getOaiEsClient() { - return this.oaiEsClient; - } - - /** - * @param oaiEsClient - */ - public void setOaiEsClient(OAI_ESClient oaiEsClient) { - this.oaiEsClient = oaiEsClient; - } - } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java index 073188275ca70b669ac6f7ec86105310b0143794..0a8f1a03b493332f18d537a1877831025ee56b46 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java @@ -23,9 +23,11 @@ public class OaiPmhTestDH { new MetadataFormatListDelivererDH(); private static SetDeliverer setListDARIAH = new SetDeliverer(false, true); - private static OpenAireRecord openAireRecord; + // private static OpenAireRecord openAireRecord; + private static RecordDelivererDATACITE recordDATACITE; private static OpenAireRecordList openAireRecordList; - private static OpenAireIdentifierList openAireIdentifierList; + // private static OpenAireIdentifierList openAireIdentifierList; + private static IdentifierListDelivererDATACITE identifierListDATACITE; private DeletedRecordType deletedRecordType = DeletedRecordType.NO; private GranularityType granularityType = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; @@ -41,14 +43,13 @@ public class OaiPmhTestDH { private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false); - - private OAIPMHImpl request = new OAIPMHImpl( - this.rep, OaiPmhTestDH.record, OaiPmhTestDH.recordIDIOM, OaiPmhTestDH.openAireRecord, - OaiPmhTestDH.recordList, - OaiPmhTestDH.recordListIDIOM, OaiPmhTestDH.openAireRecordList, - OaiPmhTestDH.metadataFormatList, - OaiPmhTestDH.setListDARIAH, OaiPmhTestDH.identifierList, OaiPmhTestDH.identifierListIDIOM, - OaiPmhTestDH.openAireIdentifierList); + private OAIPMHImpl request = + new OAIPMHImpl(this.rep, OaiPmhTestDH.record, OaiPmhTestDH.recordIDIOM, + OaiPmhTestDH.recordDATACITE, OaiPmhTestDH.recordList, OaiPmhTestDH.recordListIDIOM, + OaiPmhTestDH.openAireRecordList, OaiPmhTestDH.metadataFormatList, + OaiPmhTestDH.setListDARIAH, OaiPmhTestDH.identifierList, OaiPmhTestDH.identifierListIDIOM, + // OaiPmhTestDH.openAireIdentifierList); + OaiPmhTestDH.identifierListDATACITE); OAIPMHUtilities settings = new OAIPMHUtilities(); diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java index ac44d25af03bc29e90adf6aea36e8cd818a5e04b..314d8e3710a45a013fe57203eca1d4e99d40d2b8 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java @@ -30,9 +30,11 @@ public class OaiPmhTestTG { public static OAI_ESClient oaiEsClient; private static RecordDelivererDC record; private static RecordDelivererIDIOM recordIDIOM; - private static OpenAireRecord openAireRecord; + // private static OpenAireRecord openAireRecord; + private static RecordDelivererDATACITE recordDATACITE; private static OpenAireRecordList openAireRecordList; - private static OpenAireIdentifierList openAireIdentifierList; + // private static OpenAireIdentifierList openAireIdentifierList; + private static IdentifierListDelivererDATACITE identifierListDATACITE; private static RecordListDelivererDC recordList; private static RecordListDelivererIDIOM recordListIDIOM; private static IdentifierListDelivererDC identifierList = @@ -52,11 +54,13 @@ public class OaiPmhTestTG { private MetadataFormatListDelivererInterface metadataFormatList = new MetadataFormatListDelivererTG(); private OAIPMHImpl request = new OAIPMHImpl( - this.rep, OaiPmhTestTG.record, OaiPmhTestTG.recordIDIOM, OaiPmhTestTG.openAireRecord, + this.rep, OaiPmhTestTG.record, OaiPmhTestTG.recordIDIOM, OaiPmhTestTG.recordDATACITE, OaiPmhTestTG.recordList, OaiPmhTestTG.recordListIDIOM, OaiPmhTestTG.openAireRecordList, this.metadataFormatList, OaiPmhTestTG.setListTextGrid, OaiPmhTestTG.identifierList, OaiPmhTestTG.identifierListIDIOM, - OaiPmhTestTG.openAireIdentifierList); + // OaiPmhTestTG.openAireIdentifierList); + OaiPmhTestTG.identifierListDATACITE); + OAIPMHUtilities settings = new OAIPMHUtilities(); /** diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index 51f8d42dba33ea3a2712c537b9557788b16bb502..bae999c06bb0e74fc8ea61789e2de74736f3c195 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.4-SNAPSHOT</version> + <version>3.4.1-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index 433c178b50e670f35aca66039282674797cd4b0b..696eae1ff7a76e370f2a56cbe85af5020bbadd3c 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -31,6 +31,8 @@ <property name="ignoreUnresolvablePlaceholders" value="true" /> </bean> + <!-- ES client bean --> + <bean id="ElasticSearchClient" class="info.textgrid.middleware.OAI_ESClient"> <constructor-arg index="0" @@ -43,8 +45,40 @@ <property name="esType" value="${elasticSearch.type}" /> </bean> + <!-- Main class bean --> + + <bean id="oai" class="info.textgrid.middleware.OAIPMHImpl"> + <constructor-arg ref="RepIdentification" /> + <constructor-arg ref="RecordDC" /> + <constructor-arg ref="RecordIDIOM" /> + <!-- constructor-arg ref="OpenAireRecord" / --> + <constructor-arg ref="RecordDATACITE" /> + <constructor-arg ref="RecordListDC" /> + <constructor-arg ref="RecordListIDIOM" /> + <constructor-arg ref="OpenAireRecordList" /> + <constructor-arg ref="${metadataFormatListInstance}" /> + <constructor-arg ref="SetDeliverer" /> + <constructor-arg ref="ListIdentifierDC" /> + <constructor-arg ref="ListIdentifierIDIOM" /> + <constructor-arg ref="ListIdentifierDATACITE" /> + <!-- constructor-arg ref="OpenAireIdentifierList" / --> + <property name="textGrid" value="${textgrid}" /> + <property name="dariah" value="${dariah}" /> + </bean> + <!--bean id="drc" class="info.textgrid.middleware.oaipmh.${DeletedRecordInfo}" --> + <!-- Define all implementing classes here, chose needed class in main config + file! --> + <bean id="MetadataFormatListDelivererDH" + class="info.textgrid.middleware.MetadataFormatListDelivererDH"> + </bean> + <bean id="MetadataFormatListDelivererTG" + class="info.textgrid.middleware.MetadataFormatListDelivererTG"> + </bean> + + <!-- Bean for verb=Identify --> + <bean id="RepIdentification" class="info.textgrid.middleware.RepIdentification"> <constructor-arg index="0" value="${RepositoryName}" /> @@ -58,12 +92,22 @@ <constructor-arg index="6" value="${AdminMail}" /> </bean> - <bean id="RecordListDC" - class="info.textgrid.middleware.RecordListDelivererDC"> + <!-- Beans for verb=GetRecords --> + + <bean id="AbstractRecord" abstract="true" + class="info.textgrid.middleware.RecordDelivererAbstract"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + </bean> + + <bean scope="prototype" id="RecordDC" + class="info.textgrid.middleware.RecordDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + <property name="fields" value="${fields}" /> <property name="workFields" value="${workFields}" /> + <property name="formatField" value="${formatField}" /> <property name="formatToFilter" value="${formatToFilter}" /> <property name="dateOfObjectCreation" @@ -72,10 +116,11 @@ value="${relationToFurtherMetadataObject}" /> <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> - <property name="FieldForRange" value="${rangeField}" /> + <property name="identifierField" value="${identifierField}" /> + <property name="contributor" value="${contributorList}" /> <property name="coverage" value="${coverageList}" /> - <property name="creators" value="${creatorList}" /> + <property name="creator" value="${creatorList}" /> <property name="dates" value="${dateList}" /> <property name="descriptions" value="${descriptionList}" /> <property name="formats" value="${formatList}" /> @@ -83,92 +128,156 @@ <property name="languages" value="${languageList}" /> <property name="publishers" value="${publisherList}" /> <property name="relations" value="${relationList}" /> - <property name="relationsForWork" - value="${relationsForWorkList}" /> + <!-- property name="relationsForWork" value="${relationsForWorkList}" / --> <property name="rights" value="${rightsList}" /> <property name="sources" value="${sourceList}" /> <property name="subjects" value="${subjectList}" /> <property name="titles" value="${titleList}" /> <property name="types" value="${typeList}" /> - <property name="modifiedField" value="${modifiedField}" /> - <property name="identifierField" value="${identifierField}" /> - <property name="searchResponseSize" - value="${searchResponseSize}" /> </bean> - <bean id="RecordListIDIOM" - class="info.textgrid.middleware.RecordListDelivererIDIOM"> + <bean id="RecordIDIOM" + class="info.textgrid.middleware.RecordDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + + <property name="fields" value="${fields}" /> + <property name="workFields" value="${workFields}" /> + + <property name="formatField" value="${formatField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="relationToFurtherMetadataObject" + value="${relationToFurtherMetadataObject}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="identifierField" value="${identifierField}" /> + + <property name="contributor" value="${contributorList}" /> + <property name="coverage" value="${coverageList}" /> + <property name="creator" value="${creatorList}" /> + <property name="dates" value="${dateList}" /> + <property name="descriptions" value="${descriptionList}" /> + <property name="formats" value="${formatList}" /> + <property name="identifiers" value="${identifierList}" /> + <property name="languages" value="${languageList}" /> + <property name="publishers" value="${publisherList}" /> + <property name="relations" value="${relationList}" /> + <!-- property name="relationsForWork" value="${relationsForWorkList}" / --> + <property name="rights" value="${rightsList}" /> + <property name="sources" value="${sourceList}" /> + <property name="subjects" value="${subjectList}" /> + <property name="titles" value="${titleList}" /> + <property name="types" value="${typeList}" /> </bean> - <bean id="OpenAireRecord" - class="info.textgrid.middleware.OpenAireRecord"> + <!-- <bean id="OpenAireRecord" class="info.textgrid.middleware.OpenAireRecord"> + <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" + value="${dariah}" /> <property name="titleFields" value="${oar.titleFields}" + /> <property name="dateFields" value="${oar.dateFields}" /> <property name="contributorFields" + value="${oar.contributorFields}" /> <property name="languageFields" value="${oar.languageFields}" + /> <property name="alternateIdentifierFields" value="${oar.alternateIdentifierFields}" + /> <property name="formatFields" value="${oar.formatFields}" /> <property + name="rightsFields" value="${oar.rightsFields}" /> <property name="descriptionFields" + value="${oar.descriptionFields}" /> <property name="relatedIdentifierFields" + value="${oar.relatedIdentifierFields}" /> <property name="workFields" value="${workFields}" + /> <property name="geoLocationFields" value="${oar.geoLocationFields}" /> + <property name="versionFields" value="${oar.versionFields}" /> <property + name="subjectFields" value="${oar.subjectFields}" /> <property name="relationToWorkObject" + value="${oar.relationToWorkObject}" /> <property name="identifierField" value="${identifierField}" + /> <property name="handle" value="${oar.handle}" /> <property name="sizeField" + value="${oar.sizeField}" /> </bean> --> + + <bean id="RecordDATACITE" + class="info.textgrid.middleware.RecordDelivererDATACITE"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> - <property name="titleFields" value="${oar.titleFields}" /> - <property name="dateFields" value="${oar.dateFields}" /> - <property name="contributorFields" + + <property name="fields" value="${fields}" /> + <property name="workFields" value="${workFields}" /> + + <property name="formatField" value="${formatField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="relationToFurtherMetadataObject" + value="${relationToFurtherMetadataObject}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="identifierField" value="${identifierField}" /> + + <property name="contributor" value="${contributorList}" /> + <property name="coverage" value="${coverageList}" /> + <property name="creator" value="${creatorList}" /> + <property name="dates" value="${dateList}" /> + <property name="descriptions" value="${descriptionList}" /> + <property name="formats" value="${formatList}" /> + <property name="identifiers" value="${identifierList}" /> + <property name="languages" value="${languageList}" /> + <property name="publishers" value="${publisherList}" /> + <property name="relations" value="${relationList}" /> + <!-- property name="relationsForWork" value="${relationsForWorkList}" / --> + <property name="rights" value="${rightsList}" /> + <property name="sources" value="${sourceList}" /> + <property name="subjects" value="${subjectList}" /> + <property name="titles" value="${titleList}" /> + <property name="types" value="${typeList}" /> + + <property name="oarTitleFields" value="${oar.titleFields}" /> + <property name="oarDateFields" value="${oar.dateFields}" /> + <property name="oarContributorFields" value="${oar.contributorFields}" /> - <property name="languageFields" value="${oar.languageFields}" /> - <property name="alternateIdentifierFields" + <property name="oarLanguageFields" + value="${oar.languageFields}" /> + <property name="oarAlternateIdentifierFields" value="${oar.alternateIdentifierFields}" /> - <property name="formatFields" value="${oar.formatFields}" /> - <property name="rightsFields" value="${oar.rightsFields}" /> - <property name="descriptionFields" + <property name="oarFormatFields" value="${oar.formatFields}" /> + <property name="oarRightsFields" value="${oar.rightsFields}" /> + <property name="oarDescriptionFields" value="${oar.descriptionFields}" /> - <property name="relatedIdentifierFields" + <property name="oarRelatedIdentifierFields" value="${oar.relatedIdentifierFields}" /> - <property name="workFields" value="${workFields}" /> - <property name="geoLocationFields" + <property name="oarWorkFields" value="${workFields}" /> + <property name="oarGeoLocationFields" value="${oar.geoLocationFields}" /> - <property name="versionFields" value="${oar.versionFields}" /> - <property name="subjectFields" value="${oar.subjectFields}" /> + <property name="oarVersionFields" + value="${oar.versionFields}" /> + <property name="oarSubjectFields" + value="${oar.subjectFields}" /> + <property name="relationToWorkObject" value="${oar.relationToWorkObject}" /> - <property name="identifierField" value="${identifierField}" /> <property name="handle" value="${oar.handle}" /> <property name="sizeField" value="${oar.sizeField}" /> </bean> + <!-- Beans for verb=ListRecords --> + <bean id="AbstractRecordList" abstract="true" class="info.textgrid.middleware.RecordListDelivererAbstract"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> - <property name="rangeField" value="${rangeField}" /> - <property name="formatField" value="${oar.formatFields}" /> - <property name="formatToFilter" value="${formatToFilter}" /> - <property name="searchResponseSize" - value="${searchResponseSize}" /> </bean> - <bean id="OpenAireRecordList" - class="info.textgrid.middleware.OpenAireRecordList"> - <constructor-arg index="0" value="${textgrid}" /> - <constructor-arg index="1" value="${dariah}" /> - </bean> - - <bean id="AbstractIdentifierList" abstract="true" - class="info.textgrid.middleware.IdentifierListDelivererAbstract"> + <bean id="RecordListIDIOM" + class="info.textgrid.middleware.RecordListDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> - <property name="rangeField" value="${rangeField}" /> - <property name="formatField" value="${oar.formatFields}" /> - <property name="formatToFilter" value="${formatToFilter}" /> - <property name="searchResponseSize" - value="${searchResponseSize}" /> </bean> - <bean id="OpenAireIdentifierList" - class="info.textgrid.middleware.OpenAireIdentifierList"> + <bean id="OpenAireRecordList" + class="info.textgrid.middleware.OpenAireRecordList"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> </bean> - <bean scope="prototype" id="RecordDC" - class="info.textgrid.middleware.RecordDelivererDC"> + <bean id="RecordListDC" + class="info.textgrid.middleware.RecordListDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + <property name="fields" value="${fields}" /> + <property name="workFields" value="${workFields}" /> <property name="formatField" value="${formatField}" /> <property name="formatToFilter" value="${formatToFilter}" /> <property name="dateOfObjectCreation" @@ -177,12 +286,10 @@ value="${relationToFurtherMetadataObject}" /> <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> - <property name="identifierField" value="${identifierField}" /> - <property name="fields" value="${fields}" /> - <property name="workFields" value="${workFields}" /> + <property name="fieldForRange" value="${rangeField}" /> <property name="contributor" value="${contributorList}" /> <property name="coverage" value="${coverageList}" /> - <property name="creator" value="${creatorList}" /> + <property name="creators" value="${creatorList}" /> <property name="dates" value="${dateList}" /> <property name="descriptions" value="${descriptionList}" /> <property name="formats" value="${formatList}" /> @@ -190,16 +297,23 @@ <property name="languages" value="${languageList}" /> <property name="publishers" value="${publisherList}" /> <property name="relations" value="${relationList}" /> - <!-- property name="relationsForWork" value="${relationsForWorkList}" / --> + <property name="relationsForWork" + value="${relationsForWorkList}" /> <property name="rights" value="${rightsList}" /> <property name="sources" value="${sourceList}" /> <property name="subjects" value="${subjectList}" /> <property name="titles" value="${titleList}" /> <property name="types" value="${typeList}" /> + <property name="modifiedField" value="${modifiedField}" /> + <property name="identifierField" value="${identifierField}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> </bean> - <bean id="RecordIDIOM" - class="info.textgrid.middleware.RecordDelivererIDIOM"> + <!-- Beans for verb=ListIdentifiers --> + + <bean id="AbstractIdentifierList" abstract="true" + class="info.textgrid.middleware.IdentifierListDelivererAbstract"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> </bean> @@ -208,24 +322,59 @@ class="info.textgrid.middleware.IdentifierListDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + <property name="fieldForRange" value="${rangeField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> <property name="dateOfObjectCreation" value="${dateOfObjectCreation}" /> <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> <property name="identifierListFields" value="${identifierListFields}"></property> - <property name="FieldForRange" value="${rangeField}" /> <property name="identifierField" value="${identifierField}" /> - <property name="searchResponseSize" - value="${searchResponseSize}" /> </bean> <bean id="ListIdentifierIDIOM" class="info.textgrid.middleware.IdentifierListDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + <property name="fieldForRange" value="${rangeField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="identifierListFields" + value="${identifierListFields}"></property> + <property name="identifierField" value="${identifierField}" /> + </bean> + + <!-- <bean id="OpenAireIdentifierList" class="info.textgrid.middleware.OpenAireIdentifierList"> + <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" + value="${dariah}" /> </bean> --> + + <bean id="ListIdentifierDATACITE" + class="info.textgrid.middleware.IdentifierListDelivererDATACITE"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + <property name="fieldForRange" value="${rangeField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="identifierListFields" + value="${identifierListFields}"></property> + <property name="identifierField" value="${identifierField}" /> </bean> + <!-- Bean for verb=ListSets --> + <bean id="SetDeliverer" class="info.textgrid.middleware.SetDeliverer"> <constructor-arg index="0" value="${textgrid}" /> @@ -239,16 +388,8 @@ <property name="specFieldPrefix" value="${specFieldPrefix}" /> </bean> - <!-- Define all implementing classes here, chose needed class in main config - file! --> - <bean id="MetadataFormatListDelivererDH" - class="info.textgrid.middleware.MetadataFormatListDelivererDH"> - </bean> - <bean id="MetadataFormatListDelivererTG" - class="info.textgrid.middleware.MetadataFormatListDelivererTG"> - </bean> - <!-- REST Interface --> + <bean id="rest" class="info.textgrid.middleware.Rest" /> <bean id="cors-filter" @@ -258,23 +399,6 @@ </property> </bean> - <bean id="oai" class="info.textgrid.middleware.OAIPMHImpl"> - <constructor-arg ref="RepIdentification" /> - <constructor-arg ref="RecordDC" /> - <constructor-arg ref="RecordIDIOM" /> - <constructor-arg ref="OpenAireRecord" /> - <constructor-arg ref="RecordListDC" /> - <constructor-arg ref="RecordListIDIOM" /> - <constructor-arg ref="OpenAireRecordList" /> - <constructor-arg ref="${metadataFormatListInstance}" /> - <constructor-arg ref="SetDeliverer" /> - <constructor-arg ref="ListIdentifierDC" /> - <constructor-arg ref="ListIdentifierIDIOM" /> - <constructor-arg ref="OpenAireIdentifierList" /> - <property name="textGrid" value="${textgrid}" /> - <property name="dariah" value="${dariah}" /> - </bean> - <jaxrs:server id="root" address="/root" publishedEndpointUrl="${RS_ENDPOINT}"> <jaxrs:serviceBeans> 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 40e018555efa945a8914734b79854752134fa9f6..f8caf3dbcfbf0b23a2e5c1dea1c7b52fcfcdfd97 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties @@ -46,6 +46,26 @@ metadataFormatListInstance = MetadataFormatListDelivererDH fields = descriptiveMetadata.dc:contributor, descriptiveMetadata.dc:coverage, descriptiveMetadata.dc:creator, descriptiveMetadata.dc:date, administrativeMetadata.dcterms:modified, descriptiveMetadata.dc:description, descriptiveMetadata.dc:format, descriptiveMetadata.dc:identifier, administrativeMetadata.dcterms:identifier, descriptiveMetadata.dc:language, descriptiveMetadata.dc:publisher, descriptiveMetadata.dc:relation, descriptiveMetadata.dc:rights, descriptiveMetadata.dc:source, descriptiveMetadata.dc:subject, descriptiveMetadata.dc:title, descriptiveMetadata.dc:type workFields = descriptiveMetadata.dc:title +###################### +## OpenAireRecords ### +###################### + +oar.titleFields = descriptiveMetadata.dc:title +oar.dateFields = administrativeMetadata.dcterms:created,administrativeMetadata.dcterms:modified +oar.contributorFields = descriptiveMetadata.dc:contributor +oar.languageFields = descriptiveMetadata.dc:language +oar.alternateIdentifierFields = descriptiveMetadata.dc:identifier +oar.formatFields = administrativeMetadata.dcterms:format +oar.rightsFields = descriptiveMetadata.dc:rights +oar.descriptionFields = descriptiveMetadata.dc:decsription +oar.relatedIdentifierFields = descriptiveMetadata.dc:relation +oar.relationToWorkObject = +oar.geoLocationFields = descriptiveMetadata.dc:coverage +oar.handle = administrativeMetadata.dcterms:identifier +oar.versionFields = +oar.subjectFields = descriptiveMetadata.dc:subject +oar.sizeField = administrativeMetadata.dcterms:extent + ########################## ## Dublin Core Fields ## ########################## diff --git a/pom.xml b/pom.xml index 5e0aaa957c6445ea112fec84e58b30f7bde33aae..2c99eb7c3af4066cf49a99a8cc5114ca7c412a31 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>3.4-SNAPSHOT</version> + <version>3.4.1-SNAPSHOT</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties>