Commit c6b373223add8b0b21a70c2d6b13566456b25e2e

Authored by Elena.Budnik
1 parent d1b01060

data version : new service

src/DDSERVICES/REST/getLastUpdate.php 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +<?php
  2 +
  3 +/**
  4 +* @file getLastUpdate.php
  5 +* @brief Returns last modif of *_times.nc for a given DataSet
  6 +* @version $Id: $
  7 +*/
  8 +
  9 + if (!$_GET['id']) exit('INPUT ERROR');
  10 + require_once './DDserverWeb_ini.php';
  11 + error_reporting(E_ERROR | E_WARNING | E_PARSE);
  12 +
  13 + $replace = array("-" => "_");
  14 +
  15 + $dataSet = strtr($_GET['id'], $replace);
  16 +
  17 + $referXML = baseDir."DDsys.xml";
  18 + $DDsys = new DOMDocument("1.0");
  19 + $DDsys->load($referXML);
  20 + $xp = new domxpath($DDsys);
  21 + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']");
  22 +
  23 + if ($VI_NAME->item(0)->nodeValue != NULL)
  24 + {
  25 + $VI = $VI_NAME->item(0)->parentNode;
  26 + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  27 + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue;
  28 + if (!file_exists($location.$times))
  29 + exit('NO TIMES FILE');
  30 +
  31 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS
  32 + $dateModif = exec($cmd);
  33 + exit($dateModif);
  34 + }
  35 + else {
  36 + exit('NO SUCH DATASET');
  37 + }
  38 +?>
... ...
src/DDSERVICES/REST/getStartStop.php 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +<?php
  2 +
  3 +/**
  4 +* @file getStartStop.php
  5 +* @brief Returns GlobalStart - GlobalStop for a given DataSet
  6 +* @version $Id: $
  7 +*/
  8 +
  9 + if (!$_GET['id']) exit('INPUT ERROR');
  10 + require_once './DDserverWeb_ini.php';
  11 + error_reporting(E_ERROR | E_WARNING | E_PARSE);
  12 +
  13 + $replace = array("-" => "_");
  14 +
  15 + $dataSet = strtr($_GET['id'], $replace);
  16 +
  17 + $referXML = baseDir."DDsys.xml";
  18 + $DDsys = new DOMDocument("1.0");
  19 + $DDsys->load($referXML);
  20 + $xp = new domxpath($DDsys);
  21 + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']");
  22 +
  23 + if ($VI_NAME->item(0)->nodeValue != NULL)
  24 + {
  25 + $VI = $VI_NAME->item(0)->parentNode;
  26 + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  27 + $info = basename($VI->getElementsByTagName("INFO")->item(0)->nodeValue, '.nc').'.xml';
  28 + if (!file_exists($location.$info))
  29 + exit('NO INFO XML');
  30 +
  31 + $infoDom = new DOMDocument("1.0");
  32 + $infoDom->loadXML(file_get_contents($location.$info)); // for NFS
  33 +
  34 + $Start = $infoDom->getElementsByTagName("GlobalStart")->item(0)->nodeValue;
  35 + $Stop = $infoDom->getElementsByTagName("GlobalStop")->item(0)->nodeValue;
  36 + exit($Start.",".$Stop);
  37 + }
  38 + else {
  39 + exit('NO SUCH DATASET');
  40 + }
  41 +?>
... ...
src/DDSERVICES/SOAP/DDserverWeb.php
... ... @@ -307,20 +307,45 @@
307 307 }
308 308 }
309 309  
  310 +/**
  311 +* Returns date of last modif of *times.nc in DD Base
  312 +*/
310 313  
  314 + function getLastUpdate($dataSet)
  315 + {
  316 + $referXML = baseDir."/DDsys.xml";
  317 + $DDsys = new DOMDocument("1.0");
  318 + $DDsys->load($referXML);
  319 + $xp = new domxpath($DDsys);
  320 + $VI = $xp->query("//NAME[.='".$dataSet."']");
  321 +
  322 + if ($VI->item(0)->nodeValue != NULL)
  323 + {
  324 + $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  325 + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue;
  326 + if (!file_exists($location.$times))
  327 + return null;
  328 +
  329 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS
  330 + $dateModif = exec($cmd);
  331 + return $dateModif;
  332 + }
  333 +
  334 + return null;
  335 + }
  336 +
311 337 /**
312 338 * Returns String Start-Stop for local DataSet in DD Base
313 339 */
314 340  
315 341 function getStartStop($dataSet)
316 342 {
317   - if ($dataSet != "compound") {
318   - $referFile = baseDir."/refer.nc";
319   - $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet;
320   - $res = system($cmd);
321   -
322   - return $res;
323   - }
  343 +
  344 + $referFile = baseDir."/refer.nc";
  345 + $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet;
  346 + $res = system($cmd);
  347 +
  348 + return $res;
324 349 }
325 350  
326 351 /**
... ...
src/DDSERVICES/SOAP/dd.wsdl.in
... ... @@ -62,6 +62,12 @@
62 62 <message name='getStartStopResponse'>
63 63 <part name='Result' type='xsd:string'/>
64 64 </message>
  65 +<message name='getLastUpdateRequest'>
  66 + <part name='dataSet' type='xsd:string'/>
  67 +</message>
  68 +<message name='getLastUpdateResponse'>
  69 + <part name='Result' type='xsd:string'/>
  70 +</message>
65 71 <message name='getInfoRequest'>
66 72 <part name='dataSet' type='xsd:string'/>
67 73 <part name='infoName' type='xsd:string'/>
... ... @@ -147,6 +153,10 @@
147 153 <operation name='getStartStop'>
148 154 <input message='tns:getStartStopRequest'/>
149 155 <output message='tns:getStartStopResponse'/>
  156 + </operation>
  157 + <operation name='getLastUpdate'>
  158 + <input message='tns:getLastUpdateRequest'/>
  159 + <output message='tns:getLastUpdateResponse'/>
150 160 </operation>
151 161 <operation name='getInfo'>
152 162 <input message='tns:getInfoRequest'/>
... ... @@ -240,7 +250,18 @@
240 250 <soap:body use='encoded'
241 251 encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
242 252 </output>
243   - </operation>
  253 + </operation>
  254 + <operation name='getLastUpdate'>
  255 + <soap:operation soapAction='getLastUpdate'/>
  256 + <input>
  257 + <soap:body use='encoded'
  258 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  259 + </input>
  260 + <output>
  261 + <soap:body use='encoded'
  262 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  263 + </output>
  264 + </operation>
244 265 <operation name='getInfo'>
245 266 <soap:operation soapAction='getSInfo'/>
246 267 <input>
... ...