class VulnerabilityRepository implements Constants {

	public Map<String, Object> getVulnerabilityByQid(String qid) {

		StringBuilder urlToQuery = new StringBuilder(esUrl).append("/").append("qualys-kb/kb/_search");
		StringBuilder requestBody = new StringBuilder(
				"{\"query\":{\"bool\":{\"must\":[{\"term\":{\"latest\":\"true\"}},{\"term\":{\"qid.keyword\":\"");
		requestBody.append(qid);
		requestBody.append("\"}}]}}}");

		String responseJson = "";
		try {
			responseJson = PacHttpUtils.doHttpPost(urlToQuery.toString(), requestBody.toString());
		} catch (Exception e) {
			LOGGER.error("Error in getVulnerabilityByQid from ES", e);
		}
		JsonParser jsonParser = new JsonParser();
		Map<String, Object> vuln = new HashMap<>();
		if (StringUtils.isNotEmpty(responseJson)) {
			JsonObject resultJson = (JsonObject) jsonParser.parse(responseJson);
			JsonArray hits = resultJson.get("hits").getAsJsonObject().get("hits").getAsJsonArray();
			if (hits.size() > 0) {
				for (int i = 0; i < hits.size(); i++) {
					JsonObject obj = (JsonObject) hits.get(i);
					JsonObject sourceJson = (JsonObject) obj.get("_source");
					if (sourceJson != null) {
						vuln = new Gson().fromJson(sourceJson, new TypeToken<Map<String, Object>>() {
						}.getType());
						vuln.remove("latest");
						vuln.remove("_loadDate");
					}
				}
			}
		}
		return vuln;
	}

}