fixed issues with related resources that have a single link for a hasMany relationship (e.g. item.bitstreams)

This commit is contained in:
Art Lowel
2017-06-20 15:04:42 +02:00
parent b69f2ff4cb
commit 21a6a80d13
17 changed files with 119 additions and 38 deletions

View File

@@ -72,7 +72,16 @@ export class RequestEffects {
.filter(property => data.hasOwnProperty(property))
.filter(property => hasValue(data[property]))
.forEach(property => {
uuids = [...uuids, ...this.deserializeAndCache(data[property], requestHref)];
let propertyUUIDs;
if (isPaginatedResponse(data[property])) {
propertyUUIDs = this.process(data[property], requestHref);
}
else {
propertyUUIDs = this.deserializeAndCache(data[property], requestHref);
}
uuids = [...uuids, ...propertyUUIDs];
});
return uuids;
}
@@ -122,13 +131,15 @@ export class RequestEffects {
}
else {
//TODO move check to Validator?
throw new Error(`The server returned an object with an unknown a known type: ${type}`);
// throw new Error(`The server returned an object with an unknown a known type: ${type}`);
return [];
}
}
else {
//TODO move check to Validator
throw new Error(`The server returned an object without a type: ${JSON.stringify(obj)}`);
// throw new Error(`The server returned an object without a type: ${JSON.stringify(obj)}`);
return [];
}
}