Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

package gov.va.med.ars.controller;

import javax.validation.Valid;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gov.va.med.ars.exceptions.GenericException;
import gov.va.med.ars.model.request.SearchReportRequest;
import gov.va.med.ars.model.response.GenericResponse;
import gov.va.med.ars.service.IReportService;
import net.minidev.json.JSONObject;

@RestController
@RequestMapping("api/v1/reports")
public class ReportController {

private static final Logger logger = LogManager.getLogger(ReportController.class);

@Autowired
IReportService reportService;

@PostMapping(value = "/search")
public ResponseEntity<?> searchReports(@Valid @RequestBody SearchReportRequest searchReportRequest)
throws GenericException {
JSONObject response = null;
try {
if (searchReportRequest != null) {

GenericResponse searchResponse = reportService.getReports(searchReportRequest);
return new ResponseEntity<>(searchResponse, HttpStatus.OK);

} else {
response = new JSONObject();
response.put("errorCode", "Invalid Request");
response.put("message", "Please enter in a valid Data.");
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}

} catch (Exception e) {
logger.error("ReportController.searchReports() exception occured " + e.getMessage());
throw e;
}
}
}