Add error handling to improve user experience
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / controller / AcXappController.java
index c1aac8f..46a4aab 100644 (file)
@@ -43,8 +43,10 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
 /**
- * Provides methods to manage policies of the Admission Control xApp, which
- * initially defines just one. All requests go via the A1 Mediatior.
+ * * Proxies calls from the front end to the AC xApp via the A1 Mediator API.
+ * All methods answer 502 on failure: <blockquote>HTTP server received an
+ * invalid response from a server it consulted when acting as a proxy or
+ * gateway.</blockquote>
  */
 @RestController
 @RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/xapp/ac", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -62,12 +64,13 @@ public class AcXappController {
        public AcXappController(final A1MediatorApi a1MediatorApi) {
                Assert.notNull(a1MediatorApi, "API must not be null");
                this.a1MediatorApi = a1MediatorApi;
+               if (logger.isDebugEnabled())
+                       logger.debug("ctor: configured with client type {}", a1MediatorApi.getClass().getName());
        }
 
        @ApiOperation(value = "Gets the A1 client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
        @RequestMapping(value = DashboardConstants.VERSION_PATH, method = RequestMethod.GET)
-       public SuccessTransport getVersion() {
-               logger.debug("getVersion enter");
+       public SuccessTransport getA1MediatorClientVersion() {
                return new SuccessTransport(200, DashboardApplication.getImplementationVersion(A1MediatorApi.class));
        }
 
@@ -76,18 +79,18 @@ public class AcXappController {
         */
        @ApiOperation(value = "Gets the admission control policy for AC xApp via the A1 Mediator")
        @RequestMapping(value = "admctrl", method = RequestMethod.GET)
-       public Object getAdmissionControlPolicy() {
+       public Object getAdmissionControlPolicy(HttpServletResponse response) {
                logger.debug("getAdmissionControlPolicy");
-               a1MediatorApi.a1ControllerGetHandler(AC_CONTROL_NAME);
+               response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
                return null;
        }
 
        /*
-        * This controller is deliberately kept ignorant of the
-        * ACAdmissionIntervalControl Typescript interface.
+        * This controller is deliberately kept ignorant of the data expected by AC. The
+        * fields are defined in the ACAdmissionIntervalControl Typescript interface.
         */
        @ApiOperation(value = "Sets the admission control policy for AC xApp via the A1 Mediator")
-       @RequestMapping(value = "admctrl", method = RequestMethod.PUT)
+       @RequestMapping(value = "catime", method = RequestMethod.PUT)
        public void setAdmissionControlPolicy(@ApiParam(value = "Admission control policy") @RequestBody JsonNode acPolicy, //
                        HttpServletResponse response) {
                logger.debug("setAdmissionControlPolicy {}", acPolicy);