Commit 1ec5d7bd88b2e9f2ff0b9e0e7f678d256d790696
1 parent
2396ac7b
Exists in
master
and in
111 other branches
WS getParameter, getDataset + getOrbites functions use now the new kernel + Add …
…client class for WS + Add test script for WS
Showing
5 changed files
with
751 additions
and
162 deletions
Show diff stats
... | ... | @@ -0,0 +1,136 @@ |
1 | +<?php | |
2 | +abstract class WSOutputFileFormat | |
3 | +{ | |
4 | + const NETCDF = "netCDF"; | |
5 | + const VOTABLE = "VOTable"; | |
6 | + const ASCII = "ASCII"; | |
7 | +} | |
8 | + | |
9 | +abstract class WSOutputTimeFormat | |
10 | +{ | |
11 | + const ISO = "ISO8601"; | |
12 | + const TIMESTAMP = "unixtime"; | |
13 | +} | |
14 | + | |
15 | +abstract class WSOrbitUnit | |
16 | +{ | |
17 | + const KM = "km"; | |
18 | + const RS = "Rs"; | |
19 | + const RJ = "Rj"; | |
20 | + const RCA = "Rca"; | |
21 | + const RGA = "Rga"; | |
22 | + const RIO = "Rio"; | |
23 | + const REU = "Reu"; | |
24 | + const RV = "Rv"; | |
25 | + const RM = "Rm"; | |
26 | + const RE = "Re"; | |
27 | + const AU = "AU"; | |
28 | +} | |
29 | + | |
30 | +abstract class WSSpacecraft | |
31 | +{ | |
32 | + const CASSINI = "Cassini_Public"; | |
33 | + const GALILEO = "Galileo"; | |
34 | + const VOYAGER1 = "Voyager_1"; | |
35 | + const VOYAGER2 = "Voyager_2"; | |
36 | + const PIONEER10 = "Pioneer_10"; | |
37 | + const PIONEER11 = "Pioneer_11"; | |
38 | + const PVO = "PVO"; | |
39 | + const ACE = "ACE"; | |
40 | + const VEX = "VEX"; | |
41 | + const MEX = "MEX"; | |
42 | + const MGS = "MGS"; | |
43 | + const MAVEN = "MAVEN"; | |
44 | + const MESSENGER = "MESSENGER"; | |
45 | + const ULYSSES = "ULYSSES"; | |
46 | + const STEREOA = "Stereo-A"; | |
47 | + const STEREOB = "Stereo-B"; | |
48 | + const WIND = "WIND"; | |
49 | + const THEMISA = "THEMIS-A"; | |
50 | + const THEMISB = "THEMIS-B"; | |
51 | + const THEMISC = "THEMIS-C"; | |
52 | + const THEMISD = "THEMIS-D"; | |
53 | + const THEMISE = "THEMIS-E"; | |
54 | + const CLUSTER1 = "CLUSTER1"; | |
55 | + const CLUSTER2 = "CLUSTER2"; | |
56 | + const CLUSTER3 = "CLUSTER3"; | |
57 | + const CLUSTER4 = "CLUSTER4"; | |
58 | + const DOUBLESTAR1 = "DoubleStar1"; | |
59 | + const IMP8 = "IMP-8"; | |
60 | + const GEOTAIL = "GEOTAIL"; | |
61 | + const POLAR = "POLAR"; | |
62 | + const INTERBALLTAIL = "INTERBALL-Tail"; | |
63 | + const ISEE1 = "ISEE-1"; | |
64 | + const ISEE2 = "ISEE-2"; | |
65 | +} | |
66 | + | |
67 | +abstract class WSCoordinatesSytem | |
68 | +{ | |
69 | + const CPHIO = "CPHIO"; | |
70 | + const GPHIO = "GPHIO"; | |
71 | + const IPHIO = "IPHIO"; | |
72 | + const EPHIO = "EPHIO"; | |
73 | + const EQUATORIAL = "Equatorial"; | |
74 | + const CGM = "CGM"; | |
75 | + const CARRINGTON = "Carrington"; | |
76 | + const DM = "DM"; | |
77 | + const GEI = "GEI"; | |
78 | + const GEO = "GEO"; | |
79 | + const GSE = "GSE"; | |
80 | + const GSEQ = "GSEQ"; | |
81 | + const GSM = "GSM"; | |
82 | + const HAE = "HAE"; | |
83 | + const HCC = "HCC"; | |
84 | + const HCI = "HCI"; | |
85 | + const HCR = "HCR"; | |
86 | + const HEE = "HEE"; | |
87 | + const HEEQ = "HEEQ"; | |
88 | + const HG = "HG"; | |
89 | + const HGI = "HGI"; | |
90 | + const HPC = "HPC"; | |
91 | + const HPR = "HPR"; | |
92 | + const J2000 = "J2000"; | |
93 | + const LGM = "LGM"; | |
94 | + const MAG = "MAG"; | |
95 | + const MFA = "MFA"; | |
96 | + const RTN = "RTN"; | |
97 | + const SC = "SC"; | |
98 | + const SE = "SE"; | |
99 | + const SM = "SM"; | |
100 | + const SR = "SR"; | |
101 | + const SR2 = "SR2"; | |
102 | + const SSE = "SSE"; | |
103 | + const SSE_L = "SSE_L"; | |
104 | + const SPACECRAFTORBPLANE = "SpacecraftOrbitPlane"; | |
105 | + const WGS84 = "WGS84"; | |
106 | + const MSO = "MSO"; | |
107 | + const VSO = "VSO"; | |
108 | +} | |
109 | + | |
110 | +Interface WSClientInterface | |
111 | +{ | |
112 | + public function getTimeTablesList($userID = "", $password = ""); | |
113 | + | |
114 | + public function getTimeTable($ttID, $userID = "", $password = ""); | |
115 | + | |
116 | + public function getParameterList($userID, $password = ""); | |
117 | + | |
118 | + public function getParameter($startTime, $stopTime, $parameterID, $sampling = 0, $userID = "", $password = "", | |
119 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0); | |
120 | + | |
121 | + public function getDataset($startTime, $stopTime, $datasetID, $sampling = 0, $userID = "", $password = "", | |
122 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0); | |
123 | + | |
124 | + /*public function getPlot($startTime, $stopTime, $missionID, $userID = "", $password = ""); | |
125 | + | |
126 | + public function getResultPlot($plotDirectoryURL);*/ | |
127 | + | |
128 | + public function getOrbites($startTime, $stopTime, $spacecraft, $coordinateSystem, $units = WSOrbitUnit::KM, | |
129 | + $sampling = 0, $userID = "", $password = "", $outputFormat = WSOutputFileFormat::NETCDF, | |
130 | + $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0); | |
131 | + | |
132 | + public function isAlive(); | |
133 | + | |
134 | + public function getObsDataTree(); | |
135 | +} | |
136 | +?> | |
0 | 137 | \ No newline at end of file |
... | ... |
... | ... | @@ -0,0 +1,153 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once("WSClientInterface.php"); | |
4 | + | |
5 | +class WSClientREST implements WSClientInterface | |
6 | +{ | |
7 | + private $baseURL = ""; | |
8 | + | |
9 | + function __construct($baseURL) | |
10 | + { | |
11 | + $this->baseURL = $baseURL; | |
12 | + } | |
13 | + | |
14 | + public function isAlive() | |
15 | + { | |
16 | + return $this->call(__FUNCTION__, array()); | |
17 | + } | |
18 | + | |
19 | + public function getObsDataTree() | |
20 | + { | |
21 | + return $this->call(__FUNCTION__, array()); | |
22 | + } | |
23 | + | |
24 | + public function getTimeTablesList($userID = "", $password = "") | |
25 | + { | |
26 | + $params = array('parameters' => array()); | |
27 | + if ($userID != "" && $password != "") | |
28 | + { | |
29 | + $params['parameters'] = array( | |
30 | + "userID" => $userID, | |
31 | + "password"=> $password | |
32 | + ); | |
33 | + } | |
34 | + return $this->call(__FUNCTION__, $params); | |
35 | + } | |
36 | + | |
37 | + public function getTimeTable($ttID, $userID = "", $password = "") | |
38 | + { | |
39 | + $params = array('parameters' => array()); | |
40 | + if ($userID != "" && $password != "") | |
41 | + { | |
42 | + $params['parameters'] = array( | |
43 | + "userID" => $userID, | |
44 | + "password"=> $password | |
45 | + ); | |
46 | + } | |
47 | + $params['parameters']['ttID'] = $ttID; | |
48 | + return $this->call(__FUNCTION__, $params); | |
49 | + } | |
50 | + | |
51 | + public function getParameterList($userID, $password = "") | |
52 | + { | |
53 | + $params = array('parameters' => array( | |
54 | + "userID" => $userID | |
55 | + )); | |
56 | + if ($password != "") | |
57 | + $params['parameters']["password"] = $password; | |
58 | + return $this->call(__FUNCTION__, $params); | |
59 | + } | |
60 | + | |
61 | + public function getParameter($startTime, $stopTime, $parameterID, $sampling = 0, $userID = "", $password = "", | |
62 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
63 | + { | |
64 | + $params = array('parameters' => array( | |
65 | + "startTime" => $startTime, | |
66 | + "stopTime" => $stopTime, | |
67 | + "parameterID" => $parameterID, | |
68 | + "outputFormat" => $outputFormat, | |
69 | + "timeFormat" => $timeFormat, | |
70 | + "gzip" => $gzip | |
71 | + )); | |
72 | + | |
73 | + if ($sampling > 0) | |
74 | + $params["parameters"]["sampling"] = $sampling; | |
75 | + | |
76 | + if ($userID != "" && $password != "") | |
77 | + { | |
78 | + $params["parameters"]["userID"] = $userID; | |
79 | + $params["parameters"]["password"] = $password; | |
80 | + } | |
81 | + | |
82 | + return $this->call(__FUNCTION__, $params); | |
83 | + } | |
84 | + | |
85 | + public function getDataset($startTime, $stopTime, $datasetID, $sampling = 0, $userID = "", $password = "", | |
86 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
87 | + { | |
88 | + $params = array('parameters' => array( | |
89 | + "startTime" => $startTime, | |
90 | + "stopTime" => $stopTime, | |
91 | + "datasetID" => $datasetID, | |
92 | + "outputFormat" => $outputFormat, | |
93 | + "timeFormat" => $timeFormat, | |
94 | + "gzip" => $gzip | |
95 | + )); | |
96 | + | |
97 | + if ($sampling > 0) | |
98 | + $params["parameters"]["sampling"] = $sampling; | |
99 | + | |
100 | + if ($userID != "" && $password != "") | |
101 | + { | |
102 | + $params["parameters"]["userID"] = $userID; | |
103 | + $params["parameters"]["password"] = $password; | |
104 | + } | |
105 | + | |
106 | + return $this->call(__FUNCTION__, $params); | |
107 | + } | |
108 | + | |
109 | + public function getOrbites($startTime, $stopTime, $spacecraft, $coordinateSystem, $units = WSOrbitUnit::KM, | |
110 | + $sampling = 0, $userID = "", $password = "", $outputFormat = WSOutputFileFormat::NETCDF, | |
111 | + $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
112 | + { | |
113 | + $params = array('parameters' => array( | |
114 | + "startTime" => $startTime, | |
115 | + "stopTime" => $stopTime, | |
116 | + "spacecraft" => $spacecraft, | |
117 | + "coordinateSystem" => $coordinateSystem, | |
118 | + "units" => $units, | |
119 | + "outputFormat" => $outputFormat, | |
120 | + "timeFormat" => $timeFormat, | |
121 | + "gzip" => $gzip | |
122 | + )); | |
123 | + | |
124 | + if ($sampling > 0) | |
125 | + $params["parameters"]["sampling"] = $sampling; | |
126 | + | |
127 | + if ($userID != "" && $password != "") | |
128 | + { | |
129 | + $params["parameters"]["userID"] = $userID; | |
130 | + $params["parameters"]["password"] = $password; | |
131 | + } | |
132 | + | |
133 | + return $this->call(__FUNCTION__, $params); | |
134 | + } | |
135 | + | |
136 | + private function call($function, $params) | |
137 | + { | |
138 | + $functionURL = $this->baseURL."/".$function.".php"; | |
139 | + | |
140 | + $isFirstParam = true; | |
141 | + foreach ($params as $paramName => $paramValue) | |
142 | + { | |
143 | + if ($isFirstParam) | |
144 | + $functionURL .= "?"; | |
145 | + else | |
146 | + $functionURL .= "&"; | |
147 | + $functionURL .= $paramName."=".$paramValue; | |
148 | + } | |
149 | + | |
150 | + return file_get_contents($functionURL); | |
151 | + } | |
152 | +} | |
153 | +?> | |
0 | 154 | \ No newline at end of file |
... | ... |
... | ... | @@ -0,0 +1,162 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once("WSClientInterface.php"); | |
4 | + | |
5 | +class WSClientSOAP implements WSClientInterface | |
6 | +{ | |
7 | + private $wsdl = ""; | |
8 | + private $client = null; | |
9 | + | |
10 | + function __construct($wsdl) | |
11 | + { | |
12 | + $this->wsdl = $wsdl; | |
13 | + ini_set('soap.wsdl_cache_enabled', 0); | |
14 | + } | |
15 | + | |
16 | + public function isAlive() | |
17 | + { | |
18 | + return $this->call(__FUNCTION__, array()); | |
19 | + } | |
20 | + | |
21 | + public function getObsDataTree() | |
22 | + { | |
23 | + return $this->call(__FUNCTION__, array()); | |
24 | + } | |
25 | + | |
26 | + public function getTimeTablesList($userID = "", $password = "") | |
27 | + { | |
28 | + $params = array('parameters' => array()); | |
29 | + if ($userID != "" && $password != "") | |
30 | + { | |
31 | + $params['parameters'] = array( | |
32 | + "userID" => $userID, | |
33 | + "password"=> $password | |
34 | + ); | |
35 | + } | |
36 | + return $this->call(__FUNCTION__, $params); | |
37 | + } | |
38 | + | |
39 | + public function getTimeTable($ttID, $userID = "", $password = "") | |
40 | + { | |
41 | + $params = array('parameters' => array()); | |
42 | + if ($userID != "" && $password != "") | |
43 | + { | |
44 | + $params['parameters'] = array( | |
45 | + "userID" => $userID, | |
46 | + "password"=> $password | |
47 | + ); | |
48 | + } | |
49 | + $params['parameters']['ttID'] = $ttID; | |
50 | + return $this->call(__FUNCTION__, $params); | |
51 | + } | |
52 | + | |
53 | + public function getParameterList($userID, $password = "") | |
54 | + { | |
55 | + $params = array('parameters' => array( | |
56 | + "userID" => $userID | |
57 | + )); | |
58 | + if ($password != "") | |
59 | + $params['parameters']["password"] = $password; | |
60 | + return $this->call(__FUNCTION__, $params); | |
61 | + } | |
62 | + | |
63 | + public function getParameter($startTime, $stopTime, $parameterID, $sampling = 0, $userID = "", $password = "", | |
64 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
65 | + { | |
66 | + $params = array('parameters' => array( | |
67 | + "startTime" => $startTime, | |
68 | + "stopTime" => $stopTime, | |
69 | + "parameterID" => $parameterID, | |
70 | + "outputFormat" => $outputFormat, | |
71 | + "timeFormat" => $timeFormat, | |
72 | + "gzip" => $gzip | |
73 | + )); | |
74 | + | |
75 | + if ($sampling > 0) | |
76 | + $params["parameters"]["sampling"] = $sampling; | |
77 | + | |
78 | + if ($userID != "" && $password != "") | |
79 | + { | |
80 | + $params["parameters"]["userID"] = $userID; | |
81 | + $params["parameters"]["password"] = $password; | |
82 | + } | |
83 | + | |
84 | + return $this->call(__FUNCTION__, $params); | |
85 | + } | |
86 | + | |
87 | + public function getDataset($startTime, $stopTime, $datasetID, $sampling = 0, $userID = "", $password = "", | |
88 | + $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
89 | + { | |
90 | + $params = array('parameters' => array( | |
91 | + "startTime" => $startTime, | |
92 | + "stopTime" => $stopTime, | |
93 | + "datasetID" => $datasetID, | |
94 | + "outputFormat" => $outputFormat, | |
95 | + "timeFormat" => $timeFormat, | |
96 | + "gzip" => $gzip | |
97 | + )); | |
98 | + | |
99 | + if ($sampling > 0) | |
100 | + $params["parameters"]["sampling"] = $sampling; | |
101 | + | |
102 | + if ($userID != "" && $password != "") | |
103 | + { | |
104 | + $params["parameters"]["userID"] = $userID; | |
105 | + $params["parameters"]["password"] = $password; | |
106 | + } | |
107 | + | |
108 | + return $this->call(__FUNCTION__, $params); | |
109 | + } | |
110 | + | |
111 | + public function getOrbites($startTime, $stopTime, $spacecraft, $coordinateSystem, $units = WSOrbitUnit::KM, | |
112 | + $sampling = 0, $userID = "", $password = "", $outputFormat = WSOutputFileFormat::NETCDF, | |
113 | + $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0) | |
114 | + { | |
115 | + $params = array('parameters' => array( | |
116 | + "startTime" => $startTime, | |
117 | + "stopTime" => $stopTime, | |
118 | + "spacecraft" => $spacecraft, | |
119 | + "coordinateSystem" => $coordinateSystem, | |
120 | + "units" => $units, | |
121 | + "outputFormat" => $outputFormat, | |
122 | + "timeFormat" => $timeFormat, | |
123 | + "gzip" => $gzip | |
124 | + )); | |
125 | + | |
126 | + if ($sampling > 0) | |
127 | + $params["parameters"]["sampling"] = $sampling; | |
128 | + | |
129 | + if ($userID != "" && $password != "") | |
130 | + { | |
131 | + $params["parameters"]["userID"] = $userID; | |
132 | + $params["parameters"]["password"] = $password; | |
133 | + } | |
134 | + | |
135 | + return $this->call(__FUNCTION__, $params); | |
136 | + } | |
137 | + | |
138 | + private function call($function, $params) | |
139 | + { | |
140 | + if ($this->client == null) | |
141 | + $this->createSOAPClient(); | |
142 | + try { | |
143 | + return $this->client ->__call($function, $params); | |
144 | + } | |
145 | + catch (Exception $e) { | |
146 | + print_r($this->client->__getLastResponse()); | |
147 | + var_dump($e); | |
148 | + return null; | |
149 | + } | |
150 | + } | |
151 | + | |
152 | + private function createSOAPClient() | |
153 | + { | |
154 | + $this->client = new SoapClient( | |
155 | + $this->wsdl, | |
156 | + array( | |
157 | + "trace"=> 1, | |
158 | + "soap_version"=> SOAP_1_1 | |
159 | + )); | |
160 | + } | |
161 | +} | |
162 | +?> | |
0 | 163 | \ No newline at end of file |
... | ... |
php/classes/WebServer.php
... | ... | @@ -10,6 +10,8 @@ class WebResultMgr |
10 | 10 | private $resDOM; |
11 | 11 | private $rootEl; |
12 | 12 | private $resXP; |
13 | + private $requestManager = null; | |
14 | + private $paramLoader = null; | |
13 | 15 | |
14 | 16 | function __construct() |
15 | 17 | { |
... | ... | @@ -787,146 +789,141 @@ $vars["sampling"] = strtr($vars["sampling"], array($matches[1] => "")); |
787 | 789 | |
788 | 790 | |
789 | 791 | protected function doDownloadRequest($interval,$paramList,$user,$formatInfo,$dataFileName) { |
790 | - | |
791 | - | |
792 | - $duration = $this->timeIntervalToDuration($interval['startTime'],$interval['stopTime']); | |
793 | - | |
794 | - if ($interval['sampling']) $structure = 0;// sampling | |
795 | -else $structure = 2; // not sampling | |
796 | - | |
797 | - $obj = (object)array( | |
798 | -"nodeType" => "download", | |
799 | -"type" => "Download", | |
800 | -"downloadSrc" => "0", | |
801 | -"structure" => $structure, | |
802 | -"sampling" => $interval['sampling'], | |
803 | -"output" => "", | |
804 | -"header" => "0", | |
805 | -"timesrc" => "Interval", | |
806 | -"startDate" => $interval['startTime'], | |
807 | -"durationDay" => $duration["days"], | |
808 | -"durationHour" => $duration["hours"], | |
809 | -"durationMin" => $duration["mins"], | |
810 | -"durationSec" => $duration["secs"], | |
811 | -"list" => $paramList['params'], | |
812 | -"milli" => true, | |
813 | -"fileformat" => "ASCII", | |
814 | -"timeformat" => "YYYY-MM-DDThh:mm:ss", | |
815 | -"compression" => "tar+gzip", | |
816 | -"leaf" => true, | |
817 | - //ToChange | |
818 | - "username" => $user['userName'], | |
819 | - "password" => $user['userPwd'], | |
820 | - "sessionID" => $user['sessionID'] | |
821 | - ); | |
822 | - | |
823 | - $objectMgr = new RequestMgr('download'); | |
824 | - | |
825 | - if (!$objectMgr){ | |
826 | - if ($this->isSoap) throw new SoapFault("server01","Cannot init request manager"); | |
827 | - else return array('success' => false, 'message' => "Cannot init request manager"); | |
828 | - } | |
829 | - | |
830 | -// $res = $objectMgr->execute($obj); | |
831 | - | |
832 | - $downloadResult = $objectMgr->execute($obj); $error = $downloadResult['error']; | |
833 | - $pid = $downloadResult['pid']; | |
834 | - $bach= false; | |
835 | - if ( $downloadResult['pid'] != 0) | |
836 | - $bach= true; | |
837 | - | |
838 | - $jobMgr = new JobsMgr(); | |
839 | - | |
840 | - if ($bach){ | |
841 | - | |
842 | -if (!$jobMgr){ | |
843 | - if ($this->isSoap) throw new SoapFault("server06","Cannot init job manager"); | |
844 | - else return array('success' => false, 'message' => "Cannot init job manager"); | |
845 | -} | |
846 | - | |
847 | - while (!($jobMgr->isFinished($pid))){ | |
848 | - sleep(JOBTIMEOUT); | |
849 | -} | |
850 | - | |
851 | -$newName='result_'.$objectMgr->cachekiller(); | |
852 | -$objectMgr->postProcessing($downloadResult['rawname'], $newName); | |
853 | -$downloadResult['id']= $downloadResult['rawname']; | |
854 | -$downloadResult['name'] = $newName; | |
855 | -$downloadResult['pid'] = 0; | |
856 | - | |
857 | - } | |
858 | - | |
859 | - $from_path = USERPATH.$this->userID.'/RES/'.$downloadResult['id'].'_/'; | |
860 | - | |
861 | - if (!file_exists($from_path)){ | |
862 | - if ($this->isSoap) throw new SoapFault("server07","User result folder doesn't exist $from_path ERROR $error "); | |
863 | - else return array('success' => false, 'message' => "User result folder doesn't exist"); | |
864 | - } | |
865 | - | |
866 | - $from_file = $from_path.$downloadResult['name'].'.tar.gz'; | |
867 | - | |
868 | - if (!file_exists($from_file)){ | |
869 | - if ($this->isSoap) throw new SoapFault("server08","Impossible find result file"); | |
870 | - else return array('success' => false, 'message' => "Impossible find result file"); | |
871 | - } | |
872 | - | |
873 | - if(($downloadResult['pid'] == 0) && file_exists($from_file)){ | |
874 | -if ($formatInfo['format'] == "VOTable"){ | |
875 | - $res = $objectMgr->generateVOTableFromDownloadResult($downloadResult['id'], $downloadResult['name']); | |
876 | - if ($res['success']){ | |
877 | - $outputFile = $res['files'][0]; | |
878 | - rename($res['files'][0], WSRESULT.$this->dataFileName.".xml"); | |
879 | - $outputFile = WSRESULT.$this->dataFileName.".xml"; | |
880 | - } | |
881 | - else { | |
882 | - if ($this->isSoap) throw new SoapFault("server08",$res['message']); | |
883 | - else return array('success' => false, 'message' => $res['message']); | |
884 | - } | |
885 | -} | |
886 | -elseif ($formatInfo['format'] == "netCDF"){ | |
887 | - $formatNc = true; | |
888 | - if ($this->isSoap) throw new SoapFault("server09","netCDF format not implemented yet"); | |
889 | - else return array('success' => false, 'message' => "netCDF format not implemented yet"); | |
890 | -} | |
891 | -else { | |
892 | - exec("tar zxvf $from_file"); | |
893 | - exec("mv $from_path*.txt ".WSRESULT."'".$this->dataFileName.".txt'"); | |
894 | - $outputFile = WSRESULT.$this->dataFileName.".txt"; | |
895 | - chmod ($outputFile, 0664); | |
896 | -} | |
897 | - } | |
898 | - | |
899 | - if ($formatInfo['gzip'] == 1){ | |
900 | - $zipFile = $outputFile.".gz"; | |
901 | - $this->compress($outputFile, $zipFile); | |
902 | - $outputFile = $zipFile; | |
903 | - } | |
904 | - | |
905 | - if ($outputFile) { | |
906 | - if ($formatInfo['format'] == "VOTable"){ | |
907 | - $dom = new DOMDocument; | |
908 | - $dom->load($outputFile); | |
909 | - $tds = $dom->getElementsByTagName('TD'); | |
910 | - | |
911 | - if ($tds->length < 1){ | |
912 | - if ($this->isSoap) throw new SoapFault("server10","No data"); | |
913 | - else return array('success' => false, 'message' => "No data"); | |
914 | - } | |
915 | - } | |
916 | - $outputFile = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$outputFile); | |
917 | - } | |
918 | - | |
919 | - if ($bach){ | |
920 | - $obj = (object)array( | |
921 | - "id" => "bkgrd_down_".$pid, | |
922 | - "leaf" => true, | |
923 | - "nodeType"=>"bkgWorks"); | |
924 | - $jobMgr->deleteObject($obj); | |
925 | - | |
926 | -} | |
927 | -else $jobMgr->deleteTmp(); | |
928 | - | |
929 | - return array('success' => true, 'dataFileURLs' => $outputFile); | |
792 | + if ($interval['sampling']) | |
793 | + $structure = 0;// sampling | |
794 | + else | |
795 | + $structure = 2; // not sampling | |
796 | + | |
797 | + $fileExtension = ""; | |
798 | + switch ($formatInfo['format']) | |
799 | + { | |
800 | + case 'netCDF' : | |
801 | + if (!$jobMgr){ | |
802 | + if ($this->isSoap) throw new SoapFault("server01","netCDF format not implemented"); | |
803 | + else return array('success' => false, 'message' => "netCDF format not implemented"); | |
804 | + } | |
805 | + break; | |
806 | + case 'VOTable' : | |
807 | + $fileformat = "vot"; | |
808 | + $kernelExtension = ".vot"; | |
809 | + $wsExtension = ".xml"; | |
810 | + break; | |
811 | + case 'ASCII' : | |
812 | + default : | |
813 | + $fileformat = "ASCII"; | |
814 | + $kernelExtension = ".txt"; | |
815 | + $wsExtension = ".txt"; | |
816 | + } | |
817 | + | |
818 | + switch ($formatInfo['timeFormat']) | |
819 | + { | |
820 | + case 'unixtime' : | |
821 | + $timeformat = 'Timestamp'; | |
822 | + break; | |
823 | + default : | |
824 | + $timeformat = 'YYYY-MM-DDThh:mm:ss'; | |
825 | + } | |
826 | + | |
827 | + if ($formatInfo['gzip'] == 1) | |
828 | + { | |
829 | + $compression = "gzip"; | |
830 | + $kernelExtension .= ".gz"; | |
831 | + $wsExtension .= ".gz"; | |
832 | + } | |
833 | + else | |
834 | + $compression = ""; | |
835 | + | |
836 | + require_once(INTEGRATION_SRC_DIR."RequestManager.php"); | |
837 | + IHMConfigClass::setUserName($this->userID); | |
838 | + if (!isset($this->paramLoader)) | |
839 | + $this->paramLoader = new IHMUserParamLoaderClass(); | |
840 | + | |
841 | + //Build parameter list | |
842 | + $params = array(); | |
843 | + | |
844 | + foreach ($paramList['params'] as $paramId) | |
845 | + { | |
846 | + if (preg_match("#^ws_#",$paramId)) | |
847 | + { | |
848 | + $res = $this->paramLoader->getDerivedParameterNameFromId($paramId); | |
849 | + if (!$res["success"]) | |
850 | + { | |
851 | + if ($this->isSoap) throw new SoapFault("server02", 'Not available derived parameter '.$paramId); | |
852 | + else return array('success' => false, 'message' => 'Not available derived parameter '.$paramId); | |
853 | + } | |
854 | + $params[] = "ws_".$res['name']; | |
855 | + } | |
856 | + else if (preg_match("#^wsd_#",$paramId)) | |
857 | + { | |
858 | + $res = $this->paramLoader->getUploadedParameterNameFromId($paramId); | |
859 | + if (!$res["success"]) | |
860 | + { | |
861 | + if ($this->isSoap) throw new SoapFault("server02", 'Not available user parameter '.$paramId); | |
862 | + else return array('success' => false, 'message' => 'Not available user parameter '.$paramId); | |
863 | + } | |
864 | + $params[] = "wsd_".$res['name']; | |
865 | + } | |
866 | + else | |
867 | + $params[] = $paramId; | |
868 | + } | |
869 | + | |
870 | + $obj = (object)array( | |
871 | + "nodeType" => "download", | |
872 | + "downloadSrc" => "0", | |
873 | + "structure" => $structure, | |
874 | + "refparamSampling" => false, | |
875 | + "sampling" => $interval['sampling'], | |
876 | + "timesrc" => "Interval", | |
877 | + "startDate" => $interval['startTime'], | |
878 | + "stopDate" => $interval['stopTime'], | |
879 | + "list" => $params, | |
880 | + "fileformat" => $fileformat, | |
881 | + "timeformat" => $timeformat, | |
882 | + "compression" => $compression, | |
883 | + "disablebatch" => true | |
884 | + ); | |
885 | + | |
886 | + if (!isset($this->requestManager)) | |
887 | + $this->requestManager = new RequestManagerClass(); | |
888 | + | |
889 | + try { | |
890 | + $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PARAMS, $obj); | |
891 | + } catch (Exception $e) { | |
892 | + if ($this->isSoap) throw new SoapFault("server02", 'Exception detected : '.$e->getMessage()); | |
893 | + else return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage()); | |
894 | + } | |
895 | + | |
896 | + if (!$downloadResult['success']) | |
897 | + { | |
898 | + if ($this->isSoap) throw new SoapFault("server03", $downloadResult['message']); | |
899 | + else return array('success' => false, 'message' => $downloadResult['message']); | |
900 | + } | |
901 | + | |
902 | + $resultFile = USERPATH.$this->userID.'/RES/'.$downloadResult['folder'].'/'.$downloadResult['result']; | |
903 | + $resultFile .= $kernelExtension; | |
904 | + | |
905 | + if (!file_exists($resultFile)) | |
906 | + { | |
907 | + if ($this->isSoap) throw new SoapFault("server04", 'Cannot retrieve result file '.$resultFile); | |
908 | + else return array('success' => false, 'message' => 'Cannot retrieve result file'); | |
909 | + } | |
910 | + | |
911 | + rename($resultFile, WSRESULT.$this->dataFileName.$wsExtension); | |
912 | + $outputFile = WSRESULT.$this->dataFileName.$wsExtension; | |
913 | + chmod ($outputFile, 0664); | |
914 | + $outputFile = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$outputFile); | |
915 | + | |
916 | + $obj = (object)array( | |
917 | + 'id' => $downloadResult['id'] | |
918 | + ); | |
919 | + | |
920 | + try { | |
921 | + $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, id); | |
922 | + } catch (Exception $e) { | |
923 | + //Nothing to do | |
924 | + } | |
925 | + | |
926 | + return array('success' => true, 'dataFileURLs' => $outputFile); | |
930 | 927 | |
931 | 928 | } |
932 | 929 | |
... | ... | @@ -948,26 +945,30 @@ else $jobMgr->deleteTmp(); |
948 | 945 | } |
949 | 946 | |
950 | 947 | protected function getDataFileName($vars, $multiParam){ |
951 | - if ($vars['startTime'] && $vars['stopTime'] && $vars['parameterID'] && !$multiParam){ | |
952 | - $fileName = $vars['parameterID']."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime'])."-".$vars['sampling']; | |
953 | - return array('success' => true, 'fileName' => $fileName); | |
954 | - } | |
955 | - elseif ($vars['startTime'] && $vars['stopTime'] && $vars['datasetID'] && $multiParam){ | |
956 | - $datasetName = strtr($vars["datasetID"], array(":" => "_")); | |
957 | - $fileName = $datasetName."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime'])."-".$vars['sampling']; | |
958 | - return array('success' => true, 'fileName' => $fileName); | |
959 | - } | |
960 | - else { | |
961 | -if (!$vars['startTime']) | |
962 | -$message="Start time not specified"; | |
963 | -if (!$vars['stopTime']) | |
964 | -$message="Stop time not specified"; | |
965 | -if (!$vars['parameterID'] && !$multiParam) | |
966 | -$message="Parameter not specified"; | |
967 | -if (!$vars['datasetID'] && $multiParam) | |
968 | -$message="DataSet not specified"; | |
969 | -return array('success' => false, 'message' => $message); | |
970 | - } | |
948 | + if ($vars['startTime'] && $vars['stopTime'] && $vars['parameterID'] && !$multiParam){ | |
949 | + $fileName = $vars['parameterID']."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); | |
950 | + if (isset($vars['sampling']) && $vars['sampling'] != "" && $vars['sampling'] != 0) | |
951 | + $fileName .= "-".$vars['sampling']; | |
952 | + return array('success' => true, 'fileName' => $fileName); | |
953 | + } | |
954 | + else if ($vars['startTime'] && $vars['stopTime'] && $vars['datasetID'] && $multiParam){ | |
955 | + $datasetName = strtr($vars["datasetID"], array(":" => "_")); | |
956 | + $fileName = $datasetName."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); | |
957 | + if (isset($vars['sampling']) && $vars['sampling'] != "" && $vars['sampling'] != 0) | |
958 | + $fileName .= "-".$vars['sampling']; | |
959 | + return array('success' => true, 'fileName' => $fileName); | |
960 | + } | |
961 | + else { | |
962 | + if (!$vars['startTime']) | |
963 | + $message="Start time not specified"; | |
964 | + if (!$vars['stopTime']) | |
965 | + $message="Stop time not specified"; | |
966 | + if (!$vars['parameterID'] && !$multiParam) | |
967 | + $message="Parameter not specified"; | |
968 | + if (!$vars['datasetID'] && $multiParam) | |
969 | + $message="DataSet not specified"; | |
970 | + return array('success' => false, 'message' => $message); | |
971 | + } | |
971 | 972 | } |
972 | 973 | |
973 | 974 | private function compress($srcName, $dstName) { |
... | ... | @@ -982,5 +983,4 @@ return array('success' => false, 'message' => $message); |
982 | 983 | } |
983 | 984 | |
984 | 985 | } |
985 | -?> | |
986 | - | |
986 | +?> | |
987 | 987 | \ No newline at end of file |
... | ... |
... | ... | @@ -0,0 +1,138 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once("classes/WSClientSOAP.php"); | |
4 | +require_once("classes/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("testKernel", "amda"); | |
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", "testKernel", "amda"); | |
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("testKernel", "amda"); | |
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 | + | |
126 | +$clientSOAP = new WSClientSOAP("http://localhost/NEWAMDA-BENJAMIN/public/wsdl/Methods_AMDA.wsdl"); | |
127 | + | |
128 | +echo "==> Suite tests for SOAP client".PHP_EOL; | |
129 | +runSuiteTests($clientSOAP); | |
130 | + | |
131 | +//REST client is obsolete | |
132 | +/*$clientREST = new WSClientREST("http://localhost/NEWAMDA-BENJAMIN/php/rest/"); | |
133 | + | |
134 | +echo "==> Suite tests for REST client".PHP_EOL; | |
135 | +runSuiteTests($clientREST);*/ | |
136 | + | |
137 | + | |
138 | +?> | |
0 | 139 | \ No newline at end of file |
... | ... |