[icinga-checkins] icinga.org: icinga-reports/mluebben/default: Add new method setParserType()

git at icinga.org git at icinga.org
Thu Jun 16 22:41:34 CEST 2011


Module: icinga-reports
Branch: mluebben/default
Commit: 36b8b2b666092b302484cbc1d2dbe6220fa49c33
URL:    https://git.icinga.org/?p=icinga-reports.git;a=commit;h=36b8b2b666092b302484cbc1d2dbe6220fa49c33

Author: Michael Luebben <michael_luebben at web.de>
Date:   Thu Jun 16 22:41:00 2011 +0200

Add new method setParserType()

---

 .../Modules/Reporting/Availability.pm              |   42 +++++++++++++++++++-
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/AvailReportParser/Modules/Reporting/Availability.pm b/AvailReportParser/Modules/Reporting/Availability.pm
index b971dbf..60bf6e8 100755
--- a/AvailReportParser/Modules/Reporting/Availability.pm
+++ b/AvailReportParser/Modules/Reporting/Availability.pm
@@ -14,7 +14,7 @@ Availability.pm
 
 =head1 Version
 
-Version 0.0.7
+Version 0.1.0
 
 =head1 DESCRIPTION
 
@@ -179,6 +179,8 @@ sub new {
 	$self->{url}->{param}->{name}->{22} = "backtrack";
 	$self->{url}->{param}->{value}->{22} = "0";
 	
+	$self->{parser}->{type} = "HTML";
+	
 	bless $self, $pkg;
 	return $self;
 }
@@ -435,6 +437,38 @@ sub setUrlParameter {
 
 =over
 
+=item setParserType()
+
+Set the parser type to HTML or JSON. Default: HTML
+
+=back
+
+=head2 EXAMPLE
+
+  my $urlParameter = $Avail->setParserType("JSON")
+
+=cut
+sub setParserType {
+	my $self = shift;
+	my $parserType = shift;
+	
+	if ($parserType eq "HTML") {
+		$self->{parser}->{type} = "HTML";
+		return 0
+	} elsif ($parserType eq "JSON") {
+		$self->{parser}->{type} = "JSON";
+		return 0
+	} else {
+		$self->{errMessage} = $parserType." is not a allowed parser type!\n";
+		return -1;
+	}
+}
+
+
+=pod
+
+=over
+
 =item getUrlParameter()
 
 Returns value from url parameter.
@@ -512,7 +546,11 @@ sub getUrl {
 		$result = "You musst first set the url path!"	
 	}
 	
-	return $result;
+	if ($self->{parser}->{type} eq "JSON") {
+		return $result."&jsonoutput";
+	} else {
+		return $result;
+	}
 }
 
 





More information about the icinga-checkins mailing list