Commit 4bc7749a5f462ec4edb3b08850ea4e081de7fc5a

Authored by Elena.Budnik
1 parent 00dedb86

getParameter (simple) finished

Showing 1 changed file with 29 additions and 16 deletions   Show diff stats
php/classes/WebServer.php
... ... @@ -79,6 +79,7 @@ class WebServer
79 79 private $dataFileName;
80 80 private $requestManager = null;
81 81 private $paramLoader = null;
  82 + private $service;
82 83  
83 84 function __construct()
84 85 {
... ... @@ -173,6 +174,7 @@ class WebServer
173 174 $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $this->isSoap);
174 175  
175 176 $this->IPclient = $wsUserMgr->getIPClient();
  177 +
176 178 return array('success' => true);
177 179 }
178 180  
... ... @@ -417,12 +419,13 @@ class WebServer
417 419 return array('success' => false);
418 420 }
419 421  
  422 +/*
  423 +* get status for jobs in batch
  424 +*/
420 425 public function getStatus($data)
421 426 {
422 427 $result = $this->init($data);
423 428  
424   - $this->userID = 'impex';
425   -
426 429 $id = $result['vars']['id'];
427 430  
428 431 if (!isset($this->requestManager))
... ... @@ -430,13 +433,13 @@ class WebServer
430 433  
431 434 try
432 435 {
433   - $res = $this->requestManager->runWSRequest($this->userID, 'unknown', FunctionTypeEnumClass::PROCESSGETINFO, null, $id);
  436 + $res = $this->requestManager->runWSRequest('nobody', 'nobody', FunctionTypeEnumClass::PROCESSGETINFO, null, $id);
434 437 }
435 438 catch (Exception $e)
436 439 {
437 440 // if ($e->getMessage() == "Exception detected : Request execution error : Cannot get process from id" )
438 441 // {
439   - // after first getStatus() call process is cleaned up
  442 + // after first getStatus() call process is deleted
440 443 $jobsManager = new WSJobsManagerClass();
441 444  
442 445 try
... ... @@ -483,7 +486,7 @@ class WebServer
483 486 // [result] => download_imf_1484352000_1494806400.txt
484 487 // [format] =>
485 488 // [compression] => 0
486   - $this->cleanProcess($res['id']);
  489 + $this->deleteProcess($res['id']);
487 490 return array('success' => true, 'status' => $res['status'], 'dataFileURLs' => WSConfigClass::getUrl().$res['result']);
488 491 }
489 492  
... ... @@ -521,6 +524,9 @@ class WebServer
521 524 return array('success' => true,'ParameterList' => array("UserDefinedParameters"=>$wsParamResult, "LocalDataBaseParameters"=>$locParamResult, "RemoteDataBaseParameters"=>$remoteParamResult));
522 525 }
523 526  
  527 +/*
  528 +* generate AUTH token for access to REST services
  529 +*/
524 530 public function getNewToken()
525 531 {
526 532 $timeStamp = (new DateTime())->getTimestamp();
... ... @@ -540,7 +546,7 @@ class WebServer
540 546 $this->throwError("requestError", "Cannot parse request");
541 547 }
542 548  
543   - $resMgr = $this->initUserMgr();
  549 + $this->initUserMgr();
544 550  
545 551 $vars = $res['vars'];
546 552  
... ... @@ -560,11 +566,13 @@ class WebServer
560 566 $gzip = 0;
561 567 else
562 568 $gzip = $vars["gzip"];
563   -/*
564   - if (!$vars["stream"])
565   - $stream = 0;
566   - else
567   - $stream = $vars["stream"];*/
  569 +
  570 + if (!$vars["stream"])
  571 + $stream = 0;
  572 + else
  573 + $stream = $vars["stream"];
  574 +
  575 + $this->service = strtolower(__FUNCTION__);
568 576  
569 577 $res = $this->doDownloadRequest(
570 578 array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]),
... ... @@ -865,7 +873,7 @@ class WebServer
865 873 $this->requestManager = new RequestManagerClass();
866 874  
867 875 try {
868   - $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, WSConfigClass::DOWNLOAD, $obj);
  876 + $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $this->service, $obj);
869 877 } catch (Exception $e) {
870 878 $this->throwError("executionError", "Exception detected : ".$e->getMessage());
871 879 }
... ... @@ -878,14 +886,19 @@ class WebServer
878 886 return ['success' => true, 'status' => 'in progress', 'id' => $downloadResult['id']];
879 887 } elseif ($downloadResult['status'] == 'done')
880 888 {
881   - $this->cleanProcess($downloadResult['id']);
  889 + $this->deleteProcess($downloadResult['id']);
882 890 return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']);
883 891 } else {
884 892 return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']];
885 893 }
886 894 }
887 895  
888   - private function cleanProcess($id)
  896 +/*
  897 +* delete process after execution :
  898 +* delete temporary files/folders ( JOBS/process_xxxx, RES/DDxxx );
  899 +* delete job node in processManager.xml
  900 +*/
  901 + private function deleteProcess($id)
889 902 {
890 903 $obj = (object)array('id' => $id);
891 904  
... ... @@ -893,9 +906,9 @@ class WebServer
893 906 $this->requestManager = new RequestManagerClass();
894 907  
895 908 try {
896   - $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, WSConfigClass::DOWNLOAD, $obj);
  909 + $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, null, $obj);
897 910 } catch (Exception $e) {
898   - $this->throwError("cleanProcessError", $e->getMessage());
  911 + $this->throwError("deleteProcessError", $e->getMessage());
899 912 }
900 913 }
901 914  
... ...