Skip to content

Commit f933e7c

Browse files
authored
Merge pull request #1738 from UNC-Libraries/bxc-4589-solr
BXC-4589 - Prevent attempt to update work before it is indexed
2 parents 3e9b029 + a5a2baa commit f933e7c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/solrUpdate/AggregateUpdateProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public void process(Exchange exchange) throws Exception {
5050
}
5151
for (Object idObj : idCollection) {
5252
PID pid = PIDs.get(idObj.toString());
53-
messageSender.sendIndexingOperation(null, pid, actionType);
53+
// Make sure the object exists in solr before attempting to update it
54+
if (solrClient.getById(pid.getId()) != null) {
55+
messageSender.sendIndexingOperation(null, pid, actionType);
56+
}
5457
}
5558
}
5659

services-camel-app/src/test/java/edu/unc/lib/boxc/services/camel/solrUpdate/SolrUpdateRouterTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.apache.camel.test.spring.CamelSpringRunner;
1717
import org.apache.camel.test.spring.CamelTestContextBootstrapper;
1818
import org.apache.solr.client.solrj.SolrClient;
19+
import org.apache.solr.common.SolrDocument;
1920
import org.jdom2.Document;
2021
import org.jdom2.Element;
2122
import org.junit.Before;
@@ -42,6 +43,7 @@
4243
import static org.mockito.Mockito.timeout;
4344
import static org.mockito.Mockito.times;
4445
import static org.mockito.Mockito.verify;
46+
import static org.mockito.Mockito.when;
4547

4648
/**
4749
*
@@ -236,6 +238,8 @@ public void indexLowPriority() throws Exception {
236238

237239
@Test
238240
public void multipleWorkFromFile() throws Exception {
241+
when(solrClient.getById(any(String.class))).thenReturn(new SolrDocument());
242+
239243
PID targetPid1 = pidMinter.mintContentPid();
240244
PID targetPid2 = pidMinter.mintContentPid();
241245

0 commit comments

Comments
 (0)