diff options
author | Eran (ev672n), Vosk <ev672n@att.com> | 2018-08-07 14:15:05 +0300 |
---|---|---|
committer | Eran (ev672n), Vosk <ev672n@att.com> | 2018-08-07 14:15:05 +0300 |
commit | b9708a7c3cfaf5767992a2b15180e7b85c459242 (patch) | |
tree | 076e19ea52232232e9060a9d7e074947a4a49508 /src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java | |
parent | cc32bd38d72e5c1c92048657083952d3e45c1819 (diff) |
adding the dcae dt code
Adding DCAE-dt code
Change-Id: Id6b779db9d24e10825fb97ad5fd46f41e65e6738
Issue-ID: SDC-1614
Signed-off-by: Eran (ev672n), Vosk <ev672n@att.com>
Diffstat (limited to 'src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java')
-rw-r--r-- | src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java b/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java new file mode 100644 index 0000000..9086600 --- /dev/null +++ b/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java @@ -0,0 +1,72 @@ +package org.onap.sdc.dcae.controller.health; + +import java.util.ArrayList; +import java.util.List; + +import org.onap.sdc.dcae.FeApp; +import org.onap.sdc.dcae.composition.restmodels.health.ComponentsInfo; +import org.onap.sdc.dcae.composition.restmodels.health.HealthResponse; +import org.onap.sdc.dcae.composition.util.DcaeFeConstants; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.google.gson.Gson; + + +/** + * + * @author lezer + * Example: + * { + "healthCheckComponent": "DCAE Designer", + "healthCheckStatus": "UP", + "description": "OK", + "componentsInfo": [{ + "healthCheckComponent": "FE", + "healthCheckStatus": "UP", + "description": "OK" + }] +} + * + */ +@RestController +@EnableAutoConfiguration +@CrossOrigin +public class HealthController { + Gson gson = new Gson(); + + @RequestMapping(value = "/healthCheckOld", method = RequestMethod.GET) + public ResponseEntity<String> healthCheck() { + try{ + HealthResponse healthResponse = new HealthResponse(); + healthResponse.setHealthCheckComponent(DcaeFeConstants.Health.APP_NAME); + healthResponse.setHealthCheckStatus(DcaeFeConstants.Health.UP); + healthResponse.setSdcVersion(FeApp.getDcaeVersion()); + healthResponse.setDescription(DcaeFeConstants.Health.OK); + + List<ComponentsInfo> componentsInfoList = new ArrayList<ComponentsInfo>(); + ComponentsInfo componentsInfo = new ComponentsInfo(); + componentsInfo.setHealthCheckComponent(DcaeFeConstants.Health.FE); + componentsInfo.setHealthCheckStatus(DcaeFeConstants.Health.UP); + componentsInfo.setVersion(FeApp.getDcaeVersion()); + componentsInfo.setDescription(DcaeFeConstants.Health.OK); + componentsInfoList.add(componentsInfo); + + healthResponse.setComponentsInfo(componentsInfoList); + String json = gson.toJson(healthResponse, HealthResponse.class); + System.out.println("Health Check response: "+json); + + return new ResponseEntity<String>(json, HttpStatus.OK); + } + catch(Exception e){ + System.err.println("Error occured while performing HealthCheck: "+e.getLocalizedMessage()); + return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); + } + } + +} |