diff --git a/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java b/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java index 2db53bff9be5..1f608ab01794 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java @@ -400,8 +400,11 @@ private SolrInputDocument index(Item item) doc.addField("item.id", item.getID().toString()); String legacyOaiId = itemService.getMetadataFirstValue(item, "dspace", "legacy", "oai-identifier", Item.ANY); - String handle = StringUtils.isNotEmpty(legacyOaiId) ? legacyOaiId.split(":")[2] : item.getHandle(); - doc.addField("item.handle", handle); + String handle = item.getHandle(); + doc.addField("item.handle", item.getHandle()); + if (StringUtils.isNotEmpty(legacyOaiId)) { + doc.addField("item.legacyoaiidentifier", legacyOaiId.split(":")[2]); + } boolean isEmbargoed = !this.isPublic(item); boolean isCurrentlyVisible = this.checkIfVisibleInOAI(item); diff --git a/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceItem.java b/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceItem.java index d1f78ee67152..b179229987da 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceItem.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceItem.java @@ -105,7 +105,8 @@ public List getAbout() { @Override public String getIdentifier() { - return buildIdentifier(getHandle()); + return !getMetadata("dspace","legacy", "oai-identifier").isEmpty() ? + getMetadata("dspace","legacy", "oai-identifier").get(0) : buildIdentifier(getHandle()); } private static class MetadataNamePredicate implements Predicate { diff --git a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceItemSolrRepository.java b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceItemSolrRepository.java index 281095e01aab..fc08fb6fb413 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceItemSolrRepository.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceItemSolrRepository.java @@ -59,8 +59,13 @@ public Item getItem(String identifier) throws IdDoesNotExistException { String parts[] = identifier.split(Pattern.quote(":")); if (parts.length == 3) { try { - SolrQuery params = new SolrQuery("item.handle:" + parts[2]); - return new DSpaceSolrItem(DSpaceSolrSearch.querySingle(server, params)); + try { + SolrQuery params = new SolrQuery("item.legacyoaiidentifier:" + parts[2]); + return new DSpaceSolrItem(DSpaceSolrSearch.querySingle(server, params)); + } catch (SolrSearchEmptyException ex) { + SolrQuery altParams = new SolrQuery("item.handle:" + parts[2]); + return new DSpaceSolrItem(DSpaceSolrSearch.querySingle(server, altParams)); + } } catch (SolrSearchEmptyException | IOException ex) { throw new IdDoesNotExistException(ex); } diff --git a/dspace/solr/oai/conf/schema.xml b/dspace/solr/oai/conf/schema.xml index b2f61c2de9dd..9881e18c375a 100644 --- a/dspace/solr/oai/conf/schema.xml +++ b/dspace/solr/oai/conf/schema.xml @@ -120,6 +120,7 @@ +