From 34e44995ca7f980565d3945d52c6df0d8a6f0701 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:16:11 -0400 Subject: [PATCH] v3_issue_909: Finished refactoring request methods --- ...estfulAttestationCertificateAuthority.java | 11 ++-- .../CertificatePageController.java | 24 ++++----- .../controllers/PolicyPageController.java | 43 +++++++++------- .../ReferenceManifestPageController.java | 51 +++++++++---------- .../RimDatabasePageController.java | 15 +++--- .../ValidationReportsPageController.java | 9 ++-- 6 files changed, 78 insertions(+), 75 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/RestfulAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/RestfulAttestationCertificateAuthority.java index db00267d..289b998e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/RestfulAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/RestfulAttestationCertificateAuthority.java @@ -16,9 +16,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySources; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +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.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -95,8 +96,7 @@ public class RestfulAttestationCertificateAuthority extends AttestationCertifica */ @Override @ResponseBody - @RequestMapping(value = "/identity-claim-tpm2/process", - method = RequestMethod.POST, + @PostMapping(value = "/identity-claim-tpm2/process", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE) public byte[] processIdentityClaimTpm2(@RequestBody final byte[] identityClaim) { return super.processIdentityClaimTpm2(identityClaim); @@ -113,8 +113,7 @@ public class RestfulAttestationCertificateAuthority extends AttestationCertifica */ @Override @ResponseBody - @RequestMapping(value = "/request-certificate-tpm2", - method = RequestMethod.POST, + @PostMapping(value = "/request-certificate-tpm2", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE) public byte[] processCertificateRequest(@RequestBody final byte[] certificateRequest) { return super.processCertificateRequest(certificateRequest); @@ -129,7 +128,7 @@ public class RestfulAttestationCertificateAuthority extends AttestationCertifica */ @Override @ResponseBody - @RequestMapping(value = "/public-key", method = RequestMethod.GET) + @GetMapping("/public-key") public byte[] getPublicKey() { return super.getPublicKey(); } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java index 4639e411..92825536 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java @@ -43,9 +43,10 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; @@ -244,9 +245,8 @@ public class CertificatePageController extends PageController<NoPageParams> { * @return the data table */ @ResponseBody - @RequestMapping(value = "/{certificateType}/list", - produces = MediaType.APPLICATION_JSON_VALUE, - method = RequestMethod.GET) + @GetMapping(value = "/{certificateType}/list", + produces = MediaType.APPLICATION_JSON_VALUE) public DataTableResponse<? extends Certificate> getTableData( @PathVariable("certificateType") final String certificateType, final DataTableInput input) { @@ -402,7 +402,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * @return the redirection view * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "/{certificateType}/upload", method = RequestMethod.POST) + @PostMapping("/{certificateType}/upload") protected RedirectView upload( @PathVariable("certificateType") final String certificateType, @RequestParam("file") final MultipartFile[] files, @@ -440,7 +440,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * @return redirect to this page * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "/{certificateType}/delete", method = RequestMethod.POST) + @PostMapping("/{certificateType}/delete") public RedirectView delete( @PathVariable("certificateType") final String certificateType, @RequestParam final String id, @@ -510,7 +510,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * file name) * @throws IOException when writing to response output stream */ - @RequestMapping(value = "/{certificateType}/download", method = RequestMethod.GET) + @GetMapping("/{certificateType}/download") public void download( @PathVariable("certificateType") final String certificateType, @RequestParam final String id, @@ -557,7 +557,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * @throws IOException when writing to response output stream */ @ResponseBody - @RequestMapping(value = "/trust-chain/download-aca-cert", method = RequestMethod.GET) + @GetMapping("/trust-chain/download-aca-cert") public void downloadAcaCertificate(final HttpServletResponse response) throws IOException { @@ -577,7 +577,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * file name) * @throws IOException when writing to response output stream */ - @RequestMapping(value = "/trust-chain/bulk", method = RequestMethod.GET) + @GetMapping("/trust-chain/bulk") public void caBulkDownload(final HttpServletResponse response) throws IOException { log.info("Handling request to download all trust chain certificates"); @@ -609,7 +609,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * file name) * @throws IOException when writing to response output stream */ - @RequestMapping(value = "/platform-credentials/bulk", method = RequestMethod.GET) + @GetMapping("/platform-credentials/bulk") public void pcBulkDownload(final HttpServletResponse response) throws IOException { log.info("Handling request to download all platform certificates"); @@ -641,7 +641,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * file name) * @throws IOException when writing to response output stream */ - @RequestMapping(value = "/issued-certificates/bulk", method = RequestMethod.GET) + @GetMapping("/issued-certificates/bulk") public void icBulkDownload(final HttpServletResponse response) throws IOException { log.info("Handling request to download all issued certificates"); @@ -674,7 +674,7 @@ public class CertificatePageController extends PageController<NoPageParams> { * file name) * @throws IOException when writing to response output stream */ - @RequestMapping(value = "/endorsement-key-credentials/bulk", method = RequestMethod.GET) + @GetMapping("/endorsement-key-credentials/bulk") public void ekBulkDownload(final HttpServletResponse response) throws IOException { log.info("Handling request to download all endorsement certificates"); diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java index ecd94bc8..a304a687 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java @@ -13,8 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.view.RedirectView; @@ -118,7 +118,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-pc-validation", method = RequestMethod.POST) + @PostMapping("update-pc-validation") public RedirectView updatePcVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -169,7 +169,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-pc-attribute-validation", method = RequestMethod.POST) + @PostMapping("update-pc-attribute-validation") public RedirectView updatePcAttributeVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -219,7 +219,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-revision-ignore", method = RequestMethod.POST) + @PostMapping("update-revision-ignore") public RedirectView updateIgnoreRevisionAttribute(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -270,7 +270,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-issue-attestation", method = RequestMethod.POST) + @PostMapping("update-issue-attestation") public RedirectView updateAttestationVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -314,7 +314,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-issue-devid", method = RequestMethod.POST) + @PostMapping("update-issue-devid") public RedirectView updateDevIdVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -359,7 +359,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-expire-on", method = RequestMethod.POST) + @PostMapping("update-expire-on") public RedirectView updateExpireOnVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -429,7 +429,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-devid-expire-on", method = RequestMethod.POST) + @PostMapping("update-devid-expire-on") public RedirectView updateDevIdExpireOnVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -499,7 +499,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-threshold", method = RequestMethod.POST) + @PostMapping("update-threshold") public RedirectView updateThresholdVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -570,7 +570,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-devid-threshold", method = RequestMethod.POST) + @PostMapping("update-devid-threshold") public RedirectView updateDevIdThresholdVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -640,7 +640,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-ec-validation", method = RequestMethod.POST) + @PostMapping("update-ec-validation") public RedirectView updateEcVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -692,7 +692,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-firmware-validation", method = RequestMethod.POST) + @PostMapping("update-firmware-validation") public RedirectView updateFirmwareVal(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { @@ -749,7 +749,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-ima-ignore", method = RequestMethod.POST) + @PostMapping("update-ima-ignore") public RedirectView updateIgnoreIma(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { // set the data received to be populated back into the form @@ -800,7 +800,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-tboot-ignore", method = RequestMethod.POST) + @PostMapping("update-tboot-ignore") public RedirectView updateIgnoreTboot(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { // set the data received to be populated back into the form @@ -851,7 +851,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-gpt-ignore", method = RequestMethod.POST) + @PostMapping("update-gpt-ignore") public RedirectView updateIgnoreGptEvents(@ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) throws URISyntaxException { // set the data received to be populated back into the form @@ -902,7 +902,7 @@ public class PolicyPageController extends PageController<NoPageParams> { * @return View containing the url and parameters * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "update-os-evt-ignore", method = RequestMethod.POST) + @PostMapping("update-os-evt-ignore") public RedirectView updateIgnoreOsEvents( @ModelAttribute final PolicyPageModel ppModel, final RedirectAttributes attr) @@ -995,6 +995,15 @@ public class PolicyPageController extends PageController<NoPageParams> { return policy; } + /** + * Helper method that saves the provided policy to the database and displays a success message. + * + * @param ppModel policy page model + * @param model model + * @param messages page messages + * @param successMessage success message + * @param settings policy settings + */ private void savePolicyAndApplySuccessMessage( final PolicyPageModel ppModel, final Map<String, Object> model, final PageMessages messages, final String successMessage, @@ -1004,7 +1013,7 @@ public class PolicyPageController extends PageController<NoPageParams> { // Log and set the success message messages.addSuccess(successMessage); - log.debug("ACA Policy set to: " + ppModel.toString()); + log.debug("ACA Policy set to: {}", ppModel.toString()); model.put(MESSAGES_ATTRIBUTE, messages); } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index fc84e213..5c96cec3 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -29,8 +29,9 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; @@ -107,16 +108,15 @@ public class ReferenceManifestPageController extends PageController<NoPageParams * information */ @ResponseBody - @RequestMapping(value = "/list", - produces = MediaType.APPLICATION_JSON_VALUE, - method = RequestMethod.GET) + @GetMapping(value = "/list", + produces = MediaType.APPLICATION_JSON_VALUE) public DataTableResponse<ReferenceManifest> getTableData( @Valid final DataTableInput input) { - log.debug("Handling request for summary list: " + input); + log.debug("Handling request for summary list: {}", input); String orderColumnName = input.getOrderColumnName(); - log.info("Ordering on column: " + orderColumnName); - log.info("Querying with the following dataTableInput: " + input); + log.info("Ordering on column: {}", orderColumnName); + log.info("Querying with the following dataTableInput: {}", input); FilteredRecordsList<ReferenceManifest> records = new FilteredRecordsList<>(); int currentPage = input.getStart() / input.getLength(); @@ -137,7 +137,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams records.setRecordsFiltered(referenceManifestRepository.findByArchiveFlag(false).size()); - log.debug("Returning list of size: " + records.size()); + log.debug("Returning list of size: {}", records.size()); return new DataTableResponse<>(records, input); } @@ -150,7 +150,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams * @throws URISyntaxException if malformed URI * @throws Exception if malformed URI */ - @RequestMapping(value = "/upload", method = RequestMethod.POST) + @PostMapping("/upload") protected RedirectView upload( @RequestParam("file") final MultipartFile[] files, final RedirectAttributes attr) throws URISyntaxException, Exception { @@ -162,7 +162,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams Matcher matcher; List<BaseReferenceManifest> baseRims = new ArrayList<>(); List<SupportReferenceManifest> supportRims = new ArrayList<>(); - log.info(String.format("Processing %s uploaded files", files.length)); + log.info("Processing {} uploaded files", files.length); // loop through the files for (MultipartFile file : files) { @@ -182,16 +182,16 @@ public class ReferenceManifestPageController extends PageController<NoPageParams + " Base RIMs support the extension \".swidtag\", and support RIMs support " + "\".rimpcr\", \".rimel\", \".bin\", and \".log\". " + "Please verify your upload and retry."; - log.error("File extension in " + fileName + " not recognized as base or support RIM."); + log.error("File extension in {} not recognized as base or support RIM.", fileName); messages.addError(errorString); } } baseRims.forEach((rim) -> { - log.info(String.format("Storing swidtag %s", rim.getFileName())); + log.info("Storing swidtag {}", rim.getFileName()); this.referenceManifestRepository.save(rim); }); supportRims.forEach((rim) -> { - log.info(String.format("Storing event log %s", rim.getFileName())); + log.info("Storing event log {}", rim.getFileName()); this.referenceManifestRepository.save(rim); }); @@ -223,10 +223,10 @@ public class ReferenceManifestPageController extends PageController<NoPageParams * @return redirect to this page * @throws URISyntaxException if malformed URI */ - @RequestMapping(value = "/delete", method = RequestMethod.POST) + @PostMapping("/delete") public RedirectView delete(@RequestParam final String id, final RedirectAttributes attr) throws URISyntaxException { - log.info("Handling request to delete " + id); + log.info("Handling request to delete {}", id); Map<String, Object> model = new HashMap<>(); PageMessages messages = new PageMessages(); @@ -267,11 +267,11 @@ public class ReferenceManifestPageController extends PageController<NoPageParams * file name) * @throws java.io.IOException when writing to response output stream */ - @RequestMapping(value = "/download", method = RequestMethod.GET) + @GetMapping("/download") public void download(@RequestParam final String id, final HttpServletResponse response) throws IOException { - log.info("Handling RIM request to download " + id); + log.info("Handling RIM request to download {}", id); try { ReferenceManifest referenceManifest = getRimFromDb(id); @@ -282,10 +282,11 @@ public class ReferenceManifestPageController extends PageController<NoPageParams // send a 404 error when invalid Reference Manifest response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { - StringBuilder fileName = new StringBuilder("filename=\""); - fileName.append(referenceManifest.getFileName()); // Set filename for download. - response.setHeader("Content-Disposition", "attachment;" + fileName); + response.setHeader("Content-Disposition", + "attachment;" + "filename=\"" + referenceManifest.getFileName() + // Set filename for download. + ); response.setContentType("application/octet-stream"); // write cert to output stream @@ -307,7 +308,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams * file name) * @throws java.io.IOException when writing to response output stream */ - @RequestMapping(value = "/bulk", method = RequestMethod.GET) + @GetMapping("/bulk") public void bulk(final HttpServletResponse response) throws IOException { log.info("Handling request to download all Reference Integrity Manifests"); @@ -481,7 +482,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams */ private ReferenceManifest findBaseRim(final SupportReferenceManifest supportRim) { if (supportRim != null && (supportRim.getId() != null - && !supportRim.getId().toString().equals(""))) { + && !supportRim.getId().toString().isEmpty())) { List<BaseReferenceManifest> baseRims = new LinkedList<>(); baseRims.addAll(this.referenceManifestRepository .getBaseByManufacturerModel(supportRim.getPlatformManufacturer(), @@ -522,11 +523,7 @@ public class ReferenceManifestPageController extends PageController<NoPageParams this.referenceDigestValueRepository.save(newRdv); } - } catch (CertificateException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (IOException e) { + } catch (CertificateException | NoSuchAlgorithmException | IOException e) { e.printStackTrace(); } } else { diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index 6766c4d8..e7448a24 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -27,8 +27,8 @@ import org.springframework.data.domain.Sort; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @@ -84,15 +84,14 @@ public class RimDatabasePageController extends PageController<NoPageParams> { * information */ @ResponseBody - @RequestMapping(value = "/list", - produces = MediaType.APPLICATION_JSON_VALUE, - method = RequestMethod.GET) + @GetMapping(value = "/list", + produces = MediaType.APPLICATION_JSON_VALUE) public DataTableResponse<ReferenceDigestValue> getTableData( @Valid final DataTableInput input) { - log.info("Handling request for summary list: " + input); + log.info("Handling request for summary list: {}", input); String orderColumnName = input.getOrderColumnName(); - log.info("Ordering on column: " + orderColumnName); + log.info("Ordering on column: {}", orderColumnName); // check that the alert is not archived and that it is in the specified report CriteriaModifier criteriaModifier = new CriteriaModifier() { @@ -106,7 +105,7 @@ public class RimDatabasePageController extends PageController<NoPageParams> { } }; - log.info("Querying with the following dataTableInput: " + input.toString()); + log.info("Querying with the following dataTableInput: {}", input); FilteredRecordsList<ReferenceDigestValue> referenceDigestValues = new FilteredRecordsList<>(); @@ -139,7 +138,7 @@ public class RimDatabasePageController extends PageController<NoPageParams> { } } - log.debug("Returning list of size: " + referenceDigestValues.size()); + log.debug("Returning list of size: {}", referenceDigestValues.size()); return new DataTableResponse<>(referenceDigestValues, input); } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index ba4fad8e..e9926aa3 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -28,9 +28,9 @@ import org.springframework.data.domain.Sort; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @@ -111,8 +111,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams * @return the data table response containing the supply chain summary records */ @ResponseBody - @RequestMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE, - method = RequestMethod.GET) + @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE) public DataTableResponse<SupplyChainValidationSummary> getTableData( final DataTableInput input) { @@ -146,7 +145,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams * @param response object * @throws IOException thrown by BufferedWriter object */ - @PostMapping(value = "download") + @PostMapping("download") public void download(final HttpServletRequest request, final HttpServletResponse response) throws IOException { @@ -340,7 +339,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams final String company, final String contractNumber) { JsonObject systemData = new JsonObject(); - String deviceName = deviceRepository.findById((pc) + String deviceName = deviceRepository.findById(pc .getDeviceId()).get().getName(); systemData.addProperty("Company", company);