Module: nagvis
Branch: master
Commit: 7ba3cc7965f09e502cd8dfd60f51d3c8ca471484
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=7ba3cc7965f09e502cd8dfd60f51d3c8ca471484

Author: Lars Michelsen <[email protected]>
Date:   Wed Dec 29 19:34:34 2010 +0100

Cleaned up error handling in overview map parse code; Catching deletion of maps 
correctly now

---

 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |    2 +-
 share/frontend/nagvis-js/js/frontend.js            |    8 ++-
 share/server/core/classes/GlobalIndexPage.php      |   60 ++++++++++++--------
 share/server/core/classes/GlobalMapCfg.php         |    6 +-
 4 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index e1080ca..e4157a8 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -29,7 +29,7 @@ var NagVisStatefulObject = NagVisObject.extend({
        // Stores the information from last refresh (Needed for change 
detection)
        last_state: null,
        // Array of member objects
-       members: null,
+       members: [],
        
        constructor: function(oConf) {
                // Call parent constructor
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index 57355b9..21b2134 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -630,7 +630,7 @@ function updateMapBasics() {
        
        // Get new map state from core
        oMapSummaryObj = new 
NagVisMap(getSyncRequest(oGeneralProperties.path_server
-                                      + '?mod=' + mod + 
'&act=getObjectStates&ty=summary&i[]='
+                                      + '?mod=' + mod + 
'&act=getObjectStates&ty=summary&show='
                                                                                
                                                 + 
escapeUrlValues(oPageProperties.map_name)
                                                                                
                                                 + sAutomapParams, false)[0]);
        sAutomapParams = null;
@@ -730,6 +730,12 @@ function updateObjects(aMapObjectInformations, aObjs, 
sType) {
                        
                        // Save for return code
                        bStateChanged = true;
+
+                       // Reparse the static macros of the hover template.
+                       // It might happen that some static things like if the 
host has
+                       // members or not change during state change. e.g. when 
a map is
+                       // removed while viewed via the overview page
+                       aObjs[intIndex].getHoverTemplateCode();
                        
                        // Reparse object to map
                        if(sType === 'map') {
diff --git a/share/server/core/classes/GlobalIndexPage.php 
b/share/server/core/classes/GlobalIndexPage.php
index f24f32b..306e7ce 100644
--- a/share/server/core/classes/GlobalIndexPage.php
+++ b/share/server/core/classes/GlobalIndexPage.php
@@ -97,13 +97,17 @@ class GlobalIndexPage {
                        }
                        
                        $map = Array();
-                       $map['type'] = $type;
                        
                        if($mapType == 'automap')
                                $MAPCFG = new NagVisAutomapCfg($this->CORE, 
$mapName);
                        else
                                $MAPCFG = new NagVisMapCfg($this->CORE, 
$mapName);
 
+                       if(!$MAPCFG->checkMapConfigExists(false)) {
+                               $aMaps[] = $this->mapError($mapType, $mapName, 
'Map configuration file does not exist.');
+                               continue;
+                       }
+
                        try {
                                $MAPCFG->readMapConfig();
                                
@@ -113,9 +117,8 @@ class GlobalIndexPage {
                                
                                $objConf = $MAPCFG->getTypeDefaults('global');
                        } catch(MapCfgInvalid $e) {
-                               $objConf = Array();
-                               $map['configError'] = true;
-                               $map['configErrorMsg'] = $e->getMessage();
+                               $aMaps[] = $this->mapError($mapType, $mapName, 
$e->getMessage());
+                               continue;
                        }
 
                        if($mapType == 'automap')
@@ -125,28 +128,11 @@ class GlobalIndexPage {
                                $MAP = new NagVisMap($this->CORE, $MAPCFG, 
$this->BACKEND, GET_STATE, !IS_VIEW);
                        
                        // Apply default configuration to object
-                       $objConf['type']              = 'map';
-                       $objConf['map_name']          = $mapName;
-                       $objConf['object_id']         = $mapType.'-'.$mapName;
-                       // Enable the hover menu in all cases - maybe make it 
configurable
-                       $objConf['hover_menu']        = 1;
-                       $objConf['hover_childs_show'] = 1;
-                       $objConf['hover_template']    = 'default';
-                       // Enforce std_medium iconset - don't use map default 
iconset
-                       $objConf['iconset']           = 'std_medium';
-                       $objConf['alias']             = $MAPCFG->getAlias();
+                       $objConf = array_merge($objConf, 
$this->getMapAndAutomapDefaultOpts($mapType, $mapName, $MAPCFG->getAlias()));
 
                        $MAP->MAPOBJ->setConfiguration($objConf);
                        
-                       if(isset($map['configError'])) {
-                               $map['overview_class']  = 'error';
-                               $map['overview_url']    = 
'javascript:alert(\''.$map['configErrorMsg'].'\');';
-                               $map['summary_output']  = 
$this->CORE->getLang()->getText('Map Configuration Error: [ERR]', Array('ERR' 
=> $map['configErrorMsg']));
-                               
-                               $MAP->MAPOBJ->clearMembers();
-                               $MAP->MAPOBJ->setSummaryState('ERROR');
-                               $MAP->MAPOBJ->fetchIcon();
-                       } elseif($MAP->MAPOBJ->checkMaintenance(0)) {
+                       if($MAP->MAPOBJ->checkMaintenance(0)) {
                                if($mapType == 'automap')
                                        $map['overview_url']    = 
$this->htmlBase.'/index.php?mod=AutoMap&act=view&show='.$mapName.$MAPCFG->getValue(0,
 'default_params');
                                else
@@ -199,6 +185,34 @@ class GlobalIndexPage {
                return json_encode($aMaps);
        }
 
+       private function getMapAndAutomapDefaultOpts($type, $name, $alias) {
+               return Array(
+                 'type'              => 'map',
+                 'map_name'          => $name,
+                 'object_id'         => $type.'-'.$name,
+                 // Enable the hover menu in all cases - maybe make it 
configurable
+                 'hover_menu'        => 1,
+                 'hover_childs_show' => 1,
+                 'hover_template'    => 'default',
+                 // Enforce std_medium iconset - don't use map default iconset
+                 'iconset'           => 'std_medium',
+                 'alias'             => $alias
+               );
+       }
+
+       private function mapError($type, $name, $msg) {
+               $map = $this->getMapAndAutomapDefaultOpts($type, $name, $name);
+               $map['state']           = 'ERROR';
+               $map['summary_state']   = 'ERROR';
+               $map['icon']            = 'std_medium_error.png';
+               $map['members']         = Array();
+               $map['num_members']     = 0;
+               $map['overview_class']  = 'error';
+               $map['overview_url']    = 'javascript:alert(\''.$msg.'\');';
+               $map['summary_output']  = $this->CORE->getLang()->getText('Map 
Configuration Error: [ERR]', Array('ERR' => $msg));
+               return $map;
+       }
+
        private function renderMapThumb($MAPCFG) {
                $imgPath     = $MAPCFG->BACKGROUND->getFile(GET_PHYSICAL_PATH);
                
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index c6a0dc1..c212d6e 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -33,7 +33,7 @@ class GlobalMapCfg {
        
        protected $name;
        protected $type = 'map';
-       protected $mapConfig;
+       protected $mapConfig = Array();
   protected $typeDefaults = Array();
        
        private $configFile = '';
@@ -1556,8 +1556,6 @@ class GlobalMapCfg {
                        if(!$this->checkMapConfigExists(TRUE) || 
!$this->checkMapConfigReadable(TRUE))
                                return false;
 
-                       $this->mapConfig = Array();
-                       
                        // Read file in array (Don't read empty lines and 
ignore new line chars)
                        $file = file($this->configFile, FILE_SKIP_EMPTY_LINES | 
FILE_IGNORE_NEW_LINES);
                        
@@ -2091,7 +2089,7 @@ class GlobalMapCfg {
        public function filterMapObjects($objIds) {
                $newConfig =  Array();
                foreach($objIds AS $id)
-                       if(isset($newConfig[$id]))
+                       if(isset($this->mapConfig[$id]))
                                $newConfig[$id] = $this->mapConfig[$id];
                $this->mapConfig = $newConfig;
        }


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to