From 1adb9de9618995938a8f51454fb0092e14604f66 Mon Sep 17 00:00:00 2001 From: ppel Date: Thu, 5 Sep 2024 11:15:29 +0200 Subject: [PATCH 1/2] #442292 - Removed unnecesary information --- .../controllers/get-federated-catalog.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/get-federated-catalog/controllers/get-federated-catalog.js b/src/api/get-federated-catalog/controllers/get-federated-catalog.js index f66b9e0..c3d307f 100644 --- a/src/api/get-federated-catalog/controllers/get-federated-catalog.js +++ b/src/api/get-federated-catalog/controllers/get-federated-catalog.js @@ -39,6 +39,17 @@ module.exports = { } }); + catalogsResponse.data.forEach(catalog => { + delete catalog['http://www.w3.org/ns/dcat#service']; + delete catalog['originator']; + + catalog['http://www.w3.org/ns/dcat#dataset'].forEach(dataset => { + delete dataset['http://www.w3.org/ns/dcat#distribution']; + delete dataset['odrl:hasPolicy']; + delete dataset['@type']; + }); + }); + const finalResponse = { catalogs: catalogsResponse.data, totalElements: countResponse.data From ee8e48c32dfae2ba33d417246f9e016854d1883c Mon Sep 17 00:00:00 2001 From: ppel Date: Thu, 5 Sep 2024 15:18:46 +0200 Subject: [PATCH 2/2] #442292 - Adapt functionality when dataset is not an array --- .../controllers/get-federated-catalog.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/api/get-federated-catalog/controllers/get-federated-catalog.js b/src/api/get-federated-catalog/controllers/get-federated-catalog.js index c3d307f..94df324 100644 --- a/src/api/get-federated-catalog/controllers/get-federated-catalog.js +++ b/src/api/get-federated-catalog/controllers/get-federated-catalog.js @@ -23,7 +23,7 @@ module.exports = { delete body.sortOrder delete body.sortField - const countResponse = await axios.post(countCatalogUrl, body,{ + const countResponse = await axios.post(countCatalogUrl, body, { headers: { Authorization: `Bearer ${accessToken}` } @@ -40,14 +40,21 @@ module.exports = { }); catalogsResponse.data.forEach(catalog => { - delete catalog['http://www.w3.org/ns/dcat#service']; - delete catalog['originator']; + delete catalog['http://www.w3.org/ns/dcat#service']; + delete catalog['originator']; - catalog['http://www.w3.org/ns/dcat#dataset'].forEach(dataset => { - delete dataset['http://www.w3.org/ns/dcat#distribution']; - delete dataset['odrl:hasPolicy']; - delete dataset['@type']; + const datasets = catalog['http://www.w3.org/ns/dcat#dataset']; + if (Array.isArray(datasets)) { + datasets.forEach(dataset => { + delete dataset['http://www.w3.org/ns/dcat#distribution']; + delete dataset['odrl:hasPolicy']; + delete dataset['@type']; }); + } else { + delete datasets['http://www.w3.org/ns/dcat#distribution']; + delete datasets['odrl:hasPolicy']; + delete datasets['@type']; + } }); const finalResponse = {