class AssetDetailController {

    @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/installed-softwares", method = RequestMethod.GET)
    public ResponseEntity<Object> getInstalledSoftwareDetailsByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId,
            @RequestParam(name = "from", required = false) Integer from,
            @RequestParam(name = "size", required = false) Integer size,
            @RequestParam(name = "searchtext", required = false) String searchText) {
    	if (!qualysEnabled) {
            return ResponseUtils.buildFailureResponse(new Exception(AssetConstants.ERROR_QUALYS_NOT_ENABLED));
    	}
        List<Map<String, Object>> subDetailList ;
        if (Strings.isNullOrEmpty(instanceId)) {
            return ResponseUtils.buildFailureResponse(new Exception("Instance Id is Mandatory"));
        }
        ResponseWithCount response;
        try {
            List<Map<String, Object>> softWareList = assetService.getInstanceSoftwareInstallDetails(instanceId, from,
                    size, searchText);

            if (softWareList.isEmpty()) {
                throw new NoDataFoundException(" No data found");
            }

            if (from != null && size != null) {

                if (from >= softWareList.size()) {
                    throw new DataException(AssetConstants.ERROR_FROM_EXCEEDS);
                }

                int endIndex = 0;

                if ((from + size) > softWareList.size()) {
                    endIndex = softWareList.size();
                } else {
                    endIndex = from + size;
                }

                if (from == 0 && size == 0) {
                    subDetailList = softWareList;
                } else {
                    subDetailList = softWareList.subList(from, endIndex);
                }
            } else {
                subDetailList = softWareList;
            }
            response = new ResponseWithCount(subDetailList, softWareList.size());
        } catch (Exception e) {
            return ResponseUtils.buildFailureResponse(e);
        }
        return ResponseUtils.buildSucessResponse(response);
    }

}