Skip to content

Commit

Permalink
Merged in DSC-1296 (pull request DSpace#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaksei.bykau authored and LucaGiamminonni committed Oct 16, 2023
2 parents 0dc58de + b5aafe5 commit 6143382
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public List<About> 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<Element> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions dspace/solr/oai/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<field name="item.id" type="uuid" indexed="true" stored="true" multiValued="false" />
<field name="item.public" type="boolean" indexed="true" stored="true" multiValued="false" />
<field name="item.handle" type="string" indexed="true" stored="true" multiValued="false" />
<field name="item.legacyoaiidentifier" type="string" indexed="true" stored="true" multiValued="false" />
<field name="item.collections" type="string" indexed="true" stored="true" multiValued="true" />
<field name="item.communities" type="string" indexed="true" stored="true" multiValued="true" />
<field name="item.lastmodified" type="date" indexed="true" stored="true" multiValued="false" />
Expand Down

0 comments on commit 6143382

Please sign in to comment.