aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java44
1 files changed, 20 insertions, 24 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
index 4e9a827f..f7787fc7 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019,2021 Nordix Foundation.
* Modifications Copyright (C) 2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,13 +32,14 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.ResponseHeader;
import java.util.Map;
import java.util.UUID;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
+import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.tuple.Pair;
-import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
/**
* Class to provide REST end point for PAP component to fetch all policy components, including PAP,
@@ -45,18 +47,13 @@ import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
*
* @author Yehui Wang (yehui.wang@est.tech)
*/
+@RestController
+@RequestMapping(path = "/policy/pap/v1")
+@RequiredArgsConstructor
public class PolicyComponentsHealthCheckControllerV1 extends PapRestControllerV1 {
- private PolicyComponentsHealthCheckProvider provider;
+ private final PolicyComponentsHealthCheckProvider provider;
- /**
- * Constructs the object.
- *
- * @throws HttpClientConfigException if creating http client failed
- */
- public PolicyComponentsHealthCheckControllerV1() throws HttpClientConfigException {
- provider = new PolicyComponentsHealthCheckProvider();
- }
/**
* Returns health status of all Policy components, including PAP, API, Distribution, and PDPs.
@@ -65,8 +62,7 @@ public class PolicyComponentsHealthCheckControllerV1 extends PapRestControllerV1
* @return a response
*/
// @formatter:off
- @GET
- @Path("components/healthcheck")
+ @GetMapping("components/healthcheck")
@ApiOperation(value = "Returns health status of all policy components, including PAP, API, Distribution, and PDPs",
notes = "Queries health status of all policy components, returning all policy components health status",
response = Map.class,
@@ -94,12 +90,12 @@ public class PolicyComponentsHealthCheckControllerV1 extends PapRestControllerV1
@ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
})
// @formatter:on
-
- public Response policyComponentsHealthCheck(
- @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) final UUID requestId) {
- final Pair<Status, Map<String, Object>> pair =
- provider.fetchPolicyComponentsHealthStatus();
- return addLoggingHeaders(addVersionControlHeaders(Response.status(pair.getLeft())), requestId)
- .entity(pair.getRight()).build();
+ public ResponseEntity<Map<String, Object>> policyComponentsHealthCheck(
+ @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) @RequestHeader(
+ required = false,
+ value = REQUEST_ID_NAME) final UUID requestId) {
+ final Pair<HttpStatus, Map<String, Object>> pair = provider.fetchPolicyComponentsHealthStatus();
+ return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.status(pair.getLeft())), requestId)
+ .body(pair.getRight());
}
}