Synch up paths front-end vs back-end for A1/AC 40/740/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Fri, 16 Aug 2019 19:51:05 +0000 (15:51 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Fri, 16 Aug 2019 20:09:57 +0000 (16:09 -0400)
Also extend the error controller to log more details.

Issue-Id: RICPLT-1994
Change-Id: I2bc5462e4bddac632f8eeedd9dd60fe7ee8d2b09
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AcXappController.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java

index 8868d2b..7b97ca0 100644 (file)
@@ -59,10 +59,10 @@ public class AcXappController {
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        // Publish paths in constants so tests are easy to write
-       public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/xapp/admctrl";
+       public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/xapp/admctl";
        // Endpoints
-       public static final String POLICY_METHOD = "policy";
        public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
+       public static final String POLICY_METHOD = "policy";
 
        // A "control" is an element in the XApp descriptor
        private static final String AC_CONTROL_NAME = "admission_control_policy";
@@ -86,7 +86,8 @@ public class AcXappController {
        }
 
        /*
-        * GET policy is not supported at present by A1 Mediator! Always returns 501.
+        * This controller is deliberately kept ignorant of the data expected by AC. The
+        * fields are defined in the ACAdmissionIntervalControl Typescript interface.
         */
        @ApiOperation(value = "Gets the admission control policy for AC xApp via the A1 Mediator")
        @GetMapping(POLICY_METHOD)
index 3102e4e..ca3df22 100644 (file)
 package org.oransc.ric.portal.dashboard.controller;
 
 import java.lang.invoke.MethodHandles;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.servlet.error.ErrorAttributes;
 import org.springframework.boot.web.servlet.error.ErrorController;
 import org.springframework.http.MediaType;
 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;
 
@@ -56,6 +62,13 @@ public class SimpleErrorController implements ErrorController {
 
        public static final String ERROR_PATH = "/error";
 
+       private final ErrorAttributes errorAttributes;
+
+       @Autowired
+       public SimpleErrorController(ErrorAttributes errorAttributes) {
+               this.errorAttributes = errorAttributes;
+       }
+
        @Override
        public String getErrorPath() {
                logger.warn("getErrorPath");
@@ -63,8 +76,15 @@ public class SimpleErrorController implements ErrorController {
        }
 
        @GetMapping
-       public String handleError() {
-               logger.warn("handleError");
+       public String handleError(HttpServletRequest request) {
+               ServletWebRequest servletWebRequest = new ServletWebRequest(request);
+               Throwable t = errorAttributes.getError(servletWebRequest);
+               if (t != null)
+                       logger.warn("handleError", t);
+               Map<String, Object> 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";