Skip to content

Commit 2c57112

Browse files
committed
check if response from uri.gbv.de actually contain data before using it and fall back to data from ws.gbv.de if not
1 parent de6a738 commit 2c57112

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/updater/gndUpdater.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ main = (payload) => {
9999
let requests = [];
100100

101101
URIList.forEach((uri) => {
102-
if(uri) {
102+
if (uri) {
103103
var gndURIParts = uri.split('/');
104104
let gndID = gndURIParts.pop();
105105
let dataRequestUrl = `https://uri.gbv.de/terminology/entityfacts/${gndID}?format=json`
@@ -126,7 +126,11 @@ main = (payload) => {
126126
error: null
127127
};
128128
if (response.ok) {
129-
result.data = response.json();
129+
if (response.headers.get('content-length') === '0') {
130+
result.data = null
131+
} else {
132+
result.data = response.json();
133+
}
130134
} else {
131135
result.error = "Error fetching data from " + url + ": " + response.status + " " + response.statusText;
132136
}

src/webfrontend/CustomDataTypeGND.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class CustomDataTypeGND extends CustomDataTypeWithCommonsAsPlugin
317317
.done((data, status, statusText) ->
318318
# note: subjectheadings and works are not part of entityfacts yet
319319
# --> data will be empty, which is handled by falling back to cdata-defaults from autocomplete
320+
if !data
321+
data = {}
320322

321323
pluginConfig = ez5.session.getBaseConfig("plugin", "custom-data-type-gnd")
322324

src/webfrontend/GNDUtil.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GNDUtil
5757

5858
# changed: lobid used 'id', entityfacts uses '@id'
5959
if fulltextConfig?.id
60-
if efJSON['@id'] and
60+
if efJSON['@id']
6161
_fulltext += efJSON['@id'] + ' '
6262
else
6363
_fulltext += cdata.conceptURI + ' '

0 commit comments

Comments
 (0)