Module: nagvis
Branch: master
Commit: a594132c4092f77b2ae137f6fed8533ddcfdac06
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=a594132c4092f77b2ae137f6fed8533ddcfdac06

Author: Roman Kyrylych <[email protected]>
Date:   Tue Aug 25 10:52:42 2009 +0300

gmap: Create an initial XML file when it does not exist

Signed-off-by: Roman Kyrylych <[email protected]>

---

 share/netmap/LinkService.php      |   10 ++++++++++
 share/netmap/LocationService.php  |   10 ++++++++++
 share/netmap/SettingsService.php  |   10 ++++++++++
 share/netmap/ViewpointService.php |   11 +++++++++++
 4 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/share/netmap/LinkService.php b/share/netmap/LinkService.php
index cc8f2eb..ad4d2f3 100644
--- a/share/netmap/LinkService.php
+++ b/share/netmap/LinkService.php
@@ -53,12 +53,22 @@ class LinkService
                        $link->state = State::UNKNOWN;
        }
 
+       private function createFile()
+       {
+               $xml = '<?xml version="1.0" standalone="yes" ?><links/>';
+               if (file_put_contents('links.xml', $xml) === FALSE)
+                       throw new Exception('Could not create links.xml');
+       }
+
        /**
         * @param  boolean $problemonly
         * @return array of Link
         */
        public function getAll($problemonly = false)
        {
+               if (!file_exists('links.xml'))
+                       self::createFile();
+
                if (($xml = @simplexml_load_file('links.xml')) === FALSE)
                        throw new Exception('Could not read links.xml');
 
diff --git a/share/netmap/LocationService.php b/share/netmap/LocationService.php
index 8fd3c89..decd5a5 100644
--- a/share/netmap/LocationService.php
+++ b/share/netmap/LocationService.php
@@ -53,12 +53,22 @@ class LocationService
                        $location->state = State::UNKNOWN;
        }
 
+       private function createFile()
+       {
+               $xml = '<?xml version="1.0" standalone="yes" ?><locations/>';
+               if (file_put_contents('locations.xml', $xml) === FALSE)
+                       throw new Exception('Could not create locations.xml');
+       }
+
        /**
         * @param  boolean $problemonly
         * @return array of Location
         */
        public function getAll($problemonly = false)
        {
+               if (!file_exists('locations.xml'))
+                       self::createFile();
+
                if (($xml = @simplexml_load_file('locations.xml')) === FALSE)
                        throw new Exception('Could not read locations.xml');
 
diff --git a/share/netmap/SettingsService.php b/share/netmap/SettingsService.php
index 4c5ce25..ef566db 100644
--- a/share/netmap/SettingsService.php
+++ b/share/netmap/SettingsService.php
@@ -23,6 +23,13 @@
 
 class SettingsService
 {
+       private function createFile()
+       {
+               $xml = '<?xml version="1.0" standalone="yes" ?><settings/>';
+               if (file_put_contents('settings.xml', $xml) === FALSE)
+                       throw new Exception('Could not create settings.xml');
+       }
+
        /**
         * @return array of Settings
         */
@@ -56,6 +63,9 @@ class SettingsService
                if (($mapurl = $CORE->MAINCFG->getValue('defaults', 'mapurl')) 
=== false)
                        throw new Exception('Error in NagVis configuration');
 
+               if (!file_exists('settings.xml'))
+                       self::createFile();
+
                if (($xml = @simplexml_load_file('settings.xml')) === FALSE)
                        throw new Exception('Could not read settings.xml');
 
diff --git a/share/netmap/ViewpointService.php 
b/share/netmap/ViewpointService.php
index 2cb4723..d7e1985 100644
--- a/share/netmap/ViewpointService.php
+++ b/share/netmap/ViewpointService.php
@@ -23,11 +23,22 @@
 
 class ViewpointService
 {
+       private function createFile()
+       {
+               $xml = '<?xml version="1.0" standalone="yes" ?><viewpoints/>';
+               if (file_put_contents('viewpoints.xml', $xml) === FALSE)
+                       throw new Exception('Could not create viewpoints.xml');
+       }
+
        /**
         * @return array of Viewpoint
         */
        public function getAll()
        {
+
+               if (!file_exists('viewpoints.xml'))
+                       self::createFile();
+
                if (($xml = @simplexml_load_file('viewpoints.xml')) === FALSE)
                        throw new Exception('Could not read viewpoints.xml');
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to