Skip to content

Commit 802df48

Browse files
authored
Merge pull request #11038 from Recherche-Data-Gouv/11020-unconsidered-harvesting-granularity
Harvesting : Add granularity to ListRecords when using from parameter
2 parents 0b3f93e + 9ced7d1 commit 802df48

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Bug Fix:
2+
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.

src/main/java/edu/harvard/iq/dataverse/harvest/client/oai/OaiHandler.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.gdcc.xoai.model.oaipmh.results.record.Header;
55
import io.gdcc.xoai.model.oaipmh.results.MetadataFormat;
66
import io.gdcc.xoai.model.oaipmh.results.Set;
7+
import io.gdcc.xoai.model.oaipmh.verbs.Identify;
78
import io.gdcc.xoai.serviceprovider.ServiceProvider;
89
import io.gdcc.xoai.serviceprovider.exceptions.BadArgumentException;
910
import io.gdcc.xoai.serviceprovider.exceptions.InvalidOAIResponse;
@@ -289,6 +290,8 @@ private ListIdentifiersParameters buildListIdentifiersParams() throws OaiHandler
289290
mip.withMetadataPrefix(metadataPrefix);
290291

291292
if (this.fromDate != null) {
293+
Identify identify = runIdentify();
294+
mip.withGranularity(identify.getGranularity().toString());
292295
mip.withFrom(this.fromDate.toInstant());
293296
}
294297

@@ -311,10 +314,13 @@ public String getProprietaryDataverseMetadataURL(String identifier) {
311314
return requestURL.toString();
312315
}
313316

314-
public void runIdentify() {
315-
// not implemented yet
316-
// (we will need it, both for validating the remote server,
317-
// and to learn about its extended capabilities)
317+
public Identify runIdentify() throws OaiHandlerException {
318+
ServiceProvider sp = getServiceProvider();
319+
try {
320+
return sp.identify();
321+
} catch (InvalidOAIResponse ior) {
322+
throw new OaiHandlerException("No valid response received from the OAI server.");
323+
}
318324
}
319325

320326
public Map<String,String> makeCustomHeaders(String headersString) {

0 commit comments

Comments
 (0)