@@ -78,6 +78,9 @@ public class ProducerController {
78
78
@ Value ("${activedirectory.publish.enabled}" )
79
79
private boolean isAuthenticationEnabled ;
80
80
81
+ @ Value ("${maxSizeOfInputArray:250}" )
82
+ private int maxSizeOfInputArray ;
83
+
81
84
private RestTemplate restTemplate = new RestTemplate ();
82
85
83
86
private JsonParser parser = new JsonParser ();
@@ -153,6 +156,14 @@ public ResponseEntity send(final String msgProtocol, final String userDomain, fi
153
156
return new ResponseEntity (e .getMessage (), HttpStatus .NOT_FOUND );
154
157
}
155
158
}
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
+ }
156
167
synchronized (this ) {
157
168
SendResult result = messageService .send (body , msgService , userDomain , tag , routingKey );
158
169
log .info ("HTTP Status: {}" , messageService .getHttpStatus ().value ());
@@ -303,7 +314,14 @@ public ResponseEntity generateAndPublish(final String msgProtocol, final String
303
314
if (bodyJson .isJsonObject ()) {
304
315
events .add (getAsJsonObject (bodyJson ));
305
316
} else if (bodyJson .isJsonArray ()) {
306
- for (JsonElement element : bodyJson .getAsJsonArray ()) {
317
+ JsonArray bodyJsonArray = bodyJson .getAsJsonArray ();
318
+ //here add check for limitation for events in array is fetched from REMReM property and checked during publishing.
319
+ if (bodyJsonArray .size () > maxSizeOfInputArray ) {
320
+ return createResponseEntity (HttpStatus .BAD_REQUEST , JSON_ERROR_STATUS ,
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." );
323
+ }
324
+ for (JsonElement element : bodyJsonArray ) {
307
325
if (element .isJsonObject ()) {
308
326
events .add (getAsJsonObject (element ));
309
327
} else {
0 commit comments