@sap/xsodata
Version:
Expose data from a HANA database as OData V2 service with help of .xsodata files.
28 lines (21 loc) • 892 B
JavaScript
;
var Http501_NotSupported= require('../../utils/errors/http/notSupported');
module.exports = function checkGenKeyRestrictions(context, callback) {
if (!context.oData.dbSegmentLast.entityType.keys.generatedKey) {
return callback(null, context);
}
if (context.request.method.toLowerCase() !== 'get') {
return callback(createError(), context);
} else {
if (!context.oData.dbSegmentLast.isCollection) {
return callback(createError(), context);
}
}
return callback(null, context);
};
function createError() {
var errorMessage = 'GET, PUT/MERGE, DELETE are not allowed for entity requests, ' +
'where generated local key is defined on the corresponding entity set. ' +
'In addition POST requests to the entity set are also not allowed.';
return new Http501_NotSupported(errorMessage);
}