Skip to content

Commit

Permalink
a few more lines to accommodate the changes in gdcc/xoai (#8372)
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Jun 23, 2022
1 parent 4abf016 commit f87bea8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public void init(ServletConfig config) throws ServletException {
//addMetadataFormatConditions(xoaiContext);

setRepository = new DataverseXoaiSetRepository(setService);
itemRepository = new DataverseXoaiItemRepository(recordService, datasetService, systemConfig.getDataverseSiteUrl()+"/oai");
itemRepository = new DataverseXoaiItemRepository(recordService, datasetService, systemConfig.getDataverseSiteUrl());

repositoryConfiguration = createRepositoryConfiguration();

xoaiRepository = new Repository()
.withSetRepository(setRepository)
.withItemRepository(itemRepository)
Expand Down Expand Up @@ -182,20 +182,19 @@ private RepositoryConfiguration createRepositoryConfiguration() {
// (Note: if the setting does not exist, we are going to assume that they
// have a reason not to want to advertise their email address, so no
// email will be shown in the output of Identify.
InternetAddress internetAddress = MailUtil.parseSystemAddress(settingsService.getValueForKey(SettingsServiceBean.Key.SystemEmail));
InternetAddress systemEmailAddress = MailUtil.parseSystemAddress(settingsService.getValueForKey(SettingsServiceBean.Key.SystemEmail));

RepositoryConfiguration repositoryConfiguration = new RepositoryConfiguration()
RepositoryConfiguration repositoryConfiguration = RepositoryConfiguration.defaults()
.withRepositoryName(repositoryName)
.withBaseUrl(systemConfig.getDataverseSiteUrl()+"/oai")
.withCompression("gzip")
.withCompression("deflate")
.withAdminEmail(internetAddress != null ? internetAddress.getAddress() : null)
.withAdminEmail(systemEmailAddress != null ? systemEmailAddress.getAddress() : null)
.withDeleteMethod(DeletedRecord.TRANSIENT)
.withGranularity(Granularity.Second)
.withMaxListIdentifiers(systemConfig.getOaiServerMaxIdentifiers())
.withMaxListRecords(systemConfig.getOaiServerMaxRecords())
.withMaxListSets(systemConfig.getOaiServerMaxSets())
.withEarliestDate(new Date().toInstant()); // TODO:
.withEnableMetadataAttributes(true);

return repositoryConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Item getItem(String identifier, MetadataFormat metadataFormat) throws Han
@Override
public ResultsPage<ItemIdentifier> getItemIdentifiers(List<ScopedFilter> filters, MetadataFormat metadataFormat, int maxResponseLength, ResumptionToken.Value resumptionToken) throws HandlerException {

int offset = resumptionToken.getOffset().intValue();
int offset = Long.valueOf(resumptionToken.getOffset()).intValue();
String setSpec = resumptionToken.getSetSpec();
Instant from = resumptionToken.getFrom();
Instant until = resumptionToken.getUntil();
Expand Down Expand Up @@ -183,7 +183,7 @@ public ResultsPage<ItemIdentifier> getItemIdentifiers(List<ScopedFilter> filters
final ResumptionToken.Value resumptionToken) throws HandlerException; */
@Override
public ResultsPage<Item> getItems(List<ScopedFilter> filters, MetadataFormat metadataFormat, int maxResponseLength, ResumptionToken.Value resumptionToken) throws HandlerException {
int offset = resumptionToken.getOffset().intValue();
int offset = Long.valueOf(resumptionToken.getOffset()).intValue();
String setSpec = resumptionToken.getSetSpec();
Instant from = resumptionToken.getFrom();
Instant until = resumptionToken.getUntil();
Expand Down Expand Up @@ -297,11 +297,12 @@ private Metadata getDatasetMetadata(Dataset dataset, String metadataPrefix) thro
Metadata metadata;

if ("dataverse_json".equals(metadataPrefix)) {
// Slightly modified version of the old proprietary Json harvesting hack:
// (decision pending as to whether we want to provide backward compatibility
// for older Dataverse harvesting clients)
// Solely for backward compatibility, for older Dataverse harvesting clients
// that may still be relying on harvesting "dataverse_json";
// we will want to eventually get rid of this hack!
String apiUrl = customDataverseJsonApiUri(dataset.getGlobalId().asString());
metadata = new Metadata(new EchoElement("<dataverse_json><directApiUri>" + apiUrl + "</directApiUri></dataverse_json>"));
metadata = new Metadata(new EchoElement("<dataverse_json>custom metadata</dataverse_json>")).withAttribute("directApiCall", apiUrl);

} else {
InputStream pregeneratedMetadataStream;
pregeneratedMetadataStream = ExportService.getInstance().getExport(dataset, metadataPrefix);
Expand Down

0 comments on commit f87bea8

Please sign in to comment.