Commit 039d19acfa24b03f67f1720aca8d281686b3bff5
1 parent
aa2786b4
Exists in
master
and in
94 other branches
Fix getParameter WS API
Showing
5 changed files
with
51 additions
and
30 deletions
Show diff stats
php/WebServices/WSUserMgr.php
@@ -17,7 +17,7 @@ class WSUserMgr extends UserMgr | @@ -17,7 +17,7 @@ class WSUserMgr extends UserMgr | ||
17 | exit(json_encode(array("error" => $msg))); | 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 | $this->user = trim($username); | 22 | $this->user = trim($username); |
23 | if (isset($sessionID)) | 23 | if (isset($sessionID)) |
@@ -55,11 +55,10 @@ class WSUserMgr extends UserMgr | @@ -55,11 +55,10 @@ class WSUserMgr extends UserMgr | ||
55 | if ( $setPathOnly ) | 55 | if ( $setPathOnly ) |
56 | return array('success' => true); | 56 | return array('success' => true); |
57 | 57 | ||
58 | - $this->userGrps = $this->getUserGrps(); | ||
59 | $this->makeLocalTree(); | 58 | $this->makeLocalTree(); |
60 | $this->makeRemoteTree(); | 59 | $this->makeRemoteTree(); |
61 | 60 | ||
62 | return array('success' => true); | 61 | return array('success' => true); |
63 | } | 62 | } |
64 | } | 63 | } |
65 | -?> | ||
66 | \ No newline at end of file | 64 | \ No newline at end of file |
65 | +?> |
php/WebServices/WebServer.php
@@ -19,7 +19,7 @@ class WebServer | @@ -19,7 +19,7 @@ class WebServer | ||
19 | if (!is_dir(WSConfigClass::getWsResultDir())) mkdir(WSConfigClass::getWsResultDir(), 0775); | 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 | $this->requestTime = date('Ymd',time()); | 24 | $this->requestTime = date('Ymd',time()); |
25 | 25 | ||
@@ -57,7 +57,7 @@ class WebServer | @@ -57,7 +57,7 @@ class WebServer | ||
57 | private function initUserMgr($setPathOnly = false) | 57 | private function initUserMgr($setPathOnly = false) |
58 | { | 58 | { |
59 | $wsUserMgr = new WSUserMgr(); | 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 | $this->IPclient = $wsUserMgr->getIPClient(); | 62 | $this->IPclient = $wsUserMgr->getIPClient(); |
63 | 63 | ||
@@ -175,6 +175,8 @@ class WebServer | @@ -175,6 +175,8 @@ class WebServer | ||
175 | $xpath = new DOMXpath($orbitsXml); | 175 | $xpath = new DOMXpath($orbitsXml); |
176 | $path = '//orbites[@mission="'.$spacecraft.'" and @coordinate_system="'.$orbitRequest['coordinateSystem'].'" and @units="'.$orbitRequest['units'].'" ] '; | 176 | $path = '//orbites[@mission="'.$spacecraft.'" and @coordinate_system="'.$orbitRequest['coordinateSystem'].'" and @units="'.$orbitRequest['units'].'" ] '; |
177 | 177 | ||
178 | +error_log($path); | ||
179 | + | ||
178 | $orbits = $xpath->query($path); | 180 | $orbits = $xpath->query($path); |
179 | 181 | ||
180 | foreach ($orbits as $orbit) | 182 | foreach ($orbits as $orbit) |
@@ -243,7 +245,8 @@ class WebServer | @@ -243,7 +245,8 @@ class WebServer | ||
243 | "timeformat" => $formatInfo['timeFormat'], | 245 | "timeformat" => $formatInfo['timeFormat'], |
244 | "compression" => $formatInfo['gzip'] | 246 | "compression" => $formatInfo['gzip'] |
245 | ); | 247 | ); |
246 | - | 248 | + |
249 | + | ||
247 | if (!isset($this->requestManager)) | 250 | if (!isset($this->requestManager)) |
248 | $this->requestManager = new RequestManagerClass(); | 251 | $this->requestManager = new RequestManagerClass(); |
249 | 252 | ||
@@ -252,6 +255,7 @@ class WebServer | @@ -252,6 +255,7 @@ class WebServer | ||
252 | } catch (Exception $e) { | 255 | } catch (Exception $e) { |
253 | $this->throwError("executionError", "Exception detected : ".$e->getMessage()); | 256 | $this->throwError("executionError", "Exception detected : ".$e->getMessage()); |
254 | } | 257 | } |
258 | + | ||
255 | 259 | ||
256 | if (!$downloadResult['success']) { | 260 | if (!$downloadResult['success']) { |
257 | $this->throwError("serverError", $downloadResult['message']); | 261 | $this->throwError("serverError", $downloadResult['message']); |
@@ -262,7 +266,7 @@ class WebServer | @@ -262,7 +266,7 @@ class WebServer | ||
262 | } elseif ($downloadResult['status'] == 'done') | 266 | } elseif ($downloadResult['status'] == 'done') |
263 | { | 267 | { |
264 | $this->deleteProcess($downloadResult['id']); | 268 | $this->deleteProcess($downloadResult['id']); |
265 | - return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']); | 269 | + return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result'], 'exectime' => $downloadResult['exectime']); |
266 | } else { | 270 | } else { |
267 | return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; | 271 | return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; |
268 | } | 272 | } |
@@ -386,6 +390,7 @@ class WebServer | @@ -386,6 +390,7 @@ class WebServer | ||
386 | */ | 390 | */ |
387 | public function getParameter($data) | 391 | public function getParameter($data) |
388 | { | 392 | { |
393 | +error_log("BRE =============================> getParameter"); | ||
389 | $res = $this->init($data); | 394 | $res = $this->init($data); |
390 | 395 | ||
391 | if (!$res['success']){ | 396 | if (!$res['success']){ |
@@ -395,6 +400,14 @@ class WebServer | @@ -395,6 +400,14 @@ class WebServer | ||
395 | $this->initUserMgr(); | 400 | $this->initUserMgr(); |
396 | 401 | ||
397 | $vars = $res['vars']; | 402 | $vars = $res['vars']; |
403 | + | ||
404 | + if (empty($vars["startTime"])) { | ||
405 | + $this->throwError("requestError", "Missing startTime definition"); | ||
406 | + } | ||
407 | + | ||
408 | + if (empty($vars["stopTime"])) { | ||
409 | + $this->throwError("requestError", "Missing stopTime definition"); | ||
410 | + } | ||
398 | 411 | ||
399 | if (is_numeric($vars["startTime"])) { | 412 | if (is_numeric($vars["startTime"])) { |
400 | $this->checkInputTime($vars["startTime"],$vars["stopTime"]); | 413 | $this->checkInputTime($vars["startTime"],$vars["stopTime"]); |
@@ -405,37 +418,40 @@ class WebServer | @@ -405,37 +418,40 @@ class WebServer | ||
405 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); | 418 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); |
406 | } | 419 | } |
407 | 420 | ||
408 | - if (!$vars["timeFormat"]) { | 421 | + if (empty($vars["timeFormat"])) { |
409 | $timeFormat = "ISO8601"; | 422 | $timeFormat = "ISO8601"; |
410 | } | 423 | } |
411 | else { | 424 | else { |
412 | $timeFormat = $vars["timeFormat"]; | 425 | $timeFormat = $vars["timeFormat"]; |
413 | } | 426 | } |
414 | - | 427 | + |
428 | + | ||
429 | + if (empty($vars["parameterID"])) { | ||
430 | + $this->throwError("requestError", "Missing parameterID definition"); | ||
431 | + } | ||
415 | $paramId = array(); | 432 | $paramId = array(); |
416 | array_push($paramId, $vars["parameterID"]); | 433 | array_push($paramId, $vars["parameterID"]); |
417 | 434 | ||
418 | - if (!$vars["gzip"]) | 435 | + if (empty($vars["gzip"])) |
419 | $gzip = 0; | 436 | $gzip = 0; |
420 | else | 437 | else |
421 | - $gzip = $vars["gzip"]; | 438 | + $gzip = ($vars["gzip"] == 1); |
422 | 439 | ||
423 | - if (!$vars["stream"]) | ||
424 | - $stream = 0; | ||
425 | - else | ||
426 | - $stream = $vars["stream"]; | 440 | + $sampling = !empty($vars["sampling"]) ? $vars["sampling"] : NULL; |
441 | + | ||
442 | + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII'; | ||
427 | 443 | ||
428 | $this->service = strtolower(__FUNCTION__); | 444 | $this->service = strtolower(__FUNCTION__); |
429 | 445 | ||
430 | $res = $this->doDownloadRequest( | 446 | $res = $this->doDownloadRequest( |
431 | - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), | 447 | + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), |
432 | array("params" => $paramId), | 448 | array("params" => $paramId), |
433 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | 449 | + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip)); |
434 | 450 | ||
435 | if ($res['success']) | 451 | if ($res['success']) |
436 | return $res; | 452 | return $res; |
437 | 453 | ||
438 | - $this->throwError("serverError", $res['message']); | 454 | + $this->throwError("serverError", $res['message']); |
439 | } | 455 | } |
440 | 456 | ||
441 | /* | 457 | /* |
@@ -535,17 +551,12 @@ class WebServer | @@ -535,17 +551,12 @@ class WebServer | ||
535 | else | 551 | else |
536 | $gzip = $vars["gzip"]; | 552 | $gzip = $vars["gzip"]; |
537 | 553 | ||
538 | - if (!$vars["stream"]) | ||
539 | - $stream = 0; | ||
540 | - else | ||
541 | - $stream = $vars["stream"]; | ||
542 | - | ||
543 | $this->service = strtolower(__FUNCTION__); | 554 | $this->service = strtolower(__FUNCTION__); |
544 | 555 | ||
545 | $res = $this->doDownloadRequest( | 556 | $res = $this->doDownloadRequest( |
546 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), | 557 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), |
547 | array("params" => $paramId), | 558 | array("params" => $paramId), |
548 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | 559 | + array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip)); |
549 | 560 | ||
550 | if ($res['success']) return $res; | 561 | if ($res['success']) return $res; |
551 | 562 | ||
@@ -571,6 +582,17 @@ class WebServer | @@ -571,6 +582,17 @@ class WebServer | ||
571 | catch (Exception $e) | 582 | catch (Exception $e) |
572 | { | 583 | { |
573 | // after first getStatus() call process is deleted | 584 | // after first getStatus() call process is deleted |
585 | + /*$obj = array('id' => $id); | ||
586 | + | ||
587 | + try | ||
588 | + { | ||
589 | + $res = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, null, $id); | ||
590 | + } | ||
591 | + catch (Exception $e) | ||
592 | + { | ||
593 | + | ||
594 | + } | ||
595 | + | ||
574 | $jobsManager = new WSJobsManagerClass(); | 596 | $jobsManager = new WSJobsManagerClass(); |
575 | 597 | ||
576 | try | 598 | try |
@@ -587,7 +609,7 @@ class WebServer | @@ -587,7 +609,7 @@ class WebServer | ||
587 | catch (Exception $e) | 609 | catch (Exception $e) |
588 | { | 610 | { |
589 | $this->throwError("getResultFromProcessIdError", "Exception detected : ".$e->getMessage()); | 611 | $this->throwError("getResultFromProcessIdError", "Exception detected : ".$e->getMessage()); |
590 | - } | 612 | + }*/ |
591 | } | 613 | } |
592 | 614 | ||
593 | if (!$res['success']) { | 615 | if (!$res['success']) { |
@@ -708,7 +730,7 @@ class WebServer | @@ -708,7 +730,7 @@ class WebServer | ||
708 | $res = $this->doDownloadRequest( | 730 | $res = $this->doDownloadRequest( |
709 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), | 731 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), |
710 | array("params" => $paramId), | 732 | array("params" => $paramId), |
711 | - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); | 733 | + array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip)); |
712 | 734 | ||
713 | if ($res['success']) return $res; | 735 | if ($res['success']) return $res; |
714 | 736 |
php/classes/AmdaAction.php
@@ -933,7 +933,7 @@ class AmdaAction | @@ -933,7 +933,7 @@ class AmdaAction | ||
933 | if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID)) | 933 | if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID)) |
934 | { | 934 | { |
935 | $dd = new WSUserMgr(); | 935 | $dd = new WSUserMgr(); |
936 | - $dd->init($obj->username,$obj->password,$obj->sessionID, false); | 936 | + $dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false); |
937 | } | 937 | } |
938 | else { | 938 | else { |
939 | $dd = new UserMgr(); | 939 | $dd = new UserMgr(); |
php/classes/AmdaStats.php
@@ -12,7 +12,7 @@ class AmdaStats { | @@ -12,7 +12,7 @@ class AmdaStats { | ||
12 | public $usersToExclude = array('bouchemit', 'impex'); | 12 | public $usersToExclude = array('bouchemit', 'impex'); |
13 | public $success = true; | 13 | public $success = true; |
14 | private $user = null; | 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','getparameter'=>'ws_print'); |
16 | 16 | ||
17 | public function __construct($user) { | 17 | public function __construct($user) { |
18 | 18 |
php/classes/ProxyUtils.php
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | class ProxyUtils { | 3 | class ProxyUtils { |
4 | static function addProxyForCurl(&$ch) { | 4 | static function addProxyForCurl(&$ch) { |
5 | - if ( defined(PROXY_HOST) ) { | 5 | + if ( defined("PROXY_HOST") ) { |
6 | $proxy_host = PROXY_HOST; | 6 | $proxy_host = PROXY_HOST; |
7 | if (!empty($proxy_host)) { | 7 | if (!empty($proxy_host)) { |
8 | curl_setopt($ch, CURLOPT_PROXY, "http://".$proxy_host); | 8 | curl_setopt($ch, CURLOPT_PROXY, "http://".$proxy_host); |
@@ -15,7 +15,7 @@ class ProxyUtils { | @@ -15,7 +15,7 @@ class ProxyUtils { | ||
15 | } | 15 | } |
16 | 16 | ||
17 | static function getStreamContextWithProxy() { | 17 | static function getStreamContextWithProxy() { |
18 | - if (!defined(PROXY_HOST)) | 18 | + if (!defined("PROXY_HOST")) |
19 | return; | 19 | return; |
20 | $proxy_host = PROXY_HOST; | 20 | $proxy_host = PROXY_HOST; |
21 | if (empty($proxy_host)) | 21 | if (empty($proxy_host)) |