Commit 251a97ec9be851f4237e7cc0fedb84c603e1b50e
Exists in
master
and in
95 other branches
Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_IHM
Showing
34 changed files
with
1405 additions
and
306 deletions
Show diff stats
js/app/models/PlotObjects/MultiplotRequestObject.js
... | ... | @@ -67,6 +67,25 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { |
67 | 67 | return newPlotNode; |
68 | 68 | }, |
69 | 69 | |
70 | + overwritePlot: function(plotNode, targetPlotNode) { | |
71 | + var targetIndex = -1; | |
72 | + this.plots().each(function(node, index) { | |
73 | + if (node == targetPlotNode) { | |
74 | + targetIndex = index; | |
75 | + } | |
76 | + }); | |
77 | + if (targetIndex < 0) { | |
78 | + //Target not exists in multiplot node => add it | |
79 | + this.plots().add(targetPlotNode); | |
80 | + targetIndex = this.plots().count() - 1; | |
81 | + } | |
82 | + var data = plotNode.get('object').getJsonValues(); | |
83 | + data.id = targetPlotNode.get('id'); | |
84 | + targetPlotNode.set('object', Ext.create('amdaPlotObj.PlotRequestObject', data)); | |
85 | + plotNode.get('object').reject(); | |
86 | + return targetPlotNode; | |
87 | + }, | |
88 | + | |
70 | 89 | createNewPlotFromObject: function(plotObject) { |
71 | 90 | var plotNode = Ext.create('amdaModel.PlotNode', { |
72 | 91 | leaf : true |
... | ... |
js/app/views/PlotComponents/PlotTabContent.js
... | ... | @@ -112,27 +112,40 @@ Ext.define('amdaPlotComp.PlotTabContent', { |
112 | 112 | }); |
113 | 113 | }, |
114 | 114 | |
115 | - saveProcess : function(toRename) { | |
115 | + saveProcess : function(overwriteExistingNode) { | |
116 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
117 | + if (!plotModule) | |
118 | + return; | |
119 | + | |
116 | 120 | var me = this; |
117 | - if (toRename) { | |
121 | + if (overwriteExistingNode) { | |
118 | 122 | this.updateTimeObject(); |
119 | - this.plotNode.update({plot: true, callback: function() { | |
120 | - me.setPlotNode(me.plotNode); //to update initial request data | |
121 | - me.plotTabPanel.updatePlotTabs(); | |
122 | - }}); | |
123 | + amdaModel.InteractiveNode.preloadNodes(this.plotNode.getRootNode(), function () { | |
124 | + var targetPlotNode = me.plotNode.getRootNode().findChild('text', me.plotNode.get('object').get('name'), true); | |
125 | + if (!targetPlotNode) { | |
126 | + myDesktopApp.errorMsg('Cannot retrieve request node'); | |
127 | + return; | |
128 | + } | |
129 | + targetPlotNode = plotModule.linkedNode.get('object').overwritePlot(me.plotNode, targetPlotNode); | |
130 | + if (targetPlotNode) { | |
131 | + //Reject modifications in old plot node | |
132 | + me.resetModif(); | |
133 | + targetPlotNode.update({plot: true, callback: function() { | |
134 | + me.setPlotNode(targetPlotNode); | |
135 | + me.plotTabPanel.updatePlotTabs(); | |
136 | + me.updateUI(); | |
137 | + }}); | |
138 | + } | |
139 | + }); | |
123 | 140 | } |
124 | 141 | else { |
125 | 142 | if (this.plotNode.get('object').get('id') != '') { |
126 | 143 | //Duplicate request |
127 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
128 | - if (!plotModule) | |
129 | - return; | |
130 | - var newPlotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); | |
144 | + var newPlotNode = this.plotTabPanel.duplicatePlotNode(this.plotNode); | |
131 | 145 | if (newPlotNode) { |
132 | 146 | //Reject modifications in old plot node |
133 | - this.plotNode.reject(); | |
134 | - this.plotNode.set('object', Ext.create('amdaPlotObj.PlotRequestObject', this.initialObjectData)); | |
135 | - //Set new plot node | |
147 | + this.resetModif(); | |
148 | + //Set new plot node to the current tab | |
136 | 149 | this.setPlotNode(newPlotNode); |
137 | 150 | } |
138 | 151 | } |
... | ... | @@ -146,6 +159,10 @@ Ext.define('amdaPlotComp.PlotTabContent', { |
146 | 159 | } |
147 | 160 | }, |
148 | 161 | |
162 | + resetModif : function() { | |
163 | + this.plotNode.set('object', Ext.create('amdaPlotObj.PlotRequestObject', this.initialObjectData)); | |
164 | + }, | |
165 | + | |
149 | 166 | getDataProcess : function() { |
150 | 167 | var downObject = amdaModel.DownloadNode.decodeObject(this.plotNode.get('object')); |
151 | 168 | amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); |
... | ... |
js/app/views/PlotComponents/PlotTabPanel.js
... | ... | @@ -88,10 +88,14 @@ Ext.define('amdaPlotComp.PlotTabPanel', { |
88 | 88 | }, |
89 | 89 | close: function( tab, eOpts ) { |
90 | 90 | if (tab.items.getAt(0).plotNode) { |
91 | + tab.items.getAt(0).resetModif(); | |
91 | 92 | this.multiplot_object.removePlotByInternalId(tab.items.getAt(0).plotNode.internalId); |
92 | 93 | } |
93 | 94 | }, |
94 | 95 | destroy: function(tab, eOpts) { |
96 | + if (tab.items.getAt(0) && tab.items.getAt(0).plotNode) { | |
97 | + tab.items.getAt(0).resetModif(); | |
98 | + } | |
95 | 99 | if (!this.tabbar_destroy) |
96 | 100 | this.updatePlotTabs(); |
97 | 101 | } |
... | ... | @@ -103,6 +107,14 @@ Ext.define('amdaPlotComp.PlotTabPanel', { |
103 | 107 | |
104 | 108 | return tabContent; |
105 | 109 | }, |
110 | + | |
111 | + duplicatePlotNode: function(plotNode) | |
112 | + { | |
113 | + var newPlotNode = this.multiplot_object.duplicatePlot(plotNode); | |
114 | + if (!newPlotNode) | |
115 | + return null; | |
116 | + return newPlotNode; | |
117 | + }, | |
106 | 118 | |
107 | 119 | updatePlotTabs: function() |
108 | 120 | { |
... | ... | @@ -119,6 +131,18 @@ Ext.define('amdaPlotComp.PlotTabPanel', { |
119 | 131 | } |
120 | 132 | }, |
121 | 133 | |
134 | + closePlotTabIfOpened: function(plotNodeToClose) { | |
135 | + for (i = 0; i < this.items.getCount(); ++i) | |
136 | + { | |
137 | + var tabItem = this.items.getAt(i); | |
138 | + var tabContent = tabItem.items.getAt(0); | |
139 | + var plotNode = tabContent.plotNode; | |
140 | + if (plotNode == renamedNode) { | |
141 | + this.remove(tabItem.getId()); | |
142 | + } | |
143 | + } | |
144 | + }, | |
145 | + | |
122 | 146 | updateRequestName: function(renamedNode) |
123 | 147 | { |
124 | 148 | for (i = 0; i < this.items.getCount(); ++i) |
... | ... |
php/RemoteDataCenter/IPIM.php
... | ... | @@ -136,7 +136,7 @@ class IPIM extends SimulationDataCenterClass |
136 | 136 | return $this->getFileName($resourceID); |
137 | 137 | } |
138 | 138 | |
139 | - public function getData($params) | |
139 | + public function getData($params, $isSpectra = false) | |
140 | 140 | { |
141 | 141 | // $r = print_r($params,true); |
142 | 142 | // error_log($params['accessUrl'],3,'/home/budnik/LOG'); |
... | ... |
php/RemoteDataCenter/LESIA.php
... | ... | @@ -300,7 +300,7 @@ class LESIA extends SimulationDataCenterClass |
300 | 300 | $TemplatesXml->save(RemoteData.$this->baseID."/".$this->templateFile); |
301 | 301 | } |
302 | 302 | |
303 | - public function getData($params) | |
303 | + public function getData($params, $isSpectra = false) | |
304 | 304 | { |
305 | 305 | // $r = print_r($params,true); |
306 | 306 | // error_log($r,3,'/home/budnik/LOG'); |
... | ... |
php/RemoteDataCenter/SimulationDataCenterClass.php
... | ... | @@ -445,7 +445,7 @@ class SimulationDataCenterClass extends RemoteDataCenterClass |
445 | 445 | $TemplatesXml->save(RemoteData.$this->baseID.'/'.$this->templateFile); |
446 | 446 | } |
447 | 447 | |
448 | - protected function createSpecialArgs($dom = null) | |
448 | + protected function createSpecialArgs($dom) | |
449 | 449 | { |
450 | 450 | return array(); |
451 | 451 | } |
... | ... |
... | ... | @@ -0,0 +1,83 @@ |
1 | +<?php | |
2 | + | |
3 | +abstract class TestAbstract | |
4 | +{ | |
5 | + abstract public function getAPI(); | |
6 | + | |
7 | + abstract public function getParams(); | |
8 | + | |
9 | + abstract public function getDescription(); | |
10 | + | |
11 | + abstract protected function checkRESTResult($result); | |
12 | + | |
13 | + abstract protected function checkSOAPResult($result); | |
14 | + | |
15 | + protected function needRESTAuth() { | |
16 | + return FALSE; | |
17 | + } | |
18 | + | |
19 | + public function getWSTypes() { | |
20 | + return array("REST", "SOAP"); | |
21 | + } | |
22 | + | |
23 | + public function runREST($base_url) { | |
24 | + $params = $this->getParams(); | |
25 | + if ($this->needRESTAuth()) { | |
26 | + $url = $base_url . '/php/rest/auth.php'; | |
27 | + $curl = curl_init(); | |
28 | + curl_setopt($curl, CURLOPT_URL, $url); | |
29 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
30 | + $token = curl_exec($curl); | |
31 | + if (curl_errno($curl) || empty($token)) { | |
32 | + echo "[ERROR] Cannot retrieve REST token".PHP_EOL; | |
33 | + return array( | |
34 | + 'success' => FALSE, | |
35 | + 'message' => "Cannot retrieve REST token", | |
36 | + ); | |
37 | + } | |
38 | + curl_close($curl); | |
39 | + $params['token'] = $token; | |
40 | + } | |
41 | + | |
42 | + $url = $base_url . '/php/rest/' . $this->getAPI() . '.php'; | |
43 | + if (!empty($params)) { | |
44 | + $url .= "?" . http_build_query($params); | |
45 | + } | |
46 | + $curl = curl_init(); | |
47 | + //ProxyUtils::addProxyForCurl($curl); | |
48 | + curl_setopt($curl, CURLOPT_URL, $url); | |
49 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
50 | + $result = curl_exec($curl); | |
51 | + if (curl_errno($curl)) { | |
52 | + return array( | |
53 | + 'success' => FALSE, | |
54 | + 'message' => 'Request error: '.curl_error($curl), | |
55 | + ); | |
56 | + } | |
57 | + $exec_time = curl_getinfo($curl, CURLINFO_TOTAL_TIME); | |
58 | + curl_close($curl); | |
59 | + return $this->checkRESTResult($result); | |
60 | + } | |
61 | + | |
62 | + public function runSOAP($base_url) { | |
63 | + $wsdl_url = $base_url . '/help/Methods_AMDA.xml'; | |
64 | + try { | |
65 | + $client = new SoapClient($wsdl_url, array( | |
66 | + //'proxy_host' => "localhost", | |
67 | + //'proxy_port' => 8080, | |
68 | + //'proxy_login' => "some_name", | |
69 | + //'proxy_password' => "some_password" | |
70 | + )); | |
71 | + $result = $client->__soapCall($this->getAPI(), array($this->getParams())); | |
72 | + } | |
73 | + catch (SoapFault $exception) { | |
74 | + return array( | |
75 | + 'success' => FALSE, | |
76 | + 'message' => 'SOAP error: '.$exception->getMessage(), | |
77 | + ); | |
78 | + } | |
79 | + return $this->checkSOAPResult($result); | |
80 | + } | |
81 | +} | |
82 | + | |
83 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,134 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "TestAbstract.php"; | |
4 | + | |
5 | +abstract class TestDownloadBase extends TestAbstract | |
6 | +{ | |
7 | + abstract protected function checkResultInfo($info); | |
8 | + | |
9 | + protected function checkRESTResult($result) { | |
10 | + if (empty($result)) { | |
11 | + return array( | |
12 | + 'success' => FALSE, | |
13 | + 'message' => 'Empty result', | |
14 | + ); | |
15 | + } | |
16 | + $json_res = json_decode($result); | |
17 | + if (!$json_res) { | |
18 | + return array( | |
19 | + 'success' => FALSE, | |
20 | + 'message' => 'Result is not in JSON format', | |
21 | + ); | |
22 | + } | |
23 | + $info = $this->getResultInfo($json_res); | |
24 | + if (!$info['success']) { | |
25 | + return $info; | |
26 | + } | |
27 | + return $this->checkResultInfo($info); | |
28 | + } | |
29 | + | |
30 | + protected function checkSOAPResult($result) { | |
31 | + $info = $this->getResultInfo($result); | |
32 | + if (!$info['success']) { | |
33 | + return $info; | |
34 | + } | |
35 | + return $this->checkResultInfo($info); | |
36 | + } | |
37 | + | |
38 | + private function gz_get_contents($path) { | |
39 | + $gzip = file_get_contents($path); | |
40 | + $rest = substr($gzip, -4); | |
41 | + $unpacked = unpack("V", $rest); | |
42 | + $uncompressedSize = end($unpacked); | |
43 | + | |
44 | + // read the gzipped content, specifying the exact length | |
45 | + $handle = gzopen($path, "rb"); | |
46 | + $contents = gzread($handle, $uncompressedSize); | |
47 | + gzclose($handle); | |
48 | + | |
49 | + return $contents; | |
50 | + } | |
51 | + | |
52 | + private function isCompressed($path) { | |
53 | + return (substr($path, -3) == ".gz"); | |
54 | + } | |
55 | + | |
56 | + private function isVOTable($path, $compressed) { | |
57 | + if ($compressed) { | |
58 | + $path = substr($path, 0, strlen($path)-3); | |
59 | + } | |
60 | + return (substr($path, -4) == ".vot"); | |
61 | + } | |
62 | + | |
63 | + private function getResultInfo($obj) { | |
64 | + if (empty($obj) || empty($obj->status)) { | |
65 | + return array( | |
66 | + 'success' => FALSE, | |
67 | + 'message' => 'Bad result format', | |
68 | + ); | |
69 | + } | |
70 | + | |
71 | + if ($obj->status != 'done') { | |
72 | + return array( | |
73 | + 'success' => FALSE, | |
74 | + 'message' => 'Status is not done ('.$obj->status.')', | |
75 | + ); | |
76 | + } | |
77 | + | |
78 | + if (empty($obj->dataFileURLs)) { | |
79 | + return array( | |
80 | + 'success' => FALSE, | |
81 | + 'message' => 'Missing data file URL in result', | |
82 | + ); | |
83 | + } | |
84 | + | |
85 | + $result = array( | |
86 | + 'success' => TRUE, | |
87 | + ); | |
88 | + | |
89 | + $result['compressed'] = $this->isCompressed($obj->dataFileURLs); | |
90 | + | |
91 | + if ($result['compressed']) { | |
92 | + $data = $this->gz_get_contents($obj->dataFileURLs); | |
93 | + } | |
94 | + else { | |
95 | + $data = file_get_contents($obj->dataFileURLs); | |
96 | + } | |
97 | + if (!$data) { | |
98 | + return array( | |
99 | + 'success' => FALSE, | |
100 | + 'message' => 'Cannot load data result file', | |
101 | + ); | |
102 | + } | |
103 | + | |
104 | + $result['isVOTable'] = $this->isVOTable($obj->dataFileURLs, $result['compressed']); | |
105 | + | |
106 | + $request_info = array(); | |
107 | + | |
108 | + foreach (explode(PHP_EOL, $data) as $line) { | |
109 | + $pattern = $result['isVOTable'] ? "REQUEST_" : "# REQUEST_"; | |
110 | + if (strpos($line, $pattern) === 0) { | |
111 | + $sep_pos = strpos($line, ":"); | |
112 | + if ($result['isVOTable']) | |
113 | + $key = trim(substr($line, 0, $sep_pos)); | |
114 | + else | |
115 | + $key = trim(substr($line, 2, $sep_pos-2)); | |
116 | + $value = trim(substr($line, $sep_pos+1)); | |
117 | + $request_info[$key] = $value; | |
118 | + } | |
119 | + } | |
120 | + | |
121 | + $result['parameters'] = array(); | |
122 | + if (!empty($request_info['REQUEST_OUTPUT_PARAMS'])) { | |
123 | + $result['parameters'] = explode(',',$request_info['REQUEST_OUTPUT_PARAMS']); | |
124 | + } | |
125 | + | |
126 | + $result['structure'] = !empty($request_info['REQUEST_STRUCTURE']) ? $request_info['REQUEST_STRUCTURE'] : ''; | |
127 | + $result['timeFormat'] = !empty($request_info['REQUEST_TIME_FORMAT']) ? $request_info['REQUEST_TIME_FORMAT'] : ''; | |
128 | + $result['sampling'] = !empty($request_info['REQUEST_TIME_RESOLUTION']) ? doubleval($request_info['REQUEST_TIME_RESOLUTION']) : NULL; | |
129 | + | |
130 | + return $result; | |
131 | + } | |
132 | +} | |
133 | + | |
134 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,68 @@ |
1 | +<?php | |
2 | + | |
3 | +function cmpTest($a, $b) { | |
4 | + if ($a == $b) { | |
5 | + return 0; | |
6 | + } | |
7 | + | |
8 | + list($prefix_a, $number_a) = sscanf($a, "%[A-Za-z]_%[0-9]"); | |
9 | + list($prefix_b, $number_b) = sscanf($b, "%[A-Za-z]_%[0-9]"); | |
10 | + | |
11 | + if (empty($number_a)) { | |
12 | + return -1; | |
13 | + } | |
14 | + else if (empty($number_b)) { | |
15 | + return 1; | |
16 | + } | |
17 | + | |
18 | + return (intval($number_a) < intval($number_b)) ? -1 : 1; | |
19 | +} | |
20 | + | |
21 | +class TestsSuite { | |
22 | + private $tests = NULL; | |
23 | + | |
24 | + function __construct() { | |
25 | + $this->tests = array(); | |
26 | + } | |
27 | + | |
28 | + public function init($tests_path) { | |
29 | + $this->tests = array(); | |
30 | + $files = array_diff(scandir($tests_path), array('.', '..')); | |
31 | + foreach ($files as $file) { | |
32 | + $name = basename($file, ".php"); | |
33 | + require_once($tests_path."/".$file); | |
34 | + $this->tests[$name] = new $name(); | |
35 | + } | |
36 | + uksort($this->tests, "cmpTest"); | |
37 | + } | |
38 | + | |
39 | + public function getDescriptions() { | |
40 | + return $this->run(TRUE); | |
41 | + } | |
42 | + | |
43 | + public function run($descriptionsOnly = FALSE) { | |
44 | + $results = array(); | |
45 | + foreach ($this->tests as $name => $test) { | |
46 | + $res = array(); | |
47 | + foreach ($test->getWSTypes() as $ws_type) { | |
48 | + $res = array( | |
49 | + "name" => $name, | |
50 | + "description" => $test->getDescription(), | |
51 | + "type" => $ws_type, | |
52 | + "api" => $test->getAPI(), | |
53 | + "params" => $test->getParams(), | |
54 | + "status" => NULL, | |
55 | + ); | |
56 | + if (!$descriptionsOnly) { | |
57 | + $runFunc = "run".$ws_type; | |
58 | + $res["status"] = $test->$runFunc(BASE_URL); | |
59 | + } | |
60 | + $results[] = $res; | |
61 | + } | |
62 | + | |
63 | + } | |
64 | + return $results; | |
65 | + } | |
66 | +} | |
67 | + | |
68 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,58 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetDataset_10 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getDataset"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "datasetID" => "mex-els-all", | |
20 | + ); | |
21 | + } | |
22 | + | |
23 | + public function getDescription() { | |
24 | + return "Get mex-els-all data. No sampling."; | |
25 | + } | |
26 | + | |
27 | + protected function checkResultInfo($info) { | |
28 | + if ($info['structure'] != 'all-in-one-file-refparam') { | |
29 | + return array( | |
30 | + 'success' => FALSE, | |
31 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
32 | + ); | |
33 | + } | |
34 | + if ($info['timeFormat'] != 'ISO 8601') { | |
35 | + return array( | |
36 | + 'success' => FALSE, | |
37 | + 'message' => 'Bad time format ('.$info['timeFormat'].')', | |
38 | + ); | |
39 | + } | |
40 | + if (!in_array('mex_els_spec_0', $info['parameters'])) { | |
41 | + return array( | |
42 | + 'success' => FALSE, | |
43 | + 'message' => 'Missing mex_els_spec_0 in result file', | |
44 | + ); | |
45 | + } | |
46 | + if (!in_array('mex_els_spec_sum', $info['parameters'])) { | |
47 | + return array( | |
48 | + 'success' => FALSE, | |
49 | + 'message' => 'Missing mex_els_spec_sum in result file', | |
50 | + ); | |
51 | + } | |
52 | + return array( | |
53 | + 'success' => TRUE, | |
54 | + ); | |
55 | + } | |
56 | +} | |
57 | + | |
58 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,71 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetDataset_11 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getDataset"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "datasetID" => "mex-els-all", | |
20 | + "sampling" => 60, | |
21 | + ); | |
22 | + } | |
23 | + | |
24 | + public function getDescription() { | |
25 | + return "Get mex-els-all data. Sampling 60s."; | |
26 | + } | |
27 | + | |
28 | + protected function checkResultInfo($info) { | |
29 | + if ($info['structure'] != 'all-in-one-file') { | |
30 | + return array( | |
31 | + 'success' => FALSE, | |
32 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
33 | + ); | |
34 | + } | |
35 | + if ($info['timeFormat'] != 'ISO 8601') { | |
36 | + return array( | |
37 | + 'success' => FALSE, | |
38 | + 'message' => 'Bad time format ('.$info['timeFormat'].')', | |
39 | + ); | |
40 | + } | |
41 | + if (!isset($info['sampling'])) { | |
42 | + return array( | |
43 | + 'success' => FALSE, | |
44 | + 'message' => 'Missing sampling time', | |
45 | + ); | |
46 | + } | |
47 | + else if ($info['sampling'] != 60) { | |
48 | + return array( | |
49 | + 'success' => FALSE, | |
50 | + 'message' => 'Bad sampling time ('.$info['sampling'].')', | |
51 | + ); | |
52 | + } | |
53 | + if (!in_array('mex_els_spec_0', $info['parameters'])) { | |
54 | + return array( | |
55 | + 'success' => FALSE, | |
56 | + 'message' => 'Missing mex_els_spec_0 in result file', | |
57 | + ); | |
58 | + } | |
59 | + if (!in_array('mex_els_spec_sum', $info['parameters'])) { | |
60 | + return array( | |
61 | + 'success' => FALSE, | |
62 | + 'message' => 'Missing mex_els_spec_sum in result file', | |
63 | + ); | |
64 | + } | |
65 | + return array( | |
66 | + 'success' => TRUE, | |
67 | + ); | |
68 | + } | |
69 | +} | |
70 | + | |
71 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetDataset_12 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getDataset"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "datasetID" => "mex-els-all", | |
20 | + "sampling" => 60, | |
21 | + "timeFormat" => "UNIXTIME", | |
22 | + ); | |
23 | + } | |
24 | + | |
25 | + public function getDescription() { | |
26 | + return "Get mex-els-all data. Sampling 60s. TimeFormat UNIXTIME"; | |
27 | + } | |
28 | + | |
29 | + protected function checkResultInfo($info) { | |
30 | + if ($info['timeFormat'] != 'Seconds from 1970, milliseconds') { | |
31 | + return array( | |
32 | + 'success' => FALSE, | |
33 | + 'message' => 'Bad time format ('.$info['timeFormat'].')', | |
34 | + ); | |
35 | + } | |
36 | + return array( | |
37 | + 'success' => TRUE, | |
38 | + ); | |
39 | + } | |
40 | +} | |
41 | + | |
42 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetDataset_13 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getDataset"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "datasetID" => "mex-els-all", | |
20 | + "sampling" => 60, | |
21 | + "gzip" => 1, | |
22 | + ); | |
23 | + } | |
24 | + | |
25 | + public function getDescription() { | |
26 | + return "Get mex-els-all data. Sampling 60s. Compressed result"; | |
27 | + } | |
28 | + | |
29 | + protected function checkResultInfo($info) { | |
30 | + if (!$info['compressed']) { | |
31 | + return array( | |
32 | + 'success' => FALSE, | |
33 | + 'message' => 'Result file is not compressed', | |
34 | + ); | |
35 | + } | |
36 | + return array( | |
37 | + 'success' => TRUE, | |
38 | + ); | |
39 | + } | |
40 | +} | |
41 | + | |
42 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetDataset_14 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getDataset"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "datasetID" => "mex-els-all", | |
20 | + "sampling" => 60, | |
21 | + "outputFormat" => "VOTable", | |
22 | + ); | |
23 | + } | |
24 | + | |
25 | + public function getDescription() { | |
26 | + return "Get mex-els-all data. Sampling 60s. VOTable"; | |
27 | + } | |
28 | + | |
29 | + protected function checkResultInfo($info) { | |
30 | + if (!$info['isVOTable']) { | |
31 | + return array( | |
32 | + 'success' => FALSE, | |
33 | + 'message' => 'Result file not in VOTable format', | |
34 | + ); | |
35 | + } | |
36 | + return array( | |
37 | + 'success' => TRUE, | |
38 | + ); | |
39 | + } | |
40 | +} | |
41 | + | |
42 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,99 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestAbstract.php"; | |
4 | + | |
5 | +class TestGetObsDataTree_40 extends TestAbstract | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getObsDataTree"; | |
9 | + } | |
10 | + | |
11 | + public function getParams() { | |
12 | + return array(); | |
13 | + } | |
14 | + | |
15 | + public function getDescription() { | |
16 | + return "Provides the hierarchy of public access data in AMDA."; | |
17 | + } | |
18 | + | |
19 | + protected function checkRESTResult($result) { | |
20 | + if (empty($result)) { | |
21 | + return array( | |
22 | + 'success' => FALSE, | |
23 | + 'message' => 'Empty result', | |
24 | + ); | |
25 | + } | |
26 | + $doc = new DOMDocument(); | |
27 | + if (!$doc->loadXML($result)) { | |
28 | + return array( | |
29 | + 'success' => FALSE, | |
30 | + 'message' => 'Result is not in XML format', | |
31 | + ); | |
32 | + } | |
33 | + $nodes = $doc->getElementsByTagName('LocalDataBaseParameters'); | |
34 | + if ($nodes->count() == 0) { | |
35 | + return array( | |
36 | + 'success' => FALSE, | |
37 | + 'message' => 'Cannot retrieve LocalDataBaseParameters node', | |
38 | + ); | |
39 | + } | |
40 | + $xml_url = $nodes->item(0)->nodeValue; | |
41 | + if (empty($xml_url)) { | |
42 | + return array( | |
43 | + 'success' => FALSE, | |
44 | + 'message' => 'Cannot retrieve XML file path', | |
45 | + ); | |
46 | + } | |
47 | + return $this->checkObsDataTree($xml_url); | |
48 | + } | |
49 | + | |
50 | + protected function checkSOAPResult($result) { | |
51 | + if (empty($result)) { | |
52 | + return array( | |
53 | + 'success' => FALSE, | |
54 | + 'message' => 'Empty result', | |
55 | + ); | |
56 | + } | |
57 | + if (empty($result->success)) { | |
58 | + return array( | |
59 | + 'success' => FALSE, | |
60 | + 'message' => 'Error in request', | |
61 | + ); | |
62 | + } | |
63 | + if (empty($result->WorkSpace) || empty($result->WorkSpace->LocalDataBaseParameters)) { | |
64 | + return array( | |
65 | + 'success' => FALSE, | |
66 | + 'message' => 'Cannot retrieve XML file path', | |
67 | + ); | |
68 | + } | |
69 | + return $this->checkObsDataTree($result->WorkSpace->LocalDataBaseParameters); | |
70 | + } | |
71 | + | |
72 | + private function checkObsDataTree($xml_path) { | |
73 | + $data = file_get_contents($xml_path); | |
74 | + if (!$data) { | |
75 | + return array( | |
76 | + 'success' => FALSE, | |
77 | + 'message' => 'Cannot load tree XML file', | |
78 | + ); | |
79 | + } | |
80 | + $doc = new DOMDocument(); | |
81 | + if (!@$doc->loadXML($data)) { | |
82 | + return array( | |
83 | + 'success' => FALSE, | |
84 | + 'message' => 'Local tree is not in XML format', | |
85 | + ); | |
86 | + } | |
87 | + if ($doc->documentElement->nodeName != 'dataRoot') { | |
88 | + return array( | |
89 | + 'success' => FALSE, | |
90 | + 'message' => 'Cannot retrieve dataRoot node in tree file', | |
91 | + ); | |
92 | + } | |
93 | + return array( | |
94 | + 'success' => TRUE, | |
95 | + ); | |
96 | + } | |
97 | +} | |
98 | + | |
99 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,54 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetOrbites_20 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getOrbites"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "spacecraft" => "cluster1", | |
20 | + "coordinateSystem" => "GSE", | |
21 | + "units" => "km", | |
22 | + ); | |
23 | + } | |
24 | + | |
25 | + public function getDescription() { | |
26 | + return "Get Cluster 1 orbit in GSE. No sampling."; | |
27 | + } | |
28 | + | |
29 | + protected function checkResultInfo($info) { | |
30 | + if ($info['structure'] != 'one-file-per-parameter-per-interval') { | |
31 | + return array( | |
32 | + 'success' => FALSE, | |
33 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
34 | + ); | |
35 | + } | |
36 | + if (isset($info['sampling'])) { | |
37 | + return array( | |
38 | + 'success' => FALSE, | |
39 | + 'message' => 'A sampling time has been applied in result file', | |
40 | + ); | |
41 | + } | |
42 | + if (!in_array('c1_xyz_gse_km', $info['parameters'])) { | |
43 | + return array( | |
44 | + 'success' => FALSE, | |
45 | + 'message' => 'Missing c1_xyz_gse_km in result file', | |
46 | + ); | |
47 | + } | |
48 | + return array( | |
49 | + 'success' => TRUE, | |
50 | + ); | |
51 | + } | |
52 | +} | |
53 | + | |
54 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,55 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetOrbites_21 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getOrbites"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "spacecraft" => "cluster1", | |
20 | + "coordinateSystem" => "GSE", | |
21 | + "units" => "km", | |
22 | + "sampling" => "100" | |
23 | + ); | |
24 | + } | |
25 | + | |
26 | + public function getDescription() { | |
27 | + return "Get Cluster 1 orbit in GSE. Sampling 100s."; | |
28 | + } | |
29 | + | |
30 | + protected function checkResultInfo($info) { | |
31 | + if (!in_array('c1_xyz_gse_km', $info['parameters'])) { | |
32 | + return array( | |
33 | + 'success' => FALSE, | |
34 | + 'message' => 'Missing c1_xyz_gse_km in result file', | |
35 | + ); | |
36 | + } | |
37 | + if (!isset($info['sampling'])) { | |
38 | + return array( | |
39 | + 'success' => FALSE, | |
40 | + 'message' => 'Missing sampling time', | |
41 | + ); | |
42 | + } | |
43 | + else if ($info['sampling'] != 100) { | |
44 | + return array( | |
45 | + 'success' => FALSE, | |
46 | + 'message' => 'Bad sampling time ('.$info['sampling'].')', | |
47 | + ); | |
48 | + } | |
49 | + return array( | |
50 | + 'success' => TRUE, | |
51 | + ); | |
52 | + } | |
53 | +} | |
54 | + | |
55 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,58 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetParameter_30 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getParameter"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "parameterID" => "imf", | |
20 | + ); | |
21 | + } | |
22 | + | |
23 | + public function getDescription() { | |
24 | + return "Get imf data. No sampling."; | |
25 | + } | |
26 | + | |
27 | + protected function checkResultInfo($info) { | |
28 | + if ($info['structure'] != 'one-file-per-parameter-per-interval') { | |
29 | + return array( | |
30 | + 'success' => FALSE, | |
31 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
32 | + ); | |
33 | + } | |
34 | + if (isset($info['sampling'])) { | |
35 | + return array( | |
36 | + 'success' => FALSE, | |
37 | + 'message' => 'A sampling time has been applied in result file', | |
38 | + ); | |
39 | + } | |
40 | + if ($info['timeFormat'] != 'ISO 8601') { | |
41 | + return array( | |
42 | + 'success' => FALSE, | |
43 | + 'message' => 'Bad time format ('.$info['timeFormat'].')', | |
44 | + ); | |
45 | + } | |
46 | + if (!in_array('imf', $info['parameters'])) { | |
47 | + return array( | |
48 | + 'success' => FALSE, | |
49 | + 'message' => 'Missing imf in result file', | |
50 | + ); | |
51 | + } | |
52 | + return array( | |
53 | + 'success' => TRUE, | |
54 | + ); | |
55 | + } | |
56 | +} | |
57 | + | |
58 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,80 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetParameter_31 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getParameter"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "parameterID" => "imf", | |
20 | + "sampling" => 60, | |
21 | + "timeFormat" => 'UNIXTIME', | |
22 | + "gzip" => 1, | |
23 | + "outputFormat" => "VOTable", | |
24 | + ); | |
25 | + } | |
26 | + | |
27 | + public function getDescription() { | |
28 | + return "Get imf data. Sampling time 60s. Unix time. VOTable. Compressed"; | |
29 | + } | |
30 | + | |
31 | + protected function checkResultInfo($info) { | |
32 | + if ($info['structure'] != 'all-in-one-file') { | |
33 | + return array( | |
34 | + 'success' => FALSE, | |
35 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
36 | + ); | |
37 | + } | |
38 | + if (!isset($info['sampling'])) { | |
39 | + return array( | |
40 | + 'success' => FALSE, | |
41 | + 'message' => 'Missing sampling time', | |
42 | + ); | |
43 | + } | |
44 | + else if ($info['sampling'] != 60) { | |
45 | + return array( | |
46 | + 'success' => FALSE, | |
47 | + 'message' => 'Bad sampling time ('.$info['sampling'].')', | |
48 | + ); | |
49 | + } | |
50 | + if ($info['timeFormat'] != 'Seconds from 1970, milliseconds') { | |
51 | + return array( | |
52 | + 'success' => FALSE, | |
53 | + 'message' => 'Bad time format ('.$info['timeFormat'].')', | |
54 | + ); | |
55 | + } | |
56 | + if (!$info['compressed']) { | |
57 | + return array( | |
58 | + 'success' => FALSE, | |
59 | + 'message' => 'Result file is not compressed', | |
60 | + ); | |
61 | + } | |
62 | + if (!$info['isVOTable']) { | |
63 | + return array( | |
64 | + 'success' => FALSE, | |
65 | + 'message' => 'Result file not in VOTable format' | |
66 | + ); | |
67 | + } | |
68 | + if (!in_array('imf', $info['parameters'])) { | |
69 | + return array( | |
70 | + 'success' => FALSE, | |
71 | + 'message' => 'Missing imf in result file', | |
72 | + ); | |
73 | + } | |
74 | + return array( | |
75 | + 'success' => TRUE, | |
76 | + ); | |
77 | + } | |
78 | +} | |
79 | + | |
80 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetParameter_32 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getParameter"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "parameterID" => "imf,mex_els_spec_sum", | |
20 | + ); | |
21 | + } | |
22 | + | |
23 | + public function getDescription() { | |
24 | + return "Get imf data. Sampling time 60s. Unix time. VOTable. Compressed"; | |
25 | + } | |
26 | + | |
27 | + protected function checkResultInfo($info) { | |
28 | + if ($info['structure'] != 'all-in-one-file-refparam') { | |
29 | + return array( | |
30 | + 'success' => FALSE, | |
31 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
32 | + ); | |
33 | + } | |
34 | + if (!in_array('imf', $info['parameters'])) { | |
35 | + return array( | |
36 | + 'success' => FALSE, | |
37 | + 'message' => 'Missing imf in result file', | |
38 | + ); | |
39 | + } | |
40 | + if (!in_array('mex_els_spec_sum', $info['parameters'])) { | |
41 | + return array( | |
42 | + 'success' => FALSE, | |
43 | + 'message' => 'Missing mex_els_spec_sum in result file', | |
44 | + ); | |
45 | + } | |
46 | + return array( | |
47 | + 'success' => TRUE, | |
48 | + ); | |
49 | + } | |
50 | +} | |
51 | + | |
52 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,65 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestDownloadBase.php"; | |
4 | + | |
5 | +class TestGetParameter_33 extends TestDownloadBase | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getParameter"; | |
9 | + } | |
10 | + | |
11 | + protected function needRESTAuth() { | |
12 | + return TRUE; | |
13 | + } | |
14 | + | |
15 | + public function getParams() { | |
16 | + return array( | |
17 | + "startTime" => "2008-01-01T00:00:00", | |
18 | + "stopTime" => "2008-01-01T01:00:00", | |
19 | + "parameterID" => "imf,mex_els_spec_sum", | |
20 | + "sampling" => 60, | |
21 | + ); | |
22 | + } | |
23 | + | |
24 | + public function getDescription() { | |
25 | + return "Get imf data. Sampling time 60s. Unix time. VOTable. Compressed"; | |
26 | + } | |
27 | + | |
28 | + protected function checkResultInfo($info) { | |
29 | + if ($info['structure'] != 'all-in-one-file') { | |
30 | + return array( | |
31 | + 'success' => FALSE, | |
32 | + 'message' => 'Bad file structure ('.$info['structure'].')', | |
33 | + ); | |
34 | + } | |
35 | + if (!isset($info['sampling'])) { | |
36 | + return array( | |
37 | + 'success' => FALSE, | |
38 | + 'message' => 'Missing sampling time', | |
39 | + ); | |
40 | + } | |
41 | + else if ($info['sampling'] != 60) { | |
42 | + return array( | |
43 | + 'success' => FALSE, | |
44 | + 'message' => 'Bad sampling time ('.$info['sampling'].')', | |
45 | + ); | |
46 | + } | |
47 | + if (!in_array('imf', $info['parameters'])) { | |
48 | + return array( | |
49 | + 'success' => FALSE, | |
50 | + 'message' => 'Missing imf in result file', | |
51 | + ); | |
52 | + } | |
53 | + if (!in_array('mex_els_spec_sum', $info['parameters'])) { | |
54 | + return array( | |
55 | + 'success' => FALSE, | |
56 | + 'message' => 'Missing mex_els_spec_sum in result file', | |
57 | + ); | |
58 | + } | |
59 | + return array( | |
60 | + 'success' => TRUE, | |
61 | + ); | |
62 | + } | |
63 | +} | |
64 | + | |
65 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,69 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestAbstract.php"; | |
4 | + | |
5 | +class TestGetPlot_50 extends TestAbstract | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "getPlot"; | |
9 | + } | |
10 | + | |
11 | + public function getParams() { | |
12 | + return array( | |
13 | + "startTime" => "2008-01-01T00:00:00", | |
14 | + "stopTime" => "2008-01-02T00:00:00", | |
15 | + "missionID" => "ACE", | |
16 | + ); | |
17 | + } | |
18 | + | |
19 | + public function getDescription() { | |
20 | + return "Plot ACE data."; | |
21 | + } | |
22 | + | |
23 | + public function getWSTypes() { | |
24 | + return array("SOAP"); | |
25 | + } | |
26 | + | |
27 | + protected function checkRESTResult($result) { | |
28 | + return array( | |
29 | + 'success' => FALSE, | |
30 | + 'message' => 'Not implemented', | |
31 | + ); | |
32 | + } | |
33 | + | |
34 | + protected function checkSOAPResult($result) { | |
35 | + if (empty($result)) { | |
36 | + return array( | |
37 | + 'success' => FALSE, | |
38 | + 'message' => 'Empty result', | |
39 | + ); | |
40 | + } | |
41 | + | |
42 | + if (empty($result->success)) { | |
43 | + return array( | |
44 | + 'success' => FALSE, | |
45 | + 'message' => 'Error during plot request', | |
46 | + ); | |
47 | + } | |
48 | + | |
49 | + if ($result->status != 'done') { | |
50 | + return array( | |
51 | + 'success' => FALSE, | |
52 | + 'message' => 'Status is not done ('.$obj->status.')', | |
53 | + ); | |
54 | + } | |
55 | + | |
56 | + if (empty($result->plotFileURL)) { | |
57 | + return array( | |
58 | + 'success' => FALSE, | |
59 | + 'message' => 'Missing plot file URL in result', | |
60 | + ); | |
61 | + } | |
62 | + | |
63 | + return array( | |
64 | + 'success' => TRUE, | |
65 | + ); | |
66 | + } | |
67 | +} | |
68 | + | |
69 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,57 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once "Base/TestAbstract.php"; | |
4 | + | |
5 | +class TestIsAlive_01 extends TestAbstract | |
6 | +{ | |
7 | + public function getAPI() { | |
8 | + return "isAlive"; | |
9 | + } | |
10 | + | |
11 | + public function getParams() { | |
12 | + return array(); | |
13 | + } | |
14 | + | |
15 | + public function getDescription() { | |
16 | + return "Used to check whether AMDA services are available or not."; | |
17 | + } | |
18 | + | |
19 | + protected function checkRESTResult($result) { | |
20 | + if (empty($result)) { | |
21 | + return array( | |
22 | + 'success' => FALSE, | |
23 | + 'message' => 'Empty result', | |
24 | + ); | |
25 | + } | |
26 | + $json_res = json_decode($result, TRUE); | |
27 | + if (!$json_res) { | |
28 | + return array( | |
29 | + 'success' => FALSE, | |
30 | + 'message' => 'Result is not in JSON format', | |
31 | + ); | |
32 | + } | |
33 | + if (empty($json_res['alive'])) { | |
34 | + return array( | |
35 | + 'success' => FALSE, | |
36 | + 'message' => 'Service is not alive', | |
37 | + ); | |
38 | + } | |
39 | + return array( | |
40 | + 'success' => TRUE, | |
41 | + ); | |
42 | + } | |
43 | + | |
44 | + protected function checkSOAPResult($result) { | |
45 | + if ($result) { | |
46 | + return array( | |
47 | + 'success' => TRUE, | |
48 | + ); | |
49 | + } | |
50 | + return array( | |
51 | + 'success' => FALSE, | |
52 | + 'message' => 'Service is not alive', | |
53 | + ); | |
54 | + } | |
55 | +} | |
56 | + | |
57 | +?> | |
... | ... |
php/WebServices/Tests/testWebServer.php deleted
... | ... | @@ -1,172 +0,0 @@ |
1 | -<?php | |
2 | - | |
3 | -require_once("../Client/WSClientSOAP.php"); | |
4 | -//require_once("../Client/WSClientREST.php"); | |
5 | - | |
6 | -function runSuiteTests($client) | |
7 | -{ | |
8 | - //Test isAlive function | |
9 | - $res = $client->isAlive(); | |
10 | - if (!isset($res) || ($res != true)) | |
11 | - echo "[ERROR] - Error during call of isAlive function".PHP_EOL; | |
12 | - else | |
13 | - echo "[OK] - isAlive".PHP_EOL; | |
14 | - | |
15 | - //Test getTimeTablesList function without userID & password | |
16 | -// $res = $client->getTimeTablesList(); | |
17 | -// if (!isset($res) || !$res->success) | |
18 | -// echo "[ERROR] - Error during call of getTimeTablesList function - Test 1".PHP_EOL; | |
19 | -// else | |
20 | -// echo "[OK] - getTimeTablesList - Test 1 - ".$res->TimeTablesList.PHP_EOL; | |
21 | - | |
22 | - //Test getTimeTablesList function with userID & password | |
23 | - $res = $client->getTimeTablesList(dduser, ddpass); | |
24 | - if (!isset($res) || !$res->success) | |
25 | - echo "[ERROR] - Error during call of getTimeTablesList function - Test 2".PHP_EOL; | |
26 | - else | |
27 | - echo "[OK] - getTimeTablesList - Test 2 - ".$res->TimeTablesList.PHP_EOL; | |
28 | - | |
29 | - //Test getTimeTable function without userID & password | |
30 | -// $res = $client->getTimeTable("sharedtt_0"); | |
31 | -// if (!isset($res) || !$res->success) | |
32 | -// echo "[ERROR] - Error during call of getTimeTable function - Test 1".PHP_EOL; | |
33 | -// else | |
34 | -// echo "[OK] - getTimeTable - Test 1 - ".$res->ttFileURL.PHP_EOL; | |
35 | - | |
36 | - //Test getTimeTable function with userID & password | |
37 | - $res = $client->getTimeTable("tt_0", dduser, ddpass); | |
38 | - if (!isset($res) || !$res->success) | |
39 | - echo "[ERROR] - Error during call of getTimeTable function - Test 2".PHP_EOL; | |
40 | - else | |
41 | - echo "[OK] - getTimeTable - Test 2 - ".$res->ttFileURL.PHP_EOL; | |
42 | - | |
43 | - //Test getParameterList function for impex user | |
44 | -// $res = $client->getParameterList("impex"); | |
45 | -// if (!isset($res) || !$res->success) | |
46 | -// echo "[ERROR] - Error during call of getParameterList function - Test 1".PHP_EOL; | |
47 | -// else | |
48 | -// echo "[OK] - getParameterList - Test 1 - ".$res->ParameterList->LocalDataBaseParameters.PHP_EOL; | |
49 | - | |
50 | - //Test getParameterList function with userID & password | |
51 | - $res = $client->getParameterList(dduser, ddpass); | |
52 | - if (!isset($res) || !$res->success) | |
53 | - echo "[ERROR] - Error during call of getParameterList function - Test 2".PHP_EOL; | |
54 | - else | |
55 | - { | |
56 | - echo "[OK] - getParameterList - Test 2 :".PHP_EOL; | |
57 | - echo " - UserDefinedParameters : ".$res->ParameterList->UserDefinedParameters.PHP_EOL; | |
58 | - echo " - LocalDataBaseParameters : ".$res->ParameterList->LocalDataBaseParameters.PHP_EOL; | |
59 | - } | |
60 | - | |
61 | - //Test getObsDataTree function | |
62 | - $res = $client->getObsDataTree(); | |
63 | - if (!isset($res) || !$res->success) | |
64 | - echo "[ERROR] - Error during call of getObsDataTree function".PHP_EOL; | |
65 | - else | |
66 | - echo "[OK] - getObsDataTree - Test 1 - ".$res->WorkSpace->LocalDataBaseParameters.PHP_EOL; | |
67 | - | |
68 | - //Test getParameter function | |
69 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::ASCII); | |
70 | - if (!isset($res) || !$res->success) | |
71 | - echo "[ERROR] - Error during call of getParameter function - Test 1".PHP_EOL; | |
72 | - else | |
73 | - echo "[OK] - getParameter - Test 1 - ".$res->dataFileURLs.PHP_EOL; | |
74 | - | |
75 | - //Test getParameter function | |
76 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 3600, "", "", WSOutputFileFormat::ASCII); | |
77 | - if (!isset($res) || !$res->success) | |
78 | - echo "[ERROR] - Error during call of getParameter function - Test 2".PHP_EOL; | |
79 | - else | |
80 | - echo "[OK] - getParameter - Test 2 - ".$res->dataFileURLs.PHP_EOL; | |
81 | - | |
82 | - //Test getParameter function | |
83 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::VOTABLE); | |
84 | - if (!isset($res) || !$res->success) | |
85 | - echo "[ERROR] - Error during call of getParameter function - Test 3".PHP_EOL; | |
86 | - else | |
87 | - echo "[OK] - getParameter - Test 3 - ".$res->dataFileURLs.PHP_EOL; | |
88 | - | |
89 | - //Test getParameter function | |
90 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 3600, "", "", WSOutputFileFormat::VOTABLE); | |
91 | - if (!isset($res) || !$res->success) | |
92 | - echo "[ERROR] - Error during call of getParameter function - Test 4".PHP_EOL; | |
93 | - else | |
94 | - echo "[OK] - getParameter - Test 4 - ".$res->dataFileURLs.PHP_EOL; | |
95 | - | |
96 | - //Test getParameter function | |
97 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::ASCII, WSOutputTimeFormat::TIMESTAMP); | |
98 | - if (!isset($res) || !$res->success) | |
99 | - echo "[ERROR] - Error during call of getParameter function - Test 5".PHP_EOL; | |
100 | - else | |
101 | - echo "[OK] - getParameter - Test 5 - ".$res->dataFileURLs.PHP_EOL; | |
102 | - | |
103 | - //Test getParameter function | |
104 | - $res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::VOTABLE, WSOutputTimeFormat::ISO, 1); | |
105 | - if (!isset($res) || !$res->success) | |
106 | - echo "[ERROR] - Error during call of getParameter function - Test 6".PHP_EOL; | |
107 | - else | |
108 | - echo "[OK] - getParameter - Test 6 - ".$res->dataFileURLs.PHP_EOL; | |
109 | - | |
110 | - //Test getDataset function | |
111 | - $res = $client->getDataset("2008-01-01T00:00:00", "2008-01-02T00:00:00", "ground:based:asy", 0, "", "", WSOutputFileFormat::ASCII); | |
112 | - if (!isset($res) || !$res->success) | |
113 | - echo "[ERROR] - Error during call of getDataset function".PHP_EOL; | |
114 | - else | |
115 | - echo "[OK] - getDataset - ".$res->dataFileURLs.PHP_EOL; | |
116 | - | |
117 | - //Test getOrbites function | |
118 | - $res = $client->getOrbites("2008-01-01T00:00:00", "2008-01-02T00:00:00", WSSpacecraft::VEX, WSCoordinatesSytem::VSO, WSOrbitUnit::RV, | |
119 | - 0, "", "", WSOutputFileFormat::ASCII); | |
120 | - if (!isset($res) || !$res->success) | |
121 | - echo "[ERROR] - Error during call of getOrbites function".PHP_EOL; | |
122 | - else | |
123 | - echo "[OK] - getOrbites - ".$res->dataFileURLs.PHP_EOL; | |
124 | - | |
125 | - //Test getPlot function | |
126 | - $res = $client->getPlot("2008-01-01T00:00:00", "2009-01-01T00:00:00", "ACE"); | |
127 | - if (!isset($res) || !$res->success) | |
128 | - echo "[ERROR] - Error during call of getPlot function".PHP_EOL; | |
129 | - else | |
130 | - { | |
131 | - $plotDirectoryURL = $res->plotDirectoryURL; | |
132 | - echo "[OK] - getPlot".PHP_EOL; | |
133 | - while (true) | |
134 | - { | |
135 | - echo " -> getResultPlot".PHP_EOL; | |
136 | - $res = $client->getResultPlot($plotDirectoryURL); | |
137 | - if (!isset($res)) | |
138 | - { | |
139 | - echo "[ERROR] - Error during call of getResultPlot function".PHP_EOL; | |
140 | - break; | |
141 | - } | |
142 | - else if ($res->success) | |
143 | - { | |
144 | - echo " -> plotFileURL : ".$res->plotFileURL.PHP_EOL; | |
145 | - break; | |
146 | - } | |
147 | - echo " -> Result not ready => Wait 5s".PHP_EOL; | |
148 | - sleep(5); | |
149 | - } | |
150 | - } | |
151 | -} | |
152 | - | |
153 | -$clientSOAP = new WSClientSOAP("http://apus.irap.omp.eu/NEWAMDA/public/wsdl/Methods_AMDA.wsdl"); | |
154 | - | |
155 | -if ( getenv('DDUSER') && getenv('DDPASS')) { | |
156 | - define('dduser', getenv('DDUSER')); | |
157 | - define('ddpass', getenv('DDPASS')); | |
158 | -} | |
159 | -else { | |
160 | - die("Export env vars : DDUSER and DDPASS"); | |
161 | -} | |
162 | -echo "==> Suite tests for SOAP client".PHP_EOL; | |
163 | -runSuiteTests($clientSOAP); | |
164 | - | |
165 | -//REST client is obsolete | |
166 | -/*$clientREST = new WSClientREST("http://localhost/NEWAMDA-BENJAMIN/php/rest/"); | |
167 | - | |
168 | -echo "==> Suite tests for REST client".PHP_EOL; | |
169 | -runSuiteTests($clientREST);*/ | |
170 | - | |
171 | - | |
172 | -?> | |
173 | 0 | \ No newline at end of file |
php/WebServices/WSUserMgr.php
... | ... | @@ -17,7 +17,7 @@ class WSUserMgr extends UserMgr |
17 | 17 | exit(json_encode(array("error" => $msg))); |
18 | 18 | } |
19 | 19 | |
20 | - public function init($username, $password, $sessionID, $setPathOnly, $isSoap) | |
20 | + public function initWS($username, $password, $sessionID, $setPathOnly, $isSoap) | |
21 | 21 | { |
22 | 22 | $this->user = trim($username); |
23 | 23 | if (isset($sessionID)) |
... | ... | @@ -55,11 +55,10 @@ class WSUserMgr extends UserMgr |
55 | 55 | if ( $setPathOnly ) |
56 | 56 | return array('success' => true); |
57 | 57 | |
58 | - $this->userGrps = $this->getUserGrps(); | |
59 | 58 | $this->makeLocalTree(); |
60 | 59 | $this->makeRemoteTree(); |
61 | 60 | |
62 | 61 | return array('success' => true); |
63 | 62 | } |
64 | 63 | } |
65 | -?> | |
66 | 64 | \ No newline at end of file |
65 | +?> | |
... | ... |
php/WebServices/WebServer.php
... | ... | @@ -19,12 +19,12 @@ class WebServer |
19 | 19 | if (!is_dir(WSConfigClass::getWsResultDir())) mkdir(WSConfigClass::getWsResultDir(), 0775); |
20 | 20 | } |
21 | 21 | |
22 | - protected function init($data) | |
22 | + protected function init($data = NULL) | |
23 | 23 | { |
24 | 24 | $this->requestTime = date('Ymd',time()); |
25 | 25 | |
26 | 26 | if (!isset($data)) { |
27 | - $this->userID = 'impex'; | |
27 | + $this->userID = WSConfigClass::getAnonymousUserName(); | |
28 | 28 | return array('success' => true); |
29 | 29 | } |
30 | 30 | |
... | ... | @@ -41,7 +41,7 @@ class WebServer |
41 | 41 | IHMConfigClass::setUserName($this->userID); |
42 | 42 | } |
43 | 43 | else { |
44 | - $this->userID = 'impex'; | |
44 | + $this->userID = WSConfigClass::getAnonymousUserName(); | |
45 | 45 | } |
46 | 46 | |
47 | 47 | $this->sessionID = $this->userID; |
... | ... | @@ -49,7 +49,7 @@ class WebServer |
49 | 49 | if (isset($vars['password'])) |
50 | 50 | $this->userPWD = $vars['password']; |
51 | 51 | else |
52 | - $this->userPWD = 'impexfp7'; | |
52 | + $this->userPWD = WSConfigClass::getAnonymousUserPwd(); | |
53 | 53 | |
54 | 54 | return array('success' => true, 'vars' => $vars); |
55 | 55 | } |
... | ... | @@ -57,7 +57,7 @@ class WebServer |
57 | 57 | private function initUserMgr($setPathOnly = false) |
58 | 58 | { |
59 | 59 | $wsUserMgr = new WSUserMgr(); |
60 | - $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $setPathOnly, $this->isSoap); | |
60 | + $wsUserMgr->initWS($this->userID, $this->userPWD, $this->sessionID, $setPathOnly, $this->isSoap); | |
61 | 61 | |
62 | 62 | $this->IPclient = $wsUserMgr->getIPClient(); |
63 | 63 | |
... | ... | @@ -116,14 +116,14 @@ class WebServer |
116 | 116 | } |
117 | 117 | |
118 | 118 | /* |
119 | -* get user TimeTables list; Shared for impex | |
119 | +* get user TimeTables list; Shared for anonymous user ('impex') | |
120 | 120 | */ |
121 | 121 | private function getTimeTablesCatalogsList($object) |
122 | 122 | { |
123 | 123 | $this->initUserMgr(); |
124 | 124 | $dom = new DOMDocument("1.0"); |
125 | 125 | |
126 | - if ($this->userID == 'impex') { | |
126 | + if ($this->userID == WSConfigClass::getAnonymousUserName()) { | |
127 | 127 | $sharedObjMgr = new SharedObjectsMgr(); |
128 | 128 | if (!@$dom->load($sharedObjMgr->getTreeFilePath())) |
129 | 129 | $this->throwError("workspaceError", "Workspace Error : Cannot load Shared TimeTable list"); |
... | ... | @@ -197,7 +197,7 @@ class WebServer |
197 | 197 | "Cannot find orbit data for ".$orbitRequest['spacecraft']." for ".$orbitRequest['startTime']."-".$orbitRequest['stopTime']." in ".$orbitRequest['units']." ".$orbitRequest['coordinateSystem']."($paramStart - $paramStop)"); |
198 | 198 | } |
199 | 199 | |
200 | - private function doDownloadRequest($interval, $paramList, $formatInfo) | |
200 | + private function doDownloadRequest($interval, $paramList, $formatInfo, $file_info) | |
201 | 201 | { |
202 | 202 | if (!isset($this->paramLoader)) |
203 | 203 | $this->paramLoader = new IHMUserParamLoaderClass(); |
... | ... | @@ -234,6 +234,8 @@ class WebServer |
234 | 234 | $params[] = $param; |
235 | 235 | } |
236 | 236 | |
237 | + $ref_sampling_param = isset($interval['ref_sampling_param']) ? $interval['ref_sampling_param'] : NULL; | |
238 | + | |
237 | 239 | $obj = (object)array( |
238 | 240 | "sampling" => $interval['sampling'], |
239 | 241 | "startDate" => $interval['startTime'], |
... | ... | @@ -241,9 +243,12 @@ class WebServer |
241 | 243 | "list" => $params, |
242 | 244 | "fileformat" => $formatInfo['format'], |
243 | 245 | "timeformat" => $formatInfo['timeFormat'], |
244 | - "compression" => $formatInfo['gzip'] | |
246 | + "compression" => $formatInfo['gzip'], | |
247 | + "ref_sampling_param" => $ref_sampling_param, | |
248 | + "file_info" => $file_info, | |
245 | 249 | ); |
246 | - | |
250 | + | |
251 | + | |
247 | 252 | if (!isset($this->requestManager)) |
248 | 253 | $this->requestManager = new RequestManagerClass(); |
249 | 254 | |
... | ... | @@ -252,6 +257,7 @@ class WebServer |
252 | 257 | } catch (Exception $e) { |
253 | 258 | $this->throwError("executionError", "Exception detected : ".$e->getMessage()); |
254 | 259 | } |
260 | + | |
255 | 261 | |
256 | 262 | if (!$downloadResult['success']) { |
257 | 263 | $this->throwError("serverError", $downloadResult['message']); |
... | ... | @@ -262,7 +268,7 @@ class WebServer |
262 | 268 | } elseif ($downloadResult['status'] == 'done') |
263 | 269 | { |
264 | 270 | $this->deleteProcess($downloadResult['id']); |
265 | - return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']); | |
271 | + return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result'], 'exectime' => $downloadResult['exectime']); | |
266 | 272 | } else { |
267 | 273 | return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; |
268 | 274 | } |
... | ... | @@ -292,7 +298,7 @@ class WebServer |
292 | 298 | $locParamSrcDom = new DomDocument("1.0"); |
293 | 299 | $locParamSrcDom->preserveWhiteSpace = FALSE; /// Important !!! otherwise removeChild() leaves empty text nodes |
294 | 300 | |
295 | - if (!$locParamSrcDom->load($locParamSrc)) | |
301 | + if (!@$locParamSrcDom->load($locParamSrc)) | |
296 | 302 | $this->throwError("getObsDataTree", "Cannot load Amda Local DataBase Parameters description file".$this->userID); |
297 | 303 | |
298 | 304 | $xp = new domxpath($locParamSrcDom); |
... | ... | @@ -333,7 +339,7 @@ class WebServer |
333 | 339 | } |
334 | 340 | |
335 | 341 | /* |
336 | -* public data only : user impex | |
342 | +* public data only : anonymous user (impex) | |
337 | 343 | */ |
338 | 344 | public function getObsDataTree() |
339 | 345 | { |
... | ... | @@ -372,10 +378,10 @@ class WebServer |
372 | 378 | |
373 | 379 | $this->excludePrivateNodes($locParamSrc,$locParamDst); |
374 | 380 | |
375 | - if (!copy($wsParamSrc, WSConfigClass::getWsResultDir().$wsParamDst)) | |
381 | + if (($this->userID == WSConfigClass::getAnonymousUserName()) || !copy($wsParamSrc, WSConfigClass::getWsResultDir().$wsParamDst)) | |
376 | 382 | return array('success' => true,'ParameterList' => |
377 | 383 | array("LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst)); |
378 | - | |
384 | + | |
379 | 385 | return array('success' => true,'ParameterList' => |
380 | 386 | array("UserDefinedParameters" => WSConfigClass::getUrl().$wsParamDst, |
381 | 387 | "LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst)); |
... | ... | @@ -395,6 +401,14 @@ class WebServer |
395 | 401 | $this->initUserMgr(); |
396 | 402 | |
397 | 403 | $vars = $res['vars']; |
404 | + | |
405 | + if (empty($vars["startTime"])) { | |
406 | + $this->throwError("requestError", "Missing startTime definition"); | |
407 | + } | |
408 | + | |
409 | + if (empty($vars["stopTime"])) { | |
410 | + $this->throwError("requestError", "Missing stopTime definition"); | |
411 | + } | |
398 | 412 | |
399 | 413 | if (is_numeric($vars["startTime"])) { |
400 | 414 | $this->checkInputTime($vars["startTime"],$vars["stopTime"]); |
... | ... | @@ -405,41 +419,65 @@ class WebServer |
405 | 419 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); |
406 | 420 | } |
407 | 421 | |
408 | - if (!$vars["timeFormat"]) { | |
422 | + if (empty($vars["timeFormat"])) { | |
409 | 423 | $timeFormat = "ISO8601"; |
410 | 424 | } |
411 | 425 | else { |
412 | 426 | $timeFormat = $vars["timeFormat"]; |
413 | 427 | } |
414 | - | |
428 | + | |
429 | + $sampling = !empty($vars["sampling"]) ? $vars["sampling"] : NULL; | |
430 | + $ref_sampling_param = NULL; | |
431 | + $file_info = ""; | |
432 | + | |
433 | + if (empty($vars["parameterID"])) { | |
434 | + $this->throwError("requestError", "Missing parameterID definition"); | |
435 | + } | |
415 | 436 | $paramId = array(); |
416 | - array_push($paramId, $vars["parameterID"]); | |
437 | + if (strpos($vars["parameterID"], ',')) { | |
438 | + $paramId = explode(',', $vars["parameterID"]); | |
417 | 439 | |
418 | - if (!$vars["gzip"]) | |
440 | + if (!isset($sampling)) | |
441 | + { | |
442 | + $ref_sampling_param = trim($paramId[0]); | |
443 | + } | |
444 | + | |
445 | + foreach ($paramId as &$id) { | |
446 | + $id = trim($id); | |
447 | + if (!empty($file_info)) { | |
448 | + $file_info .= "-"; | |
449 | + } | |
450 | + $file_info .= $id; | |
451 | + } | |
452 | + } | |
453 | + else { | |
454 | + array_push($paramId, $vars["parameterID"]); | |
455 | + $file_info = $vars["parameterID"]; | |
456 | + } | |
457 | + | |
458 | + if (empty($vars["gzip"])) | |
419 | 459 | $gzip = 0; |
420 | 460 | else |
421 | - $gzip = $vars["gzip"]; | |
461 | + $gzip = ($vars["gzip"] == 1); | |
422 | 462 | |
423 | - if (!$vars["stream"]) | |
424 | - $stream = 0; | |
425 | - else | |
426 | - $stream = $vars["stream"]; | |
463 | + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII'; | |
427 | 464 | |
428 | 465 | $this->service = strtolower(__FUNCTION__); |
429 | 466 | |
430 | 467 | $res = $this->doDownloadRequest( |
431 | - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), | |
468 | + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling, | |
469 | + "ref_sampling_param" => $ref_sampling_param), | |
432 | 470 | array("params" => $paramId), |
433 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | |
471 | + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $file_info); | |
434 | 472 | |
435 | 473 | if ($res['success']) |
436 | 474 | return $res; |
437 | 475 | |
438 | - $this->throwError("serverError", $res['message']); | |
476 | + $this->throwError("serverError", $res['message']); | |
439 | 477 | } |
440 | 478 | |
441 | 479 | /* |
442 | -* get user Catalogs list; Shared for impex | |
480 | +* get user Catalogs list; Shared for anonymous user (impex) | |
443 | 481 | */ |
444 | 482 | public function getCatalogsList($data) |
445 | 483 | { |
... | ... | @@ -449,7 +487,7 @@ class WebServer |
449 | 487 | } |
450 | 488 | |
451 | 489 | /* |
452 | -* get user TimeTables list; Shared for impex | |
490 | +* get user TimeTables list; Shared for anonymous user (impex) | |
453 | 491 | */ |
454 | 492 | public function getTimeTablesList($data) |
455 | 493 | { |
... | ... | @@ -487,65 +525,52 @@ class WebServer |
487 | 525 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); |
488 | 526 | } |
489 | 527 | |
490 | - if (!$vars["timeFormat"]) { | |
528 | + if (empty($vars["timeFormat"])) { | |
491 | 529 | $timeFormat = "ISO8601"; |
492 | 530 | } |
493 | 531 | else { |
494 | 532 | $timeFormat = $vars["timeFormat"]; |
495 | 533 | } |
496 | - | |
497 | - $dataSetDom = $this->getDatasetInfo($vars['datasetID']); | |
534 | + | |
535 | + if (empty($vars['datasetID'])) { | |
536 | + $this->throwError("requestError", "Missing datasetID definition"); | |
537 | + } | |
538 | + $datasetId = $vars['datasetID']; | |
539 | + $dataSetDom = $this->getDatasetInfo($datasetId); | |
498 | 540 | |
499 | 541 | $params = $dataSetDom->getElementsByTagName("parameter"); |
500 | 542 | |
501 | 543 | if ($params->length == 0) |
502 | - $this->throwError("systemError", "Cannot find parameter list for dataset ".$vars['datasetID']); | |
544 | + $this->throwError("systemError", "Cannot find parameter list for dataset ".$datasetId); | |
503 | 545 | |
504 | 546 | $paramId = array(); |
505 | 547 | |
506 | 548 | foreach ($params as $p) |
507 | 549 | $paramId[] = $p->nodeValue; |
508 | 550 | |
509 | - if (!$vars["sampling"]) | |
551 | + if (empty($vars["sampling"])) | |
510 | 552 | { |
511 | - $sampling = $dataSetDom->getElementsByTagName('min_sampling')->item(0)->nodeValue; | |
512 | - | |
513 | - $units = substr($sampling,-1); | |
514 | - $sampling = substr($sampling,0,strlen($sampling)-1); | |
515 | - | |
516 | - switch ($units) { | |
517 | -// case 'S': | |
518 | -// $sampling = floatval($sampling); | |
519 | -// break; | |
520 | - case 'M': | |
521 | - $sampling = floatval($sampling)*60; | |
522 | - break; | |
523 | - case 'H': | |
524 | - $sampling = floatval($sampling)*60*60; | |
525 | - break; | |
526 | - default: | |
527 | - } | |
553 | + $sampling = NULL; | |
554 | + $ref_sampling_param = $paramId[0]; | |
528 | 555 | } |
529 | 556 | else { |
530 | 557 | $sampling = $vars["sampling"]; |
558 | + $ref_sampling_param = NULL; | |
531 | 559 | } |
532 | 560 | |
533 | - if (!$vars["gzip"]) | |
561 | + if (empty($vars["gzip"])) | |
534 | 562 | $gzip = 0; |
535 | 563 | else |
536 | - $gzip = $vars["gzip"]; | |
564 | + $gzip = ($vars["gzip"] == 1); | |
565 | + | |
566 | + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII'; | |
537 | 567 | |
538 | - if (!$vars["stream"]) | |
539 | - $stream = 0; | |
540 | - else | |
541 | - $stream = $vars["stream"]; | |
542 | - | |
543 | 568 | $this->service = strtolower(__FUNCTION__); |
544 | 569 | |
545 | 570 | $res = $this->doDownloadRequest( |
546 | - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), | |
571 | + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling, "ref_sampling_param" => $ref_sampling_param), | |
547 | 572 | array("params" => $paramId), |
548 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | |
573 | + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $datasetId); | |
549 | 574 | |
550 | 575 | if ($res['success']) return $res; |
551 | 576 | |
... | ... | @@ -570,24 +595,7 @@ class WebServer |
570 | 595 | } |
571 | 596 | catch (Exception $e) |
572 | 597 | { |
573 | - // after first getStatus() call process is deleted | |
574 | - $jobsManager = new WSJobsManagerClass(); | |
575 | - | |
576 | - try | |
577 | - { | |
578 | - $res = $jobsManager->getResultFromProcessId($id); | |
579 | - if (!$res['success']) { | |
580 | - $this->throwError("processError","Cannot retrieve process $id info"); | |
581 | - } | |
582 | - | |
583 | - $resultTag = $this->isGetPlotRequest($res['result']) ? 'plotURL' : 'dataFileURLs'; | |
584 | - | |
585 | - return array('success' => true, 'status' => 'done', $resultTag => WSConfigClass::getUrl().$res['result']); | |
586 | - } | |
587 | - catch (Exception $e) | |
588 | - { | |
589 | - $this->throwError("getResultFromProcessIdError", "Exception detected : ".$e->getMessage()); | |
590 | - } | |
598 | + $this->throwError("executionError", "Exception detected : ".$e->getMessage()); | |
591 | 599 | } |
592 | 600 | |
593 | 601 | if (!$res['success']) { |
... | ... | @@ -613,7 +621,7 @@ class WebServer |
613 | 621 | * TODO Can be done by TTCONVERT function of AMDA_Kernel - more hard !!! |
614 | 622 | * TODO Think about this if merge/union will be also done by AMDA_Kernel |
615 | 623 | * |
616 | -* get Time Table : shared for impex ; user' for user | |
624 | +* get Time Table : shared for anonymous user (impex) ; user' for user | |
617 | 625 | */ |
618 | 626 | public function getTimeTable($data) |
619 | 627 | { |
... | ... | @@ -627,7 +635,7 @@ class WebServer |
627 | 635 | |
628 | 636 | $ttID = $res['vars']['ttID']; |
629 | 637 | |
630 | - if ($this->userID == 'impex') { | |
638 | + if ($this->userID == WSConfigClass::getAnonymousUserName()) { | |
631 | 639 | $sharedObjMgr = new SharedObjectsMgr(); |
632 | 640 | $ttSrc = $sharedObjMgr->getDataFilePath('timeTable', $ttID); |
633 | 641 | } |
... | ... | @@ -671,17 +679,24 @@ class WebServer |
671 | 679 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); |
672 | 680 | } |
673 | 681 | |
674 | - if (!$vars["timeFormat"]) { | |
682 | + if (empty($vars["timeFormat"])) { | |
675 | 683 | $timeFormat = "ISO8601"; |
676 | 684 | } |
677 | 685 | else { |
678 | 686 | $timeFormat = $vars["timeFormat"]; |
679 | 687 | } |
680 | - | |
688 | + | |
689 | + if (empty($vars["spacecraft"])) { | |
690 | + $this->throwError("requestError", "Missing spacecraft definition"); | |
691 | + } | |
681 | 692 | $spacecraft = $vars["spacecraft"]; |
693 | + | |
694 | + if (empty($vars["coordinateSystem"])) { | |
695 | + $this->throwError("requestError", "Missing coordinateSystem definition"); | |
696 | + } | |
682 | 697 | $coordinateSystem = $vars["coordinateSystem"]; |
683 | 698 | |
684 | - if (!$vars["units"]) | |
699 | + if (empty($vars["units"])) | |
685 | 700 | $units = "km"; |
686 | 701 | else |
687 | 702 | $units = $vars["units"]; |
... | ... | @@ -698,17 +713,21 @@ class WebServer |
698 | 713 | $paramId = array(); |
699 | 714 | array_push($paramId, $orbitParam['parameterID']); |
700 | 715 | |
701 | - if (!$vars["gzip"]) | |
716 | + if (empty($vars["gzip"])) | |
702 | 717 | $gzip = 0; |
703 | 718 | else |
704 | - $gzip = $vars["gzip"]; | |
719 | + $gzip = ($vars["gzip"] == 1); | |
720 | + | |
721 | + $sampling = !empty($vars["sampling"]) ? $vars["sampling"] : NULL; | |
722 | + | |
723 | + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII'; | |
705 | 724 | |
706 | - $this->service = strtolower(__FUNCTION__); | |
725 | + $this->service = strtolower(__FUNCTION__); | |
707 | 726 | |
708 | 727 | $res = $this->doDownloadRequest( |
709 | - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), | |
728 | + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), | |
710 | 729 | array("params" => $paramId), |
711 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | |
730 | + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $orbitParam['parameterID']); | |
712 | 731 | |
713 | 732 | if ($res['success']) return $res; |
714 | 733 | |
... | ... | @@ -742,7 +761,7 @@ class WebServer |
742 | 761 | |
743 | 762 | $resultFilePrefix = strtolower(__FUNCTION__)."_".$mission."_".date("YmdHms",strtotime($vars["startTime"]))."_".date("YmdHms",strtotime($vars["stopTime"])); |
744 | 763 | |
745 | - if ($this->userID != "impex") | |
764 | + if ($this->userID != WSConfigClass::getAnonymousUserName()) | |
746 | 765 | $resultFilePrefix .= "_".$this->userID; |
747 | 766 | |
748 | 767 | $dom = new DomDocument("1.0"); |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -942,7 +942,7 @@ class AmdaAction |
942 | 942 | if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID)) |
943 | 943 | { |
944 | 944 | $dd = new WSUserMgr(); |
945 | - $dd->init($obj->username,$obj->password,$obj->sessionID, false); | |
945 | + $dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false); | |
946 | 946 | } |
947 | 947 | else { |
948 | 948 | $dd = new UserMgr(); |
... | ... | @@ -957,7 +957,7 @@ class AmdaAction |
957 | 957 | return array('success' => false, 'message' => 'ddLogin error: '.$res); |
958 | 958 | } |
959 | 959 | |
960 | - if ($dd->user == 'impex') | |
960 | + if ($dd->user == WSConfigClass::getAnonymousUserName()) | |
961 | 961 | { |
962 | 962 | //if ($dd->getWsSize() > DISK_QUOTA * 100) |
963 | 963 | // error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu'); |
... | ... |
php/classes/AmdaStats.php
... | ... | @@ -12,7 +12,8 @@ class AmdaStats { |
12 | 12 | public $usersToExclude = array('bouchemit', 'impex'); |
13 | 13 | public $success = true; |
14 | 14 | private $user = null; |
15 | - private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistics'=>'statistics'); | |
15 | + private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistics'=>'statistics', | |
16 | + 'getparameter'=>'ws_print', 'getdataset' => 'ws_print', 'getorbites' => 'ws_print', 'getplot' => 'ws_plot'); | |
16 | 17 | |
17 | 18 | public function __construct($user) { |
18 | 19 | |
... | ... |
php/classes/CatalogMgr.php
... | ... | @@ -31,7 +31,7 @@ class CatalogMgr extends TimeTableMgr |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | - public function loadIntervalsFromObject($id, $type, $start = NULL, $limit = NULL) | |
34 | + public function loadIntervalsFromObject($id, $type = '', $start = NULL, $limit = NULL) | |
35 | 35 | { |
36 | 36 | $result = parent::loadIntervalsFromObject($id, $type, $start, $limit); |
37 | 37 | if (!isset($result['success']) || !$result['success']) { |
... | ... |
php/classes/ProxyUtils.php
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | class ProxyUtils { |
4 | 4 | static function addProxyForCurl(&$ch) { |
5 | - if ( defined(PROXY_HOST) ) { | |
5 | + if ( defined("PROXY_HOST") ) { | |
6 | 6 | $proxy_host = PROXY_HOST; |
7 | 7 | if (!empty($proxy_host)) { |
8 | 8 | curl_setopt($ch, CURLOPT_PROXY, "http://".$proxy_host); |
... | ... | @@ -15,7 +15,7 @@ class ProxyUtils { |
15 | 15 | } |
16 | 16 | |
17 | 17 | static function getStreamContextWithProxy() { |
18 | - if (!defined(PROXY_HOST)) | |
18 | + if (!defined("PROXY_HOST")) | |
19 | 19 | return; |
20 | 20 | $proxy_host = PROXY_HOST; |
21 | 21 | if (empty($proxy_host)) |
... | ... |
php/classes/UserMgr.php
... | ... | @@ -22,6 +22,7 @@ class UserMgr |
22 | 22 | 'USERWORKINGDIR' =>'RES', 'USERTTDIR' => 'TT', 'USERJOBDIR' => 'JOBS', |
23 | 23 | 'USERTEMPDIR' => 'TEMP'); |
24 | 24 | protected $userGrps; |
25 | + protected $userGrpsCheckSum; //use to know if there is a modification in user groups | |
25 | 26 | protected $amdaClient; //client to dd webservice |
26 | 27 | protected $paramMgr, $baseExtXml; |
27 | 28 | |
... | ... | @@ -136,14 +137,18 @@ class UserMgr |
136 | 137 | return true; |
137 | 138 | } |
138 | 139 | |
139 | - protected function getUserGrps() | |
140 | + protected function loadUserGrps() | |
140 | 141 | { |
142 | + if (isset($this->userGrps)) { | |
143 | + return; | |
144 | + } | |
141 | 145 | $info = $this->amdaClient->getUserInfo($this->user); |
142 | - | |
143 | - if (empty($info['group'])) | |
144 | - return null; | |
145 | - else | |
146 | - return explode(',',$info['group']); | |
146 | + | |
147 | + $this->userGrpsCheckSum = ''; | |
148 | + if (!empty($info['group'])) { | |
149 | + $this->userGrpsCheckSum = md5($info['group']); | |
150 | + $this->userGrps = explode(',',$info['group']); | |
151 | + } | |
147 | 152 | } |
148 | 153 | |
149 | 154 | /* |
... | ... | @@ -152,6 +157,9 @@ class UserMgr |
152 | 157 | */ |
153 | 158 | protected function isSpecialGroup() |
154 | 159 | { |
160 | + if (!isset($this->userGrps)) | |
161 | + return NULL; | |
162 | + | |
155 | 163 | $specialGrps = new DomDocument("1.0"); |
156 | 164 | |
157 | 165 | if (!($specialGrps->load(specialGrpsXml))) return null; |
... | ... | @@ -259,7 +267,13 @@ class UserMgr |
259 | 267 | foreach ($basesWS as $base) |
260 | 268 | { |
261 | 269 | $baseId = $base->getAttribute('xml:id'); |
262 | - | |
270 | + $lastModif = $base->getAttribute('lastModif'); | |
271 | + if (!empty($lastModif)) { | |
272 | + $lastModif = intval($lastModif); | |
273 | + if (($lastModif > 0) && ((time() - $lastModif) < REMOTE_PARAMS_UPDATE_DELAY)) { | |
274 | + continue; | |
275 | + } | |
276 | + } | |
263 | 277 | if (!$this->baseExtXml->load(RemoteData.$baseId.'/base.xml')) |
264 | 278 | { |
265 | 279 | $base->setAttribute("desc","ATTENTION!!! This DataCenter DOES NOT EXIST ANY MORE!!! Remove it from your tree"); |
... | ... | @@ -270,6 +284,7 @@ class UserMgr |
270 | 284 | } |
271 | 285 | |
272 | 286 | if ($base->hasAttribute('addable')) { |
287 | + $base->setAttribute('lastModif', time()); | |
273 | 288 | // keep this base tree |
274 | 289 | // error_log($baseId,1,email); |
275 | 290 | } |
... | ... | @@ -294,6 +309,8 @@ class UserMgr |
294 | 309 | |
295 | 310 | $centerNode->setAttribute('name', $base->getAttribute('name')); |
296 | 311 | $centerNode->setAttribute('desc', $base->getAttribute('desc')); |
312 | + $centerNode->setAttribute('lastModif', time()); | |
313 | + | |
297 | 314 | |
298 | 315 | $base->parentNode->removeChild($base); |
299 | 316 | |
... | ... | @@ -355,7 +372,7 @@ class UserMgr |
355 | 372 | $this->paramMgr->xmlDom->appendChild($BASE); |
356 | 373 | |
357 | 374 | return $this->paramMgr->xmlDom->save($this->paramMgr->xmlName); |
358 | - } | |
375 | + } | |
359 | 376 | } |
360 | 377 | |
361 | 378 | protected function makeNewBase($baseId) |
... | ... | @@ -546,8 +563,6 @@ class UserMgr |
546 | 563 | |
547 | 564 | $this->setPath(); |
548 | 565 | |
549 | - $this->userGrps = $this->getUserGrps(); | |
550 | - | |
551 | 566 | if (!$this->makeLocalTree()) |
552 | 567 | die("Login for ".$this->user." failed: Can't make LocalParams.xml");; |
553 | 568 | |
... | ... | @@ -568,7 +583,7 @@ class UserMgr |
568 | 583 | /* |
569 | 584 | * Special groups are defined in the generic_data/SpecialSettings/Groups.xml |
570 | 585 | */ |
571 | - if ($this->userGrps) { | |
586 | + if (isset($this->userGrps)) { | |
572 | 587 | // $specialGroup = $this->isSpecialGroup(); |
573 | 588 | $specialGroup = false; |
574 | 589 | // Special Info for special groups |
... | ... | @@ -602,20 +617,40 @@ class UserMgr |
602 | 617 | |
603 | 618 | protected function makeLocalTree() |
604 | 619 | { |
605 | - if (file_exists(USERWSDIR.'LocalParams.xml')) | |
606 | - unlink(USERWSDIR.'LocalParams.xml'); | |
620 | + $this->loadUserGrps(); | |
621 | + | |
622 | + if (file_exists(USERWSDIR.'LocalParams.xml')) { | |
623 | + if (file_exists(USERWSDIR.'userGrpsChecksum')) { | |
624 | + $lastGrpsChecksum = file_get_contents(USERWSDIR.'userGrpsChecksum'); | |
625 | + if ($lastGrpsChecksum == $this->userGrpsCheckSum) { | |
626 | + //No modification in groups for this user | |
627 | + if (filemtime(USERWSDIR.'LocalParams.xml') == filemtime(LocalData.'/LocalParams.xml')) { | |
628 | + //And no modification in LocalParams file => skip makeLocalTree | |
629 | + return true; | |
630 | + } | |
631 | + } | |
632 | + } | |
633 | + unlink(USERWSDIR.'LocalParams.xml'); | |
634 | + } | |
607 | 635 | |
608 | 636 | if (!copy(LocalData.'/LocalParams.xml', USERWSDIR.'LocalParams.xml')) |
609 | - die("Login for ".$this->user." failed: Can't copy LocalParams.xml"); | |
610 | - | |
611 | - if ($this->userGrps) | |
612 | - return $this->updateTreeForGrps(USERWSDIR.'LocalParams.xml'); | |
637 | + die("Login for ".$this->user." failed: Can't copy LocalParams.xml"); | |
638 | + //Save groups checksum used to generate this user local tree | |
639 | + file_put_contents(USERWSDIR.'userGrpsChecksum', $this->userGrpsCheckSum); | |
613 | 640 | |
614 | - return true; | |
641 | + $result = $this->updateTreeForGrps(USERWSDIR.'LocalParams.xml'); | |
642 | + | |
643 | + //Set modif time to the original one | |
644 | + touch(USERWSDIR.'LocalParams.xml', filemtime(LocalData.'/LocalParams.xml')); | |
645 | + | |
646 | + return TRUE; | |
615 | 647 | } |
616 | 648 | |
617 | 649 | protected function updateTreeForGrps($file) |
618 | 650 | { |
651 | + if (!isset($this->userGrps)) | |
652 | + return TRUE; | |
653 | + | |
619 | 654 | $xml = new DomDocument("1.0"); |
620 | 655 | |
621 | 656 | if(!$xml->load($file)) |
... | ... |
php/config.php
... | ... | @@ -66,6 +66,8 @@ ini_set('user_agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:7.0) Gecko/201 |
66 | 66 | // ini_set('upload_max_filesize',100000000); |
67 | 67 | // ini_set('post_max_size',1050000000); |
68 | 68 | |
69 | +// Delay between two update of remote parameters (in sec.) | |
70 | +define('REMOTE_PARAMS_UPDATE_DELAY', 3600); | |
69 | 71 | |
70 | 72 | // General Info dirs |
71 | 73 | define('DATAPATH', IHM_SRC_DIR.'/generic_data/'); |
... | ... | @@ -104,7 +106,7 @@ define('USERPATH', IHM_SRC_DIR.'/data/'); |
104 | 106 | define('SHAREDPATH', IHM_SRC_DIR.'/shared_data/'); |
105 | 107 | |
106 | 108 | // Web Service servers WSDL : $_SERVER['SERVER_NAME'] (par apache) gethostname() (par command) |
107 | -$SERVER_NAME = $_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : gethostname(); | |
109 | +$SERVER_NAME = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : gethostname(); | |
108 | 110 | define('webAlias',"http://".$SERVER_NAME.APACHE_ALIAS); |
109 | 111 | |
110 | 112 | define('DD_WSDL',DDSERVICE.'/dd.wsdl'); |
... | ... |
php/rest/getParameterList.php
... | ... | @@ -0,0 +1,26 @@ |
1 | +<?php | |
2 | + | |
3 | +if (php_sapi_name() !='cli') die("This script can be only executed from command line"); | |
4 | + | |
5 | +require_once("config.php"); | |
6 | +set_include_path(get_include_path() . PATH_SEPARATOR . "WebServices/Tests/"); | |
7 | + | |
8 | +require_once("Base/TestsSuite.php"); | |
9 | + | |
10 | +define("BASE_URL","http://127.0.0.1"); | |
11 | + | |
12 | +$suite = new TestsSuite(); | |
13 | +$suite->init('WebServices/Tests/Suite'); | |
14 | +$results = $suite->run(); | |
15 | + | |
16 | +$error = FALSE; | |
17 | +foreach ($results as $result) { | |
18 | + if (!$result['status']['success']) { | |
19 | + echo "[ERROR] ".$result['name']." - ".$result['status']['message'].PHP_EOL; | |
20 | + $error = TRUE; | |
21 | + } | |
22 | +} | |
23 | + | |
24 | +exit ($error); | |
25 | + | |
26 | +?> | |
... | ... |