From: Michael Wiebusch Date: Wed, 3 Jul 2013 15:05:03 +0000 (+0200) Subject: now with more error reports: e.g. specification mismatch, circular includes X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=329073585574f73cc0d9b8490e73dc6939b679f5;p=mvdsensorcontrol.git now with more error reports: e.g. specification mismatch, circular includes --- diff --git a/xml_spielwiese/cgitest.pl b/xml_spielwiese/cgitest.pl index 8bbbf0d..c76bf2e 100755 --- a/xml_spielwiese/cgitest.pl +++ b/xml_spielwiese/cgitest.pl @@ -4,7 +4,13 @@ print "Content-type: text/html\n\n"; # TODO # do not accept "..." as input file # what happens when files are not writable? +# cannot inherit from files with the wrong specification! +# DONE +# do not include wrong type, different specfile +# whine, wenn specfile/setfiles not found +# supress circular dependencies +# nested include graphic my $me = "cgitest.pl"; @@ -66,6 +72,7 @@ my $specfileName = ""; my $setfileName = ""; my $spectree; my $settree; +my $setMapsType; my %fileLevelHash; @@ -83,6 +90,10 @@ if ( $cgiHash{'print'} eq 'fileSelection' ) { if ( $cgiHash{'print'} eq 'spectree' ) { print "
Available Settings
\n"; + unless(-e $confDir."/".$cgiHash{'configFile'}){ + print "

config file does not exist

"; + exit; + } parseSetAndSpec( $cgiHash{'configFile'} ); print "
specifications loaded from $specfileName
"; @@ -91,6 +102,10 @@ if ( $cgiHash{'print'} eq 'spectree' ) { if ( $cgiHash{'print'} eq 'settree' ) { print "
Selected Settings
\n"; + unless(-e $confDir."/".$cgiHash{'configFile'}){ + print "

config file does not exist

"; + exit; + } parseSetAndSpec( $cgiHash{'configFile'} ); buildAncestry($setfileName,""); #arg1: target file, # arg2: recursion parent target file @@ -216,6 +231,10 @@ sub parseSetAndSpec { parseSet( $_[0] ); $specfileName = $settree->findvalue("/MAPS/\@specDbFile"); $specfile = $specDir . "/" . $specfileName; + unless(-e $specfile){ + print "

specification file \"$specfileName\" could not be found in the specification directory \"$specDir\"

"; + exit; + } $spectree = $parser->parse_file($specfile); } @@ -223,6 +242,7 @@ sub parseSet { $setfileName = $_[0]; $setfile = $confDir . "/" . $_[0]; $settree = $parser->parse_file($setfile); + $setMapsType = $settree->findvalue("/MAPS/\@type"); } sub buildAncestry { # recursive @@ -278,6 +298,25 @@ sub buildAncestry { # recursive my $ancestorFileName = $xmltree->findvalue("/MAPS/\@inheritSettingsFrom") || ""; + my $currentMapsType = $xmltree->findvalue("/MAPS/\@type"); + my $currentSpecFileName = $xmltree->findvalue("/MAPS/\@specDbFile"); + + # compliance checking MAPS type + unless ($currentMapsType eq $setMapsType){ + print "

the included config file does not comply with the MAPS type of the current config file

"; + print "

The faulty include directive was removed.

"; + print "

"; + changeAncestor(""); # break the evil circle where it was closed! + exit; + } + # compliance checking specDbFile + unless ($currentSpecFileName eq $specfileName){ + print "

the included config file is not based on the same specification file as current config file

"; + print "

The faulty include directive was removed.

"; + print "

"; + changeAncestor(""); # break the evil circle where it was closed! + exit; + } unless ( $ancestorFileName eq "" ) { # this block is executed when an ancestor is found @@ -821,7 +860,8 @@ function changeAncestor(newAncestor){ function selectedConfigFile(){ if(document.getElementById("fileSelector")){ var e = document.getElementById("fileSelector"); -return e.options[e.selectedIndex].text;} +return e.options[e.selectedIndex].text; +} else { return ""; } @@ -875,6 +915,7 @@ showElement(key); function loadFile(){ + debugOutput("load data from "+selectedConfigFile()); visHash = new Object(); reloadSpecTree();