import io.swagger.annotations.ApiParam;
/**
- * * 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>
+ * Proxies calls from the front end to the AC xApp via the A1 Mediator API.
+ *
+ * If a method throws RestClientResponseException, it is handled by
+ * {@link CustomResponseEntityExceptionHandler#handleProxyMethodException(Exception, org.springframework.web.context.request.WebRequest)}
+ * which returns status 502. All other exceptions are handled by Spring which
+ * returns status 500.
*/
@RestController
@RequestMapping(value = AcXappController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
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/ac";
+ public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/xapp/admctl";
// Endpoints
- public static final String ADMCTRL_METHOD = "/admctrl";
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";
}
/*
- * 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(ADMCTRL_METHOD)
+ @GetMapping(POLICY_METHOD)
@Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
public Object getAdmissionControlPolicy(HttpServletResponse response) {
logger.debug("getAdmissionControlPolicy");
* fields are defined in the ACAdmissionIntervalControl Typescript interface.
*/
@ApiOperation(value = "Sets the admission control policy for AC xApp via the A1 Mediator")
- @PutMapping(ADMCTRL_METHOD)
+ @PutMapping(POLICY_METHOD)
@Secured({ DashboardConstants.ROLE_ADMIN })
- public void setAdmissionControlPolicy(@ApiParam(value = "Admission control policy") @RequestBody JsonNode acPolicy, //
+ public void putAdmissionControlPolicy(@ApiParam(value = "Admission control policy") @RequestBody JsonNode acPolicy, //
HttpServletResponse response) {
- logger.debug("setAdmissionControlPolicy {}", acPolicy);
+ logger.debug("putAdmissionControlPolicy {}", acPolicy);
a1MediatorApi.a1ControllerPutHandler(AC_CONTROL_NAME, acPolicy);
response.setStatus(a1MediatorApi.getApiClient().getStatusCode().value());
}