Skip to content

Commit 18c64c6

Browse files
Add limitation in the array of events for the publish endpoint generateAndPublish
1 parent bcabf45 commit 18c64c6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/controller/ProducerController.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ public ResponseEntity send(final String msgProtocol, final String userDomain, fi
156156
return new ResponseEntity(e.getMessage(), HttpStatus.NOT_FOUND);
157157
}
158158
}
159+
160+
//here add check for limitation for events in array is fetched from REMReM property and checked during publishing.
161+
if (body.isJsonArray() && (body.getAsJsonArray().size() > maxSizeOfInputArray)) {
162+
return createResponseEntity(HttpStatus.BAD_REQUEST, JSON_ERROR_STATUS,
163+
"The number of events in the input array is too high: " + body.getAsJsonArray().size() + " > "
164+
+ maxSizeOfInputArray + "; you can modify the property 'maxSizeOfInputArray' to increase it.");
165+
166+
}
159167
synchronized (this) {
160168
SendResult result = messageService.send(body, msgService, userDomain, tag, routingKey);
161169
log.info("HTTP Status: {}", messageService.getHttpStatus().value());
@@ -310,8 +318,8 @@ public ResponseEntity generateAndPublish(final String msgProtocol, final String
310318
//here add check for limitation for events in array is fetched from REMReM property and checked during publishing.
311319
if (bodyJsonArray.size() > maxSizeOfInputArray) {
312320
return createResponseEntity(HttpStatus.BAD_REQUEST, JSON_ERROR_STATUS,
313-
"The number of events in the input array is too high: " + bodyJsonArray.size() + " > " + maxSizeOfInputArray + ", " +
314-
"You can modify the property 'maxSizeOfInputArray' to increase it");
321+
"The number of events in the input array is too high: " + bodyJsonArray.size() + " > "
322+
+ maxSizeOfInputArray + "; you can modify the property 'maxSizeOfInputArray' to increase it.");
315323
}
316324
for (JsonElement element : bodyJsonArray) {
317325
if (element.isJsonObject()) {

0 commit comments

Comments
 (0)