class VulnerabilityController implements Constants {

	@PostMapping(value = "/v1/vulnerabilities/trend")
	public ResponseEntity<Object> getVulnerabilitiesTrend(@RequestBody(required = true) TrendRequest request) {

		Map<String, Object> response = new HashMap<>();
		String assetGroup = request.getAg();
		if (Strings.isNullOrEmpty(assetGroup)) {
			return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY));
		}
		Date from = request.getFrom();
		Date to = request.getTo();
		Map<String, String> filter = request.getFilter();
		try {
			if (from == null && to == null) {
				Calendar cal = Calendar.getInstance();
				cal.setTimeZone(TimeZone.getTimeZone("UTC"));
				to = cal.getTime();
				cal.add(Calendar.DATE, NEG_THIRTY);
				from = cal.getTime();
			}
			response.put("ag", assetGroup);
			List<Map<String, Object>> trendList = vulnerabilityService.getVulnerabilityTrend(assetGroup, filter, from,
					to);
			response.put("trend", trendList);
		} catch (Exception e) {
			LOGGER.error(EXE_VULN, e);
			return ResponseUtils.buildFailureResponse(e);
		}
		return ResponseUtils.buildSucessResponse(response);
	}

}