diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/Settings.java b/core/src/main/java/org/fao/geonet/kernel/setting/Settings.java
index 6b4106e3525f..9e65245dacff 100644
--- a/core/src/main/java/org/fao/geonet/kernel/setting/Settings.java
+++ b/core/src/main/java/org/fao/geonet/kernel/setting/Settings.java
@@ -83,6 +83,7 @@ public class Settings {
public static final String SYSTEM_SELECTIONMANAGER_MAXRECORDS = "system/selectionmanager/maxrecords";
public static final String SYSTEM_CSW_ENABLE = "system/csw/enable";
public static final String SYSTEM_CSW_ENABLEWHENINDEXING = "system/csw/enabledWhenIndexing";
+ public static final String SYSTEM_CSW_GETRECORDS_IGNORE_METADATA_NOT_SUPPORTED = "system/csw/getRecordsIgnoreMetadataNotSupported";
public static final String SYSTEM_CSW_CAPABILITY_RECORD_UUID = "system/csw/capabilityRecordUuid";
public static final String SYSTEM_CSW_METADATA_PUBLIC = "system/csw/metadataPublic";
public static final String SYSTEM_USERSELFREGISTRATION_ENABLE = "system/userSelfRegistration/enable";
diff --git a/csw-server/src/main/java/org/fao/geonet/kernel/csw/services/getrecords/SearchController.java b/csw-server/src/main/java/org/fao/geonet/kernel/csw/services/getrecords/SearchController.java
index 7abea41d66ba..b072f04b1252 100644
--- a/csw-server/src/main/java/org/fao/geonet/kernel/csw/services/getrecords/SearchController.java
+++ b/csw-server/src/main/java/org/fao/geonet/kernel/csw/services/getrecords/SearchController.java
@@ -51,9 +51,12 @@
import org.fao.geonet.kernel.schema.MetadataSchema;
import org.fao.geonet.kernel.search.EsFilterBuilder;
import org.fao.geonet.kernel.search.EsSearchManager;
+import org.fao.geonet.kernel.setting.SettingManager;
+import org.fao.geonet.kernel.setting.Settings;
import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.Xml;
import org.jdom.Attribute;
+import org.jdom.Comment;
import org.jdom.Content;
import org.jdom.Element;
import org.jdom.Namespace;
@@ -458,6 +461,9 @@ public Element search(ServiceContext context, int startPos, int maxRecords,
// TODO: Check to get summary or remove custom summary output
try {
+ SettingManager sm = context.getBean(SettingManager.class);
+ boolean ignoreMetadataNotSupported = sm.getValueAsBool(Settings.SYSTEM_CSW_GETRECORDS_IGNORE_METADATA_NOT_SUPPORTED, true);
+
SearchResponse result = searchManager.query(esJsonQuery, new HashSet<>(), startPos - 1, maxRecords, sort);
List hits = result.hits().hits();
@@ -482,18 +488,25 @@ public Element search(ServiceContext context, int startPos, int maxRecords,
AbstractMetadata metadata = metadataUtils.findOne(mdId);
String displayLanguage = context.getLanguage();
- // The query to retrieve GetRecords, filters by portal. No need to re-check again when retrieving each metadata.
- Element resultMD = retrieveMetadata(context, metadata.getId() + "",
- setName, outSchema, elemNames, typeName, resultType, strategy, displayLanguage, false);
+ try {
+ // The query to retrieve GetRecords, filters by portal. No need to re-check again when retrieving each metadata.
+ Element resultMD = retrieveMetadata(context, metadata.getId() + "",
+ setName, outSchema, elemNames, typeName, resultType, strategy, displayLanguage, false);
- if (resultMD != null) {
- if (resultType == ResultType.RESULTS) {
- results.addContent(resultMD);
- }
+ if (resultMD != null) {
+ if (resultType == ResultType.RESULTS) {
+ results.addContent(resultMD);
+ }
- counter++;
+ counter++;
+ }
+ } catch (InvalidParameterValueEx e) {
+ if (ignoreMetadataNotSupported) {
+ results.addContent(new Comment(e.getMessage()));
+ } else {
+ throw e;
+ }
}
-
}
results.setAttribute("numberOfRecordsMatched", Long.toString(numMatches));
diff --git a/docs/manual/docs/administrator-guide/configuring-the-catalog/csw-configuration.md b/docs/manual/docs/administrator-guide/configuring-the-catalog/csw-configuration.md
index 9faf9da1ad19..c3c891b27967 100644
--- a/docs/manual/docs/administrator-guide/configuring-the-catalog/csw-configuration.md
+++ b/docs/manual/docs/administrator-guide/configuring-the-catalog/csw-configuration.md
@@ -20,6 +20,8 @@ Configuration options:
- *Create element if it does not exist when using XPath in CSW transaction.*: If not checked, only existing elements can be updated.
+- *Ignore metadata not supporting requested outputSchema.*: If checked, when a metadata record does not support the requested outputSchema in GetRecords operation, it will be skipped from the search results. If not checked, an exception will be returned.
+
## Service Metadata Record {#csw-configuration_service_record}
In order to create a custom capabilities, it is recommended to create a dedicated service metadata record (using ISO19115-3 or ISO19139 standards). This record is used to build the capabilities document using the template `web/src/main/webapp/xml/csw/capabilities.xml`.
diff --git a/docs/manual/docs/administrator-guide/configuring-the-catalog/img/csw.png b/docs/manual/docs/administrator-guide/configuring-the-catalog/img/csw.png
index 9314c97407e7..79ca6eacfda9 100644
Binary files a/docs/manual/docs/administrator-guide/configuring-the-catalog/img/csw.png and b/docs/manual/docs/administrator-guide/configuring-the-catalog/img/csw.png differ
diff --git a/services/src/main/java/org/fao/geonet/api/site/model/SettingSet.java b/services/src/main/java/org/fao/geonet/api/site/model/SettingSet.java
index f3f839c193bb..0cadb601a219 100644
--- a/services/src/main/java/org/fao/geonet/api/site/model/SettingSet.java
+++ b/services/src/main/java/org/fao/geonet/api/site/model/SettingSet.java
@@ -37,7 +37,8 @@ public enum SettingSet {
Settings.SYSTEM_CSW_ENABLE,
Settings.SYSTEM_CSW_ENABLEWHENINDEXING,
Settings.SYSTEM_CSW_METADATA_PUBLIC,
- Settings.SYSTEM_CSW_TRANSACTION_XPATH_UPDATE_CREATE_NEW_ELEMENTS
+ Settings.SYSTEM_CSW_TRANSACTION_XPATH_UPDATE_CREATE_NEW_ELEMENTS,
+ Settings.SYSTEM_CSW_GETRECORDS_IGNORE_METADATA_NOT_SUPPORTED
}),
HARVESTER(new String[]{
Settings.SYSTEM_HARVESTER_ENABLE_EDITING
diff --git a/web-ui/src/main/resources/catalog/locales/en-admin.json b/web-ui/src/main/resources/catalog/locales/en-admin.json
index adad56b1dee8..7c0a680bf378 100644
--- a/web-ui/src/main/resources/catalog/locales/en-admin.json
+++ b/web-ui/src/main/resources/catalog/locales/en-admin.json
@@ -703,6 +703,8 @@
"system/csw/metadataPublic-help": "When a transaction insert a new record via the CSW-T protocol, automatically publish the record to all users.",
"system/csw/transactionUpdateCreateXPath": "Create element if it does not exist when using XPath in CSW transaction.",
"system/csw/transactionUpdateCreateXPath-help": "If not checked, only existing elements can be updated.",
+ "system/csw/getRecordsIgnoreMetadataNotSupported": "Ignore metadata not supporting requested outputSchema",
+ "system/csw/getRecordsIgnoreMetadataNotSupported-help": "When enabled, if a metadata record does not support the requested outputSchema in GetRecords operation, it will be skipped from the search results. If disabled, an exception will be returned.",
"system/feedback": "Feedback",
"system/feedback/email": "Email",
"system/feedback/email-help": "This is the administrator's email address used to send feedback.",
diff --git a/web-ui/src/main/resources/catalog/templates/admin/settings/csw.html b/web-ui/src/main/resources/catalog/templates/admin/settings/csw.html
index 09be51f60768..6a213ede5a08 100644
--- a/web-ui/src/main/resources/catalog/templates/admin/settings/csw.html
+++ b/web-ui/src/main/resources/catalog/templates/admin/settings/csw.html
@@ -79,6 +79,23 @@
{{'system/csw/transactionUpdateCreateXPath-help' | translate}}