@sap/xsodata 8.2.1 → 8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/index.js +2 -2
- package/lib/configuration.js +1 -1
- package/lib/db/connect.js +1 -1
- package/lib/db/dbSegment.js +68 -123
- package/lib/db/dbVersionChecks.js +2 -8
- package/lib/handlerConfiguration.js +2 -2
- package/lib/http/conditionalHttpHandler.js +27 -34
- package/lib/http/simpleHttpRequest.js +14 -18
- package/lib/http/simpleHttpResponse.js +9 -6
- package/lib/http/uriParser.js +9 -9
- package/lib/http/validator/httpRequestValidator.js +9 -9
- package/lib/model/annotationFactory.js +11 -11
- package/lib/model/association.js +3 -3
- package/lib/model/entityType.js +33 -67
- package/lib/model/metadataReader.js +31 -52
- package/lib/model/model.js +0 -1
- package/lib/model/validator/xsoDataConcurrencyTokenValidator.js +6 -6
- package/lib/model/xsodataReader.js +36 -28
- package/lib/processor/authorizationProcessor.js +22 -33
- package/lib/processor/batchProcessor.js +22 -33
- package/lib/processor/errorProcessor.js +4 -4
- package/lib/processor/exitProcessor.js +19 -19
- package/lib/processor/processor.js +9 -9
- package/lib/processor/resourceProcessor.js +31 -61
- package/lib/processor/resourceProcessorDelete.js +16 -16
- package/lib/processor/resourceProcessorDeleteLinks.js +25 -25
- package/lib/processor/resourceProcessorGet.js +5 -5
- package/lib/processor/resourceProcessorPost.js +43 -45
- package/lib/processor/resourceProcessorPut.js +35 -39
- package/lib/processor/resourceProcessorPutPostLinks.js +38 -39
- package/lib/security/securityContext.js +5 -5
- package/lib/serializer/atomSerializer.js +54 -55
- package/lib/serializer/atomXmlToJsonSerializer.js +32 -44
- package/lib/serializer/content.js +5 -5
- package/lib/serializer/json.js +31 -33
- package/lib/serializer/jsonSerializer.js +4 -4
- package/lib/serializer/metadataSerializer.js +32 -35
- package/lib/serializer/serializer.js +29 -43
- package/lib/serializer/serviceSerializer.js +19 -24
- package/lib/serializer/value.js +1 -2
- package/lib/serializer/xmlToJsonSerializer.js +18 -18
- package/lib/sql/createDeleteLinksStatements.js +10 -10
- package/lib/sql/createDeleteStatements.js +12 -12
- package/lib/sql/createGetStatements.js +49 -107
- package/lib/sql/createLinksSQLStatements_1_n.js +27 -27
- package/lib/sql/createPutPostLinksStatements.js +9 -9
- package/lib/sql/createPutStatements.js +0 -1
- package/lib/sql/dataCollectorDelete.js +9 -9
- package/lib/sql/dataCollectorDeleteLinks.js +3 -3
- package/lib/sql/dataCollectorGet.js +9 -17
- package/lib/sql/dataCollectorLinks.js +23 -27
- package/lib/sql/dataCollectorPost.js +20 -20
- package/lib/sql/dataCollectorPut.js +36 -36
- package/lib/sql/dataCollectorPutPostLinks.js +3 -3
- package/lib/sql/sqlStatement.js +81 -128
- package/lib/sql/sqlTools.js +3 -7
- package/lib/sql/statementProcessor.js +7 -14
- package/lib/uri/applyChecks.js +3 -3
- package/lib/uri/checks/checkAllowedMethod.js +3 -3
- package/lib/uri/checks/checkAllowedMethodForBatch.js +2 -2
- package/lib/uri/checks/checkAllowedMethodsForResourcePath.js +3 -3
- package/lib/uri/checks/checkFilterOnAggregatedColumn.js +5 -5
- package/lib/uri/checks/checkFilterOrderByOnGenKeyColumn.js +6 -6
- package/lib/uri/checks/checkGenKeyRestrictions.js +2 -2
- package/lib/uri/checks/checkModificationForbidden.js +3 -3
- package/lib/uri/checks/checkPostPutDeleteChecks.js +5 -5
- package/lib/uri/checks/checkSystemQueryOptions.js +10 -10
- package/lib/uri/checks.js +15 -15
- package/lib/uri/expandSelectTreeBuilder.js +12 -16
- package/lib/uri/oDataUriParser.js +20 -20
- package/lib/uri/queryParameterParser.js +25 -33
- package/lib/uri/resourcePathParser.js +47 -62
- package/lib/uri/uriType.js +4 -4
- package/lib/utils/associations.js +4 -4
- package/lib/utils/batch/batchExecutor.js +49 -51
- package/lib/utils/batch/batchObjects.js +10 -10
- package/lib/utils/batch/batchParser.js +27 -28
- package/lib/utils/batch/batchWriter.js +1 -1
- package/lib/utils/checkContentType.js +34 -39
- package/lib/utils/debugView.js +35 -36
- package/lib/utils/errors/applicationError.js +2 -2
- package/lib/utils/errors/debugInfo.js +2 -2
- package/lib/utils/errors/http/badRequest.js +2 -2
- package/lib/utils/errors/http/forbidden.js +2 -2
- package/lib/utils/errors/http/methodNotAllowed.js +2 -2
- package/lib/utils/errors/http/notAcceptable.js +2 -2
- package/lib/utils/errors/http/notFound.js +2 -2
- package/lib/utils/errors/http/notImplemented.js +2 -2
- package/lib/utils/errors/http/notModified.js +2 -2
- package/lib/utils/errors/http/notSupported.js +2 -2
- package/lib/utils/errors/http/preconditionFailed.js +2 -2
- package/lib/utils/errors/http/preconditionRequired.js +2 -2
- package/lib/utils/errors/http/unauthorized.js +2 -2
- package/lib/utils/errors/http/unsupportedMediaType.js +2 -2
- package/lib/utils/errors/httpError.js +2 -2
- package/lib/utils/errors/internalError.js +2 -2
- package/lib/utils/errors/modelFileError.js +2 -2
- package/lib/utils/errors/sqlError.js +2 -2
- package/lib/utils/errors/testError.js +2 -2
- package/lib/utils/errors/typeError.js +5 -5
- package/lib/utils/errors/xsODataError.js +1 -1
- package/lib/utils/logger.js +21 -32
- package/lib/utils/measurement.js +14 -13
- package/lib/utils/requestContext.js +2 -2
- package/lib/utils/stateMaschine.js +6 -6
- package/lib/utils/tableCleanup.js +3 -3
- package/lib/utils/typeConverter.js +21 -21
- package/lib/utils/typeConverters/converterTools.js +25 -331
- package/lib/utils/typeConverters/dbToJson.js +3 -3
- package/lib/utils/typeConverters/dbToUri.js +7 -7
- package/lib/utils/typeConverters/dbToXml.js +9 -9
- package/lib/utils/typeConverters/jsonToDb.js +20 -27
- package/lib/utils/typeConverters/uriToDb.js +45 -92
- package/lib/utils/typeConverters/xmlValueToJson.js +9 -13
- package/lib/utils/typedObjects.js +11 -79
- package/lib/utils/utils.js +20 -23
- package/lib/xsodata.js +37 -47
- package/package.json +9 -11
- package/.npmignore +0 -40
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* @type {exports}
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const postProcessor = require('./resourceProcessorPost');
|
|
10
|
+
const putProcessor = require('./resourceProcessorPut');
|
|
11
|
+
const putPostLinksProcessor = require('./resourceProcessorPutPostLinks');
|
|
12
|
+
const deleteProcessor = require('./resourceProcessorDelete');
|
|
13
|
+
const deleteLinksProcessor = require('./resourceProcessorDeleteLinks');
|
|
14
|
+
const getProcessor = require('./resourceProcessorGet');
|
|
15
|
+
const MethodNotAllowedError = require('./../utils/errors/http/methodNotAllowed');
|
|
16
|
+
const NotImplementedError = require('./../utils/errors/http/notImplemented');
|
|
17
|
+
const db = require('./../db/connect');
|
|
18
18
|
|
|
19
19
|
exports.process = function (context, asyncDone) {
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ exports.process = function (context, asyncDone) {
|
|
|
23
23
|
return asyncDone(err, asyncDone);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const method = context.request.method;
|
|
27
27
|
|
|
28
28
|
switch (method) {
|
|
29
29
|
case "GET":
|
|
@@ -31,24 +31,18 @@ exports.process = function (context, asyncDone) {
|
|
|
31
31
|
case "POST":
|
|
32
32
|
if (context.oData.dbSegment.isLinks) {
|
|
33
33
|
return putPostLinksProcessor.process(context, asyncDone);
|
|
34
|
-
} else {
|
|
35
|
-
return postProcessor.process(context, asyncDone);
|
|
36
34
|
}
|
|
37
|
-
|
|
35
|
+
return postProcessor.process(context, asyncDone);
|
|
38
36
|
case "PUT":
|
|
39
37
|
if (context.oData.dbSegment.isLinks) {
|
|
40
38
|
return putPostLinksProcessor.process(context, asyncDone);
|
|
41
|
-
} else {
|
|
42
|
-
return putProcessor.process(context, asyncDone);
|
|
43
39
|
}
|
|
44
|
-
|
|
40
|
+
return putProcessor.process(context, asyncDone);
|
|
45
41
|
case "DELETE":
|
|
46
42
|
if (context.oData.dbSegment.isLinks) {
|
|
47
43
|
return deleteLinksProcessor.process(context, asyncDone);
|
|
48
|
-
} else {
|
|
49
|
-
return deleteProcessor.process(context, asyncDone);
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
return deleteProcessor.process(context, asyncDone);
|
|
52
46
|
// We do not support PATCH or MERGE
|
|
53
47
|
case "PATCH":
|
|
54
48
|
return asyncDone(new MethodNotAllowedError("Method not allowed"), context);
|
|
@@ -64,7 +58,7 @@ exports.processInBatchCreateTables = function (context, asyncDone) {
|
|
|
64
58
|
return asyncDone(err, asyncDone);
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
61
|
+
const method = context.request.method;
|
|
68
62
|
|
|
69
63
|
switch (method) {
|
|
70
64
|
case "GET":
|
|
@@ -72,24 +66,18 @@ exports.processInBatchCreateTables = function (context, asyncDone) {
|
|
|
72
66
|
case "POST":
|
|
73
67
|
if (context.oData.dbSegment.isLinks) {
|
|
74
68
|
return putPostLinksProcessor.processInBatchCreateTables(context, asyncDone);
|
|
75
|
-
} else {
|
|
76
|
-
return postProcessor.processInBatchCreateTables(context, asyncDone);
|
|
77
69
|
}
|
|
78
|
-
|
|
70
|
+
return postProcessor.processInBatchCreateTables(context, asyncDone);
|
|
79
71
|
case "PUT":
|
|
80
72
|
if (context.oData.dbSegment.isLinks) {
|
|
81
73
|
return putPostLinksProcessor.processInBatchCreateTables(context, asyncDone);
|
|
82
|
-
} else {
|
|
83
|
-
return putProcessor.processInBatchCreateTables(context, asyncDone);
|
|
84
74
|
}
|
|
85
|
-
|
|
75
|
+
return putProcessor.processInBatchCreateTables(context, asyncDone);
|
|
86
76
|
case "DELETE":
|
|
87
77
|
if (context.oData.dbSegment.isLinks) {
|
|
88
78
|
return deleteLinksProcessor.processInBatchCreateTables(context, asyncDone);
|
|
89
|
-
} else {
|
|
90
|
-
return deleteProcessor.processInBatchCreateTables(context, asyncDone);
|
|
91
79
|
}
|
|
92
|
-
|
|
80
|
+
return deleteProcessor.processInBatchCreateTables(context, asyncDone);
|
|
93
81
|
// We do not support PATCH or MERGE
|
|
94
82
|
case "PATCH":
|
|
95
83
|
return asyncDone(new MethodNotAllowedError("Method not allowed"), context);
|
|
@@ -106,7 +94,7 @@ exports.processInBatch = function (context, asyncDone) {
|
|
|
106
94
|
if (err) {
|
|
107
95
|
return asyncDone(err, asyncDone);
|
|
108
96
|
}
|
|
109
|
-
|
|
97
|
+
const method = context.request.method;
|
|
110
98
|
|
|
111
99
|
switch (method) {
|
|
112
100
|
case "GET":
|
|
@@ -114,24 +102,18 @@ exports.processInBatch = function (context, asyncDone) {
|
|
|
114
102
|
case "POST":
|
|
115
103
|
if (context.oData.dbSegment.isLinks) {
|
|
116
104
|
return putPostLinksProcessor.processInBatch(context, asyncDone);
|
|
117
|
-
} else {
|
|
118
|
-
return postProcessor.processInBatch(context, asyncDone);
|
|
119
105
|
}
|
|
120
|
-
|
|
106
|
+
return postProcessor.processInBatch(context, asyncDone);
|
|
121
107
|
case "PUT":
|
|
122
108
|
if (context.oData.dbSegment.isLinks) {
|
|
123
109
|
return putPostLinksProcessor.processInBatch(context, asyncDone);
|
|
124
|
-
} else {
|
|
125
|
-
return putProcessor.processInBatch(context, asyncDone);
|
|
126
110
|
}
|
|
127
|
-
|
|
111
|
+
return putProcessor.processInBatch(context, asyncDone);
|
|
128
112
|
case "DELETE":
|
|
129
113
|
if (context.oData.dbSegment.isLinks) {
|
|
130
114
|
return deleteLinksProcessor.processInBatch(context, asyncDone);
|
|
131
|
-
} else {
|
|
132
|
-
return deleteProcessor.processInBatch(context, asyncDone);
|
|
133
115
|
}
|
|
134
|
-
|
|
116
|
+
return deleteProcessor.processInBatch(context, asyncDone);
|
|
135
117
|
// We do not support PATCH or MERGE
|
|
136
118
|
case "PATCH":
|
|
137
119
|
return asyncDone(new MethodNotAllowedError("Method not allowed"), context);
|
|
@@ -146,7 +128,7 @@ exports.processInBatchPreCommitRun = function (context, asyncDone) {
|
|
|
146
128
|
if (err) {
|
|
147
129
|
return asyncDone(err, asyncDone);
|
|
148
130
|
}
|
|
149
|
-
|
|
131
|
+
const method = context.request.method;
|
|
150
132
|
|
|
151
133
|
switch (method) {
|
|
152
134
|
case "GET":
|
|
@@ -154,24 +136,18 @@ exports.processInBatchPreCommitRun = function (context, asyncDone) {
|
|
|
154
136
|
case "POST":
|
|
155
137
|
if (context.oData.dbSegment.isLinks) {
|
|
156
138
|
return putPostLinksProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
157
|
-
} else {
|
|
158
|
-
return postProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
159
139
|
}
|
|
160
|
-
|
|
140
|
+
return postProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
161
141
|
case "PUT":
|
|
162
142
|
if (context.oData.dbSegment.isLinks) {
|
|
163
143
|
return putPostLinksProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
164
|
-
} else {
|
|
165
|
-
return putProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
166
144
|
}
|
|
167
|
-
|
|
145
|
+
return putProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
168
146
|
case "DELETE":
|
|
169
147
|
if (context.oData.dbSegment.isLinks) {
|
|
170
148
|
return deleteLinksProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
171
|
-
} else {
|
|
172
|
-
return deleteProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
173
149
|
}
|
|
174
|
-
|
|
150
|
+
return deleteProcessor.processInBatchPreCommitRun(context, asyncDone);
|
|
175
151
|
// We do not support PATCH or MERGE
|
|
176
152
|
case "PATCH":
|
|
177
153
|
return asyncDone(new MethodNotAllowedError("Method not allowed"), context);
|
|
@@ -187,7 +163,7 @@ exports.processInBatchPostCommitRun = function (context, asyncDone) {
|
|
|
187
163
|
return asyncDone(err, asyncDone);
|
|
188
164
|
}
|
|
189
165
|
|
|
190
|
-
|
|
166
|
+
const method = context.request.method;
|
|
191
167
|
|
|
192
168
|
switch (method) {
|
|
193
169
|
case "GET":
|
|
@@ -195,29 +171,23 @@ exports.processInBatchPostCommitRun = function (context, asyncDone) {
|
|
|
195
171
|
case "POST":
|
|
196
172
|
if (context.oData.dbSegment.isLinks) {
|
|
197
173
|
return putPostLinksProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
198
|
-
} else {
|
|
199
|
-
return postProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
200
174
|
}
|
|
201
|
-
|
|
175
|
+
return postProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
202
176
|
case "PUT":
|
|
203
177
|
if (context.oData.dbSegment.isLinks) {
|
|
204
178
|
return putPostLinksProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
205
|
-
} else {
|
|
206
|
-
return putProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
207
179
|
}
|
|
208
|
-
|
|
180
|
+
return putProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
209
181
|
case "DELETE":
|
|
210
182
|
if (context.oData.dbSegment.isLinks) {
|
|
211
183
|
return deleteLinksProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
212
|
-
} else {
|
|
213
|
-
return deleteProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
214
184
|
}
|
|
215
|
-
|
|
185
|
+
return deleteProcessor.processInBatchPostCommitRun(context, asyncDone);
|
|
216
186
|
// We do not support PATCH or MERGE
|
|
217
187
|
case "PATCH":
|
|
218
|
-
return asyncDone(MethodNotAllowedError("Method not allowed"), context);
|
|
188
|
+
return asyncDone(new MethodNotAllowedError("Method not allowed"), context);
|
|
219
189
|
default:
|
|
220
|
-
return asyncDone(NotImplementedError("Not implemented"), context);
|
|
190
|
+
return asyncDone(new NotImplementedError("Not implemented"), context);
|
|
221
191
|
}
|
|
222
192
|
});
|
|
223
193
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
2
|
+
const async = require('async');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const connect = require('../db/connect');
|
|
5
|
+
const utils = require('./../utils/utils');
|
|
6
|
+
const contentIdHelper = require('./contentIdHelper');
|
|
7
|
+
const sqlDelete = require('./../sql/createDeleteStatements');
|
|
8
|
+
const dataCollectorDelete = require('./../sql/dataCollectorDelete');
|
|
9
|
+
const serializer = require('./../serializer/serializer');
|
|
10
|
+
const exitProcessor = require('./exitProcessor');
|
|
11
11
|
|
|
12
12
|
function eventBefore(context, asyncDone) {
|
|
13
13
|
context.logger.info('delete', 'event start before');
|
|
14
|
-
|
|
14
|
+
const eventFunction = exitProcessor.eventHandler('before', 'delete');
|
|
15
15
|
eventFunction(context, function (err, context) {
|
|
16
16
|
context.logger.info('delete event end', 'before');
|
|
17
17
|
if (err) {
|
|
@@ -23,7 +23,7 @@ function eventBefore(context, asyncDone) {
|
|
|
23
23
|
|
|
24
24
|
function eventAfter(context, asyncDone) {
|
|
25
25
|
context.logger.info('delete', 'event start after');
|
|
26
|
-
|
|
26
|
+
const eventFunction = exitProcessor.eventHandler('after', 'delete');
|
|
27
27
|
eventFunction(context, function (err, context) {
|
|
28
28
|
context.logger.info('delete event end', 'after');
|
|
29
29
|
if (err) {
|
|
@@ -35,7 +35,7 @@ function eventAfter(context, asyncDone) {
|
|
|
35
35
|
|
|
36
36
|
function eventPrecommit(context, asyncDone) {
|
|
37
37
|
context.logger.info('delete', 'event start precommit');
|
|
38
|
-
|
|
38
|
+
const eventFunction = exitProcessor.eventHandler('precommit', 'delete');
|
|
39
39
|
eventFunction(context, function (err, context) {
|
|
40
40
|
context.logger.info('delete event end', 'precommit');
|
|
41
41
|
if (err) {
|
|
@@ -47,7 +47,7 @@ function eventPrecommit(context, asyncDone) {
|
|
|
47
47
|
|
|
48
48
|
function eventPostCommit(context, asyncDone) {
|
|
49
49
|
context.logger.info('delete', 'event start postcommit');
|
|
50
|
-
|
|
50
|
+
const eventFunction = exitProcessor.eventHandler('postcommit', 'delete');
|
|
51
51
|
eventFunction(context, function (err, context) {
|
|
52
52
|
context.logger.info('delete event end', 'postcommit');
|
|
53
53
|
if (err) {
|
|
@@ -59,9 +59,9 @@ function eventPostCommit(context, asyncDone) {
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
function executeDelete(context, asyncDone) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
63
|
+
const entityType = dbSeg.entityType;
|
|
64
|
+
const _delete = (entityType.modifications || {})['delete'] || {};
|
|
65
65
|
if (_delete.using) {
|
|
66
66
|
exitProcessor.executeExit(_delete.using, 'using', 'delete', context, asyncDone);
|
|
67
67
|
} else {
|
|
@@ -103,7 +103,7 @@ exports.process = function (context, asyncDone) {
|
|
|
103
103
|
],
|
|
104
104
|
function (err, context) {
|
|
105
105
|
if (err) {
|
|
106
|
-
|
|
106
|
+
const dbClient = context.db.client;
|
|
107
107
|
if (dbClient) {
|
|
108
108
|
//ROLLBack the changes
|
|
109
109
|
return connect.dbRollback(context, dbClient, function (errDB) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const async = require('async');
|
|
4
|
+
const connect = require('../db/connect');
|
|
5
|
+
const sqlDeleteLinks = require('./../sql/createDeleteLinksStatements');
|
|
6
|
+
const dataCollectorLinks = require('./../sql/dataCollectorLinks');
|
|
7
|
+
const dataCollectorDeleteLinks = require('./../sql/dataCollectorDeleteLinks');
|
|
8
|
+
const serializer = require('./../serializer/serializer');
|
|
9
|
+
const exitProcessor = require('./exitProcessor');
|
|
10
|
+
const utils = require('./../utils/utils');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
function eventBefore(context, asyncDone) {
|
|
14
|
-
|
|
14
|
+
const eventFunction = exitProcessor.eventHandler('before', 'delete');
|
|
15
15
|
|
|
16
16
|
context.logger.info('delete', 'event start before');
|
|
17
17
|
eventFunction(context, function (err, context) {
|
|
@@ -24,7 +24,7 @@ function eventBefore(context, asyncDone) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function eventAfter(context, asyncDone) {
|
|
27
|
-
|
|
27
|
+
const eventFunction = exitProcessor.eventHandler('after', 'delete');
|
|
28
28
|
|
|
29
29
|
context.logger.info('delete', 'event start after');
|
|
30
30
|
eventFunction(context, function (err, context) {
|
|
@@ -37,7 +37,7 @@ function eventAfter(context, asyncDone) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function eventPrecommit(context, asyncDone) {
|
|
40
|
-
|
|
40
|
+
const eventFunction = exitProcessor.eventHandler('precommit', 'delete');
|
|
41
41
|
|
|
42
42
|
context.logger.info('delete', 'event start precommit');
|
|
43
43
|
eventFunction(context, function (err, context) {
|
|
@@ -50,7 +50,7 @@ function eventPrecommit(context, asyncDone) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function eventPostCommit(context, asyncDone) {
|
|
53
|
-
|
|
53
|
+
const eventFunction = exitProcessor.eventHandler('postcommit', 'delete');
|
|
54
54
|
|
|
55
55
|
context.logger.info('delete', 'event start postcommit');
|
|
56
56
|
eventFunction(context, function (err, context) {
|
|
@@ -63,9 +63,9 @@ function eventPostCommit(context, asyncDone) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function insertTmpTableToRealTable(context, asyncDone) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
67
|
+
const entityType = dbSeg.entityType;
|
|
68
|
+
const create = (entityType.modifications || {} ).update || {};
|
|
69
69
|
|
|
70
70
|
if (create.using) {
|
|
71
71
|
exitProcessor.executeExit(create.using, 'using', 'delete', context, asyncDone);
|
|
@@ -75,9 +75,9 @@ function insertTmpTableToRealTable(context, asyncDone) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function executeDelete(context, asyncDone) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
79
|
+
const entityType = dbSeg.entityType;
|
|
80
|
+
const _delete = (entityType.modifications || {} )['delete'] || {};
|
|
81
81
|
if (_delete.using) {
|
|
82
82
|
exitProcessor.executeExit(_delete.using, 'using', 'delete', context, asyncDone);
|
|
83
83
|
} else {
|
|
@@ -91,8 +91,8 @@ function setStatus(context, asyncDone) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
exports.process = function (context, asyncDone) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
let execArr;
|
|
95
|
+
const m2n = (context.oData.dbSegmentLast.getOver()!==undefined);
|
|
96
96
|
|
|
97
97
|
context.logger.silly('resourceProcessorDeleteLinks', 'process');
|
|
98
98
|
|
|
@@ -167,7 +167,7 @@ exports.process = function (context, asyncDone) {
|
|
|
167
167
|
execArr,
|
|
168
168
|
function (err, context) {
|
|
169
169
|
if (err) {
|
|
170
|
-
|
|
170
|
+
const dbClient = context.db.client;
|
|
171
171
|
if (dbClient) {
|
|
172
172
|
//ROLLBack the changes
|
|
173
173
|
return connect.dbRollback(context, dbClient, function (errDB) {
|
|
@@ -188,8 +188,8 @@ exports.process = function (context, asyncDone) {
|
|
|
188
188
|
exports.processInBatchCreateTables = function (context, asyncDone) {
|
|
189
189
|
context.logger.silly('resourceProcessorDeleteLinks', 'processInBatchCreateTables');
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
let execArr;
|
|
192
|
+
const m2n = (context.oData.dbSegmentLast.getOver()!==undefined);
|
|
193
193
|
if (m2n) { // INSERT into 3rd table
|
|
194
194
|
context.oData.dbSegmentLast.m2n = true;
|
|
195
195
|
execArr = [
|
|
@@ -221,8 +221,8 @@ exports.processInBatchCreateTables = function (context, asyncDone) {
|
|
|
221
221
|
exports.processInBatch = function (context, asyncDone) {
|
|
222
222
|
context.logger.silly('resourceProcessorDeleteLinks', 'processInBatch');
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
let execArr;
|
|
225
|
+
const m2n = (context.oData.dbSegmentLast.getOver()!==undefined);
|
|
226
226
|
if (m2n) { // INSERT into 3rd table
|
|
227
227
|
context.oData.dbSegmentLast.m2n = true;
|
|
228
228
|
execArr = [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const async = require('async');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const utils = require('./../utils/utils');
|
|
6
|
+
const dataCollectorGet = require('./../sql/dataCollectorGet');
|
|
7
|
+
const serializer = require('./../serializer/serializer');
|
|
8
|
+
const sqlGet = require('./../sql/createGetStatements');
|
|
9
9
|
|
|
10
10
|
exports.process = function (context, asyncDone) {
|
|
11
11
|
context.logger.silly('resourceprocessor', 'process_GET');
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const async = require('async');
|
|
4
|
+
const connect = require('../db/connect');
|
|
5
|
+
const utils = require('./../utils/utils');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const contentIdHelper = require('./contentIdHelper');
|
|
8
|
+
const contentTypeCheck = require('./../utils/checkContentType');
|
|
9
|
+
const dataCollectorPost = require('./../sql/dataCollectorPost');
|
|
10
|
+
const exitProcessor = require('./exitProcessor');
|
|
11
|
+
const serializer = require('./../serializer/serializer');
|
|
12
|
+
const sqlPost = require('./../sql/createPostStatements');
|
|
13
|
+
const typeConverter = require('./../utils/typeConverter');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const AtomXmlSerializer = require('./../serializer/atomXmlToJsonSerializer');
|
|
17
|
+
const BadRequestError = require('./../utils/errors/http/badRequest');
|
|
18
|
+
const InternalError = require('./../utils/errors/internalError');
|
|
19
|
+
const UnsupportedMediaType = require('./../utils/errors/http/unsupportedMediaType');
|
|
20
20
|
|
|
21
21
|
const model = require('../model/model.js');
|
|
22
22
|
|
|
23
23
|
function movePayloadToDbSegment_RecordNV(context, asyncDone) {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const req = context.request;
|
|
26
|
+
const contentType = req.headers['content-type'];
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
29
|
context.logger.silly('resourceProcessorPost', 'movePayloadToDbSegment');
|
|
30
30
|
|
|
31
31
|
if (contentType) {
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const isSupportedContentType =
|
|
34
34
|
contentTypeCheck.isSupportedContentType(contentType);
|
|
35
35
|
|
|
36
36
|
if (isSupportedContentType === false) {
|
|
@@ -55,15 +55,15 @@ function movePayloadToDbSegment_RecordNV(context, asyncDone) {
|
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const data = buffer.toString('utf-8');
|
|
61
61
|
|
|
62
62
|
if (contentTypeCheck.isContentTypeXml(contentType) === true && utils.isXml(data) === true) {
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
const typeModel = dbSeg.entityType.propertiesMap;
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const serializer = new AtomXmlSerializer(data, typeModel);
|
|
67
67
|
|
|
68
68
|
return serializer
|
|
69
69
|
.serialize(function (err, innerContext) {
|
|
@@ -73,17 +73,17 @@ function movePayloadToDbSegment_RecordNV(context, asyncDone) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (!Array.isArray(innerContext.result)) {
|
|
76
|
-
|
|
76
|
+
const err1 = new InternalError("Serialization result is not an array", context);
|
|
77
77
|
return asyncDone(err1, context);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const len = innerContext.result.length;
|
|
81
81
|
if (len !== 1) {
|
|
82
|
-
|
|
82
|
+
const err2 = new InternalError("Serialization result length must be 1 but is " + len, context);
|
|
83
83
|
return asyncDone(err2, context);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
const result = innerContext.result[0];
|
|
87
87
|
|
|
88
88
|
dbSeg.setRecordFromPostPayload(context, result);
|
|
89
89
|
|
|
@@ -94,7 +94,7 @@ function movePayloadToDbSegment_RecordNV(context, asyncDone) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (contentTypeCheck.isContentTypeJson(contentType) === true) {
|
|
97
|
-
|
|
97
|
+
let json;
|
|
98
98
|
|
|
99
99
|
try {
|
|
100
100
|
json = JSON.parse(data);
|
|
@@ -119,15 +119,12 @@ function movePayloadToDbSegment_RecordNV(context, asyncDone) {
|
|
|
119
119
|
} catch (err) {
|
|
120
120
|
return asyncDone(err, context);
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
return asyncDone(null, context);
|
|
124
122
|
}
|
|
125
|
-
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
|
|
129
126
|
function modifyDbSegment(context, asyncDone) {
|
|
130
|
-
|
|
127
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
131
128
|
//The dbSegments are build by URL so the last segment for a POST request is a collection.
|
|
132
129
|
//But the returned value from a POST request is the newly created entity, so the last dbsegments
|
|
133
130
|
//must be switched to by a collection to make the serialization work (the _KeyValues of the dbsegment are
|
|
@@ -138,9 +135,9 @@ function modifyDbSegment(context, asyncDone) {
|
|
|
138
135
|
|
|
139
136
|
|
|
140
137
|
function insertTmpTableToRealTable(context, asyncDone) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
139
|
+
const entityType = dbSeg.entityType;
|
|
140
|
+
const create = (entityType.modifications || {}).create || {};
|
|
144
141
|
if (create.using) {
|
|
145
142
|
exitProcessor.executeExit(create.using, 'using', 'create', context, asyncDone);
|
|
146
143
|
} else {
|
|
@@ -152,7 +149,7 @@ function insertTmpTableToRealTable(context, asyncDone) {
|
|
|
152
149
|
|
|
153
150
|
function eventBefore(context, asyncDone) {
|
|
154
151
|
context.logger.info('create', 'event start before');
|
|
155
|
-
|
|
152
|
+
const eventFunction = exitProcessor.eventHandler('before', 'create');
|
|
156
153
|
eventFunction(context, function (err, context) {
|
|
157
154
|
context.logger.info('create event end', 'before');
|
|
158
155
|
if (err) {
|
|
@@ -164,7 +161,7 @@ function eventBefore(context, asyncDone) {
|
|
|
164
161
|
|
|
165
162
|
function eventAfter(context, asyncDone) {
|
|
166
163
|
context.logger.info('create', 'event start after');
|
|
167
|
-
|
|
164
|
+
const eventFunction = exitProcessor.eventHandler('after', 'create');
|
|
168
165
|
eventFunction(context, function (err, context) {
|
|
169
166
|
context.logger.info('create event end', 'after');
|
|
170
167
|
if (err) {
|
|
@@ -176,7 +173,7 @@ function eventAfter(context, asyncDone) {
|
|
|
176
173
|
|
|
177
174
|
function eventPrecommit(context, asyncDone) {
|
|
178
175
|
context.logger.info('create', 'event start precommit');
|
|
179
|
-
|
|
176
|
+
const eventFunction = exitProcessor.eventHandler('precommit', 'create');
|
|
180
177
|
eventFunction(context, function (err, context) {
|
|
181
178
|
context.logger.info('create event end', 'precommit');
|
|
182
179
|
if (err) {
|
|
@@ -188,7 +185,7 @@ function eventPrecommit(context, asyncDone) {
|
|
|
188
185
|
|
|
189
186
|
function eventPostCommit(context, asyncDone) {
|
|
190
187
|
context.logger.info('create', 'event start postcommit');
|
|
191
|
-
|
|
188
|
+
const eventFunction = exitProcessor.eventHandler('postcommit', 'create');
|
|
192
189
|
eventFunction(context, function (err, context) {
|
|
193
190
|
context.logger.info('create event end', 'postcommit');
|
|
194
191
|
if (err) {
|
|
@@ -204,12 +201,13 @@ function setStatus(context, asyncDone) {
|
|
|
204
201
|
}
|
|
205
202
|
|
|
206
203
|
function writeLocationHeader(context, asyncDone) {
|
|
207
|
-
|
|
204
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
205
|
+
let row;
|
|
208
206
|
try {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
let location = dbSeg.entityType.name;
|
|
208
|
+
const keysProperties = dbSeg.getKeysProperties();
|
|
209
|
+
const rows = dbSeg.getRowsWithGenKey();
|
|
210
|
+
row = rows[0];
|
|
213
211
|
|
|
214
212
|
location += '(';
|
|
215
213
|
location += keysProperties.map(toValues).filter(v => v !== undefined).join(',');
|
|
@@ -226,9 +224,9 @@ function writeLocationHeader(context, asyncDone) {
|
|
|
226
224
|
}
|
|
227
225
|
|
|
228
226
|
function toValues(keyProperty, index, array) {
|
|
229
|
-
//old
|
|
227
|
+
//old const value = typeConv.serializeDbValueToUriLiteral(row[index.toString()]/*keys[index]*/, keyProperty);
|
|
230
228
|
|
|
231
|
-
|
|
229
|
+
let value;
|
|
232
230
|
if (dbSeg.entityType.kind === model.entityKind.inputParameters || dbSeg.entityType.kind === model.entityKind.calculationView) {
|
|
233
231
|
// for create, update, delete on a calcview, input parameters are optional and are NOT rendered in location url
|
|
234
232
|
//if (dbSeg.entityType._entityType.parameters && dbSeg.entityType._entityType.parameters.viaKey === true) {
|
|
@@ -291,7 +289,7 @@ exports.process = function (context, asyncDone) {
|
|
|
291
289
|
],
|
|
292
290
|
function (err, context) {
|
|
293
291
|
if (err) {
|
|
294
|
-
|
|
292
|
+
const dbClient = context.db.client;
|
|
295
293
|
if (dbClient) {
|
|
296
294
|
//ROLLBack the changes
|
|
297
295
|
return connect.dbRollback(context, dbClient, function (errDB) {
|