Skip to content

Instantly share code, notes, and snippets.

@philmadden83
Created September 1, 2016 20:23
Show Gist options
  • Save philmadden83/b913dc4ee9253e1464d8bbac7fde758b to your computer and use it in GitHub Desktop.
Save philmadden83/b913dc4ee9253e1464d8bbac7fde758b to your computer and use it in GitHub Desktop.
@Service
public class ThreatDetectService {
private final ThreatService threatService
..constructor / injection
public void recordLoginEvent(String email, ... , Environment environment) {
recordEvent(new LoginEvent(email, ..., environment));
}
public void recordXXXEvent(String xxx, ... , Environment environment) {
recordEvent(new XXXEvent(xxx, ..., environment));
}
private static void recordEvent(Event e) {
try {
RecordResponse response = threatService.recordEvent(e);
if (!response.isSuccess() {
LOGGER.warn(String.format("Error recording ThreatService %s. Response: %s Message: %s.", event.getClass().getSimpleName(), response.getRequestId() , response.getMessage()));
}
} catch (ThreatRecordException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment