Skip to content

Commit

Permalink
Add limitation in the array of events for the endpoint of generate
Browse files Browse the repository at this point in the history
  • Loading branch information
shudhansu-shekhar committed Sep 17, 2024
1 parent a870ce4 commit 7b6619b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ event-repository.enabled: false
event-repository.url: http://<host>:<port>/<context-path-if-available>

# lenientValidationEnabledToUsers true will perform the validation only on mandatory fields, non-mandatory validation failures add into Eiffel message as property remremGenerateFailures
lenientValidationEnabledToUsers: false
lenientValidationEnabledToUsers: false

#Maximum size of events in array is fetched from REMReM property and checked during publishing.
maxEventsOfInputArray: 250

0 comments on commit 7b6619b

Please sign in to comment.