@@ -120,6 +120,9 @@ public ResponseEntity<?> generate(
120
120
bodyJson = erLookup (bodyJson , failIfMultipleFound , failIfNoneFound , lookupInExternalERs , lookupLimit );
121
121
MsgService msgService = getMessageService (msgProtocol );
122
122
String response ;
123
+ if (bodyJson == null ) {
124
+ return new ResponseEntity <>(parser .parse (RemremGenerateServiceConstants .NO_ER ),HttpStatus .SERVICE_UNAVAILABLE );
125
+ }
123
126
if (msgService != null ) {
124
127
response = msgService .generateMsg (msgType , bodyJson , isLenientEnabled (okToLeaveOutInvalidOptionalFields ));
125
128
JsonElement parsedResponse = parser .parse (response );
@@ -174,18 +177,15 @@ private JsonObject erLookup(final JsonObject bodyJson, Boolean failIfMultipleFou
174
177
+ String .format ("&shallow=%s&pageSize=%d" , !lookupInExternalERs , lookupLimit );
175
178
176
179
// Execute ER Query
177
- int j = 0 ;
178
- while (j < 2 ) {
179
- try {
180
- response = restTemplate .getForEntity (url , String .class );
181
- if (response .getStatusCode () == HttpStatus .OK ) {
182
- log .info ("The result from Event Repository is: " + response .getStatusCodeValue ());
183
- break ;
184
- }
185
- } catch (Exception e ) {
186
- if (++j >= 2 )
187
- log .error ("unable to connect configured Event Repository URL" + e .getMessage ());
180
+ try {
181
+ response = restTemplate .getForEntity (url , String .class );
182
+ if (response .getStatusCode () == HttpStatus .OK ) {
183
+ log .info ("The result from Event Repository is: " + response .getStatusCodeValue ());
184
+ break ;
188
185
}
186
+ } catch (Exception e ) {
187
+ log .error ("unable to connect configured Event Repository URL" + e .getMessage ());
188
+ return null ;
189
189
}
190
190
String responseBody = response .getBody ();
191
191
ids = ERLookupController .getIdsfromResponseBody (responseBody );
0 commit comments