Commit 6acb8d2ab1dc35528b10f9c07b9fb51ed42e9344
1 parent
6657f68b
Exists in
master
and in
111 other branches
checkRequest in RequestMgr
Showing
3 changed files
with
333 additions
and
251 deletions
Show diff stats
php/classes/AmdaAction.php
... | ... | @@ -41,10 +41,9 @@ class AmdaAction |
41 | 41 | $dirs = $html->find('a[href]'); |
42 | 42 | foreach ($dirs as $dir) |
43 | 43 | { |
44 | - $name = $dir->innertext; //$dir->href; | |
45 | - $isLeaf = strrpos($name, "/") !== strlen($name) - 1; | |
46 | - $childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name, | |
47 | - 'nodeType' => 'url', 'leaf' => $isLeaf); | |
44 | + $name = $dir->innertext; //$dir->href; | |
45 | + $isLeaf = strrpos($name, "/") !== strlen($name) - 1; | |
46 | + $childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name, 'nodeType' => 'url', 'leaf' => $isLeaf); | |
48 | 47 | } |
49 | 48 | |
50 | 49 | } |
... | ... | @@ -483,12 +482,8 @@ class AmdaAction |
483 | 482 | // else |
484 | 483 | // $restricted = false; |
485 | 484 | // |
486 | - if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') | |
487 | - $restricted = FALSE; | |
488 | - | |
489 | -// if ($restricted) | |
490 | -// $info .= "<br/><b>Open soon !</b>"; | |
491 | -// | |
485 | + if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP') | |
486 | + $restricted = FALSE; | |
492 | 487 | |
493 | 488 | if ($child->tagName == 'dataset') |
494 | 489 | { |
... | ... | @@ -849,12 +844,11 @@ class AmdaAction |
849 | 844 | /* |
850 | 845 | * Get Jobs en cours |
851 | 846 | */ |
852 | - | |
853 | - public function getJobs() | |
854 | - { | |
855 | - require_once(INTEGRATION_SRC_DIR."RequestManager.php"); | |
856 | - return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO); | |
857 | - } | |
847 | + public function getJobs() | |
848 | + { | |
849 | + require_once(INTEGRATION_SRC_DIR."RequestManager.php"); | |
850 | + return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO); | |
851 | + } | |
858 | 852 | |
859 | 853 | |
860 | 854 | /* AKKA-KERNEL-INT |
... | ... | @@ -882,21 +876,21 @@ class AmdaAction |
882 | 876 | if (($res = $dd -> ddCheckUser()) != 0) |
883 | 877 | { |
884 | 878 | if ($res == 156) |
885 | - return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!'); | |
879 | + return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!'); | |
886 | 880 | |
887 | 881 | return array('success' => false, 'message' => 'ddLogin error: '.$res); |
888 | 882 | } |
889 | 883 | |
890 | - if ($dd->user == 'impex') | |
884 | + if ($dd->user == 'impex') | |
891 | 885 | { |
892 | 886 | //if ($dd->getWsSize() > DISK_QUOTA * 100) |
893 | 887 | // error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu'); |
894 | 888 | return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented"); |
895 | - } | |
896 | - else | |
889 | + } | |
890 | + else | |
897 | 891 | { |
898 | - // check disk space | |
899 | - if ($dd->getWsSize() > DISK_QUOTA) | |
892 | + // check disk space | |
893 | + if ($dd->getWsSize() > DISK_QUOTA) | |
900 | 894 | return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available'); |
901 | 895 | } |
902 | 896 | |
... | ... | @@ -905,21 +899,20 @@ class AmdaAction |
905 | 899 | return array('success' => true, 'userHost' => $dd -> getIPclient()); |
906 | 900 | } |
907 | 901 | |
908 | - private function executeRequest($obj, $function){ | |
909 | - | |
910 | - $res = $this->checkUser($obj); | |
911 | - | |
912 | - if (!$res['success']) | |
913 | - return $res; | |
902 | + private function executeRequest($obj, $function) | |
903 | + { | |
904 | + $res = $this->checkUser($obj); | |
905 | + if (!$res['success']) return $res; | |
914 | 906 | |
915 | 907 | $requestManager = new RequestManagerClass(); |
916 | 908 | |
917 | - try { | |
909 | + try | |
910 | + { | |
918 | 911 | $res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj); |
919 | - } catch (Exception $e) { | |
912 | + } catch (Exception $e) | |
913 | + { | |
920 | 914 | return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage()); |
921 | - } | |
922 | - | |
915 | + } | |
923 | 916 | return $res; |
924 | 917 | } |
925 | 918 | |
... | ... | @@ -935,8 +928,13 @@ class AmdaAction |
935 | 928 | return $this->executeRequest($obj, FunctionTypeEnumClass::TTCONVERT); |
936 | 929 | else if (isset($obj->action)) |
937 | 930 | return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION); |
938 | - else | |
931 | + else | |
932 | + { | |
933 | + $res = RequestMgr::checkRequest($obj); | |
934 | + if (!$res['success']) return $res; | |
935 | + | |
939 | 936 | return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS); |
937 | + } | |
940 | 938 | } |
941 | 939 | |
942 | 940 | /* | ... | ... |
php/classes/RequestMgr.php
... | ... | @@ -2,236 +2,318 @@ |
2 | 2 | /** |
3 | 3 | * @class RequestMgr |
4 | 4 | * @version $Id: RequestMgr.php 2914 2015-05-19 10:31:38Z elena $ |
5 | - * | |
6 | - * | |
7 | 5 | */ |
8 | 6 | |
9 | -class RequestMgr extends AmdaObjectMgr { | |
10 | - | |
11 | - public $obj; | |
12 | - public $impex_prefix = array('impex___', 'spase__', 'CLWEB_'); | |
13 | - protected $searchChain; | |
14 | - protected $jobXml, $jobXmlName; | |
15 | - protected $parser, $paramBuilder; | |
16 | - protected $derivedParamMgr; | |
17 | - protected $request, $nObjects; | |
18 | - protected $currentInt, $totalInt, $ttName; | |
19 | - protected $paramsWithoutCode = false; | |
20 | - protected $spectraParams = false; | |
21 | - protected $dataBases; | |
22 | - protected $types = array('request', 'condition'); | |
23 | - protected $argumentsByParam = array(); | |
24 | - protected $defaults = 'select...'; | |
25 | - protected $scatterOffset, $scatterOffsetX, $firstOffset; | |
26 | - protected $timeFormat = array('YYYY-MM-DDThh:mm:ss' => 0, 'YYYY MM DD hh mm ss' => 1, 'DD MM YYYY hh mm ss' => 2, 'YYYY DDD hh mm ss' => 3); | |
27 | - protected $fileMgr; | |
28 | - | |
29 | - function __construct($type) { | |
30 | - | |
31 | - parent::__construct('Request.xml'); | |
32 | - $this->type = $type; | |
33 | - | |
34 | - $this->contentRootId = $type.'-treeRootNode'; | |
35 | - $this->contentRootTag = $type.'List'; | |
36 | - $this->objTagName = $type; //'request'; | |
37 | - $this->jobXmlName = USERDIR.'jobs.xml'; | |
38 | - $this->jobXml = new DomDocument("1.0"); | |
39 | - if (file_exists($this->jobXmlName)) { | |
40 | - $this->jobXml->load($this->jobXmlName); | |
41 | - } | |
42 | - if ($type == 'request') { | |
43 | - $this->id_prefix = 'req_'; | |
44 | - $this->attributes = array('name' => ''); | |
45 | - $this->optionalAttributes = array(); | |
46 | - } | |
47 | - else { | |
48 | - $this->id_prefix = 'cond_'; | |
49 | - $this->attributes = array('name' => ''); | |
50 | - //, 'timestep' => '', 'datagap' => '', 'buildchain' => '', | |
51 | - // 'StartTime' => '', 'TimeInt' => ''); | |
52 | - $this->optionalAttributes = array(); | |
53 | - } | |
54 | - | |
55 | - if (!file_exists($this->xmlName)) { | |
56 | - $this->createDom(); | |
57 | - $this->xp = new domxpath($this->contentDom); | |
58 | - } | |
59 | - //external bases | |
60 | - if (file_exists(RemoteData.'Bases.xml')) { | |
61 | - $dataBasesDoc = new DomDocument("1.0"); | |
62 | - $dataBasesDoc->load(RemoteData.'Bases.xml'); | |
63 | - $this->dataBases = $dataBasesDoc->getElementsByTagName('dataCenter'); | |
64 | - } | |
65 | - | |
66 | - putenv("USER_DATA_PATH=".USERDATADIR); | |
67 | - putenv("USER_WS_PATH=".USERWSDIR); | |
68 | - putenv("PHP_CLASSES_PATH=".CLASSPATH); | |
69 | - | |
70 | - } | |
71 | - | |
72 | -/********************************************************************* | |
73 | -* BEGIN : generic functions | |
74 | -**********************************************************************/ | |
75 | - | |
76 | - | |
77 | - protected function setObject($obj) | |
78 | - { | |
79 | - $this->obj = $obj; | |
80 | - } | |
81 | - | |
82 | - | |
83 | -/********************************************************************* | |
84 | -* END : generic functions | |
85 | -**********************************************************************/ | |
86 | - | |
87 | - | |
88 | - | |
7 | +class RequestMgr extends AmdaObjectMgr | |
8 | +{ | |
9 | + public $obj; | |
10 | + protected $type; | |
11 | + protected $jobXml, $jobXmlName; | |
12 | + protected $types = array('request', 'condition'); | |
89 | 13 | |
90 | - | |
91 | - public function generateVOTableFromDownloadResult($id,$newName,$inputCompressed = true,$canBeAlreadyVOTable = false) | |
92 | - { | |
93 | - //ToDo - use the new kernel | |
94 | - $res = array('success' => false, 'message' => 'NOT IMPLEMENTED => To implement with the new Kernel'); | |
95 | - } | |
96 | - | |
97 | - | |
98 | - | |
14 | + function __construct($type) | |
15 | + { | |
16 | + parent::__construct('Request.xml'); | |
17 | + $this->type = $type; | |
99 | 18 | |
100 | -/***************************************************************** | |
101 | -* PUBLIC FUNCTIONS | |
102 | -*****************************************************************/ | |
103 | - | |
104 | - | |
105 | - | |
106 | - /* Stop Time from StartTime and Interval*/ | |
107 | - public function convertTime($obj) | |
108 | - { | |
19 | + $this->contentRootId = $type.'-treeRootNode'; | |
20 | + $this->contentRootTag = $type.'List'; | |
21 | + $this->objTagName = $type; | |
22 | + | |
23 | + $this->jobXmlName = USERDIR.'jobs.xml'; | |
24 | + $this->jobXml = new DomDocument("1.0"); | |
25 | + if (file_exists($this->jobXmlName)) | |
26 | + { | |
27 | + $this->jobXml->load($this->jobXmlName); | |
28 | + } | |
29 | + | |
30 | + $this->attributes = array('name' => ''); | |
31 | + $this->optionalAttributes = array(); | |
32 | + | |
33 | + if ($type == 'request') | |
34 | + { | |
35 | + $this->id_prefix = 'req_'; | |
36 | + } | |
37 | + else | |
38 | + { | |
39 | + $this->id_prefix = 'cond_'; | |
40 | + } | |
41 | + | |
42 | + if (!file_exists($this->xmlName)) | |
43 | + { | |
44 | + $this->createDom(); | |
45 | + $this->xp = new domxpath($this->contentDom); | |
46 | + } | |
109 | 47 | |
110 | - $time = strtotime($obj->startDate); | |
48 | + putenv("USER_DATA_PATH=".USERDATADIR); | |
49 | + putenv("USER_WS_PATH=".USERWSDIR); | |
50 | + putenv("PHP_CLASSES_PATH=".CLASSPATH); | |
51 | + } | |
111 | 52 | |
112 | - $interval = $obj->durationDay*86400 + | |
113 | - $obj->durationHour*3600 + | |
114 | - $obj->durationMin*60 + $obj->durationSec; | |
115 | - $stopTime = gmdate("Y-m-d\TH:i:s", $time+$interval); | |
116 | - $obj->stopDate = $stopTime; | |
53 | + protected function setObject($obj) | |
54 | + { | |
55 | + $this->obj = $obj; | |
56 | + } | |
57 | + | |
58 | + /* | |
59 | + * Delete request/condition JSON file | |
60 | + */ | |
61 | + protected function deleteParameter($id) | |
62 | + { | |
63 | + if (file_exists(USERREQDIR.$id)) unlink(USERREQDIR.$id); | |
64 | + } | |
65 | + | |
66 | +/* | |
67 | +* TODO Check file JSON objects differ in names only | |
68 | +*/ | |
69 | + protected function renameOnly($p) | |
70 | + { | |
71 | + return false; | |
72 | + } | |
73 | + | |
74 | + public function generateVOTableFromDownloadResult($id,$newName,$inputCompressed = true,$canBeAlreadyVOTable = false) | |
75 | + { | |
76 | + //TODO - use the new kernel | |
77 | + $res = array('success' => false, 'message' => 'NOT IMPLEMENTED => To implement with the new Kernel'); | |
78 | + } | |
79 | + | |
80 | + /* Stop Time from StartTime and Interval*/ | |
81 | + public function convertTime($obj) | |
82 | + { | |
83 | + $time = strtotime($obj->startDate); | |
117 | 84 | |
118 | - return $obj; | |
119 | - } | |
85 | + $interval = $obj->durationDay*86400 + | |
86 | + $obj->durationHour*3600 + | |
87 | + $obj->durationMin*60 + $obj->durationSec; | |
88 | + $stopTime = gmdate("Y-m-d\TH:i:s", $time+$interval); | |
89 | + $obj->stopDate = $stopTime; | |
120 | 90 | |
121 | - | |
91 | + return $obj; | |
92 | + } | |
93 | + //TODO | |
94 | + public function markAsUndefined($paramId) | |
95 | + { | |
96 | + $n_requests = 0; | |
122 | 97 | |
123 | - //TODO | |
124 | - public function markAsUndefined($paramId) | |
125 | - { | |
126 | - $n_requests = 0; | |
98 | + return $n_requests; | |
99 | + } | |
127 | 100 | |
128 | - return $n_requests; | |
129 | - } | |
101 | + /* | |
102 | + * Get Object JSON!!! (request or condition) into Edit | |
103 | + */ | |
104 | + public function getObject($id) | |
105 | + { | |
106 | + if (!file_exists(USERREQDIR.$id)) return array('error' => NO_OBJECT_FILE); | |
107 | + | |
108 | + if (!($objToGet = $this->contentDom->getElementById($id))) return array('error' => NO_SUCH_ID); | |
109 | + | |
110 | + $obj = json_decode(file_get_contents(USERREQDIR.$id)); | |
111 | + //if alias exists, replace parameter name by alias name | |
112 | + if (file_exists(USERWSDIR.'Alias.xml')) | |
113 | + { | |
114 | + if ($this->type == 'condition') | |
115 | + { | |
116 | + $obj->expression =$this->setAlias($obj->expression); | |
117 | + } | |
118 | + else if ($this->type == 'request') | |
119 | + { | |
120 | + for ($i=0; $i < count($obj->children); $i++) { | |
121 | + for ($j=0; $j < count($obj->children[$i]->children); $j++) { | |
122 | + $obj->children[$i]->children[$j]->name = $this->setAlias($obj->children[$i]->children[$j]->name); | |
123 | + } | |
124 | + } | |
125 | + //TODO Ajout des SCATTER | |
126 | + // if $obj->children[$i]->plotType == "SCATTER" | |
127 | + //$obj->children[$i]->scatterParam->data->name pour 1 panel (bug si 2 panels devient $obj->children[$i]->scatterParam->data->data->name) | |
128 | + } | |
129 | + } | |
130 | + //if Start Time - Stop Time | |
131 | + if (!$obj->timeTables) $obj = $this->convertTime($obj); | |
132 | + | |
133 | + return $obj; | |
134 | + } | |
130 | 135 | |
131 | - /* | |
132 | - * Get Object JSON!!! (request or condition) into Edit | |
133 | - */ | |
134 | - public function getObject($id) | |
135 | - { | |
136 | - if (!file_exists(USERREQDIR.$id)) return array('error' => NO_OBJECT_FILE); | |
136 | + /* | |
137 | + * Change NAME in JSON resource | |
138 | + */ | |
139 | + protected function renameInResource($name, $id) | |
140 | + { | |
141 | + $obj = json_decode(file_get_contents(USERREQDIR.$id)); | |
142 | + $obj->name = $name; | |
143 | + | |
144 | + $file = fopen(USERREQDIR.$id, 'w'); | |
145 | + fwrite($file, json_encode($obj)); | |
146 | + fclose($file); | |
147 | + } | |
137 | 148 | |
138 | - if (!($objToGet = $this->contentDom->getElementById($id))) return array('error' => NO_SUCH_ID); | |
139 | - $obj = json_decode(file_get_contents(USERREQDIR.$id)); | |
140 | - //if alias exists, replace parameter name by alias name | |
141 | - if (file_exists(USERWSDIR.'Alias.xml')) { | |
142 | - if ($this->type == 'condition') { | |
143 | - $obj->expression = $this->setAlias($obj->expression); | |
144 | - } | |
145 | - else if ($this->type == 'request') { | |
146 | - for ($i=0; $i < count($obj->children); $i++) { | |
147 | - for ($j=0; $j < count($obj->children[$i]->children); $j++) { | |
148 | - $obj->children[$i]->children[$j]->name = $this->setAlias($obj->children[$i]->children[$j]->name); | |
149 | - } | |
150 | - } | |
151 | - //TODO Ajout des SCATTER | |
152 | - // if $obj->children[$i]->plotType == "SCATTER" | |
153 | - //$obj->children[$i]->scatterParam->data->name pour 1 panel (bug si 2 panels devient $obj->children[$i]->scatterParam->data->data->name) | |
154 | - } | |
155 | - } | |
156 | - //if Start Time - Stop Time | |
157 | - if (!$obj->timeTables) $obj = $this->convertTime($obj); | |
158 | - return $obj; | |
159 | - } | |
160 | - | |
161 | - | |
162 | - /* | |
163 | - * Change NAME in JSON resource | |
164 | - */ | |
165 | - protected function renameInResource($name, $id) { | |
166 | - | |
167 | - $obj = json_decode(file_get_contents(USERREQDIR.$id)); | |
168 | - $obj->name = $name; | |
169 | - | |
170 | - $file = fopen(USERREQDIR.$id, 'w'); | |
171 | - fwrite($file, json_encode($obj)); | |
172 | - fclose($file); | |
173 | - } | |
174 | - | |
175 | - | |
176 | - /* | |
177 | - * Make new request/condition resource file (JSON!!) and add it to content file | |
178 | - * ATTENTION : it is not DD parameter!!! | |
179 | - */ | |
180 | - protected function createParameter($p) | |
181 | - { | |
182 | - if ($this -> objectExistsByName($p->name)) { | |
183 | - $p->id = $this->getObjectIdByName($p->name); | |
184 | - $this -> deleteObject($p); | |
185 | - } | |
186 | - $this->id = $this->setId(); | |
187 | - if (!$this->id) return array('error' => ID_CREATION_ERROR); | |
188 | - | |
189 | - //if alias exists, replace alias name by parameter name | |
190 | - if (file_exists(USERWSDIR.'Alias.xml')) { | |
191 | - if ($this->type == 'condition') { | |
192 | - $p->expression = $this->resetAlias($p->expression); | |
193 | - $info = $p->expression; | |
194 | - } | |
195 | - else if ($this->type == 'request') { | |
196 | - $info = ''; | |
197 | - for ($i=0; $i < count($p->children); $i++) { | |
198 | - for ($j=0; $j < count($p->children[$i]->children); $j++) { | |
199 | - $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name); | |
200 | - $info = $info.' '.$p->children[$i]->children[$j]->name; | |
201 | - } | |
202 | - } | |
203 | - } | |
204 | - } | |
205 | - | |
206 | - $this->descFileName = USERREQDIR.$this->id; | |
207 | - $p->id = $this->id; | |
208 | - // save request as json | |
209 | - $file = fopen($this->descFileName, 'w'); | |
210 | - fwrite($file, json_encode($p)); | |
211 | - fclose($file); | |
212 | - | |
213 | - $this -> addToContent($p, $folder); | |
214 | - | |
215 | - return array('id' => $this->id, 'info' => $info); | |
216 | - } | |
217 | - | |
218 | - /* | |
219 | - * Delete request/condition JSON file | |
220 | - */ | |
221 | - protected function deleteParameter($id){ | |
222 | - | |
223 | - if (file_exists(USERREQDIR.$id)) | |
224 | - unlink(USERREQDIR.$id); | |
225 | - } | |
226 | - | |
227 | - /* | |
228 | - * TODO Check file JSON objects differ in names only | |
229 | - */ | |
230 | - protected function renameOnly($p) { | |
231 | - | |
232 | - return false; | |
233 | - } | |
234 | - | |
149 | +/* | |
150 | +* Make new request/condition resource file (JSON!!) and add it to content file | |
151 | +* ATTENTION : it is not DD parameter!!! | |
152 | +*/ | |
153 | + protected function createParameter($p) | |
154 | + { | |
155 | + if ($this -> objectExistsByName($p->name)) | |
156 | + { | |
157 | + $p->id = $this->getObjectIdByName($p->name); | |
158 | + $this -> deleteObject($p); | |
159 | + } | |
160 | + | |
161 | + $this->id = $this->setId(); | |
162 | + | |
163 | + if (!$this->id) return array('error' => ID_CREATION_ERROR); | |
164 | + | |
165 | + //if alias exists, replace alias name by parameter name | |
166 | + if (file_exists(USERWSDIR.'Alias.xml')) | |
167 | + { | |
168 | + if ($this->type == 'condition') | |
169 | + { | |
170 | + $p->expression = $this->resetAlias($p->expression); | |
171 | + $info = $p->expression; | |
172 | + } | |
173 | + else if ($this->type == 'request') | |
174 | + { | |
175 | + $info = ''; | |
176 | + for ($i=0; $i < count($p->children); $i++) | |
177 | + { | |
178 | + for ($j=0; $j < count($p->children[$i]->children); $j++) | |
179 | + { | |
180 | + $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name); | |
181 | + $info = $info.' '.$p->children[$i]->children[$j]->name; | |
182 | + } | |
183 | + } | |
184 | + } | |
185 | + } | |
235 | 186 | |
187 | + $this->descFileName = USERREQDIR.$this->id; | |
188 | + $p->id = $this->id; | |
189 | + // save request as json | |
190 | + $file = fopen($this->descFileName, 'w'); | |
191 | + fwrite($file, json_encode($p)); | |
192 | + fclose($file); | |
193 | + | |
194 | + $this -> addToContent($p, $folder); | |
195 | + | |
196 | + return array('id' => $this->id, 'info' => $info); | |
197 | + } | |
198 | + | |
199 | + public static function checkRequest($obj) | |
200 | + { | |
201 | + if (!file_exists(orbitsAllXml)) return array('success' => false, $message => 'no orbits descriotion file'); | |
202 | + | |
203 | + //check for orbit templateArgs | |
204 | + $args = array(); | |
205 | + switch ($obj->nodeType) | |
206 | + { | |
207 | + case 'request' : | |
208 | + foreach ($obj->tabs as $tab) | |
209 | + { | |
210 | + $timesrc = $tab->{'multi-plot-linked'} ? $obj->timesrc : $tab->timesrc; | |
211 | + | |
212 | + //TODO check TT as well (first start and last stop ?) | |
213 | + if ($timesrc != 'Interval') continue; | |
214 | + // select active tab | |
215 | + if (!$tab->{'multi-plot-linked'} && $tab->id != $obj->{'last-plotted-tab'}) continue; | |
216 | + | |
217 | + $argsTab = array(); | |
218 | + foreach ($tab->panels as $panel) | |
219 | + { | |
220 | + $params = array(); | |
221 | + foreach ($panel->params as $param) | |
222 | + { | |
223 | + //TODO not in code spase___IMPEX_ !!! | |
224 | + //TODO other models (tsyganenko etc) | |
225 | + if (preg_match("#^spase___IMPEX_#", $param->paramid)) | |
226 | + { | |
227 | + if ($param->template_args->url_XYZ) $params[] = $param->template_args->url_XYZ; | |
228 | + } | |
229 | + } | |
230 | + if (count($params) > 0) | |
231 | + { | |
232 | + $argsTab['param'] = array_unique($params); | |
233 | + $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate; | |
234 | + $argsTab['stopTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->stopDate; | |
235 | + } | |
236 | + } | |
237 | + if (count($argsTab) > 0) $args[] = $argsTab; | |
238 | + } | |
239 | + break; | |
240 | + case 'condition' : | |
241 | + //$argsTab = array(); | |
242 | + if ($obj->timesrc != 'Interval') break; | |
243 | + //TODO check for condition | |
244 | + break; | |
245 | + case 'download' : | |
246 | + $argsTab = array(); | |
247 | + if ($obj->timesrc != 'Interval') break; | |
248 | + | |
249 | + foreach ($obj->list as $param) | |
250 | + { | |
251 | + //TODO not in code spase___IMPEX_ !!! | |
252 | + //TODO other models (tsyganenko etc) | |
253 | + if (preg_match("#^spase___IMPEX_#", $param->paramid)) | |
254 | + { | |
255 | + if ($param->template_args->url_XYZ) $params[] = $param->template_args->url_XYZ; | |
256 | + } | |
257 | + } | |
258 | + if (count($params) > 0) | |
259 | + { | |
260 | + $argsTab['param'] = array_unique($params); | |
261 | + $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate; | |
262 | + $argsTab['stopTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->stopDate; | |
263 | + } | |
264 | + if (count($argsTab) > 0) $args[] = $argsTab; | |
265 | + | |
266 | + break; | |
267 | + default : | |
268 | + return array('success' => false, 'message' => "unknown action ".$obj->nodeType); | |
269 | + } | |
270 | + | |
271 | + if (count($args) === 0) return array('success' => true); | |
272 | + | |
273 | + try | |
274 | + { | |
275 | + $client = new SoapClient(DD_WSDL); | |
276 | + } | |
277 | + catch (SoapFault $exception) | |
278 | + { | |
279 | + return array('success' => false, 'message' => $exception->faultstring); | |
280 | + } | |
281 | + | |
282 | + $orbitsXml = new DomDocument("1.0"); | |
283 | + $orbitsXml->load(orbitsAllXml); | |
284 | + $tr = array('_' => ':'); | |
285 | + | |
286 | + foreach ($args as $tab) | |
287 | + { | |
288 | + $startTime = $tab['startTime']; | |
289 | + $stopTime = $tab['stopTime']; | |
290 | + | |
291 | + foreach ($tab['param'] as $param) | |
292 | + { | |
293 | + $orbitNode = $orbitsXml->getElementById($param); | |
294 | + $dsId = $orbitNode->getAttribute('dataset'); | |
295 | + $mission = $orbitNode->getAttribute('mission'); | |
296 | + $target = $orbitNode->getAttribute('target'); | |
297 | + try { | |
298 | + $res = $client->getStartStop(strtr($dsId,$tr)); | |
299 | + $Time = explode("-",$res); | |
300 | + $orbStartTime = CommonClass::DDTimeToIso($Time[0]); | |
301 | + $orbStopTime = CommonClass::DDTimeToIso($Time[1]); | |
302 | + } | |
303 | + catch (SoapFault $exception) { | |
304 | + return array('success' => false, 'message' => $exception->faultstring); | |
305 | + } | |
306 | + | |
307 | + if (($startTime > $orbStopTime) || ($stopTime < $orbStartTime)) | |
308 | + return array('success' => false, 'message' => "Invalid time settings : | |
309 | + $mission $target orbiting <br/> $orbStartTime - $orbStopTime"); | |
310 | + | |
311 | + if ( strtotime($stopTime) - strtotime($startTime) > IMPEX_INTERVAL_LIMIT ) | |
312 | + return array('success' => false, 'message' => "Too big interval for IMPEX request : ".IMPEX_INTERVAL_LIMIT/86400.." day limit!"); | |
313 | + } | |
314 | + } | |
315 | + | |
316 | + return array('success' => true); | |
317 | + } | |
236 | 318 | } |
237 | 319 | ?> | ... | ... |
php/config.php
... | ... | @@ -52,6 +52,8 @@ define('DISK_QUOTA', 1024*1024*200); // 200MB |
52 | 52 | define('MAX_FILE_INDEX_TO_SHOW', 100); |
53 | 53 | // private key used to be considerate as a trust client for some functions of DD web service |
54 | 54 | define('DDSERVICE_PRIVATEKEY','!%p856Dc'); |
55 | + | |
56 | +define('IMPEX_INTERVAL_LIMIT', 86400); // one day for impex request | |
55 | 57 | |
56 | 58 | /*----------------------- BATCH JOBS section --------*/ |
57 | 59 | define('JOBTIMEOUT', '1'); // one cycle secs to sleep to allow job be executed | ... | ... |