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%2FAnrXappController.java;h=dbaa5bc03b6f1e3822e178b59d498c2276904928;hb=b8f4e986970eab6cfa5729c24680f2816f056edb;hp=dae8ae25ef3a252c6bcfe941fae09e8c1612a62a;hpb=9d33149c7bdc8566d0135406b601fc1a901ff2f5;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AnrXappController.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AnrXappController.java index dae8ae25..dbaa5bc0 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AnrXappController.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AnrXappController.java @@ -52,59 +52,74 @@ import io.swagger.annotations.ApiOperation; */ @Configuration @RestController -@RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/xapp/anr", produces = MediaType.APPLICATION_JSON_VALUE) +@RequestMapping(value = AnrXappController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE) public class AnrXappController { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - // Query parameters - private static final String QP_NODEB = "ggnodeb"; - private static final String QP_SERVING = "servingCellNrcgi"; - private static final String QP_NEIGHBOR = "neighborCellNrpci"; + // Publish paths in constants so tests are easy to write + public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/xapp/anr"; + // Endpoints + public static final String HEALTH_ALIVE_METHOD = "/health/alive"; + public static final String HEALTH_READY_METHOD = "/health/ready"; + public static final String GNODEBS_METHOD = "/gnodebs"; + public static final String NCRT_METHOD = "/ncrt"; + public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD; + // Path parameters - private static final String PP_SERVING = "servingcells"; - private static final String PP_NEIGHBOR = "neighborcells"; + public static final String PP_SERVING = "servingcells"; + public static final String PP_NEIGHBOR = "neighborcells"; + // Query parameters + public static final String QP_NODEB = "ggnodeb"; + public static final String QP_SERVING = "servingCellNrcgi"; + public static final String QP_NEIGHBOR = "neighborCellNrpci"; // Populated by the autowired constructor private final HealthApi healthApi; private final NcrtApi ncrtApi; @Autowired - public AnrXappController(final HealthApi healthApi, final NcrtApi ncrtApi) { - Assert.notNull(healthApi, "API must not be null"); - Assert.notNull(ncrtApi, "API must not be null"); - this.healthApi = healthApi; - this.ncrtApi = ncrtApi; + public AnrXappController(final HealthApi anrHealthApi, final NcrtApi anrNcrtApi) { + Assert.notNull(anrHealthApi, "API must not be null"); + Assert.notNull(anrNcrtApi, "API must not be null"); + this.healthApi = anrHealthApi; + this.ncrtApi = anrNcrtApi; + if (logger.isDebugEnabled()) + logger.debug("ctor: configured with client types {} and {}", anrHealthApi.getClass().getName(), + anrNcrtApi.getClass().getName()); } @ApiOperation(value = "Gets the ANR client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class) - @RequestMapping(value = DashboardConstants.VERSION_PATH, method = RequestMethod.GET) - public SuccessTransport getAnrXappClientVersion() { + @RequestMapping(value = VERSION_METHOD, method = RequestMethod.GET) + public SuccessTransport getClientVersion() { return new SuccessTransport(200, DashboardApplication.getImplementationVersion(HealthApi.class)); } @ApiOperation(value = "Performs a liveness probe on the ANR xApp, result expressed as the response code.") - @RequestMapping(value = "/health/alive", method = RequestMethod.GET) - public void getAnrXappHealthAlive(HttpServletResponse response) { + @RequestMapping(value = HEALTH_ALIVE_METHOD, method = RequestMethod.GET) + public void getHealthAlive(HttpServletResponse response) { + logger.debug("getHealthAlive"); healthApi.getHealthAlive(); response.setStatus(healthApi.getApiClient().getStatusCode().value()); } @ApiOperation(value = "Performs a readiness probe on the ANR xApp, result expressed as the response code.") - @RequestMapping(value = "/health/ready", method = RequestMethod.GET) - public void getAnrXappHealthReady(HttpServletResponse response) { + @RequestMapping(value = HEALTH_READY_METHOD, method = RequestMethod.GET) + public void getHealthReady(HttpServletResponse response) { + logger.debug("getHealthReady"); healthApi.getHealthReady(); response.setStatus(healthApi.getApiClient().getStatusCode().value()); } @ApiOperation(value = "Returns list of gNodeB IDs based on NCRT in ANR", response = GgNodeBTable.class) - @RequestMapping(value = "/gnodebs", method = RequestMethod.GET) + @RequestMapping(value = GNODEBS_METHOD, method = RequestMethod.GET) public GgNodeBTable getGnodebs() { + logger.debug("getGnodebs"); return ncrtApi.getgNodeB(); } @ApiOperation(value = "Returns neighbor cell relation table for all gNodeBs or based on query parameters", response = NeighborCellRelationTable.class) - @RequestMapping(value = "/ncrt", method = RequestMethod.GET) + @RequestMapping(value = NCRT_METHOD, method = RequestMethod.GET) public NeighborCellRelationTable getNcrt( // @RequestParam(name = QP_NODEB, required = false) String ggnbId, // @RequestParam(name = QP_SERVING, required = false) String servingCellNrcgi, // @@ -116,7 +131,7 @@ public class AnrXappController { // /ncrt/servingcells/{servCellNrcgi}/neighborcells/{neighCellNrpci} : @ApiOperation(value = "Modify neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI") - @RequestMapping(value = "/ncrt/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR + @RequestMapping(value = NCRT_METHOD + "/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR + "}", method = RequestMethod.PUT) public void modifyNcrt(@PathVariable(PP_SERVING) String servingCellNrcgi, // @PathVariable(PP_NEIGHBOR) String neighborCellNrpci, // @@ -128,7 +143,7 @@ public class AnrXappController { } @ApiOperation(value = "Delete neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI") - @RequestMapping(value = "/ncrt/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR + @RequestMapping(value = NCRT_METHOD + "/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR + "}", method = RequestMethod.DELETE) public void deleteNcrt(@PathVariable(PP_SERVING) String servingCellNrcgi, // @PathVariable(PP_NEIGHBOR) String neighborCellNrpci, //