diff --git a/php/classes/WebServer.php b/php/classes/WebServer.php index dc566e8..1f0695a 100644 --- a/php/classes/WebServer.php +++ b/php/classes/WebServer.php @@ -79,6 +79,7 @@ class WebServer private $dataFileName; private $requestManager = null; private $paramLoader = null; + private $service; function __construct() { @@ -173,6 +174,7 @@ class WebServer $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $this->isSoap); $this->IPclient = $wsUserMgr->getIPClient(); + return array('success' => true); } @@ -417,12 +419,13 @@ class WebServer return array('success' => false); } +/* +* get status for jobs in batch +*/ public function getStatus($data) { $result = $this->init($data); - $this->userID = 'impex'; - $id = $result['vars']['id']; if (!isset($this->requestManager)) @@ -430,13 +433,13 @@ class WebServer try { - $res = $this->requestManager->runWSRequest($this->userID, 'unknown', FunctionTypeEnumClass::PROCESSGETINFO, null, $id); + $res = $this->requestManager->runWSRequest('nobody', 'nobody', FunctionTypeEnumClass::PROCESSGETINFO, null, $id); } catch (Exception $e) { // if ($e->getMessage() == "Exception detected : Request execution error : Cannot get process from id" ) // { - // after first getStatus() call process is cleaned up + // after first getStatus() call process is deleted $jobsManager = new WSJobsManagerClass(); try @@ -483,7 +486,7 @@ class WebServer // [result] => download_imf_1484352000_1494806400.txt // [format] => // [compression] => 0 - $this->cleanProcess($res['id']); + $this->deleteProcess($res['id']); return array('success' => true, 'status' => $res['status'], 'dataFileURLs' => WSConfigClass::getUrl().$res['result']); } @@ -521,6 +524,9 @@ class WebServer return array('success' => true,'ParameterList' => array("UserDefinedParameters"=>$wsParamResult, "LocalDataBaseParameters"=>$locParamResult, "RemoteDataBaseParameters"=>$remoteParamResult)); } +/* +* generate AUTH token for access to REST services +*/ public function getNewToken() { $timeStamp = (new DateTime())->getTimestamp(); @@ -540,7 +546,7 @@ class WebServer $this->throwError("requestError", "Cannot parse request"); } - $resMgr = $this->initUserMgr(); + $this->initUserMgr(); $vars = $res['vars']; @@ -560,11 +566,13 @@ class WebServer $gzip = 0; else $gzip = $vars["gzip"]; -/* - if (!$vars["stream"]) - $stream = 0; - else - $stream = $vars["stream"];*/ + + if (!$vars["stream"]) + $stream = 0; + else + $stream = $vars["stream"]; + + $this->service = strtolower(__FUNCTION__); $res = $this->doDownloadRequest( array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), @@ -865,7 +873,7 @@ class WebServer $this->requestManager = new RequestManagerClass(); try { - $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, WSConfigClass::DOWNLOAD, $obj); + $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $this->service, $obj); } catch (Exception $e) { $this->throwError("executionError", "Exception detected : ".$e->getMessage()); } @@ -878,14 +886,19 @@ class WebServer return ['success' => true, 'status' => 'in progress', 'id' => $downloadResult['id']]; } elseif ($downloadResult['status'] == 'done') { - $this->cleanProcess($downloadResult['id']); + $this->deleteProcess($downloadResult['id']); return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']); } else { return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; } } - private function cleanProcess($id) +/* +* delete process after execution : +* delete temporary files/folders ( JOBS/process_xxxx, RES/DDxxx ); +* delete job node in processManager.xml +*/ + private function deleteProcess($id) { $obj = (object)array('id' => $id); @@ -893,9 +906,9 @@ class WebServer $this->requestManager = new RequestManagerClass(); try { - $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, WSConfigClass::DOWNLOAD, $obj); + $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, null, $obj); } catch (Exception $e) { - $this->throwError("cleanProcessError", $e->getMessage()); + $this->throwError("deleteProcessError", $e->getMessage()); } } -- libgit2 0.21.2