class ExceptionManagerImpl implements ExceptionManager {

    @Override
    public Map<String, List<IssueException>> getStickyExceptions(String ruleId, String resourceType) throws Exception {
        Map<String, Object> mustFilter = new HashMap<>();
        mustFilter.put(RULE_ID_ATTRIBUTE_NAME, ruleId);
        mustFilter.put(RESOURCE_TYPE_ATTRIBUTE_NAME, resourceType);
        Map<String, Object> rangeMap = new HashMap<String, Object>();
        rangeMap.put("gte", "now");
        Map<String, Object> dateRangeMap = new HashMap<String, Object>();
        dateRangeMap.put("expiryDate", rangeMap);
        mustFilter.put("range", dateRangeMap);
        List<Map<String, String>> exceptions = ESUtils.getDataFromES(ESUtils.getEsUrl(), INDEX_FOR_EXCEPTIONS,
                TYPE_FOR_STICKY_EXCEPTIONS, mustFilter, null, null, null, 0, 20);
        List<IssueException> stickyExceptions = exceptions.stream()
                .map(obj -> new IssueException(obj, ExceptionType.STICKY)).collect(Collectors.toList());
        // clear the must filter
        mustFilter.clear();
        // get only latest resources
        mustFilter.put("latest", true);
        Map<IssueException, List<String>> exemptedResources = new HashMap<>();
        Map<String, List<IssueException>> exceptionResourceSetMap = new HashMap<>();
        stickyExceptions.forEach(obj -> {
            try {
                exemptedResources.put(obj,
                        ESUtils.getDataFromES(ESUtils.getEsUrl(), obj.getAssetGroup(), resourceType, mustFilter, null,
                                null, null, 0, 20).stream().map(resource -> resource.get(RESOURCE_ID))
                                .collect(Collectors.toList()));
            } catch (Exception e) {
            }
        });
        exemptedResources.entrySet().forEach(entry -> {
            entry.getValue().forEach(resourceid -> {
                List<IssueException> exceptionsList = exceptionResourceSetMap.get(resourceid);
                if (exceptionsList == null) {
                    exceptionsList = new ArrayList<>();
                    exceptionResourceSetMap.put(resourceid, exceptionsList);
                }
                exceptionsList.add(entry.getKey());
            });
        });
        return exceptionResourceSetMap;
    }

}