From 3b1927208fa46f2767f95977f1c97adb1f129065 Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Thu, 2 May 2024 12:38:15 +0200 Subject: [PATCH] configurable option to skip indexing of metadatavalues with restrictive securitylevel --- .../discovery/indexobject/ItemIndexFactoryImpl.java | 10 ++++++++++ dspace/config/modules/discovery.cfg | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dspace-api/src/main/java/org/dspace/discovery/indexobject/ItemIndexFactoryImpl.java b/dspace-api/src/main/java/org/dspace/discovery/indexobject/ItemIndexFactoryImpl.java index 9959aa7cb74..b4c23875fce 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/indexobject/ItemIndexFactoryImpl.java +++ b/dspace-api/src/main/java/org/dspace/discovery/indexobject/ItemIndexFactoryImpl.java @@ -316,6 +316,11 @@ public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item } } + Integer maxsecuritylevel = DSpaceServicesFactory + .getInstance() + .getConfigurationService() + .getIntProperty("discovery.index.securitylevel.maxlevel", 0); + List toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType()); List mydc = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (MetadataValue meta : mydc) { @@ -340,6 +345,11 @@ public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item continue; } + // We are not indexing values with security level greater than the maximum value + if (meta.getSecurityLevel() != null && meta.getSecurityLevel() > maxsecuritylevel) { + continue; + } + if (StringUtils.equals(value, CrisConstants.PLACEHOLDER_PARENT_METADATA_VALUE)) { if (toProjectionFields.contains(field) || toProjectionFields .contains(unqualifiedField + "." + Item.ANY)) { diff --git a/dspace/config/modules/discovery.cfg b/dspace/config/modules/discovery.cfg index bdaa7b6042c..ab9394c18bb 100644 --- a/dspace/config/modules/discovery.cfg +++ b/dspace/config/modules/discovery.cfg @@ -55,4 +55,7 @@ discovery.facet.namedtype.workflow.pooled = 004workflow\n|||\nWaiting for Contro # Set the number of retry of a query when stale objects are found. # Set to -1 if stale objects should be ignored. Set to 0 if you want to avoid extra query but take the chance to cleanup # the index each time that stale objects are found. Default 3 -discovery.removestale.attempts = 3 \ No newline at end of file +discovery.removestale.attempts = 3 + +# the maximum securitylevel of metadatavalues which is still indexed. All above are skipped +discovery.index.securitylevel.maxlevel = 0