Skip to content

Commit

Permalink
Merge pull request #11038 from Recherche-Data-Gouv/11020-unconsidered…
Browse files Browse the repository at this point in the history
…-harvesting-granularity

Harvesting : Add granularity to ListRecords when using from parameter
  • Loading branch information
ofahimIQSS authored Jan 15, 2025
2 parents 0b3f93e + 9ced7d1 commit 802df48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand All @@ -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<String,String> makeCustomHeaders(String headersString) {
Expand Down

0 comments on commit 802df48

Please sign in to comment.