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

solr reindexing through events #873

Open
wants to merge 12 commits into
base: dtq-dev
Choose a base branch
from
23 changes: 3 additions & 20 deletions dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,18 +730,6 @@ private static void usage() {
}
}

private boolean isTest() {
try {
if (StringUtils.equals("jdbc:h2:mem:test", this.context.getDBConfig().getDatabaseUrl())) {
return true;
}
} catch (SQLException exception) {
return false;
}

return false;
}

/**
* Delete the item from Solr by the ID of the item
*/
Expand All @@ -757,14 +745,9 @@ public void indexItems(java.util.Collection<Item> items) throws Exception {
deleteItemByQuery(item);
solrServerResolver.getServer().add(this.index(item));
} catch (IOException | XMLStreamException | SQLException | WritingXmlException | SolrServerException e) {
// Do not throw RuntimeException in tests
if (this.isTest()) {
log.error("Cannot reindex the item with ID: " + item.getID() + " because: " + e.getMessage());
} else {
log.error("Cannot reindex the item with ID: " + item.getID() + " because: " + e.getMessage());
throw new RuntimeException("Cannot reindex the item with ID: " + item.getID() + " because: "
+ e.getMessage());
}
log.error("Cannot reindex the item with ID: " + item.getID() + " because: " + e.getMessage());
throw new RuntimeException("Cannot reindex the item with ID: " + item.getID() + " because: "
+ e.getMessage());
}
}
solrServerResolver.getServer().commit();
Expand Down