Commit 954c1dea39b3a5caa7071cae26a09d4f6ede8dee
1 parent
a865d59e
Exists in
master
and in
9 other branches
methode getLastRealUpdate()
Showing
3 changed files
with
88 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php | ||
2 | +/** | ||
3 | +* @file getLastRealUpdate.php | ||
4 | +* @brief Returns modif date of the last modified data file (*.nc.gz) for a given DataSet | ||
5 | +* @version $Id: $ | ||
6 | +*/ | ||
7 | + | ||
8 | + if (!isset($_GET['id'])) exit('INPUT ERROR'); | ||
9 | + | ||
10 | + require_once './DDserverWeb_ini.php'; | ||
11 | + | ||
12 | + error_reporting(E_ERROR | E_WARNING | E_PARSE); | ||
13 | + | ||
14 | + $replace = array("-" => "_"); | ||
15 | + | ||
16 | + $dataSet = strtr($_GET['id'], $replace); | ||
17 | + | ||
18 | + $referXML = baseDir."/DDsys.xml"; | ||
19 | + $DDsys = new DOMDocument("1.0"); | ||
20 | + $DDsys->load($referXML); | ||
21 | + $xp = new domxpath($DDsys); | ||
22 | + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']"); | ||
23 | + | ||
24 | + if ($VI_NAME->item(0)->nodeValue != NULL) | ||
25 | + { | ||
26 | + $VI = $VI_NAME->item(0)->parentNode; | ||
27 | + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue; | ||
28 | + $find = 'find '.$location.'*.nc.gz -type f -printf \'%T@ %p\n\' | sort -n | tail -1 | cut -f2- -d" "'; | ||
29 | + $lastFile = exec($find); | ||
30 | + if (!file_exists($lastFile)) | ||
31 | + exit('NO SUCH FILE '.$lastFile); | ||
32 | + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS | ||
33 | + $dateModif = exec($cmd); | ||
34 | + exit($dateModif); | ||
35 | + } | ||
36 | + else { | ||
37 | + exit('NO SUCH DATASET'); | ||
38 | + } | ||
39 | +?> |
src/DDSERVICES/SOAP/DDserverWeb.php
@@ -335,6 +335,34 @@ | @@ -335,6 +335,34 @@ | ||
335 | } | 335 | } |
336 | 336 | ||
337 | /** | 337 | /** |
338 | +* Returns modif date of the last modified data file (*.nc.gz) for a given DataSet | ||
339 | +*/ | ||
340 | + | ||
341 | + function getLastRealUpdate($dataSet) | ||
342 | + { | ||
343 | + $referXML = baseDir."/DDsys.xml"; | ||
344 | + $DDsys = new DOMDocument("1.0"); | ||
345 | + $DDsys->load($referXML); | ||
346 | + $xp = new domxpath($DDsys); | ||
347 | + $VI = $xp->query("//NAME[.='".$dataSet."']"); | ||
348 | + | ||
349 | + if ($VI->item(0)->nodeValue != NULL) | ||
350 | + { | ||
351 | + $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue; | ||
352 | + $lastFile = exec($find); | ||
353 | + if (!file_exists($lastFile)) | ||
354 | + exit('NO SUCH FILE '.$lastFile); | ||
355 | + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS | ||
356 | + | ||
357 | + $dateModif = exec($cmd); | ||
358 | + return $dateModif; | ||
359 | + } | ||
360 | + | ||
361 | + return null; | ||
362 | + } | ||
363 | + | ||
364 | + | ||
365 | +/** | ||
338 | * Returns String Start-Stop for local DataSet in DD Base | 366 | * Returns String Start-Stop for local DataSet in DD Base |
339 | */ | 367 | */ |
340 | 368 |
src/DDSERVICES/SOAP/dd.wsdl.in
@@ -68,6 +68,12 @@ | @@ -68,6 +68,12 @@ | ||
68 | <message name='getLastUpdateResponse'> | 68 | <message name='getLastUpdateResponse'> |
69 | <part name='Result' type='xsd:string'/> | 69 | <part name='Result' type='xsd:string'/> |
70 | </message> | 70 | </message> |
71 | +<message name='getLastRealUpdateRequest'> | ||
72 | + <part name='dataSet' type='xsd:string'/> | ||
73 | +</message> | ||
74 | +<message name='getLastRealUpdateResponse'> | ||
75 | + <part name='Result' type='xsd:string'/> | ||
76 | +</message> | ||
71 | <message name='getInfoRequest'> | 77 | <message name='getInfoRequest'> |
72 | <part name='dataSet' type='xsd:string'/> | 78 | <part name='dataSet' type='xsd:string'/> |
73 | <part name='infoName' type='xsd:string'/> | 79 | <part name='infoName' type='xsd:string'/> |
@@ -157,6 +163,10 @@ | @@ -157,6 +163,10 @@ | ||
157 | <operation name='getLastUpdate'> | 163 | <operation name='getLastUpdate'> |
158 | <input message='tns:getLastUpdateRequest'/> | 164 | <input message='tns:getLastUpdateRequest'/> |
159 | <output message='tns:getLastUpdateResponse'/> | 165 | <output message='tns:getLastUpdateResponse'/> |
166 | + </operation> | ||
167 | + <operation name='getLastRealUpdate'> | ||
168 | + <input message='tns:getLastRealUpdateRequest'/> | ||
169 | + <output message='tns:getLastRealUpdateResponse'/> | ||
160 | </operation> | 170 | </operation> |
161 | <operation name='getInfo'> | 171 | <operation name='getInfo'> |
162 | <input message='tns:getInfoRequest'/> | 172 | <input message='tns:getInfoRequest'/> |
@@ -261,6 +271,17 @@ | @@ -261,6 +271,17 @@ | ||
261 | <soap:body use='encoded' | 271 | <soap:body use='encoded' |
262 | encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | 272 | encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> |
263 | </output> | 273 | </output> |
274 | + </operation> | ||
275 | + <operation name='getLastRealUpdate'> | ||
276 | + <soap:operation soapAction='getLastRealUpdate'/> | ||
277 | + <input> | ||
278 | + <soap:body use='encoded' | ||
279 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | ||
280 | + </input> | ||
281 | + <output> | ||
282 | + <soap:body use='encoded' | ||
283 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | ||
284 | + </output> | ||
264 | </operation> | 285 | </operation> |
265 | <operation name='getInfo'> | 286 | <operation name='getInfo'> |
266 | <soap:operation soapAction='getSInfo'/> | 287 | <soap:operation soapAction='getSInfo'/> |