10
10
import gov .cms .ab2d .api .security .MissingTokenException ;
11
11
import gov .cms .ab2d .common .service .InvalidClientInputException ;
12
12
import gov .cms .ab2d .common .service .InvalidContractException ;
13
+ import gov .cms .ab2d .api .util .UtilMethods ;
14
+ import gov .cms .ab2d .eventclient .clients .SQSEventClient ;
13
15
import gov .cms .ab2d .eventclient .config .Ab2dEnvironment ;
14
16
import gov .cms .ab2d .eventclient .events .ApiResponseEvent ;
15
17
import gov .cms .ab2d .eventclient .events .ErrorEvent ;
18
+ import gov .cms .ab2d .fhir .FhirVersion ;
16
19
import gov .cms .ab2d .job .service .InvalidJobAccessException ;
17
20
import gov .cms .ab2d .job .service .InvalidJobStateTransition ;
18
- import gov .cms .ab2d .properties .service .InvalidPropertiesException ;
19
21
import gov .cms .ab2d .job .service .JobOutputMissingException ;
22
+ import gov .cms .ab2d .properties .service .InvalidPropertiesException ;
20
23
import gov .cms .ab2d .properties .service .ResourceNotFoundException ;
21
- import gov .cms .ab2d .eventlogger .LogManager ;
22
- import gov .cms .ab2d .eventlogger .utils .UtilMethods ;
23
- import gov .cms .ab2d .fhir .FhirVersion ;
24
24
import java .io .IOException ;
25
25
import java .net .URISyntaxException ;
26
26
import java .util .HashMap ;
60
60
@ Slf4j
61
61
public class ErrorHandler extends ResponseEntityExceptionHandler {
62
62
63
- private final LogManager eventLogger ;
63
+ private final SQSEventClient eventLogger ;
64
64
private final int retryAfterDelay ;
65
65
private final ApiCommon apiCommon ;
66
66
@@ -88,7 +88,7 @@ public class ErrorHandler extends ResponseEntityExceptionHandler {
88
88
RESPONSE_MAP .put (DataIntegrityViolationException .class , HttpStatus .INTERNAL_SERVER_ERROR );
89
89
}
90
90
91
- public ErrorHandler (LogManager eventLogger , @ Value ("${api.retry-after.delay}" ) int retryAfterDelay , ApiCommon apiCommon ) {
91
+ public ErrorHandler (SQSEventClient eventLogger , @ Value ("${api.retry-after.delay}" ) int retryAfterDelay , ApiCommon apiCommon ) {
92
92
this .eventLogger = eventLogger ;
93
93
this .retryAfterDelay = retryAfterDelay ;
94
94
this .apiCommon = apiCommon ;
@@ -121,7 +121,7 @@ public ResponseEntity<JsonNode> assertionException(final Exception e, HttpServle
121
121
122
122
@ ExceptionHandler ({JobOutputMissingException .class })
123
123
public ResponseEntity <JsonNode > handleJobOutputMissing (Exception e , HttpServletRequest request ) throws IOException {
124
- eventLogger .log (new ErrorEvent (MDC .get (ORGANIZATION ), UtilMethods .parseJobId (request .getRequestURI ()),
124
+ eventLogger .sendLogs (new ErrorEvent (MDC .get (ORGANIZATION ), UtilMethods .parseJobId (request .getRequestURI ()),
125
125
ErrorEvent .ErrorType .FILE_ALREADY_DELETED , getRootCause (e )));
126
126
return generateFHIRError (e , request );
127
127
}
@@ -131,7 +131,7 @@ public ResponseEntity<Void> handleInvalidContractErrors(Exception ex, HttpServle
131
131
HttpStatus status = getErrorResponse (ex .getClass ());
132
132
String description = API_INVALID_CONTRACT + " " + getRootCause (ex );
133
133
134
- eventLogger .log (new ErrorEvent (MDC .get (ORGANIZATION ), null ,
134
+ eventLogger .sendLogs (new ErrorEvent (MDC .get (ORGANIZATION ), null ,
135
135
ErrorEvent .ErrorType .UNAUTHORIZED_CONTRACT , description ));
136
136
137
137
ApiResponseEvent responseEvent = new ApiResponseEvent (MDC .get (ORGANIZATION ), null , status ,
@@ -161,7 +161,7 @@ public ResponseEntity<Void> handleAuthorizationErrors(Exception ex, HttpServletR
161
161
// Then log to other destinations
162
162
ApiResponseEvent responseEvent = new ApiResponseEvent (MDC .get (ORGANIZATION ), null , status ,
163
163
"API Error" , description , (String ) request .getAttribute (REQUEST_ID ));
164
- eventLogger .log (responseEvent );
164
+ eventLogger .sendLogs (responseEvent );
165
165
166
166
return new ResponseEntity <>(null , null , status );
167
167
}
@@ -174,7 +174,7 @@ public ResponseEntity<Void> handleMaintenanceMode(Exception ex, HttpServletReque
174
174
log .warn ("Maintenance mode blocked API request " + request .getAttribute (REQUEST_ID ));
175
175
176
176
// Then log to other destinations
177
- eventLogger .log (new ApiResponseEvent (MDC .get (ORGANIZATION ), null , status ,
177
+ eventLogger .sendLogs (new ApiResponseEvent (MDC .get (ORGANIZATION ), null , status ,
178
178
"API Error" , ex .getClass ().getSimpleName (), (String ) request .getAttribute (REQUEST_ID )));
179
179
eventLogger .trace ("API_MAINT_BLOCKED Maintenance mode blocked API request " + request .getAttribute (REQUEST_ID ), Ab2dEnvironment .PROD_LIST );
180
180
@@ -188,7 +188,7 @@ public ResponseEntity<JsonNode> handleTooManyRequestsExceptions(final TooManyReq
188
188
if (e .getJobIds () != null ) {
189
189
generateContentLocation (e , request , httpHeaders );
190
190
}
191
- eventLogger .log (new ErrorEvent (MDC .get (ORGANIZATION ), UtilMethods .parseJobId (request .getRequestURI ()),
191
+ eventLogger .sendLogs (new ErrorEvent (MDC .get (ORGANIZATION ), UtilMethods .parseJobId (request .getRequestURI ()),
192
192
ErrorEvent .ErrorType .TOO_MANY_STATUS_REQUESTS , "Too many requests performed in too short a time" ));
193
193
return generateFHIRError (e , httpHeaders , request );
194
194
}
@@ -224,7 +224,7 @@ private ResponseEntity<JsonNode> generateFHIRError(Exception e, HttpHeaders http
224
224
// Log so that Splunk can pick this up and alert
225
225
log .warn ("{} {}" , ExceptionUtils .getRootCause (e ).getClass (), msg );
226
226
227
- eventLogger .log (new ApiResponseEvent (MDC .get (ORGANIZATION ), null ,
227
+ eventLogger .sendLogs (new ApiResponseEvent (MDC .get (ORGANIZATION ), null ,
228
228
ErrorHandler .getErrorResponse (e .getClass ()),
229
229
"FHIR Error" , msg , (String ) request .getAttribute (REQUEST_ID )));
230
230
0 commit comments