Commit d05bf0bb80c0c8f8840ac52a09a7a246a0698e06
1 parent
1fd0f00c
Exists in
master
and in
112 other branches
Provide to the user some informations about an eventual error.
Showing
3 changed files
with
47 additions
and
23 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
@@ -331,8 +331,8 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -331,8 +331,8 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
331 | this.filter = Array( | 331 | this.filter = Array( |
332 | this.productTypeCB.value !== 'all' ? this.productTypeCB.value : null, // product type | 332 | this.productTypeCB.value !== 'all' ? this.productTypeCB.value : null, // product type |
333 | this.targetNameCB.value !== 'all' ? this.targetNameCB.value : null, // target name | 333 | this.targetNameCB.value !== 'all' ? this.targetNameCB.value : null, // target name |
334 | - this.timeSelector.getStartTime() !== '' ? this.timeSelector.getStartTime() : null, // start time | ||
335 | - this.timeSelector.getStopTime() !== '' ? this.timeSelector.getStopTime() : null // stop time | 334 | + Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'), // start time |
335 | + Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s') // stop time | ||
336 | ); | 336 | ); |
337 | 337 | ||
338 | AmdaAction.epnTapGetNbRows(selectedServiceId, selectedServiceURL, this.filter, this.updateNbRows); | 338 | AmdaAction.epnTapGetNbRows(selectedServiceId, selectedServiceURL, this.filter, this.updateNbRows); |
@@ -480,11 +480,13 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -480,11 +480,13 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
480 | Among other things, fill the `epnTapGranulesGrid` table (see `EpnTapUI.granulesStore`). | 480 | Among other things, fill the `epnTapGranulesGrid` table (see `EpnTapUI.granulesStore`). |
481 | */ | 481 | */ |
482 | fillGranules: function(granules) { | 482 | fillGranules: function(granules) { |
483 | - if (granules == null) { | ||
484 | - console.log("There is no granules to add."); | 483 | + // console.log(granules); |
484 | + // return; | ||
485 | + | ||
486 | + if (granules["error"] != null) { | ||
487 | + alert(granules["error"]); | ||
485 | } else { | 488 | } else { |
486 | try { | 489 | try { |
487 | - console.log('Added granules:', granules); | ||
488 | Ext.getCmp('epnTapGranulesGrid').getStore().removeAll(); | 490 | Ext.getCmp('epnTapGranulesGrid').getStore().removeAll(); |
489 | Ext.getCmp('epnTapGranulesGrid').getStore().add(granules); | 491 | Ext.getCmp('epnTapGranulesGrid').getStore().add(granules); |
490 | } catch( e ) { | 492 | } catch( e ) { |
js/app/views/IntervalUI.js
@@ -72,7 +72,7 @@ Ext.define('amdaUI.IntervalUI', { | @@ -72,7 +72,7 @@ Ext.define('amdaUI.IntervalUI', { | ||
72 | 72 | ||
73 | /** | 73 | /** |
74 | Get the start time field value. | 74 | Get the start time field value. |
75 | - - return: A Extjs Date object representing the start time. | 75 | + - return: A Extjs Date object representing the start time (null if the date is not valid). |
76 | */ | 76 | */ |
77 | getStartTime: function() { | 77 | getStartTime: function() { |
78 | // get the search form | 78 | // get the search form |
@@ -85,7 +85,7 @@ Ext.define('amdaUI.IntervalUI', { | @@ -85,7 +85,7 @@ Ext.define('amdaUI.IntervalUI', { | ||
85 | 85 | ||
86 | /** | 86 | /** |
87 | Get the stop time field value. | 87 | Get the stop time field value. |
88 | - - return: A Extjs Date object representing the stop time. | 88 | + - return: A Extjs Date object representing the stop time (null if the date is not valid). |
89 | */ | 89 | */ |
90 | getStopTime : function() | 90 | getStopTime : function() |
91 | { | 91 | { |
php/classes/VOTableMgr.php
@@ -14,6 +14,7 @@ class VOTableMgr { | @@ -14,6 +14,7 @@ class VOTableMgr { | ||
14 | private $stream; // The stream in the VOTable | 14 | private $stream; // The stream in the VOTable |
15 | private $c; // Current character position on the stream | 15 | private $c; // Current character position on the stream |
16 | private $is_little_endian; | 16 | private $is_little_endian; |
17 | + private $votable_error = false; | ||
17 | 18 | ||
18 | function __construct() | 19 | function __construct() |
19 | { | 20 | { |
@@ -23,26 +24,31 @@ class VOTableMgr { | @@ -23,26 +24,31 @@ class VOTableMgr { | ||
23 | 24 | ||
24 | function addLog($msg) | 25 | function addLog($msg) |
25 | { | 26 | { |
26 | - if (DEBUG_MODE) | ||
27 | - fwrite($this->logVotable, date("h:i:s A") . ": " . $msg . "\n"); | 27 | + if (DEBUG_MODE) |
28 | + fwrite($this->logVotable, date("h:i:s A") . ": " . $msg . "\n"); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | function load($fileName) { | 31 | function load($fileName) { |
31 | - $this->addLog("File name" . $fileName); | 32 | + $this->addLog("File name " . $fileName); |
32 | $this->is_little_endian = array_values(unpack('L1L', pack('V', 1)))[0] == 1; | 33 | $this->is_little_endian = array_values(unpack('L1L', pack('V', 1)))[0] == 1; |
33 | 34 | ||
34 | // see http://php.net/manual/en/domdocument.load.php#91384 | 35 | // see http://php.net/manual/en/domdocument.load.php#91384 |
35 | - $opts = array( | ||
36 | - 'http' => array('user_agent' => 'PHP libxml agent') | 36 | + $options = array( |
37 | + 'http' => array( | ||
38 | + 'method' => 'GET', | ||
39 | + 'timeout' => '5', | ||
40 | + 'user_agent' => 'PHP libxml agent' | ||
41 | + ) | ||
37 | ); | 42 | ); |
38 | - $context = stream_context_create($opts); | 43 | + $context = stream_context_create($options); |
39 | libxml_set_streams_context($context); | 44 | libxml_set_streams_context($context); |
40 | 45 | ||
41 | $this->xml = new DomDocument(); | 46 | $this->xml = new DomDocument(); |
42 | $res = $this->xml->load($fileName); | 47 | $res = $this->xml->load($fileName); |
43 | 48 | ||
44 | if(!$res) { | 49 | if(!$res) { |
45 | - $this->addLog("Can not load VOTAble."); | 50 | + $this->votable_error = "Can not load the XML file. Maybe the service is not accessible."; |
51 | + $this->addLog("Can not load XML."); | ||
46 | return false; | 52 | return false; |
47 | } | 53 | } |
48 | 54 | ||
@@ -63,21 +69,30 @@ class VOTableMgr { | @@ -63,21 +69,30 @@ class VOTableMgr { | ||
63 | return true; | 69 | return true; |
64 | } | 70 | } |
65 | 71 | ||
66 | - function isValidSchema() | ||
67 | - { | ||
68 | - if (!$this->xml) | ||
69 | - return FALSE; | 72 | + function getVotableError() { |
73 | + return $this->votable_error; | ||
74 | + } | ||
75 | + | ||
76 | + function isValidSchema() { | ||
77 | + if ($this->votable_error != false) { | ||
78 | + return false; | ||
79 | + } | ||
80 | + | ||
81 | + if (!$this->xml) { | ||
82 | + $this->votable_error = "The returned file is not XML."; | ||
83 | + return false; | ||
84 | + } | ||
70 | 85 | ||
71 | $infos = $this->xp->query($this->queryResourceInfo()); | 86 | $infos = $this->xp->query($this->queryResourceInfo()); |
72 | foreach($infos as $info) { | 87 | foreach($infos as $info) { |
73 | if($info->getAttribute('value') == 'ERROR') { | 88 | if($info->getAttribute('value') == 'ERROR') { |
74 | - $this->addLog("There is an error on the VOTable: " . $info->textContent); | ||
75 | - return FALSE; | 89 | + $this->votable_error = $info->textContent; |
90 | + return false; | ||
76 | } | 91 | } |
77 | } | 92 | } |
78 | 93 | ||
79 | //ToDo - BRE - add validation!! | 94 | //ToDo - BRE - add validation!! |
80 | - return TRUE; | 95 | + return true; |
81 | 96 | ||
82 | if (DEBUG_MODE) | 97 | if (DEBUG_MODE) |
83 | libxml_use_internal_errors(true); | 98 | libxml_use_internal_errors(true); |
@@ -259,6 +274,9 @@ class VOTableMgr { | @@ -259,6 +274,9 @@ class VOTableMgr { | ||
259 | 274 | ||
260 | /** Get the VOTable stream content.*/ | 275 | /** Get the VOTable stream content.*/ |
261 | public function parseStream() { | 276 | public function parseStream() { |
277 | + if (! $this->isValidSchema()) { | ||
278 | + return null; | ||
279 | + } | ||
262 | $data = Array(); | 280 | $data = Array(); |
263 | $fields = $this->xp->query($this->queryFields()); | 281 | $fields = $this->xp->query($this->queryFields()); |
264 | $nb_columns = $fields->length; | 282 | $nb_columns = $fields->length; |
@@ -266,12 +284,16 @@ class VOTableMgr { | @@ -266,12 +284,16 @@ class VOTableMgr { | ||
266 | $n_value = 0; // index of current value | 284 | $n_value = 0; // index of current value |
267 | $this->c = 0; // initialize cursor position. | 285 | $this->c = 0; // initialize cursor position. |
268 | $query_stream = $this->xp->query($this->queryStream())->item(0); | 286 | $query_stream = $this->xp->query($this->queryStream())->item(0); |
269 | - if($query_stream == NULL) | 287 | + if($query_stream == NULL) { |
288 | + $this->votable_error = "There is no STREAM node in the VOTable file."; | ||
270 | return NULL; | 289 | return NULL; |
290 | + } | ||
271 | $this->stream = base64_decode($query_stream->textContent); | 291 | $this->stream = base64_decode($query_stream->textContent); |
272 | $stream_len = strlen($this->stream); | 292 | $stream_len = strlen($this->stream); |
273 | - if($stream_len == 0) | 293 | + if($stream_len == 0) { |
294 | + $this->votable_error = "There is no result for this query."; | ||
274 | return NULL; | 295 | return NULL; |
296 | + } | ||
275 | while($this->c < strlen($this->stream)) { | 297 | while($this->c < strlen($this->stream)) { |
276 | $col_id = $n_value % $nb_columns; | 298 | $col_id = $n_value % $nb_columns; |
277 | $field_node = $fields[$col_id]; | 299 | $field_node = $fields[$col_id]; |