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 | 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,7 +19,7 @@ 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 | |
... | ... | @@ -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 | |
... | ... | @@ -175,6 +175,8 @@ class WebServer |
175 | 175 | $xpath = new DOMXpath($orbitsXml); |
176 | 176 | $path = '//orbites[@mission="'.$spacecraft.'" and @coordinate_system="'.$orbitRequest['coordinateSystem'].'" and @units="'.$orbitRequest['units'].'" ] '; |
177 | 177 | |
178 | +error_log($path); | |
179 | + | |
178 | 180 | $orbits = $xpath->query($path); |
179 | 181 | |
180 | 182 | foreach ($orbits as $orbit) |
... | ... | @@ -243,7 +245,8 @@ class WebServer |
243 | 245 | "timeformat" => $formatInfo['timeFormat'], |
244 | 246 | "compression" => $formatInfo['gzip'] |
245 | 247 | ); |
246 | - | |
248 | + | |
249 | + | |
247 | 250 | if (!isset($this->requestManager)) |
248 | 251 | $this->requestManager = new RequestManagerClass(); |
249 | 252 | |
... | ... | @@ -252,6 +255,7 @@ class WebServer |
252 | 255 | } catch (Exception $e) { |
253 | 256 | $this->throwError("executionError", "Exception detected : ".$e->getMessage()); |
254 | 257 | } |
258 | + | |
255 | 259 | |
256 | 260 | if (!$downloadResult['success']) { |
257 | 261 | $this->throwError("serverError", $downloadResult['message']); |
... | ... | @@ -262,7 +266,7 @@ class WebServer |
262 | 266 | } elseif ($downloadResult['status'] == 'done') |
263 | 267 | { |
264 | 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 | 270 | } else { |
267 | 271 | return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; |
268 | 272 | } |
... | ... | @@ -386,6 +390,7 @@ class WebServer |
386 | 390 | */ |
387 | 391 | public function getParameter($data) |
388 | 392 | { |
393 | +error_log("BRE =============================> getParameter"); | |
389 | 394 | $res = $this->init($data); |
390 | 395 | |
391 | 396 | if (!$res['success']){ |
... | ... | @@ -395,6 +400,14 @@ class WebServer |
395 | 400 | $this->initUserMgr(); |
396 | 401 | |
397 | 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 | 412 | if (is_numeric($vars["startTime"])) { |
400 | 413 | $this->checkInputTime($vars["startTime"],$vars["stopTime"]); |
... | ... | @@ -405,37 +418,40 @@ class WebServer |
405 | 418 | $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); |
406 | 419 | } |
407 | 420 | |
408 | - if (!$vars["timeFormat"]) { | |
421 | + if (empty($vars["timeFormat"])) { | |
409 | 422 | $timeFormat = "ISO8601"; |
410 | 423 | } |
411 | 424 | else { |
412 | 425 | $timeFormat = $vars["timeFormat"]; |
413 | 426 | } |
414 | - | |
427 | + | |
428 | + | |
429 | + if (empty($vars["parameterID"])) { | |
430 | + $this->throwError("requestError", "Missing parameterID definition"); | |
431 | + } | |
415 | 432 | $paramId = array(); |
416 | 433 | array_push($paramId, $vars["parameterID"]); |
417 | 434 | |
418 | - if (!$vars["gzip"]) | |
435 | + if (empty($vars["gzip"])) | |
419 | 436 | $gzip = 0; |
420 | 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 | 444 | $this->service = strtolower(__FUNCTION__); |
429 | 445 | |
430 | 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 | 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 | 451 | if ($res['success']) |
436 | 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 | 551 | else |
536 | 552 | $gzip = $vars["gzip"]; |
537 | 553 | |
538 | - if (!$vars["stream"]) | |
539 | - $stream = 0; | |
540 | - else | |
541 | - $stream = $vars["stream"]; | |
542 | - | |
543 | 554 | $this->service = strtolower(__FUNCTION__); |
544 | 555 | |
545 | 556 | $res = $this->doDownloadRequest( |
546 | 557 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), |
547 | 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 | 561 | if ($res['success']) return $res; |
551 | 562 | |
... | ... | @@ -571,6 +582,17 @@ class WebServer |
571 | 582 | catch (Exception $e) |
572 | 583 | { |
573 | 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 | 596 | $jobsManager = new WSJobsManagerClass(); |
575 | 597 | |
576 | 598 | try |
... | ... | @@ -587,7 +609,7 @@ class WebServer |
587 | 609 | catch (Exception $e) |
588 | 610 | { |
589 | 611 | $this->throwError("getResultFromProcessIdError", "Exception detected : ".$e->getMessage()); |
590 | - } | |
612 | + }*/ | |
591 | 613 | } |
592 | 614 | |
593 | 615 | if (!$res['success']) { |
... | ... | @@ -708,7 +730,7 @@ class WebServer |
708 | 730 | $res = $this->doDownloadRequest( |
709 | 731 | array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), |
710 | 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 | 735 | if ($res['success']) return $res; |
714 | 736 | ... | ... |
php/classes/AmdaAction.php
... | ... | @@ -933,7 +933,7 @@ class AmdaAction |
933 | 933 | if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID)) |
934 | 934 | { |
935 | 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 | 938 | else { |
939 | 939 | $dd = new UserMgr(); | ... | ... |
php/classes/AmdaStats.php
... | ... | @@ -12,7 +12,7 @@ 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','getparameter'=>'ws_print'); | |
16 | 16 | |
17 | 17 | public function __construct($user) { |
18 | 18 | ... | ... |
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)) | ... | ... |