X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FCustomResponseEntityExceptionHandler.java;fp=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FCustomResponseEntityExceptionHandler.java;h=6d8afa7deb6833eaab79c387e86097ba062a411c;hb=beea5ee48a0efddde5e868eb0c99ba4ba67f1d46;hp=b1ac2e8fdb90bfef7bc643024789603cc79a7ba5;hpb=74b6495875f5654013a5bda7ba3e720f27d0f327;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java index b1ac2e8f..6d8afa7d 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java @@ -24,10 +24,8 @@ import java.lang.invoke.MethodHandles; import org.oransc.ric.portal.dashboard.model.ErrorTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.client.HttpStatusCodeException; @@ -41,11 +39,6 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep * * Why 502? I quote:
HTTP server received an invalid response from a * server it consulted when acting as a proxy or gateway.
- * - * This class and the methods are not strictly necessary, the - * SimpleErrorController is invoked when any controller method takes an uncaught - * exception, but this approach provides a better response to the front end and - * doesn't signal internal server error. * * Also see:
* https://www.baeldung.com/exception-handling-for-rest-with-spring @@ -61,11 +54,6 @@ public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptio * Generates the response when a REST controller method takes an * HttpStatusCodeException. * - * It appears that the container internally redirects to /error because the web - * request that arrives here has URI /error, and {@link - * org.oransc.ric.portal.dashboard.controller.SimpleErrorController} runs before - * this. - * * @param ex The exception * * @param request The original request @@ -81,21 +69,4 @@ public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptio HttpStatus.BAD_GATEWAY); } - /* - * This exception also happens when Spring security denies access to a method - * due to missing/wrong roles (granted authorities). Override the method to - * answer permission denied, even though that may obscure a genuine developer - * error. - * - * The web request that arrives here has URI /error; how to obtain the URI of - * the original request?!? - */ - @Override - public final ResponseEntity handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, - HttpHeaders headers, HttpStatus status, WebRequest request) { - log.warn("handleHttpRequestMethodNotSupported: answering 'permission denied' for method {}", ex.getMethod()); - return new ResponseEntity(new ErrorTransport(HttpStatus.UNAUTHORIZED.value(), - "Permission denied for method " + ex.getMethod(), ex), HttpStatus.UNAUTHORIZED); - } - }