diff --git a/php/RemoteDataCenter/RemoteDataCenterClass.php b/php/RemoteDataCenter/RemoteDataCenterClass.php index 9fac523..fbdc11c 100644 --- a/php/RemoteDataCenter/RemoteDataCenterClass.php +++ b/php/RemoteDataCenter/RemoteDataCenterClass.php @@ -6,7 +6,7 @@ */ abstract class RemoteDataCenterClass { - protected $url = null, $treeXML = null; + protected $url = null, $WSDL = null, $treeXML = null; protected $needsArgs = false; protected $hasAccessUrl = false; @@ -84,5 +84,24 @@ abstract class RemoteDataCenterClass foreach ($missionNodes as $missionNode) $this->dataCenter->appendChild($missionNode); } + + public function monitor() + { + $ch = curl_init($this->url."/".$this->WSDL); + curl_setopt($ch, CURLOPT_TIMEOUT, 3); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $data = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if($httpcode >= 200 && $httpcode < 300) + { + return true; + } else + { + return false; + } + } } ?> diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 9ad7d0d..557bc6e 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -354,11 +354,10 @@ class AmdaAction case 'remoteSimuParam' : $globalStart = null; - + $service_down = false; $isSimulation = true; - if ($child->getAttribute('isAddable')) - //if ($id == 'spase://IMPEX/SimulationModel/FMI/GUMICS' ) + if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS' { $isLeaf = false; $isAddable = true; @@ -366,7 +365,11 @@ class AmdaAction if ($child->tagName == 'dataCenter') { - if ($child->getAttribute('isSimulation')) break; + if ($child->getAttribute('isSimulation')) + { + $service_down = !($child->getAttribute('available')); + break; + } else { $skip = true; @@ -431,14 +434,7 @@ class AmdaAction if ($info && !$isSimulation) { $info = str_replace(';', "<br/>Time Range: ", $info); - } - - if ($child->tagName == 'dataset') - { - /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) - $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>"; */ - // $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>"; - } + } if (($child->tagName == 'parameter') || ($child->tagName == 'component')) { @@ -480,21 +476,28 @@ class AmdaAction } else { - if ($child->tagName == 'dataCenter') - $restricted = ($child->getAttribute('available') != "1"); - else - $restricted = false; - +// if ($child->tagName == 'dataCenter') +// { +// $restricted = ($child->getAttribute('available') != "1"); +// } +// else +// $restricted = false; +// if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') $restricted = FALSE; - if ($restricted) - $info .= "<br/><b>Open soon !</b>"; - +// if ($restricted) +// $info .= "<br/><b>Open soon !</b>"; +// + if ($child->tagName == 'dataset') + { $nonavailable = ($child->getAttribute('disabled')); + } else + { $nonavailable = false; + } if ($nonavailable) $info .= "<br/><b>Not available yet</b>"; @@ -556,10 +559,16 @@ class AmdaAction if (!$specialNode && !$skip) { - if ($child->hasAttribute('desc')) + if ($child->hasAttribute('desc')) $info = $child->getAttribute('desc'); + + if ($isSimulation && $service_down) + { + $info = "<b>Service is currently down</b>"; + } + $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, - 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); } } // if $childrenToReturn we have to return [] diff --git a/php/classes/UserMgr.php b/php/classes/UserMgr.php index 858030c..d1d8c7a 100644 --- a/php/classes/UserMgr.php +++ b/php/classes/UserMgr.php @@ -216,6 +216,7 @@ class UserMgr if ($base->hasAttribute('isSimulation')) { $baseId = $base->getAttribute('xml:id'); + $baseXml = new DomDocument("1.0"); // no data base description ; skip this data base if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; @@ -240,11 +241,15 @@ class UserMgr $gumicsSimuReg->appendChild($node); } } - } + } + // Check if WebService is ON + $center = new $baseId(); + $myBase->setAttribute('available',$center->monitor()); + $myRootElement->appendChild($myBase); } - } - + } + return $myRemoteBases->save(USERWSDIR.'RemoteParams.xml'); } @@ -272,10 +277,11 @@ class UserMgr foreach ($bases as $base) { $baseId = $base->getAttribute('xml:id'); + if ($base->getAttribute('isSimulation')) continue; + $notAvailable = (array_search($baseId,$availableMis) === FALSE); - $base->setAttribute('available',!$notAvailable); - - if ($base->getAttribute('isSimulation')) continue; + $base->setAttribute('available',!$notAvailable); + // Update Info on External Data Sets in UserTree.xml for everything except IMPEX $dataSets = $base->getElementsByTagName("dataset"); if ($dataSets->length > 0) diff --git a/php/config.php b/php/config.php index 24becc4..7666157 100644 --- a/php/config.php +++ b/php/config.php @@ -129,9 +129,10 @@ putenv("DDPATH=".DDRES_DIR); // PHP classes define('XMLPATH', IHM_SRC_DIR.'php/XML/'); define('CLASSPATH', IHM_SRC_DIR.'php/classes/'); +define('REMOTE_CLASSPATH', IHM_SRC_DIR.'php/RemoteDataCenter/'); define('OLD_CLASSPATH', IHM_SRC_DIR.'php/old_amda/'); -set_include_path(".:".CLASSPATH.":".OLD_CLASSPATH); +set_include_path(".:".CLASSPATH.":".REMOTE_CLASSPATH.":".OLD_CLASSPATH); if (!function_exists('__autoload')) { -- libgit2 0.21.2