class VulnerabilityRepository implements Constants {

	public Map<String, Object> getVulnerabilitysummaryByResourceId(String resourceId) {
		
		Map<String, Object> vulnSummary = new HashMap<>();
		StringBuilder urlToQuery = new StringBuilder(esUrl);
		urlToQuery.append("/*");// any index
		urlToQuery.append("/").append(VULN_INFO);
		urlToQuery.append("/").append(SEARCH);
		StringBuilder requestBody = new StringBuilder(
				"{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":true}},{\"match\":{\"_resourceid.keyword\":\"");
		requestBody.append(resourceId);
		requestBody.append(
				"\"}},{\"terms\": {\"severitylevel.keyword\": [3,4,5]}}]}},\"aggs\":{\"NAME\":{\"filters\":{\"filters\":{\"S3\":{\"term\":{\"severitylevel.keyword\":\"3\"}},\"S4\":{\"term\":{\"severitylevel.keyword\":\"4\"}},\"S5\":{\"term\":{\"severitylevel.keyword\":\"5\"}}}}}}}");

		String responseJson = "";
		try {
			responseJson = PacHttpUtils.doHttpPost(urlToQuery.toString(), requestBody.toString());
		} catch (Exception e) {
			LOGGER.error("Error in getVulnerabilitysummaryByResourceId from ES", e);
		}
		JsonParser jsonParser = new JsonParser();
		if (StringUtils.isNotEmpty(responseJson)) {
			JsonObject resultJson = (JsonObject) jsonParser.parse(responseJson);
			JsonObject hitsJson = (JsonObject) jsonParser.parse(resultJson.get("hits").toString());
			vulnSummary.put(TOTAL, hitsJson.get(TOTAL).getAsLong());
			JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString());
			try {
				vulnSummary.put(SEVERITY_INFO,
						getSeverityInfo(aggsJson.getAsJsonObject("NAME").getAsJsonObject(BUCKETS), null));
			} catch (Exception e) {
				LOGGER.error("Error in getVulnerabilitysummaryByResourceId ", e);
			}
		}
		return vulnSummary;

	}

}