diff --git a/js/app/controllers/EpnTapModule.js b/js/app/controllers/EpnTapModule.js index b9e63b9..c68438c 100644 --- a/js/app/controllers/EpnTapModule.js +++ b/js/app/controllers/EpnTapModule.js @@ -331,8 +331,8 @@ Ext.define('amdaDesktop.EpnTapModule', { this.filter = Array( this.productTypeCB.value !== 'all' ? this.productTypeCB.value : null, // product type this.targetNameCB.value !== 'all' ? this.targetNameCB.value : null, // target name - this.timeSelector.getStartTime() !== '' ? this.timeSelector.getStartTime() : null, // start time - this.timeSelector.getStopTime() !== '' ? this.timeSelector.getStopTime() : null // stop time + Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'), // start time + Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s') // stop time ); AmdaAction.epnTapGetNbRows(selectedServiceId, selectedServiceURL, this.filter, this.updateNbRows); @@ -480,11 +480,13 @@ Ext.define('amdaDesktop.EpnTapModule', { Among other things, fill the `epnTapGranulesGrid` table (see `EpnTapUI.granulesStore`). */ fillGranules: function(granules) { - if (granules == null) { - console.log("There is no granules to add."); + // console.log(granules); + // return; + + if (granules["error"] != null) { + alert(granules["error"]); } else { try { - console.log('Added granules:', granules); Ext.getCmp('epnTapGranulesGrid').getStore().removeAll(); Ext.getCmp('epnTapGranulesGrid').getStore().add(granules); } catch( e ) { diff --git a/js/app/views/IntervalUI.js b/js/app/views/IntervalUI.js index 77276f2..f829c14 100644 --- a/js/app/views/IntervalUI.js +++ b/js/app/views/IntervalUI.js @@ -72,7 +72,7 @@ Ext.define('amdaUI.IntervalUI', { /** Get the start time field value. - - return: A Extjs Date object representing the start time. + - return: A Extjs Date object representing the start time (null if the date is not valid). */ getStartTime: function() { // get the search form @@ -85,7 +85,7 @@ Ext.define('amdaUI.IntervalUI', { /** Get the stop time field value. - - return: A Extjs Date object representing the stop time. + - return: A Extjs Date object representing the stop time (null if the date is not valid). */ getStopTime : function() { diff --git a/php/classes/VOTableMgr.php b/php/classes/VOTableMgr.php index d77a780..3ce831e 100644 --- a/php/classes/VOTableMgr.php +++ b/php/classes/VOTableMgr.php @@ -14,6 +14,7 @@ class VOTableMgr { private $stream; // The stream in the VOTable private $c; // Current character position on the stream private $is_little_endian; + private $votable_error = false; function __construct() { @@ -23,26 +24,31 @@ class VOTableMgr { function addLog($msg) { - if (DEBUG_MODE) - fwrite($this->logVotable, date("h:i:s A") . ": " . $msg . "\n"); + if (DEBUG_MODE) + fwrite($this->logVotable, date("h:i:s A") . ": " . $msg . "\n"); } function load($fileName) { - $this->addLog("File name" . $fileName); + $this->addLog("File name " . $fileName); $this->is_little_endian = array_values(unpack('L1L', pack('V', 1)))[0] == 1; // see http://php.net/manual/en/domdocument.load.php#91384 - $opts = array( - 'http' => array('user_agent' => 'PHP libxml agent') + $options = array( + 'http' => array( + 'method' => 'GET', + 'timeout' => '5', + 'user_agent' => 'PHP libxml agent' + ) ); - $context = stream_context_create($opts); + $context = stream_context_create($options); libxml_set_streams_context($context); $this->xml = new DomDocument(); $res = $this->xml->load($fileName); if(!$res) { - $this->addLog("Can not load VOTAble."); + $this->votable_error = "Can not load the XML file. Maybe the service is not accessible."; + $this->addLog("Can not load XML."); return false; } @@ -63,21 +69,30 @@ class VOTableMgr { return true; } - function isValidSchema() - { - if (!$this->xml) - return FALSE; + function getVotableError() { + return $this->votable_error; + } + + function isValidSchema() { + if ($this->votable_error != false) { + return false; + } + + if (!$this->xml) { + $this->votable_error = "The returned file is not XML."; + return false; + } $infos = $this->xp->query($this->queryResourceInfo()); foreach($infos as $info) { if($info->getAttribute('value') == 'ERROR') { - $this->addLog("There is an error on the VOTable: " . $info->textContent); - return FALSE; + $this->votable_error = $info->textContent; + return false; } } //ToDo - BRE - add validation!! - return TRUE; + return true; if (DEBUG_MODE) libxml_use_internal_errors(true); @@ -259,6 +274,9 @@ class VOTableMgr { /** Get the VOTable stream content.*/ public function parseStream() { + if (! $this->isValidSchema()) { + return null; + } $data = Array(); $fields = $this->xp->query($this->queryFields()); $nb_columns = $fields->length; @@ -266,12 +284,16 @@ class VOTableMgr { $n_value = 0; // index of current value $this->c = 0; // initialize cursor position. $query_stream = $this->xp->query($this->queryStream())->item(0); - if($query_stream == NULL) + if($query_stream == NULL) { + $this->votable_error = "There is no STREAM node in the VOTable file."; return NULL; + } $this->stream = base64_decode($query_stream->textContent); $stream_len = strlen($this->stream); - if($stream_len == 0) + if($stream_len == 0) { + $this->votable_error = "There is no result for this query."; return NULL; + } while($this->c < strlen($this->stream)) { $col_id = $n_value % $nb_columns; $field_node = $fields[$col_id]; -- libgit2 0.21.2