resDOM = new DOMDocument("1.0"); $this->resDOM->formatOutput = TRUE; $this->resDOM->preserveWhiteSpace = FALSE; if (!file_exists(wsResultsXml)) { $this->rootEl = $this->resDOM->createElement('wsresults'); $this->resDOM->appendChild($this->rootEl); $this->resDOM->save(wsResultsXml); } else { $this->resDOM->load(wsResultsXml); $this->rootEl = $this->resDOM->documentElement; } $this->resXP = new DOMXPath($this->resDOM); } public function addResult($function_name,$vars,$user,$IP,$output) { $nodes = $this->rootEl->getElementsByTagName($function_name); if($nodes->length < 1){ $funcNode = $this->resDOM->createElement($function_name); $this->rootEl->appendChild($funcNode); } else $funcNode = $nodes->item(0); $oldOutput = $this->resXP->query('//'.$function_name.'/result[@output="'.$output.'"]'); if ($oldOutput->length > 0) $funcNode->removeChild($oldOutput->item(0)); $resNode = $this->resDOM->createElement('result'); $resNode->setAttribute('date',time()); $resNode->setAttribute('user',$user); $resNode->setAttribute('input',json_encode($vars)); $resNode->setAttribute('output',$output); $funcNode->appendChild($resNode); $this->resDOM->save(wsResultsXml); return $resNode; } public function getResOutputName($function_name,$user,$suffix,$extension) { $outputFile = WSRESULT.$function_name."_".$user; if (isset($suffix)) $outputFile .= ("_".$suffix); if (isset($extension)) $outputFile .= (".".$extension); else $outputFile .= ".xml"; return $outputFile; } } class WebServer { private $isSoap = false; private $userID, $userPWD, $sessionID, $IPclient; // private $wsUserMgr; private $resultMgr; private $dataFileName; private $requestManager = null; private $paramLoader = null; private $service; function __construct() { if (!is_dir(WSConfigClass::getWsResultDir())) mkdir(WSConfigClass::getWsResultDir(), 0775); // $this->resultMgr = new WebResultMgr(); } // [startTime] => 2016-01-14T00:00:00 // [stopTime] => 2017-02-15T00:00:00 // [parameterID] => imf // [userID] => budnik // [password] => Sacre-Cour // [outputFormat] => ASCII // [timeFormat] => ISO8601 // [gzip] => 0 protected function init($data) { if(is_object($data)){ $vars = get_object_vars($data); $this->isSoap = true; } else { $vars = $data; } if (isset($vars['userID'])){ $this->userID = $vars['userID']; } else { $this->userID = 'impex'; } $this->sessionID = $this->userID; if (isset($vars['password'])) $this->userPWD = $vars['password']; else $this->userPWD = 'impexfp7'; return array('success' => true, 'vars' => $vars); } private function throwError($errorType, $msg) { if ($this->isSoap) throw new SoapFault($errorType, $msg); else return array("error" => $msg); } private function setID() { $nb_min = 10000; $nb_max = 99999; return "PP".mt_rand($nb_min,$nb_max); } /** * Function getIPclient return the IP client sent a request for needs DD scripts (DDHtmlLogin, DDCheckUser, DD_Search) * * @param void * @return string */ private function getIPclient() { return $this->wsUserMgr->getIPClient(); } private function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { // Recursively delete a directory that is not empty and directorys in directory if ($object != "." && $object != "..") { // If object isn't a directory recall recursively this function if (filetype($dir."/".$object) == "dir") $this->rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } protected function initUserMgr() { $wsUserMgr = new WSUserMgr(); $wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $this->isSoap); $this->IPclient = $wsUserMgr->getIPClient(); return array('success' => true); } public function getTimeTablesList($data) { $res = $this->init($data); $vars = $res['vars']; $ttListWSresult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID); $dom = new DOMDocument("1.0"); if ($this->userID == 'impex') { $sharedObjMgr = new SharedObjectsMgr(); if (!@$dom->load($sharedObjMgr->getTreeFilePath())) $this->throwError("workspaceError", "Workspace Error : Cannot load Shared Time Table list"); } else { if (!@$dom->load(USERPATH.$this->userID.'/WS/Tt.xml')) $this->throwError("workspaceError", "Workspace Error : Cannot load Shared Time Table list for ".$this->userID); } $timetabNode = $dom->getElementsByTagName('timetabList'); if ($timetabNode->length < 1){ $this->throwError("workspaceWarning", "Workspace Warning : No Time Tables"); } $outDOM = new DOMDocument("1.0"); $outDOM->formatOutput = TRUE; $outDOM->preserveWhiteSpace = FALSE; $newNode = $outDOM->importNode($timetabNode->item(0),TRUE); $outDOM->appendChild($newNode); // $outXP = new domxpath($outDOM); // $ttNodes = $outXP->query('//timetab'); $outDOM->save($ttListWSresult); $wsres = $this->resultMgr->addResult(__FUNCTION__,$vars,$this->userID,$ttListWSresult); $ttListResult = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$ttListWSresult); $timeTablesList = array('success' => true, 'TimeTablesList' => $ttListResult); return $timeTablesList; } public function getTimeTable($data) { $res = $this->init($data); $vars = $res['vars']; $ttID = $vars['ttID']; if ($this->userID == 'impex') { $sharedObjMgr = new SharedObjectsMgr(); $ttSrc = $sharedObjMgr->getDataFilePath('timeTable', $ttID); } else $ttSrc = USERPATH.$this->userID.'/TT/'.$ttID.'.xml'; if (!file_exists($ttSrc)) { $this->throwError("workspaceError", "No such table ".$ttID.".xml"); } $ttWSresult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID,$ttID); if (!copy($ttSrc,$ttWSresult)){ $this->throwError("workspaceError", "Cannot copy ".$ttID.".xml"); } $wsres = $this->resultMgr->addResult(__FUNCTION__,$vars,$this->userID, $ttWSresult); $myTimeTableMgr = new TimeTableMgr($this->userID); $ttWSresultVot = $myTimeTableMgr->xsl2vot($ttWSresult); if(file_exists($ttWSresultVot)){ copy($ttWSresultVot, $ttWSresult); unlink( $ttWSresultVot ) ; } return array('success' => true, 'ttFileURL' => 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$ttWSresult)); } public function isAlive() { $res = $this->init($data); return true; } public function getObsDataTree() { $res = $this->init(); $resMgr = $this->initUserMgr(); $vars = $res['vars']; $locParamSrc = USERWSDIR.'/LocalParams.xml'; $wsParamSrc = USERWSDIR.'/WsParams.xml'; $locParamResult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID.'_'.'LocalParams'); $wsParamResult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID.'_'.'WsParams'); if (!copy($locParamSrc,$locParamResult)) $locParamResult = ''; if (!copy($wsParamSrc,$wsParamResult)) $wsParamResult = ''; if ($locParamResult !='') $locParamResult = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$locParamResult); if ($wsParamResult !='') $wsParamResult = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$wsParamResult); if (($locParamResult =='') && ($wsParamResult =='')) { $this->throwError("workspaceError", "No parameter description file"); } $wsres = $this->resultMgr->addResult(__FUNCTION__,$vars,$this->userID,$wsParamResult.";".$locParamResult); return array('success' => true,'WorkSpace' => array("LocalDataBaseParameters"=>$locParamResult)); } public function getPlot($data) { $res = $this->init($data); $resMgr = $this->initUserMgr(); $vars = $res['vars']; $mission = $vars["missionID"]; $ID = $this->setID(); // unique JobID $resDirName = WSRESULT.$ID; // Define a temporary directory for results if (is_dir($resDirName)) $this->rrmdir($resDirName); mkdir($resDirName); chmod($resDirName,0775); $dom = new DomDocument("1.0"); $dom->load(plotsXml); $missionTag = $dom->getElementById($mission); $params = $missionTag->getElementsByTagName('param'); $paramsList = array(); foreach ($params as $param) $paramsList[] = $param->getAttribute('name'); $requestObject = (Object) array( "nodeType" => "request", "file-format" => "PNG", "file-output" => "WS", "ws-result-file" => $resDirName."/request.list.png", "last-plotted-tab" => 1, "timesrc" => "Interval", "startDate" => $vars["startTime"], "stopDate" => $vars["stopTime"], "tabs" => array() ); $pageObject = (Object) array( "id" => 1, "multi-plot-linked" => true, "page-margins-activated" => true, "page-margin-x" => 5, "page-margin-y" => 5, "page-orientation" => "portrait", "page-dimension" => "ISO A4", "page-layout-type" => "vertical", "page-layout-object" => (Object) array( "layout-panel-height" => 0.25, "layout-panel-spacing" => 0, "layout-expand" => false ), "panels" => array() ); foreach ($paramsList as $paramToPlot) { $panelObject = (Object) array( "panel-plot-type" => "timePlot", "axes" => array(), "params" => array() ); $timeAxisObject = (Object) array( "id" => "time", "axis-type" => "time", "axis-range-extend" => true ); $panelObject->{"axes"}[] = $timeAxisObject; $yAxisObject = (Object) array( "id" => "y-left", "axis-type" => "y-left", "axis-range-extend" => true ); $panelObject->{"axes"}[] = $yAxisObject; $paramObject = (Object) array( "id" => 1, "param-id" => $paramToPlot, "param-drawing-type" => "serie", "param-drawing-object" => (Object) array( "serie-yaxis" => "y-left", "serie-lines-activated" => true ) ); $panelObject->{"params"}[] = $paramObject; $pageObject->{"panels"}[] = $panelObject; } $requestObject->{"tabs"}[] = $pageObject; if (!isset($this->requestManager)) $this->requestManager = new RequestManagerClass(); try { $plotResult = $this->requestManager->runIHMRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $requestObject); } catch (Exception $e) { $this->throwError("plotError", "Exeption detected : ".$e->getMessage()); } return array('success' => true, 'plotDirectoryURL' => $ID); } public function getResultPlot($data) { $res = $this->init($data); $vars = $res['vars']; $ID = $vars["plotDirectoryURL"]; $filename = WSRESULT.$ID."/request.list.png"; if (file_exists($filename)) { $plotWSresult=WSRESULT.$ID."/request.list.png"; return array('success' => true, 'plotFileURL' => 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$plotWSresult)); } else return array('success' => false); } /* * get status for jobs in batch */ public function getStatus($data) { $result = $this->init($data); $id = $result['vars']['id']; if (!isset($this->requestManager)) $this->requestManager = new RequestManagerClass(); try { $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 deleted $jobsManager = new WSJobsManagerClass(); try { $res = $jobsManager->getResultFromProcessId($id); if (!$res['success']) { $this->throwError("processError","Cannot retrieve process $id info"); } return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$res['result']); } catch (Exception $e) { $this->throwError("getResultFromProcessIdError", "Exception detected : ".$e->getMessage()); } // } // else // { // $this->throwError("getStatusError", "Exception detected : ".$e->getMessage()); // } } if (!$res['success']) { $this->throwError("processError","Cannot retrieve process $id info"); } if ($res['status'] == 'in_progress') { return array('success' => true, 'status' => 'in progress'); } if ($res['error']) { $this->throwError("processError","Process $id error code"); } // [success] => 1 // [id] => process_jckrDz_1520873370_11632 // [name] => download_1520873382 // [status] => done // [jobType] => download // [info] => imf // [start] => 12-03-2018 16:49:30 // [stop] => 12-03-2018 16:51:49 // [folder] => DDfqlbZr_ // [result] => download_imf_1484352000_1494806400.txt // [format] => // [compression] => 0 $this->deleteProcess($res['id']); return array('success' => true, 'status' => $res['status'], 'dataFileURLs' => WSConfigClass::getUrl().$res['result']); } public function getParameterList($data) { $res = $this->init($data); $resMgr = $this->initUserMgr(); $vars = $res['vars']; $locParamSrc = USERWSDIR.'/LocalParams.xml'; $wsParamSrc = USERWSDIR.'/WsParams.xml'; $locParamResult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID.'_'.'LocalParams'); $wsParamResult = $this->resultMgr->getResOutputName(__FUNCTION__,$this->userID.'_'.'WsParams'); if (!copy($locParamSrc,$locParamResult)) $locParamResult = ''; if (!copy($wsParamSrc,$wsParamResult)) $wsParamResult = ''; if ($locParamResult !='') $locParamResult = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$locParamResult); if ($wsParamResult !='') $wsParamResult = 'http://'.str_replace(BASE_PATH,$_SERVER['SERVER_NAME'].APACHE_ALIAS,$wsParamResult); if (($locParamResult =='') && ($wsParamResult =='')){ $this->throwError("workspaceError", "No params descriptions for ".$this->userID); } $wsres = $this->resultMgr->addResult(__FUNCTION__,$vars,$this->userID,$wsParamResult.";".$locParamResult.";".$remoteParamResult); 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(); // generate token from timeStamp and some salt $newToken = md5(1321 * (int)($timeStamp / timeLimitQuery)); return array('success' => true, 'token' => $newToken); } /* * getParameter */ public function getParameter($data) { $res = $this->init($data); if (!$res['success']){ $this->throwError("requestError", "Cannot parse request"); } $this->initUserMgr(); $vars = $res['vars']; if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ $this->throwError("requestError", "Requested time interval should be greater than 0"); } $paramId = array(); array_push($paramId, $vars["parameterID"]); if (!$vars["timeFormat"]) $timeFormat = "ISO8601"; else $timeFormat = $vars["timeFormat"]; if (!$vars["gzip"]) $gzip = 0; else $gzip = $vars["gzip"]; 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"]), array("params" => $paramId), array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); if ($res['success']) return $res; $this->throwError("serverError", $res['message']); } /* * get Orbites */ public function getOrbites($data) { $res = $this->init($data); $resMgr = $this->initUserMgr(); if (!$resMgr['success']){ $this->throwError("serverError", "Cannot init user manager"); } $vars = $res['vars']; if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ $this->throwError("requestError", "Requested time interval should be greater than 0"); } $spacecraft = $vars["spacecraft"]; $coordinateSystem = $vars["coordinateSystem"]; if ($spacecraft == "GALILEO") $spacecraft = ucfirst(strtolower($spacecraft)); if (!$vars["units"]) $units = "km"; else $units = $vars["units"]; $orbitRequest = array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "spacecraft" => $spacecraft, "coordinateSystem" => $coordinateSystem, "units" => $units ); $orbitesParam = $this->getOrbitesParameter($orbitRequest); if ($orbitesParam['success']) { $orbParam = $orbitesParam['parameterID']; } else { $this->throwError("requestError", $orbitesParam['message']); } $dataFileName = $this->getDataFileName($orbitesParam); if ($dataFileName['success']) { $this->dataFileName = $dataFileName['fileName']; } else { $this->throwError("requestError", $dataFileName['message']); } $paramId = array(); array_push($paramId, $orbParam); if (!$vars["timeFormat"]) $timeFormat = "ISO8601"; else $timeFormat = $vars["timeFormat"]; if (!$vars["gzip"]) $gzip = 0; else $gzip = $vars["gzip"]; $res = $this->doDownloadRequest( array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]), array("params" => $paramId), array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); if ($res['success']) return $res; $this->throwError("serverError",$res['message']); } /* * get Dataset */ public function getDataset($data) { $res = $this->init($data); $resMgr = $this->initUserMgr(); $vars = $res['vars']; if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ $this->throwError("requestError", "Requested time interval should be greater than 0"); } $dataFileName = $this->getDataFileName($vars, true); if ($dataFileName['success']) { $this->dataFileName = $dataFileName['fileName']; } else { $this->throeError("requestError",$dataFileName['message']); } $paramId = array(); $localData = simplexml_load_file(USERPATH.$this->userID.'/WS/LocalParams.xml'); if (!$vars["sampling"]) { $xpath = "//dataset[@xml:id='".$vars['datasetID']."']/@sampling"; $tmp = $localData->xpath($xpath); $vars["sampling"] = (string)$tmp[0]; $matches=array(); preg_match("/([a-z])$/", $vars["sampling"], $matches); $dataFileName = $this->getDataFileName($vars, true); if ($dataFileName['success']) { $this->dataFileName = $dataFileName['fileName']; } else { $this->throwError("requestError",$dataFileName['message']); } $vars["sampling"] = strtr($vars["sampling"], array($matches[1] => "")); switch ($matches[1]) { case 's': $sampling = floatval($vars["sampling"]); break; case 'm': $sampling = floatval($vars["sampling"])*60; break; case 'h': $sampling = floatval($vars["sampling"])*60*60; break; default: } } $xpath = "//dataset[@xml:id='".$vars['datasetID']."']/parameter/@*[namespace-uri()='http://www.w3.org/XML/1998/namespace' and local-name()='id']"; $pars = $localData->xpath($xpath); foreach ($pars as $p) $paramId[] = (string)$p[0]; if (!$vars["timeFormat"]) $timeFormat = "ISO8601"; else $timeFormat = $vars["timeFormat"]; if (!$vars["gzip"]) $gzip = 0; else $gzip = $vars["gzip"]; $res = $this->doDownloadRequest( array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling), array("params" => $paramId), array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream)); if ($res['success']) return $res; $this->throwError("serverError", $res['message']); } protected function getOrbitesParameter($orbitRequest) { $orbitesXml = new DomDocument(); if (file_exists(orbitesXml)) { $orbitesXml->load(orbitesXml); $xpath = new DOMXpath($orbitesXml); $path = '//orbites[@mission="'.$orbitRequest['spacecraft'].'" and @coordinate_system="'.$orbitRequest['coordinateSystem'].'" and @units="'.$orbitRequest['units'].'" ] '; $orbites = $xpath->query($path); foreach ($orbites as $orbite){ $paramInfo = $this->myParamsInfoMgr->GetDDInfoFromParameterID($orbite->getAttribute('xml:id')); $paramStart = $paramInfo['dataset']['starttime']; $paramStop = $paramInfo['dataset']['stoptime']; if((strtotime($paramStart) <= strtotime($orbitRequest['startTime']) && (strtotime($orbitRequest['stopTime'])) <= strtotime($paramStop))) { return array('success' => true, 'parameterID' => $orbite->getAttribute('xml:id'), 'startTime' => $orbitRequest['startTime'], 'stopTime' => $orbitRequest['stopTime'] ); } } return array('success' => false, 'message' => "Cannot find orbites for ".$orbitRequest['spacecraft']." between ".$orbitRequest['startTime']." in ".$orbitRequest['units']." ".$orbitRequest['coordinateSystem']." and ".$orbitRequest['stopTime']." ($paramStart - $paramStop) "); } else { return array('success' => false, 'message' => "Orbits file doesn't exist"); } } private function getFormatInfo($fileFormat, $timeFormat, $gzip) { switch ($fileFormat) { case 'netCDF' : $this->throwError("serverError", "netCDF format not implemented"); break; case 'VOTable' : $fileFormat = "vot"; $kernelExtension = ".vot"; $wsExtension = ".xml"; break; case 'ASCII' : default : $fileFormat = "ASCII"; $kernelExtension = ".txt"; $wsExtension = ".txt"; } switch ($timeFormat) { case 'unixtime' : $timeFormat = 'Timestamp'; break; default : $timeFormat = 'YYYY-MM-DDThh:mm:ss'; } if ($gzip == 1) { $compression = "gzip"; $kernelExtension .= ".gz"; $wsExtension .= ".gz"; } else $compression = ""; return ['success' => true, 'kernelExtension' => $kernelExtension, 'wsExtension' => $wsExtension, 'fileFormat' => $fileFormat, 'timeFormat' => $timeFormat, 'compression' => $compression]; } protected function doDownloadRequest($interval, $paramList, $formatInfo) { if (!isset($this->paramLoader)) $this->paramLoader = new IHMUserParamLoaderClass(); //Build parameter list $params = array(); //TODO template arguments to implement ? foreach ($paramList['params'] as $paramId) { $param = new stdClass; if (preg_match("#^ws_#",$paramId)) { $res = $this->paramLoader->getDerivedParameterNameFromId($paramId); if (!$res["success"]) { $this->throwError("serverError", "Not available derived parameter $paramId"); } $param->paramid = "ws_".$res['name']; } else if (preg_match("#^wsd_#",$paramId)) { $res = $this->paramLoader->getUploadedParameterNameFromId($paramId); if (!$res["success"]){ $this->throwError("serverError", "Not available parameter $paramId"); } $param->paramid = "wsd_".$res['name']; } else { $param->paramid = $paramId; } $params[] = $param; } $obj = (object)array( "sampling" => $interval['sampling'], "startDate" => $interval['startTime'], "stopDate" => $interval['stopTime'], "list" => $params, "fileformat" => $formatInfo['format'], "timeformat" => $formatInfo['timeFormat'], "compression" => $formatInfo['gzip'] ); if (!isset($this->requestManager)) $this->requestManager = new RequestManagerClass(); try { $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $this->service, $obj); } catch (Exception $e) { $this->throwError("executionError", "Exception detected : ".$e->getMessage()); } if (!$downloadResult['success']) { $this->throwError("serverError", $downloadResult['message']); } if($downloadResult['status'] == 'in_progress') { return ['success' => true, 'status' => 'in progress', 'id' => $downloadResult['id']]; } elseif ($downloadResult['status'] == 'done') { $this->deleteProcess($downloadResult['id']); return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']); } else { return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']]; } } /* * 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); if (!isset($this->requestManager)) $this->requestManager = new RequestManagerClass(); try { $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, null, $obj); } catch (Exception $e) { $this->throwError("deleteProcessError", $e->getMessage()); } } protected function getDataFileName($vars, $multiParam = false) { if ($vars['startTime'] && $vars['stopTime'] && $vars['parameterID'] && !$multiParam){ $fileName = $vars['parameterID']."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); if (isset($vars['sampling']) && $vars['sampling'] != "" && $vars['sampling'] != 0) $fileName .= "-".$vars['sampling']; return array('success' => true, 'fileName' => $fileName); } else if ($vars['startTime'] && $vars['stopTime'] && $vars['datasetID'] && $multiParam){ $datasetName = strtr($vars["datasetID"], array(":" => "_")); $fileName = $datasetName."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); if (isset($vars['sampling']) && $vars['sampling'] != "" && $vars['sampling'] != 0) $fileName .= "-".$vars['sampling']; return array('success' => true, 'fileName' => $fileName); } else { if (!$vars['startTime']) $message="Start time not specified"; if (!$vars['stopTime']) $message="Stop time not specified"; if (!$vars['parameterID'] && !$multiParam) $message="Parameter not specified"; if (!$vars['datasetID'] && $multiParam) $message="DataSet not specified"; return array('success' => false, 'message' => $message); } } } ?>