2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.apihandlerinfra;
\r
23 import javax.ws.rs.DefaultValue;
\r
24 import javax.ws.rs.GET;
\r
25 import javax.ws.rs.HEAD;
\r
26 import javax.ws.rs.Path;
\r
27 import javax.ws.rs.Produces;
\r
28 import javax.ws.rs.QueryParam;
\r
29 import javax.ws.rs.core.Response;
\r
31 import org.openecomp.mso.HealthCheckUtils;
\r
32 import org.openecomp.mso.logger.MsoLogger;
\r
33 import org.openecomp.mso.utils.UUIDChecker;
\r
35 import com.wordnik.swagger.annotations.Api;
\r
36 import com.wordnik.swagger.annotations.ApiOperation;
\r
38 @Path("/globalhealthcheck")
\r
39 @Api(value="/globalhealthcheck",description="APIH Infra Global Health Check")
\r
40 public class GlobalHealthcheckHandler {
\r
42 private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
\r
46 @Produces("text/html")
\r
47 @ApiOperation(value="Performing global health check",response=Response.class)
\r
48 public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) {
\r
49 long startTime = System.currentTimeMillis ();
\r
50 MsoLogger.setServiceName ("GlobalHealthcheck");
\r
51 // Generate a Request Id
\r
52 String requestId = UUIDChecker.generateUUID(msoLogger);
\r
53 HealthCheckUtils healthCheck = new HealthCheckUtils ();
\r
54 if (!healthCheck.siteStatusCheck (msoLogger)) {
\r
55 return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
\r
58 if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) {
\r
59 msoLogger.debug("globalHealthcheck - Successful");
\r
60 return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
\r
62 msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available");
\r
63 return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
\r