Skip to content

Commit 8cfe96f

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

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.slf4j.LoggerFactory;
3333
import org.springframework.beans.factory.annotation.Autowired;
3434
import org.springframework.beans.factory.annotation.Value;
35+
import org.springframework.context.annotation.PropertySource;
3536
import org.springframework.http.HttpStatus;
3637
import org.springframework.http.MediaType;
3738
import org.springframework.http.RequestEntity;
@@ -52,7 +53,6 @@
5253
import java.util.Map.Entry;
5354

5455
import static com.ericsson.eiffel.remrem.generate.constants.RemremGenerateServiceConstants.*;
55-
5656
@RestController
5757
@RequestMapping("/*")
5858
@Api(value = "REMReM Generate Service", description = "REST API for generating Eiffel messages")
@@ -76,12 +76,8 @@ 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-
}
79+
@Value("${maxSizeOfInputArray:250}")
80+
private int maxSizeOfInputArray = 250;
8581

8682
public void setLenientValidationEnabledToUsers(boolean lenientValidationEnabledToUsers) {
8783
this.lenientValidationEnabledToUsers = lenientValidationEnabledToUsers;
@@ -167,12 +163,10 @@ public ResponseEntity<?> generate(final String msgProtocol, final String msgType
167163
if (inputData.isJsonArray()) {
168164
JsonArray inputEventJsonArray = inputData.getAsJsonArray();
169165

170-
if (inputEventJsonArray.size() > maxSize) {
166+
if (inputEventJsonArray.size() > maxSizeOfInputArray) {
171167
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.");
168+
"The number of events in the input array is to high: " + inputEventJsonArray.size() + " > " + maxSizeOfInputArray + ", " +
169+
"You can modify the property 'maxSizeOfInputArray' to increase it ");
176170
}
177171
for (JsonElement element : inputEventJsonArray) {
178172
JsonObject generatedEvent = (processEvent(msgProtocol, msgType,

service/src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ event-repository.url: http://<host>:<port>/<context-path-if-available>
3030
# lenientValidationEnabledToUsers true will perform the validation only on mandatory fields, non-mandatory validation failures add into Eiffel message as property remremGenerateFailures
3131
lenientValidationEnabledToUsers: false
3232

33-
#Maximum size of events in array is fetched from REMReM property and checked during publishing.
34-
maxEventsOfInputArray: 250
33+
#Maximum number of templates in array passed to generate endpoint
34+
maxSizeOfInputArray: 250

0 commit comments

Comments
 (0)