From 954c1dea39b3a5caa7071cae26a09d4f6ede8dee Mon Sep 17 00:00:00 2001 From: Elena.Budnik Date: Wed, 27 Feb 2019 12:24:16 +0100 Subject: [PATCH] methode getLastRealUpdate() --- src/DDSERVICES/REST/getLastRealUpdate.php | 39 +++++++++++++++++++++++++++++++++++++++ src/DDSERVICES/SOAP/DDserverWeb.php | 28 ++++++++++++++++++++++++++++ src/DDSERVICES/SOAP/dd.wsdl.in | 21 +++++++++++++++++++++ 3 files changed, 88 insertions(+), 0 deletions(-) create mode 100644 src/DDSERVICES/REST/getLastRealUpdate.php diff --git a/src/DDSERVICES/REST/getLastRealUpdate.php b/src/DDSERVICES/REST/getLastRealUpdate.php new file mode 100644 index 0000000..041be6e --- /dev/null +++ b/src/DDSERVICES/REST/getLastRealUpdate.php @@ -0,0 +1,39 @@ + "_"); + + $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; + $find = 'find '.$location.'*.nc.gz -type f -printf \'%T@ %p\n\' | sort -n | tail -1 | cut -f2- -d" "'; + $lastFile = exec($find); + if (!file_exists($lastFile)) + exit('NO SUCH FILE '.$lastFile); + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS + $dateModif = exec($cmd); + exit($dateModif); + } + else { + exit('NO SUCH DATASET'); + } +?> diff --git a/src/DDSERVICES/SOAP/DDserverWeb.php b/src/DDSERVICES/SOAP/DDserverWeb.php index e8b872e..f768fb5 100644 --- a/src/DDSERVICES/SOAP/DDserverWeb.php +++ b/src/DDSERVICES/SOAP/DDserverWeb.php @@ -335,6 +335,34 @@ } /** +* Returns modif date of the last modified data file (*.nc.gz) for a given DataSet +*/ + + function getLastRealUpdate($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; + $lastFile = exec($find); + if (!file_exists($lastFile)) + exit('NO SUCH FILE '.$lastFile); + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS + + $dateModif = exec($cmd); + return $dateModif; + } + + return null; + } + + +/** * Returns String Start-Stop for local DataSet in DD Base */ diff --git a/src/DDSERVICES/SOAP/dd.wsdl.in b/src/DDSERVICES/SOAP/dd.wsdl.in index bb8a2a4..e4d15fa 100644 --- a/src/DDSERVICES/SOAP/dd.wsdl.in +++ b/src/DDSERVICES/SOAP/dd.wsdl.in @@ -68,6 +68,12 @@ + + + + + + @@ -157,6 +163,10 @@ + + + + @@ -261,6 +271,17 @@ + + + + + + + + + -- libgit2 0.21.2