diff --git a/doc/release-notes/11038-unconsidered-harvesting-granularity.md b/doc/release-notes/11038-unconsidered-harvesting-granularity.md new file mode 100644 index 00000000000..72ebd522831 --- /dev/null +++ b/doc/release-notes/11038-unconsidered-harvesting-granularity.md @@ -0,0 +1,2 @@ +Bug Fix: +OAI Client harvesting now uses the correct granularity while re-run a partial harvest (using the `from` parameter). The correct granularity comes from the `Identify` verb request. \ No newline at end of file diff --git a/src/main/java/edu/harvard/iq/dataverse/harvest/client/oai/OaiHandler.java b/src/main/java/edu/harvard/iq/dataverse/harvest/client/oai/OaiHandler.java index bb3dc06972c..4345fb44d8f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/harvest/client/oai/OaiHandler.java +++ b/src/main/java/edu/harvard/iq/dataverse/harvest/client/oai/OaiHandler.java @@ -4,6 +4,7 @@ import io.gdcc.xoai.model.oaipmh.results.record.Header; import io.gdcc.xoai.model.oaipmh.results.MetadataFormat; import io.gdcc.xoai.model.oaipmh.results.Set; +import io.gdcc.xoai.model.oaipmh.verbs.Identify; import io.gdcc.xoai.serviceprovider.ServiceProvider; import io.gdcc.xoai.serviceprovider.exceptions.BadArgumentException; import io.gdcc.xoai.serviceprovider.exceptions.InvalidOAIResponse; @@ -289,6 +290,8 @@ private ListIdentifiersParameters buildListIdentifiersParams() throws OaiHandler mip.withMetadataPrefix(metadataPrefix); if (this.fromDate != null) { + Identify identify = runIdentify(); + mip.withGranularity(identify.getGranularity().toString()); mip.withFrom(this.fromDate.toInstant()); } @@ -311,10 +314,13 @@ public String getProprietaryDataverseMetadataURL(String identifier) { return requestURL.toString(); } - public void runIdentify() { - // not implemented yet - // (we will need it, both for validating the remote server, - // and to learn about its extended capabilities) + public Identify runIdentify() throws OaiHandlerException { + ServiceProvider sp = getServiceProvider(); + try { + return sp.identify(); + } catch (InvalidOAIResponse ior) { + throw new OaiHandlerException("No valid response received from the OAI server."); + } } public Map makeCustomHeaders(String headersString) {