| 1 | #!/bin/false | ||||||||||||||||||||||
| 2 | # PODNAME: BZ::Client::XMLRPC::Response | ||||||||||||||||||||||
| 3 | # ABSTRACT: Event handler for parsing an XML-RPC response. | ||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings 'all'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | package BZ::Client::XMLRPC::Response; | ||||||||||||||||||||||
| 9 | 1 | $BZ::Client::XMLRPC::Response::VERSION = '4.91'; | |||||||||||||||||||||
| 10 | 1 | ▶ | use parent qw( BZ::Client::XMLRPC::Handler ); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 1 | ▶ | use BZ::Client::XMLRPC::Value; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | 1 | ▶ | use BZ::Client::Exception; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 0 | ▶ | sub start { | ||||||||||||||||||||
|
Subroutine
start: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||
| 15 | 0 | my($self,$name) = @_; | |||||||||||||||||||||
| 16 | 0 | my $l = $self->inc_level(); | |||||||||||||||||||||
| 17 | 0 | ▶ | if ($l == 0) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 18 | 0 | ▶ | if ('methodResponse' ne $name) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 19 | 0 | $self->error("Expected methodResponse element, got $name"); | |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||
| 22 | elsif ($l == 1) { | ||||||||||||||||||||||
| 23 | 0 | ▶ | if ('fault' eq $name) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 24 | 0 | $self->{'in_fault'} = 1; | |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||
| 26 | elsif ('params' eq $name) { | ||||||||||||||||||||||
| 27 | 0 | ▶ | if (defined($self->{'result'})) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 28 | 0 | $self->error('Multiple elements methodResponse/params found.'); | |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||
| 30 | 0 | $self->{'in_fault'} = 0; | |||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||||
| 33 | 0 | $self->error("Unexpected element methodResponse/$name, expected fault|params"); | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||
| 36 | elsif ($l == 2) { | ||||||||||||||||||||||
| 37 | 0 | ▶ | if ($self->{'in_fault'}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 38 | 0 | ▶ | if ('value' ne $name) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 39 | 0 | $self->error("Unexpected element methodResponse/fault/$name, expected value"); | |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||
| 41 | 0 | my $handler = BZ::Client::XMLRPC::Value->new(); | |||||||||||||||||||||
| 42 | 0 | ▶ | $self->parser()->register($self, $handler, sub { | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||
| 43 | 0 | my $result = $handler->result(); | |||||||||||||||||||||
| 44 | 0 | ▶ | if ('HASH' ne ref($result)) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 45 | 0 | $self->error('Failed to parse XML-RPC response document: Error reported, but no faultCode and faultString found.'); | |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | 0 | my $faultCode = $result->{'faultCode'}; | |||||||||||||||||||||
| 48 | 0 | my $faultString = $result->{'faultString'}; | |||||||||||||||||||||
| 49 | 0 | $self->{'exception'} = BZ::Client::Exception->new('message' => $faultString, | |||||||||||||||||||||
| 50 | 'xmlrpc_code' => $faultCode); | ||||||||||||||||||||||
| 51 | 0 | }); | |||||||||||||||||||||
| 52 | 0 | $handler->start($name); | |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||
| 55 | 0 | ▶ | if ('param' ne $name) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 56 | 0 | $self->error("Unexpected element methodResponse/params/$name, expected param"); | |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||
| 58 | 0 | ▶ | if (defined($self->{'result'})) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 59 | 0 | $self->error('Multiple elements methodResponse/params/param found.'); | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||
| 63 | elsif ($l == 3) { | ||||||||||||||||||||||
| 64 | 0 | ▶ | if ($self->{'in_fault'}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 65 | 0 | $self->error("Unexpected element $name found at level $l"); | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||
| 68 | 0 | ▶ | if ('value' ne $name) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 69 | 0 | $self->error("Unexpected element methodResponse/params/param/$name, expected value"); | |||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||
| 71 | 0 | ▶ | if (defined($self->{'result'})) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 72 | 0 | $self->error('Multiple elements methodResponse/params/param/value found.'); | |||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||
| 74 | 0 | my $handler = BZ::Client::XMLRPC::Value->new(); | |||||||||||||||||||||
| 75 | 0 | ▶ | $self->parser()->register($self, $handler, sub { | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 76 | 0 | $self->{'result'} = $handler->result(); | |||||||||||||||||||||
| 77 | 0 | }); | |||||||||||||||||||||
| 78 | 0 | $handler->start($name); | |||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||
| 82 | |||||||||||||||||||||||
| 83 | 0 | ▶ | sub end { | ||||||||||||||||||||
|
Subroutine
end: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||
| 84 | 0 | my($self, $name) = @_; | |||||||||||||||||||||
| 85 | 0 | my $l = $self->SUPER::end($name); | |||||||||||||||||||||
| 86 | 0 | return $l | |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||
| 88 | |||||||||||||||||||||||
| 89 | 0 | ▶ | sub exception { | ||||||||||||||||||||
|
Subroutine
exception: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||
| 91 | 0 | return $self->{'exception'} | |||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||
| 93 | |||||||||||||||||||||||
| 94 | 0 | ▶ | sub result { | ||||||||||||||||||||
|
Subroutine
result: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||
| 96 | 0 | return $self->{'result'} | |||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||
| 98 | |||||||||||||||||||||||
| 99 | 1 | 1; | |||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||