Skip to content

Commit 7b6619b

Browse files
Add limitation in the array of events for the endpoint of generate
1 parent a870ce4 commit 7b6619b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public class RemremGenerateController {
7676
@Value("${lenientValidationEnabledToUsers:false}")
7777
private boolean lenientValidationEnabledToUsers;
7878

79+
@Value("${maxEventsOfInputArray:250}")
80+
private int maxSize;
81+
82+
public void setMaxSize(int maxSize) {
83+
this.maxSize = maxSize;
84+
}
85+
7986
public void setLenientValidationEnabledToUsers(boolean lenientValidationEnabledToUsers) {
8087
this.lenientValidationEnabledToUsers = lenientValidationEnabledToUsers;
8188
}
@@ -159,6 +166,14 @@ public ResponseEntity<?> generate(final String msgProtocol, final String msgType
159166

160167
if (inputData.isJsonArray()) {
161168
JsonArray inputEventJsonArray = inputData.getAsJsonArray();
169+
170+
if (inputEventJsonArray.size() > maxSize) {
171+
return createResponseEntity(HttpStatus.BAD_REQUEST, JSON_ERROR_STATUS,
172+
"The number of events in the input array is exceeded the allowed limit of 250 events. " +
173+
"This issue occurred because the input array contains more than 250 events, which is not supported by the system. "
174+
+ "To resolve this, please divide the events in to smaller arrays, ensuring each array contains no more than 250 events,"
175+
+ "and try to generate them again. This limitation helps to maintain system performance and stability.");
176+
}
162177
for (JsonElement element : inputEventJsonArray) {
163178
JsonObject generatedEvent = (processEvent(msgProtocol, msgType,
164179
failIfMultipleFound, failIfNoneFound, lookupInExternalERs, lookupLimit,

service/src/main/resources/application.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ event-repository.enabled: false
2828
event-repository.url: http://<host>:<port>/<context-path-if-available>
2929

3030
# lenientValidationEnabledToUsers true will perform the validation only on mandatory fields, non-mandatory validation failures add into Eiffel message as property remremGenerateFailures
31-
lenientValidationEnabledToUsers: false
31+
lenientValidationEnabledToUsers: false
32+
33+
#Maximum size of events in array is fetched from REMReM property and checked during publishing.
34+
maxEventsOfInputArray: 250

0 commit comments

Comments
 (0)