X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dashboard%2Fwebapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FSimpleErrorController.java;h=23af7860ce405d30ee7c3249bd9a1ce62ecd94c0;hb=5408c157fc8aca52731fcc2cc035ed9dbfcff219;hp=e2248e6441d72bbe4c10405e9fc2da9c5ef662c5;hpb=a2bc79c5f0027e953815d6e98814a748b36827aa;p=nonrtric.git diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java index e2248e64..23af7860 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java @@ -3,13 +3,14 @@ * O-RAN-SC * %% * Copyright (C) 2019 AT&T Intellectual Property + * Modifications Copyright (C) 2020 Nordix Foundation * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +36,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.request.ServletWebRequest; - import springfox.documentation.annotations.ApiIgnore; /** @@ -43,12 +43,12 @@ import springfox.documentation.annotations.ApiIgnore; * context, including page not found, and redirects the caller to a custom error * page. The caller is also redirected to this page if a REST controller takes * an uncaught exception. - * + * * If trace is requested via request parameter ("?trace=true") and available, * adds stack trace information to the standard JSON error response. - * + * * Excluded from Swagger API documentation. - * + * * https://stackoverflow.com/questions/25356781/spring-boot-remove-whitelabel-error-page * https://www.baeldung.com/spring-boot-custom-error-page */ @@ -58,36 +58,35 @@ import springfox.documentation.annotations.ApiIgnore; @RequestMapping(value = SimpleErrorController.ERROR_PATH, produces = MediaType.APPLICATION_JSON_VALUE) public class SimpleErrorController implements ErrorController { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - public static final String ERROR_PATH = "/error"; + @SuppressWarnings("squid:S1075") + public static final String ERROR_PATH = "/error"; - private final ErrorAttributes errorAttributes; + private final ErrorAttributes errorAttributes; - @Autowired - public SimpleErrorController(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } + @Autowired + public SimpleErrorController(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } - @Override - public String getErrorPath() { - logger.warn("getErrorPath"); - return ERROR_PATH; - } + @Override + public String getErrorPath() { + logger.warn("getErrorPath"); + return ERROR_PATH; + } - @GetMapping - public String handleError(HttpServletRequest request) { - ServletWebRequest servletWebRequest = new ServletWebRequest(request); - Throwable t = errorAttributes.getError(servletWebRequest); - if (t != null) - logger.warn("handleError", t); - Map attributes = errorAttributes.getErrorAttributes(servletWebRequest, true); - attributes.forEach((attribute, value) -> { - logger.warn("handleError: {} -> {}", attribute, value); - }); - // Return the name of the page INCLUDING suffix, which I guess is a "view" name. - // Just "error" is not enough, but don't seem to need a ModelAndView object. - return "error.html"; - } + @GetMapping + public String handleError(HttpServletRequest request) { + ServletWebRequest servletWebRequest = new ServletWebRequest(request); + Throwable t = errorAttributes.getError(servletWebRequest); + if (t != null) + logger.warn("handleError", t); + Map attributes = errorAttributes.getErrorAttributes(servletWebRequest, true); + attributes.forEach((attribute, value) -> logger.warn("handleError: {} -> {}", attribute, value)); + // Return the name of the page INCLUDING suffix, which I guess is a "view" name. + // Just "error" is not enough, but don't seem to need a ModelAndView object. + return "error.html"; + } }