class CertificateController implements Constants {

    @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST)
    
    public ResponseEntity<Object> getCertificatesDetails(
            @RequestBody(required = true) Request request) {

        String assetGroup = request.getAg();
        if (Strings.isNullOrEmpty(assetGroup)) {
            return ResponseUtils.buildFailureResponse(new ServiceException(
                    ASSET_MANDATORY));
        }
        int from = request.getFrom();
        int size = request.getSize();
        String searchText = request.getSearchtext();
        Map<String, String> filter = request.getFilter();
        if (filter == null) {
            filter = new HashMap<>();
        }

        if (from < 0) {
            return ResponseUtils.buildFailureResponse(new ServiceException(
                    "From should not be a negative number"));
        }

        ResponseWithCount response;
        try {

            List<Map<String, Object>> masterDetailList = certificateService
                    .getCerticatesDetails(assetGroup, searchText, filter);
            if (masterDetailList.isEmpty()) {
                return ResponseUtils.buildSucessResponse(new ResponseWithCount(
                        new ArrayList<Map<String, Object>>(), 0));
            }

            if (from >= masterDetailList.size()) {
                return ResponseUtils.buildFailureResponse(new ServiceException(
                        "From exceeds the size of list"));
            }

            int endIndex = 0;

            if ((from + size) > masterDetailList.size()) {
                endIndex = masterDetailList.size();
            } else {
                endIndex = from + size;
            }
            if (endIndex == 0) {
                endIndex = masterDetailList.size();
            }
            List<Map<String, Object>> subDetailList = masterDetailList.subList(
                    from, endIndex);
            response = new ResponseWithCount(subDetailList,
                    masterDetailList.size());

        } catch (Exception e) {
            LOGGER.error(EXE_CERT_EXPIRY , e.getMessage());
            return ResponseUtils.buildFailureResponse(e);
        }
        return ResponseUtils.buildSucessResponse(response);
    }

}