Skip to content

Commit

Permalink
Merge pull request #10430 from IQSS/10254-fix-harvested-redirects
Browse files Browse the repository at this point in the history
10254 fixing redirects for records harvested from "Generic OAI archives" (i.e., non-Dataverse OAI servers)
  • Loading branch information
sekmiller committed Mar 28, 2024
2 parents 082ac8a + bb49ed0 commit 834bd64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/release-notes/10254-fix-harvested-redirects.md
@@ -0,0 +1 @@
Redirects from search cards back to the original source for datasets harvested from "Generic OAI Archives", i.e. non-Dataverse OAI servers, have been fixed.
17 changes: 17 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Expand Up @@ -853,6 +853,23 @@ public String getRemoteArchiveURL() {
if (StringUtil.nonEmpty(this.getProtocol())
&& StringUtil.nonEmpty(this.getAuthority())
&& StringUtil.nonEmpty(this.getIdentifier())) {

// If there is a custom archival url for this Harvesting
// Source, we'll use that
String harvestingUrl = this.getHarvestedFrom().getHarvestingUrl();
String archivalUrl = this.getHarvestedFrom().getArchiveUrl();
if (!harvestingUrl.contains(archivalUrl)) {
// When a Harvesting Client is created, the “archive url” is set to
// just the host part of the OAI url automatically.
// For example, if the OAI url was "https://remote.edu/oai",
// the archive url will default to "https://remote.edu/".
// If this is no longer true, we know it means the admin
// went to the trouble of setting it to something else -
// so we should use this url for the redirects back to source,
// instead of the global id resolver.
return archivalUrl + this.getAuthority() + "/" + this.getIdentifier();
}
// ... if not, we'll redirect to the resolver for the global id:
return this.getPersistentURL();
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Expand Up @@ -2050,7 +2050,7 @@ private String init(boolean initFull) {
// to the local 404 page, below.
logger.warning("failed to issue a redirect to "+originalSourceURL);
}
return originalSourceURL;
return null;
}

return permissionsWrapper.notFound();
Expand Down

0 comments on commit 834bd64

Please sign in to comment.