Commit 9ecc3961f4dc76416278c8098b7f154985205058
1 parent
996432ce
Exists in
master
and in
9 other branches
nc var name; cors headers, http code 404
Showing
4 changed files
with
15 additions
and
34 deletions
Show diff stats
src/DDSERVICES/HAPI/capabilities.php
... | ... | @@ -6,5 +6,8 @@ |
6 | 6 | $response["outputFormats"] = array("csv"); |
7 | 7 | |
8 | 8 | header('Content-Type: application/json'); |
9 | + header("Access-Control-Allow-Origin: *"); | |
10 | + header("Access-Control-Allow-Methods: GET"); //'Access-Control-Allow-{Origin,Methods} = {*, GET}'); | |
11 | + | |
9 | 12 | exit(json_encode($response)); |
10 | 13 | ?> | ... | ... |
src/DDSERVICES/HAPI/catalog.php
... | ... | @@ -14,5 +14,8 @@ |
14 | 14 | $response["catalog"] = $catalog; |
15 | 15 | |
16 | 16 | header('Content-Type: application/json'); |
17 | + header("Access-Control-Allow-Origin: *"); | |
18 | + header("Access-Control-Allow-Methods: GET"); //'Access-Control-Allow-{Origin,Methods} = {*, GET}'); | |
19 | + | |
17 | 20 | exit(json_encode($response)); |
18 | 21 | ?> | ... | ... |
src/DDSERVICES/HAPI/data.php
... | ... | @@ -60,36 +60,8 @@ |
60 | 60 | |
61 | 61 | $ddId = strtr($id, "-", "_"); |
62 | 62 | |
63 | - if ($params) { | |
64 | - $pattern = "$id.xml"; | |
65 | - $files = rglob($pattern); | |
66 | - | |
67 | - $xmlName = $files[0]; | |
68 | - $dom = new DomDocument("1.0"); | |
69 | - $dom->load($xmlName); | |
70 | - | |
71 | - $dataset = $dom->getElementsByTagName("Spase")->item(0); | |
72 | - $paramsInSpase = $dataset->getElementsByTagName('Parameter'); | |
73 | - | |
74 | - $paramArray = explode(",", $params); | |
75 | - $paramsInNc = ""; | |
76 | - // params : get ncVar name | |
77 | - $paramDom = new DomDocument("1.0"); | |
78 | - | |
79 | - foreach ($paramsInSpase as $param) { | |
80 | - $name = $param->getElementsByTagName('Name')->item(0)->nodeValue; | |
81 | - if (in_array($name, $paramArray)) { | |
82 | - $paramId = $param->getElementsByTagName('ParameterKey')->item(0)->nodeValue; | |
83 | - if (file_exists("$METADATA_DIR/$paramId.xml")) { | |
84 | - $paramDom->load("$METADATA_DIR/$paramId.xml"); | |
85 | - $baseParam = $paramDom->getElementsByTagName("baseParam")->item(0); | |
86 | - $paramsInNc .= $baseParam->getAttribute('name').","; | |
87 | - } | |
88 | - } | |
89 | - } | |
90 | - $paramList = substr($paramsInNc, 0, -1); | |
91 | - | |
92 | - $cmd = "python -u reader.py -tmin $tmin -tmax $tmax -id $ddId -param $paramList"; | |
63 | + if ($params) { | |
64 | + $cmd = "python -u reader.py -tmin $tmin -tmax $tmax -id $ddId -param $params"; | |
93 | 65 | } |
94 | 66 | else { |
95 | 67 | $cmd = "python -u reader.py -tmin $tmin -tmax $tmax -id $ddId"; | ... | ... |
src/DDSERVICES/HAPI/info.php
... | ... | @@ -36,6 +36,7 @@ |
36 | 36 | $xmlName = $files[0]; |
37 | 37 | |
38 | 38 | if (!file_exists($xmlName)) {; |
39 | + header("HTTP/1.1 404 NO SUCH ID"); | |
39 | 40 | $response["status"] = array("code" => 1406, "message" => "NO SUCH ID"); |
40 | 41 | exit(json_encode($response)); |
41 | 42 | } |
... | ... | @@ -47,7 +48,8 @@ |
47 | 48 | |
48 | 49 | $parameters = $dataset->getElementsByTagName('Parameter'); |
49 | 50 | if ( $parameters->length == 0 ) { |
50 | - $response["status"] = array("code" => 404, "message" => "NO PARAMETERS"); | |
51 | + header("HTTP/1.1 404 NO PARAMETERS"); | |
52 | + $response["status"] = array("code" => 1406, "message" => "NO PARAMETERS"); | |
51 | 53 | exit(json_encode($response)); |
52 | 54 | } |
53 | 55 | |
... | ... | @@ -56,13 +58,14 @@ |
56 | 58 | $parametersResponse = array(array("name" => "Time", "type" => "isotime", "length" => 20, "units" => "", "fill" =>"")); |
57 | 59 | foreach ( $parameters as $param ) { |
58 | 60 | $oneParam = array(); |
59 | - $oneParam["name"] = $param->getElementsByTagName('Name')->item(0)->nodeValue; | |
60 | 61 | $oneParam["type"] = "double"; |
61 | 62 | $paramId = $param->getElementsByTagName('ParameterKey')->item(0)->nodeValue; |
62 | 63 | if (file_exists("$METADATA_DIR/$paramId.xml")) { |
63 | 64 | $paramDom->load("$METADATA_DIR/$paramId.xml"); |
64 | 65 | $process = $paramDom->getElementsByTagName("process")->item(0)->nodeValue; |
65 | - if (!$process) { | |
66 | + if (!$process) { | |
67 | + $baseParam = $paramDom->getElementsByTagName("baseParam")->item(0); | |
68 | + $oneParam["name"] = $baseParam->getAttribute('name'); | |
66 | 69 | $oneParam["description"] = $param->getElementsByTagName('Description')->item(0)->nodeValue; |
67 | 70 | $oneParam["fill"] = $param->getElementsByTagName('FillValue')->item(0)->nodeValue; |
68 | 71 | $oneParam["units"] = $param->getElementsByTagName('Units')->item(0)->nodeValue; |
... | ... | @@ -70,7 +73,7 @@ |
70 | 73 | if ($size->length > 0) { |
71 | 74 | $oneParam["size"] = array(intval($size->item(0)->nodeValue)); |
72 | 75 | } |
73 | - if ($paramRequest && !in_array($param->getElementsByTagName('Name')->item(0)->nodeValue, $paramRequest)) { | |
76 | + if ($paramRequest && !in_array($baseParam->getAttribute('name'), $paramRequest)) { | |
74 | 77 | // |
75 | 78 | } else { |
76 | 79 | $parametersResponse[] = $oneParam; | ... | ... |