diff options
Diffstat (limited to 'cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java')
-rw-r--r-- | cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java index efc57ec..72b80bb 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,24 +65,32 @@ public class HealthCheckImpl implements HealthCheck { HealthCheckMessage hc = new HealthCheckMessage(); hc.setHealthy(true); - addToHealthCheckMessage(hc, this.healthCheck()); + //addToHealthCheckMessage(hc, this.healthCheckDb()); - if (hc.getHealthy()) + if (hc.getHealthy()) { response = Response.ok().entity(hc).build(); - else + } + else { response = Response.status(Response.Status.BAD_REQUEST).entity(hc).build(); + } return response; } private void addToHealthCheckMessage(HealthCheckMessage hc, HealthCheckComponent hcc) { - if (!hcc.getHealthy()) + if (!hcc.getHealthy()) { hc.setHealthy(false); + } hc.setHostname(System.getenv("HOSTNAME")); hc.addComponent(hcc); } - public HealthCheckComponent healthCheck() { + /** + * Health check. + * + * @return the health check component + */ + public HealthCheckComponent healthCheckDb() { HealthCheckComponent hcc = new HealthCheckComponent(); hcc.setName("Ticket Management Database"); String url = env.getProperty("spring.datasource.url"); |