class LegacyDetectorRepositoryImpl implements LegacyDetectorRepository {

    @Override
    public void toggleDetector(String uuid, Boolean enabled) {
        MDC.put("DetectorUuid", uuid);
        val updateRequest = new UpdateRequest(DETECTOR_INDEX, DETECTOR_DOC_TYPE, uuid);
        Date nowDate = DateUtil.now();
        String nowValue = DateUtil.toDateString(nowDate.toInstant());

        Map<String, Object> jsonMap = new HashMap<>();
        Map<String, Object> metaMap = new HashMap<>();
        metaMap.put("dateUpdated", nowDate);
        jsonMap.put("lastUpdateTimestamp", nowValue);
        jsonMap.put("enabled", enabled);
        jsonMap.put("meta", metaMap);
        updateRequest.doc(jsonMap);
        try {
            val updateResponse = legacyElasticSearchClient.update(updateRequest, RequestOptions.DEFAULT);
            if (elasticsearchUtil.checkNullResponse(updateResponse.getResult())) {
                throw new RecordNotFoundException("Invalid request: " + uuid);
            }
        } catch (IOException e) {
            log.error("Updating elastic search failed", e);
            throw new RuntimeException(e);
        } finally {
            MDC.remove("DetectorUuid");
        }
    }

}