Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rest): sameAs redirect for merged docs #1537

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions rest/src/main/groovy/whelk/rest/api/Crud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ class Crud extends HttpServlet {

Document doc = whelk.storage.load(id, version)
if (doc) {
// it has been merged with another doc - main id is in sameAs of remaining doc
// TODO this could/should be implemented as a replacedBy inside the tombstone?
if (doc.deleted && !JsonLd.looksLikeIri(id)) {
String iri = Document.BASE_URI.toString() + id + Document.HASH_IT
String location = whelk.storage.getMainId(iri)
if (location) {
return new Tuple2(null, location)
}
}

return new Tuple2(doc, null)
}

Expand Down
Loading