diff --git a/rest/src/main/groovy/whelk/rest/api/Crud.groovy b/rest/src/main/groovy/whelk/rest/api/Crud.groovy index a7f2117f9c..13799d27d3 100644 --- a/rest/src/main/groovy/whelk/rest/api/Crud.groovy +++ b/rest/src/main/groovy/whelk/rest/api/Crud.groovy @@ -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) }