Skip to content

Commit 948a1fc

Browse files
committed
Add JhuItemIndexFactoryImpl to conditionally set fulltext
1 parent 4f2bd92 commit 948a1fc

File tree

5 files changed

+676
-165
lines changed

5 files changed

+676
-165
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ jobs:
8585
# Must run after 'tests' job above
8686
needs: tests
8787
runs-on: ubuntu-latest
88+
# Do not run on forks since it will fail without the token
89+
if: github.repository == 'dspace/dspace'
8890
steps:
8991
- name: Checkout
9092
uses: actions/checkout@v4
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
package edu.jhu.library.dspace.discovery.indexobject;
9+
10+
import java.io.IOException;
11+
import java.sql.SQLException;
12+
13+
import org.apache.solr.client.solrj.SolrServerException;
14+
import org.apache.solr.common.SolrInputDocument;
15+
import org.apache.solr.common.SolrInputField;
16+
import org.dspace.access.status.DefaultAccessStatusHelper;
17+
import org.dspace.core.Context;
18+
import org.dspace.discovery.indexobject.IndexableItem;
19+
import org.dspace.discovery.indexobject.ItemIndexFactoryImpl;
20+
21+
/**
22+
* This is an extended ItemIndexFactoryImpl for JHU. This class is needed for when changes are needed in the creation
23+
* and writing of the solr item document that cannot be done using solr plugins. For example, we needed to not write
24+
* fulltext to the solr document if the access_status_filter was not open.access, but fulltext is added to the document
25+
* in the writeDocument method instead of in buildDocument where the plugins are executed.
26+
*/
27+
public class JhuItemIndexFactoryImpl extends ItemIndexFactoryImpl {
28+
29+
@Override
30+
public void writeDocument(Context context, IndexableItem indexableObject, SolrInputDocument solrInputDocument)
31+
throws SQLException, IOException, SolrServerException {
32+
SolrInputField field = solrInputDocument.getField("access_status_filter");
33+
if (field != null && DefaultAccessStatusHelper.OPEN_ACCESS.equals(field.getValue())) {
34+
super.writeDocument(context, indexableObject, solrInputDocument);
35+
} else {
36+
writeDocument(solrInputDocument, null);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)