Commit ca5a298da231a01f7f46bc3eb653bf0c18bac16a
1 parent
17a56975
Exists in
master
and in
1 other branch
WIP
Showing
3 changed files
with
86 additions
and
6 deletions
Show diff stats
... | ... | @@ -0,0 +1,66 @@ |
1 | + | |
2 | +/** @file GetModificationDate.c | |
3 | +* @brief Stand-alone executable <br> Returns modification date for given VI in DDBase <br> | |
4 | +* | |
5 | +* @details GetModificationDate(string *) <br> | |
6 | +* @arg \c argv[1] Full name of *_times.nc | |
7 | +* | |
8 | +*/ | |
9 | + | |
10 | + | |
11 | +#include <stdlib.h> | |
12 | +#include <stdio.h> | |
13 | +#include <string.h> | |
14 | +#include <time.h> | |
15 | +#include <sys/stat.h> | |
16 | +#include <math.h> | |
17 | +#include <netcdf.h> | |
18 | +#include <DD.h> | |
19 | + | |
20 | + | |
21 | +int DataID, StartID; | |
22 | +double StartStamp; | |
23 | +char StartT[TIMELENGTH]; | |
24 | +size_t count[2] = {1L,TIMELENGTH}; | |
25 | +size_t start[2] = {0L,0L}; | |
26 | + | |
27 | +/*---------------- NC ERROR --------------------------------------*/ | |
28 | +void nc_handle_error(int status) | |
29 | +{ | |
30 | + fprintf(stderr, "%s\n", nc_strerror(status)); | |
31 | + exit(1); | |
32 | +} | |
33 | + | |
34 | +/* ----------------------- MAIN ------------------------------------*/ | |
35 | +int main(int argc, char *argv[]) | |
36 | +{ | |
37 | + int status, len; | |
38 | + | |
39 | + if (argc < 2){ | |
40 | + fprintf(stderr,"Usage: GetStartTime *_times.nc\n"); | |
41 | + exit(1); | |
42 | + } | |
43 | + | |
44 | + // Open VI_times.nc | |
45 | + if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR) | |
46 | + nc_handle_error(status); | |
47 | + | |
48 | + char* modificationDate = (char *) malloc(21); | |
49 | + memset(modificationDate, 0, 21*sizeof(char)); | |
50 | + if ((status = nc_get_att_text(DataID, NC_GLOBAL, "ModificationDate", modificationDate)) != NC_NOERR) { | |
51 | + struct stat b; | |
52 | + if (!stat(argv[1], &b)) { | |
53 | + strftime(modificationDate, 100, "%Y-%m-%dT%H:%M:%SZ", localtime( &b.st_mtime)); | |
54 | + } | |
55 | + } | |
56 | + | |
57 | + nc_close(DataID); | |
58 | + | |
59 | + if (strcmp(modificationDate, "") == 0) { | |
60 | + exit(1); | |
61 | + } | |
62 | + | |
63 | + printf("%s\n", modificationDate); | |
64 | + | |
65 | + exit(0); | |
66 | +} | ... | ... |
src/DDSERVICES/SOAP/DDserverWeb.php
... | ... | @@ -132,9 +132,23 @@ function getDatasetsModificationDates() |
132 | 132 | $timesNode = $timesNode->item(0); |
133 | 133 | $timesFile = $location.$timesNode->nodeValue; |
134 | 134 | if (!empty($location) && !empty($viName)) { |
135 | + | |
136 | + // Release date | |
137 | + $releaseDate = NULL; | |
138 | + $find = 'find '.$location.' -name \'*.nc.gz\' -type f -printf \'%T@ %p\n\' | sort -n | tail -1 | cut -f2- -d" "'; | |
139 | + $lastFile = exec($find); | |
140 | + if (file_exists($lastFile)) { | |
141 | + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS | |
142 | + | |
143 | + $releaseDate = exec($cmd); | |
144 | + } | |
145 | + | |
146 | + // Modification date | |
147 | + | |
148 | + | |
135 | 149 | $result[] = array( |
136 | 150 | 'vi' => $viName, |
137 | - 'releaseDate' => "2008-01-01T00:00:00.000Z", | |
151 | + 'releaseDate' => $releaseDate, | |
138 | 152 | 'modificationDate' => "2018-01-01T00:00:00.000Z", |
139 | 153 | ); |
140 | 154 | } | ... | ... |
src/DDSERVICES/SOAP/dd.wsdl.in
... | ... | @@ -187,9 +187,9 @@ |
187 | 187 | <message name='getDatasetsWithTimeRestrictionResponse'> |
188 | 188 | <part name='Result' type='tns:ListOfDatasetTimeRestrictionData'/> |
189 | 189 | </message> |
190 | -<message name='getDatasetsModficationDatesRequest'> | |
190 | +<message name='getDatasetsModificationDatesRequest'> | |
191 | 191 | </message> |
192 | -<message name='getDatasetsModficationDatesResponse'> | |
192 | +<message name='getDatasetsModificationDatesResponse'> | |
193 | 193 | <part name='Result' type='tns:ListOfDatasetModificationDate'/> |
194 | 194 | </message> |
195 | 195 | |
... | ... | @@ -274,9 +274,9 @@ |
274 | 274 | <input message='tns:getDatasetsWithTimeRestrictionRequest'/> |
275 | 275 | <output message='tns:getDatasetsWithTimeRestrictionResponse'/> |
276 | 276 | </operation> |
277 | - <operation name='getDatasetsModficationDates'> | |
278 | - <input message='tns:getDatasetsModficationDatesRequest'/> | |
279 | - <output message='tns:getDatasetsModficationDatesResponse'/> | |
277 | + <operation name='getDatasetsModificationDates'> | |
278 | + <input message='tns:getDatasetsModificationDatesRequest'/> | |
279 | + <output message='tns:getDatasetsModificationDatesResponse'/> | |
280 | 280 | </operation> |
281 | 281 | |
282 | 282 | ... | ... |