| 1 | package QualysGuard::Response::MapReportList; | ||
| 2 | |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use base qw( QualysGuard::Response ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | use Scalar::Util qw( reftype ); | ||
| 8 | |||
| 9 | our $VERSION = '0.02'; | ||
| 10 | |||
| 11 | |||
| 12 | # ============================================================= | ||
| 13 | # - new | ||
| 14 | # ============================================================= | ||
| 15 | sub new { | ||
| 16 | my ( $class, $xml ) = @_; | ||
| 17 | |||
| 18 | my $self = __PACKAGE__->SUPER::new( $xml ); | ||
| 19 | |||
| 20 | bless $self, $class; | ||
| 21 | |||
| 22 | # -- check for QualysGuard function error | ||
| 23 | |||
| 24 | if ( $self->exists('/MAP_REPORT_LIST/ERROR') ) { | ||
| 25 | $self->{error_code} = $self->findvalue('/MAP_REPORT_LIST/ERROR/@number'); | ||
| 26 | $self->{error_text} = $self->getNodeText('/MAP_REPORT_LIST/ERROR'); | ||
| 27 | $self->{error_text} =~ s/^\s+(.*)\s+$/$1/m; | ||
| 28 | } | ||
| 29 | |||
| 30 | return $self; | ||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | # ============================================================= | ||
| 36 | # - get_map_refs | ||
| 37 | # ============================================================= | ||
| 38 | sub get_map_refs { | ||
| 39 | my $self = shift; | ||
| 40 | my @nodes = $self->findnodes('/MAP_REPORT_LIST/MAP_REPORT'); | ||
| 41 | my $rv = {}; | ||
| 42 | |||
| 43 | foreach my $node ( @nodes ) { | ||
| 44 | my $key = $node->getAttribute( 'domain' ); | ||
| 45 | my $val = $node->getAttribute( 'ref' ); | ||
| 46 | |||
| 47 | if ( exists $rv->{$key} ) { | ||
| 48 | |||
| 49 | if ( reftype( \$rv->{$key} ) eq 'SCALAR' ) { | ||
| 50 | $rv->{$key} = [ $rv->{$key} ]; | ||
| 51 | push( @{$rv->{$key}}, $val ); | ||
| 52 | } | ||
| 53 | |||
| 54 | elsif ( reftype( $rv->{$key} ) eq 'ARRAY' ) { | ||
| 55 | push( @{$rv->{$key}}, $val ); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | else { | ||
| 60 | $rv->{$key} = $val; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | return $rv; | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | 1; | ||
| 70 | |||
| 71 | __END__ | ||