diff --git a/src/DDSERVICES/REST/getLastUpdate.php b/src/DDSERVICES/REST/getLastUpdate.php new file mode 100644 index 0000000..6752f90 --- /dev/null +++ b/src/DDSERVICES/REST/getLastUpdate.php @@ -0,0 +1,38 @@ +<?php + +/** +* @file getLastUpdate.php +* @brief Returns last modif of *_times.nc for a given DataSet +* @version $Id: $ +*/ + + if (!$_GET['id']) exit('INPUT ERROR'); + require_once './DDserverWeb_ini.php'; + error_reporting(E_ERROR | E_WARNING | E_PARSE); + + $replace = array("-" => "_"); + + $dataSet = strtr($_GET['id'], $replace); + + $referXML = baseDir."DDsys.xml"; + $DDsys = new DOMDocument("1.0"); + $DDsys->load($referXML); + $xp = new domxpath($DDsys); + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']"); + + if ($VI_NAME->item(0)->nodeValue != NULL) + { + $VI = $VI_NAME->item(0)->parentNode; + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue; + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue; + if (!file_exists($location.$times)) + exit('NO TIMES FILE'); + + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS + $dateModif = exec($cmd); + exit($dateModif); + } + else { + exit('NO SUCH DATASET'); + } +?> diff --git a/src/DDSERVICES/REST/getStartStop.php b/src/DDSERVICES/REST/getStartStop.php new file mode 100644 index 0000000..de7dcee --- /dev/null +++ b/src/DDSERVICES/REST/getStartStop.php @@ -0,0 +1,41 @@ +<?php + +/** +* @file getStartStop.php +* @brief Returns GlobalStart - GlobalStop for a given DataSet +* @version $Id: $ +*/ + + if (!$_GET['id']) exit('INPUT ERROR'); + require_once './DDserverWeb_ini.php'; + error_reporting(E_ERROR | E_WARNING | E_PARSE); + + $replace = array("-" => "_"); + + $dataSet = strtr($_GET['id'], $replace); + + $referXML = baseDir."DDsys.xml"; + $DDsys = new DOMDocument("1.0"); + $DDsys->load($referXML); + $xp = new domxpath($DDsys); + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']"); + + if ($VI_NAME->item(0)->nodeValue != NULL) + { + $VI = $VI_NAME->item(0)->parentNode; + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue; + $info = basename($VI->getElementsByTagName("INFO")->item(0)->nodeValue, '.nc').'.xml'; + if (!file_exists($location.$info)) + exit('NO INFO XML'); + + $infoDom = new DOMDocument("1.0"); + $infoDom->loadXML(file_get_contents($location.$info)); // for NFS + + $Start = $infoDom->getElementsByTagName("GlobalStart")->item(0)->nodeValue; + $Stop = $infoDom->getElementsByTagName("GlobalStop")->item(0)->nodeValue; + exit($Start.",".$Stop); + } + else { + exit('NO SUCH DATASET'); + } +?> diff --git a/src/DDSERVICES/SOAP/DDserverWeb.php b/src/DDSERVICES/SOAP/DDserverWeb.php index f09ee71..e8b872e 100644 --- a/src/DDSERVICES/SOAP/DDserverWeb.php +++ b/src/DDSERVICES/SOAP/DDserverWeb.php @@ -307,20 +307,45 @@ } } +/** +* Returns date of last modif of *times.nc in DD Base +*/ + function getLastUpdate($dataSet) + { + $referXML = baseDir."/DDsys.xml"; + $DDsys = new DOMDocument("1.0"); + $DDsys->load($referXML); + $xp = new domxpath($DDsys); + $VI = $xp->query("//NAME[.='".$dataSet."']"); + + if ($VI->item(0)->nodeValue != NULL) + { + $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue; + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue; + if (!file_exists($location.$times)) + return null; + + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS + $dateModif = exec($cmd); + return $dateModif; + } + + return null; + } + /** * Returns String Start-Stop for local DataSet in DD Base */ function getStartStop($dataSet) { - if ($dataSet != "compound") { - $referFile = baseDir."/refer.nc"; - $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet; - $res = system($cmd); - - return $res; - } + + $referFile = baseDir."/refer.nc"; + $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet; + $res = system($cmd); + + return $res; } /** diff --git a/src/DDSERVICES/SOAP/dd.wsdl.in b/src/DDSERVICES/SOAP/dd.wsdl.in index 1c089c8..bb8a2a4 100644 --- a/src/DDSERVICES/SOAP/dd.wsdl.in +++ b/src/DDSERVICES/SOAP/dd.wsdl.in @@ -62,6 +62,12 @@ <message name='getStartStopResponse'> <part name='Result' type='xsd:string'/> </message> +<message name='getLastUpdateRequest'> + <part name='dataSet' type='xsd:string'/> +</message> +<message name='getLastUpdateResponse'> + <part name='Result' type='xsd:string'/> +</message> <message name='getInfoRequest'> <part name='dataSet' type='xsd:string'/> <part name='infoName' type='xsd:string'/> @@ -147,6 +153,10 @@ <operation name='getStartStop'> <input message='tns:getStartStopRequest'/> <output message='tns:getStartStopResponse'/> + </operation> + <operation name='getLastUpdate'> + <input message='tns:getLastUpdateRequest'/> + <output message='tns:getLastUpdateResponse'/> </operation> <operation name='getInfo'> <input message='tns:getInfoRequest'/> @@ -240,7 +250,18 @@ <soap:body use='encoded' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> - </operation> + </operation> + <operation name='getLastUpdate'> + <soap:operation soapAction='getLastUpdate'/> + <input> + <soap:body use='encoded' + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> + </input> + <output> + <soap:body use='encoded' + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> + </output> + </operation> <operation name='getInfo'> <soap:operation soapAction='getSInfo'/> <input> -- libgit2 0.21.2