line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# PODNAME: BZ::Client::XMLRPC::Response |
3
|
|
|
|
|
|
|
# ABSTRACT: Event handler for parsing an XML-RPC response. |
4
|
|
|
|
|
|
|
# |
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package BZ::Client::XMLRPC::Response; |
9
|
|
|
|
|
|
|
$BZ::Client::XMLRPC::Response::VERSION = '4.4002'; |
10
|
1
|
|
|
1
|
|
359
|
use parent qw( BZ::Client::XMLRPC::Handler ); |
|
1
|
|
|
|
|
215
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
346
|
use BZ::Client::XMLRPC::Value; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
62
|
|
12
|
1
|
|
|
1
|
|
11
|
use BZ::Client::Exception; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
384
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub start { |
15
|
0
|
|
|
0
|
0
|
|
my($self,$name) = @_; |
16
|
0
|
|
|
|
|
|
my $l = $self->inc_level(); |
17
|
0
|
0
|
|
|
|
|
if ($l == 0) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ('methodResponse' ne $name) { |
19
|
0
|
|
|
|
|
|
$self->error("Expected methodResponse element, got $name"); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ($l == 1) { |
23
|
0
|
0
|
|
|
|
|
if ('fault' eq $name) { |
|
|
0
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$self->{'in_fault'} = 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ('params' eq $name) { |
27
|
0
|
0
|
|
|
|
|
if (defined($self->{'result'})) { |
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
|
0
|
|
|
|
|
if ($self->{'in_fault'}) { |
38
|
0
|
0
|
|
|
|
|
if ('value' ne $name) { |
39
|
0
|
|
|
|
|
|
$self->error("Unexpected element methodResponse/fault/$name, expected value"); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
my $handler = BZ::Client::XMLRPC::Value->new(); |
42
|
|
|
|
|
|
|
$self->parser()->register($self, $handler, sub { |
43
|
0
|
|
|
0
|
|
|
my $result = $handler->result(); |
44
|
0
|
0
|
|
|
|
|
if ('HASH' ne ref($result)) { |
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
|
0
|
|
|
|
|
if ('param' ne $name) { |
56
|
0
|
|
|
|
|
|
$self->error("Unexpected element methodResponse/params/$name, expected param"); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
|
if (defined($self->{'result'})) { |
59
|
0
|
|
|
|
|
|
$self->error('Multiple elements methodResponse/params/param found.'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ($l == 3) { |
64
|
0
|
0
|
|
|
|
|
if ($self->{'in_fault'}) { |
65
|
0
|
|
|
|
|
|
$self->error("Unexpected element $name found at level $l"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
0
|
0
|
|
|
|
|
if ('value' ne $name) { |
69
|
0
|
|
|
|
|
|
$self->error("Unexpected element methodResponse/params/param/$name, expected value"); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
if (defined($self->{'result'})) { |
72
|
0
|
|
|
|
|
|
$self->error('Multiple elements methodResponse/params/param/value found.'); |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
my $handler = BZ::Client::XMLRPC::Value->new(); |
75
|
|
|
|
|
|
|
$self->parser()->register($self, $handler, sub { |
76
|
0
|
|
|
0
|
|
|
$self->{'result'} = $handler->result(); |
77
|
0
|
|
|
|
|
|
}); |
78
|
0
|
|
|
|
|
|
$handler->start($name); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub end { |
84
|
0
|
|
|
0
|
0
|
|
my($self, $name) = @_; |
85
|
0
|
|
|
|
|
|
my $l = $self->SUPER::end($name); |
86
|
0
|
|
|
|
|
|
return $l |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub exception { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
return $self->{'exception'} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub result { |
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
96
|
0
|
|
|
|
|
|
return $self->{'result'} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding UTF-8 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
BZ::Client::XMLRPC::Response - Event handler for parsing an XML-RPC response. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 4.4002 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHORS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Dean Hamstead <dean@bytefoundry.com.au> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Jochen Wiedmann <jochen.wiedmann@gmail.com> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Dean Hamstad. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
134
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |