diff --git a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java index 5a1794a..bc66ae9 100644 --- a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java +++ b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java @@ -76,6 +76,13 @@ public class RemremGenerateController { @Value("${lenientValidationEnabledToUsers:false}") private boolean lenientValidationEnabledToUsers; + @Value("${maxEventsOfInputArray:250}") + private int maxSize; + + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + public void setLenientValidationEnabledToUsers(boolean lenientValidationEnabledToUsers) { this.lenientValidationEnabledToUsers = lenientValidationEnabledToUsers; } @@ -159,6 +166,14 @@ public ResponseEntity generate(final String msgProtocol, final String msgType if (inputData.isJsonArray()) { JsonArray inputEventJsonArray = inputData.getAsJsonArray(); + + if (inputEventJsonArray.size() > maxSize) { + return createResponseEntity(HttpStatus.BAD_REQUEST, JSON_ERROR_STATUS, + "The number of events in the input array is exceeded the allowed limit of 250 events. " + + "This issue occurred because the input array contains more than 250 events, which is not supported by the system. " + + "To resolve this, please divide the events in to smaller arrays, ensuring each array contains no more than 250 events," + + "and try to generate them again. This limitation helps to maintain system performance and stability."); + } for (JsonElement element : inputEventJsonArray) { JsonObject generatedEvent = (processEvent(msgProtocol, msgType, failIfMultipleFound, failIfNoneFound, lookupInExternalERs, lookupLimit, diff --git a/service/src/main/resources/application.properties b/service/src/main/resources/application.properties index 157ee16..c7553ec 100644 --- a/service/src/main/resources/application.properties +++ b/service/src/main/resources/application.properties @@ -28,4 +28,7 @@ event-repository.enabled: false event-repository.url: http://:/ # lenientValidationEnabledToUsers true will perform the validation only on mandatory fields, non-mandatory validation failures add into Eiffel message as property remremGenerateFailures -lenientValidationEnabledToUsers: false \ No newline at end of file +lenientValidationEnabledToUsers: false + +#Maximum size of events in array is fetched from REMReM property and checked during publishing. +maxEventsOfInputArray: 250 \ No newline at end of file