Merge "Fix sql injection vulnerability"
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / controller / HealthCheckController.java
index 80e16b5..6818d50 100644 (file)
@@ -33,7 +33,7 @@
  *
  * ============LICENSE_END============================================
  *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * 
  */
 package org.onap.portalapp.portal.controller;
 
@@ -48,6 +48,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
+import org.onap.music.main.MusicUtil;
 import org.onap.portalapp.controller.EPUnRestrictedBaseController;
 import org.onap.portalapp.portal.listener.HealthMonitor;
 import org.onap.portalapp.portal.logging.aop.EPAuditLog;
@@ -122,7 +123,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController {
                HealthStatus healthStatus = new HealthStatus(500, "");
 
                // Return the status as 500 if it suspended due to manual fail over
-               if (HealthMonitor.isSuspended) {
+               if (HealthMonitor.isSuspended()) {
                        healthStatus.body = "Suspended";
                        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                        MDC.put(EPCommonSystemProperties.RESPONSE_CODE,
@@ -163,14 +164,14 @@ public class HealthCheckController extends EPUnRestrictedBaseController {
                                EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
                        }
 
-                       if (!HealthMonitor.isClusterStatusOk()) {
-                               dbInfo.dbClusterStatus = "Problem, check the logs for more details";
-                               EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
-                       } else {
-                               dbInfo.dbClusterStatus = statusOk;
-                       }
+//                     if (!HealthMonitor.isClusterStatusOk()) {
+//                             dbInfo.dbClusterStatus = "Problem, check the logs for more details";
+//                             EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
+//                     } else {
+//                             dbInfo.dbClusterStatus = statusOk;
+//                     }
 
-                       if (!HealthMonitor.isDatabasePermissionsOk()) {
+                       if (!HealthMonitor.isDbPermissionsOk()) {
                                dbInfo.dbPermissions = "Problem, check the logs for more details";
                                EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
                        } else {
@@ -178,16 +179,30 @@ public class HealthCheckController extends EPUnRestrictedBaseController {
                        }
                        statusCollection.add(dbInfo);
 
-                       HealthStatusInfo uebInfo = new HealthStatusInfo("UEB");
-                       if (!HealthMonitor.isUebUp()) {
-                               // As per test case review meeting, UEB is considered as
-                               // critical as DB. Hence commenting
-                               // overallStatus = false;
-                               uebInfo.healthCheckStatus = statusDown;
-                               uebInfo.description = "Check the logs for more details";
-                               EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebConnectionError);
+                       if(org.onap.portalapp.music.util.MusicUtil.isMusicEnable()){
+                               HealthStatusInfo CassandraStatusInfo = new HealthStatusInfo("Music-Cassandra");
+                               //CassandraStatusInfo.hostName = EcompPortalUtils.getMyHostName();
+                               CassandraStatusInfo.ipAddress = MusicUtil.getMyCassaHost();
+                               
+                               if (!HealthMonitor.isCassandraStatusOk()) {
+                                       overallStatus = false;
+                                       CassandraStatusInfo.healthCheckStatus = statusDown;
+                                       CassandraStatusInfo.description = "Check the logs for more details";
+                                       EPLogUtil.logEcompError(logger, EPAppMessagesEnum.MusicHealthCheckCassandraError);
+                               }
+                               statusCollection.add(CassandraStatusInfo);
+
+                               HealthStatusInfo zookeeperStatusInfo = new HealthStatusInfo("Music-zookeeper");
+                               //zookeeperStatusInfo.hostName = EcompPortalUtils.getMyHostName();
+                               zookeeperStatusInfo.ipAddress = MusicUtil.getMyZkHost();
+                               if (!HealthMonitor.isZookeeperStatusOk()) {
+                                       overallStatus = false;
+                                       zookeeperStatusInfo.healthCheckStatus = statusDown;
+                                       zookeeperStatusInfo.description = "Check the logs for more details";
+                                       EPLogUtil.logEcompError(logger, EPAppMessagesEnum.MusicHealthCheckZookeeperError);
+                               }
+                               statusCollection.add(zookeeperStatusInfo);
                        }
-                       statusCollection.add(uebInfo);
 
                        String json = "";
                        try {
@@ -218,7 +233,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController {
        public HealthStatus healthCheckSuspend(HttpServletRequest request, HttpServletResponse response) {
                HealthStatus healthStatus = new HealthStatus(500, "Suspended for manual failover mechanism");
 
-               HealthMonitor.isSuspended = true;
+               HealthMonitor.setSuspended(true);
                healthStatus.statusCode = 200;
 
                EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckSuspend", "GET result =",
@@ -232,7 +247,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController {
        public HealthStatus healthCheckResume(HttpServletRequest request, HttpServletResponse response) {
                HealthStatus healthStatus = new HealthStatus(500, "Resumed from manual failover mechanism");
 
-               HealthMonitor.isSuspended = false;
+               HealthMonitor.setSuspended(false);
                healthStatus.statusCode = 200;
                EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckResume", "GET result =",
                                response.getStatus());