DRI/Protocol/EPP/Extensions/BR/Contact.pm

filter: Statementstmt 12.4% 19 / 153 Branchbran 0.0% 0 / 96 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 40.0% 6 / 15 Podpod 0.0% 0 / 9 totaltotal 8.0% 25 / 310 CC 60 SCAR 47.9
CC
60
Cov
7%
update
240.0
info_parse
182.0
check_parse
110.0
CRAP 120.4
« DRI/Data/Contact/LU.pm ↑ Summary DRI/Protocol/EPP/Extensions/ServiceMessage.pm »
1 ## Domain Registry Interface, .BR Contact EPP extension commands
2 ## draft-neves-epp-brorg-03.txt
3 ##
4 ## Copyright (c) 2008,2013,2016 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 ####################################################################################################
15  
16 package Net::DRI::Protocol::EPP::Extensions::BR::Contact;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Data::ContactSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Data::Contact::BR;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::BR::Contact - .BR EPP Contact extension commands for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 Please see the README file for details.
35  
36 =head1 SUPPORT
37  
38 For now, support questions should be sent to:
39  
40 E<lt>netdri@dotandco.comE<gt>
41  
42 Please also see the SUPPORT file in the distribution.
43  
44 =head1 SEE ALSO
45  
46 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
47  
48 =head1 AUTHOR
49  
50 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
51  
52 =head1 COPYRIGHT
53  
54 Copyright (c) 2008,2013,2016 Patrick Mevzek <netdri@dotandco.com>.
55 All rights reserved.
56  
57 This program is free software; you can redistribute it and/or modify
58 it under the terms of the GNU General Public License as published by
59 the Free Software Foundation; either version 2 of the License, or
60 (at your option) any later version.
61  
62 See the LICENSE file that comes with this distribution for more details.
63  
64 =cut
65  
66 ####################################################################################################
67  
68 sub register_commands
69 {
70 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my %tmp=(
72 check => [ \&check, \&check_parse ],
73 info => [ \&info, \&info_parse ],
74 create => [ \&create, undef ],
75 update => [ \&update, undef ],
76 review_complete => [ undef, \&pandata_parse ],
77 );
78  
79 0 $tmp{check_multi}=$tmp{check};
80 0 return { 'contact' => \%tmp };
81 }
82  
83 ####################################################################################################
84  
85 sub check
86 {
87 0 ▶ my ($epp,$contact,$rd)=@_;
Subroutine check: not called CC=6 SCAR=37.4
Pod undocumented
88 0 my $mes=$epp->message();
89  
90 0 my $eid=$mes->command_extension_register('brorg','check');
91 0 my @n;
92 0 ▶ foreach my $c ((ref($contact) eq 'ARRAY')? @$contact : ($contact))
Branch: 1 branch
BranchTrueFalseTotal
ref $contact eq 'ARRAY' ? : 0 0 0
93 {
94 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('contact must be Net::DRI::Data::Contact::BR object') unless Net::DRI::Util::isa_contact($c,'Net::DRI::Data::Contact::BR');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($c, "Net::DRI::Data::Contact::BR") 0 0 0
95 0 my $orgid=$c->orgid();
96 0 ▶ if (defined($orgid))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $orgid) { } 0 0 0
97 {
98 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('orgid must be an xml token string with 1 to 30 characters') unless Net::DRI::Util::xml_is_token($orgid,1,30);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($orgid, 1, 30) 0 0 0
99 0 push @n,['brorg:cd',['brorg:id',$c->srid()],['brorg:organization',$orgid]];
100 } else
101 {
102 0 push @n,['brorg:cd',['brorg:id',$c->srid()]];
103 }
104 }
105 0 $mes->command_extension($eid,\@n);
106 0 return;
107 }
108  
109 sub check_parse
110 {
111 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine check_parse: not called CC=10 SCAR=47.0
Pod undocumented
112 0 my $mes=$po->message();
113 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
114  
115 0 my $chkdata=$mes->get_extension('brorg','chkData');
116 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
117  
118 0 foreach my $cd ($chkdata->getChildrenByTagNameNS($mes->ns('brorg'),'ticketInfo'))
119 {
120 0 my $c=$cd->getFirstChild();
121 0 my ($orgid,$ticket,$domain);
122 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
123 {
124 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
125 0 ▶ my $n=$c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
126 0 ▶ if ($n eq 'organization')
Branch: 3 branches
BranchTrueFalseTotal
if ($n eq 'organization') { } 0 0 0
elsif ($n eq 'ticketNumber') { } 0 0 0
elsif ($n eq 'domainName') { } 0 0 0
127 {
128 0 $orgid=$c->getFirstChild()->getData();
129 } elsif ($n eq 'ticketNumber')
130 {
131 0 $ticket=$c->getFirstChild()->getData();
132 } elsif ($n eq 'domainName')
133 {
134 0 $domain=$c->getFirstChild()->getData();
135 }
136 0 } continue { $c=$c->getNextSibling(); }
137  
138 0 $rinfo->{orgid}->{$orgid}->{ticket}=$ticket;
139 0 $rinfo->{orgid}->{$orgid}->{domain}=$domain;
140 0 $rinfo->{domain}->{$domain}->{ticket}=$ticket;
141 0 $rinfo->{domain}->{$domain}->{orgid}=$orgid;
142 }
143 0 return;
144 }
145  
146 sub info
147 {
148 0 ▶ my ($epp,$contact,$rd)=@_;
Subroutine info: not called CC=4 SCAR=30.0
Pod undocumented
149  
150 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('contact must be Net::DRI::Data::Contact::BR object') unless Net::DRI::Util::isa_contact($contact,'Net::DRI::Data::Contact::BR');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($contact, "Net::DRI::Data::Contact::BR") 0 0 0
151 0 my $orgid=$contact->orgid();
152 0 ▶ return unless defined($orgid); ## to be able to create pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
153 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('orgid must be an xml token string with 1 to 30 characters') unless Net::DRI::Util::xml_is_token($orgid,1,30);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($orgid, 1, 30) 0 0 0
154  
155 0 my $mes=$epp->message();
156 0 my $eid=$mes->command_extension_register('brorg', 'info');
157 0 $mes->command_extension($eid,[['brorg:organization',$orgid]]);
158 0 return;
159 }
160  
161 sub info_parse
162 {
163 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=13 SCAR=52.0
Pod undocumented
164 0 my $mes=$po->message();
165 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
166  
167 0 my $infdata=$mes->get_extension('brorg','infData');
168 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
169  
170 0 my $id=(keys(%{$rinfo->{contact}}))[0];
171 0 my $co=$rinfo->{contact}->{$id}->{self};
172 0 my $cs=Net::DRI::Data::ContactSet->new();
173 0 my ($orgid,@d);
174 0 my $c=$infdata->getFirstChild();
175 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
176 {
177 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
178 0 ▶ my $n=$c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
179 0 ▶ if ($n eq 'organization')
Branch: 5 branches
BranchTrueFalseTotal
if ($n eq 'organization') { } 0 0 0
elsif ($n eq 'contact') { } 0 0 0
elsif ($n eq 'responsible') { } 0 0 0
elsif ($n eq 'proxy') { } 0 0 0
elsif ($n eq 'domainName') { } 0 0 0
180 {
181 0 $orgid=$c->getFirstChild()->getData();
182 0 $co->orgid($orgid);
183 0 $rinfo->{contact}->{$id}->{orgid}=$orgid;
184 } elsif ($n eq 'contact')
185 {
186 0 my $co=Net::DRI::Data::Contact::BR->new();
187 0 $co->srid($c->getFirstChild()->getData());
188 0 $co->orgid($orgid);
189 0 my $type=$c->getAttribute('type');
190 0 $co->type($type);
191 0 $cs->add($co,$type);
192 } elsif ($n eq 'responsible')
193 {
194 0 $co->responsible($c->getFirstChild()->getData());
195 } elsif ($n eq 'proxy')
196 {
197 0 $co->proxy($c->getFirstChild()->getData());
198 } elsif ($n eq 'domainName')
199 {
200 0 push @d,$c->getFirstChild()->getData();
201 }
202 0 } continue { $c=$c->getNextSibling(); }
203 0 ▶ $co->associated_contacts($cs) unless $cs->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
unless $cs->is_empty 0 0 0
204 0 ▶ $co->associated_domains(\@d) if @d;
Branch: 1 branch
BranchTrueFalseTotal
if @d 0 0 0
205 0 return;
206 }
207  
208 sub build_contacts
209 {
210 0 ▶ my $cs=shift;
Subroutine build_contacts: not called CC=2 SCAR=17.9
Pod undocumented
211 0 my @n;
212 0 foreach my $t (sort($cs->types()))
213 {
214 0 push @n,map { ['brorg:contact',$_->srid(),{'type'=>$t}] } ($cs->get($t));
215 }
216 0 return @n;
217 }
218  
219 sub create
220 {
221 0 ▶ my ($epp,$contact,$rd)=@_;
Subroutine create: not called CC=7 SCAR=40.3
Pod undocumented
222  
223 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('contact must be Net::DRI::Data::Contact::BR object') unless Net::DRI::Util::isa_contact($contact,'Net::DRI::Data::Contact::BR');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($contact, "Net::DRI::Data::Contact::BR") 0 0 0
224 0 my $orgid=$contact->orgid();
225 0 ▶ return unless defined($orgid); ## to be able to create pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
226 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('orgid must be an xml token string with 1 to 30 characters') unless Net::DRI::Util::xml_is_token($orgid,1,30);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($orgid, 1, 30) 0 0 0
227 0 my $cs=$contact->associated_contacts();
228 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('associated_contacts must be a ContactSet object') unless Net::DRI::Util::isa_contactset($cs);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contactset($cs) 0 0 0
229 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('associated_contacts must not be empty') if $cs->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
if $cs->is_empty 0 0 0
230  
231 0 my $mes=$epp->message();
232 0 my $eid=$mes->command_extension_register('brorg', 'create');
233 0 my @n=(['brorg:organization',$orgid]);
234 0 push @n,build_contacts($cs);
235 0 ▶ push @n,['brorg:responsible',$contact->responsible()] if $contact->responsible();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->responsible 0 0 0
236 0 $mes->command_extension($eid,\@n);
237 0 return;
238 }
239  
240 sub update
241 {
242 0 ▶ my ($epp,$contact,$todo)=@_;
Subroutine update: not called CC=15 SCAR=54.8
Pod undocumented
243  
244 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('contact must be Net::DRI::Data::Contact::BR object') unless Net::DRI::Util::isa_contact($contact,'Net::DRI::Data::Contact::BR');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($contact, "Net::DRI::Data::Contact::BR") 0 0 0
245 0 my $orgid=$contact->orgid();
246 0 ▶ return unless defined($orgid); ## to be able to update pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
247 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('orgid must be an xml token string with 1 to 30 characters') unless Net::DRI::Util::xml_is_token($orgid,1,30);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($orgid, 1, 30) 0 0 0
248  
249 0 my $cadd=$todo->add('associated_contacts');
250 0 my $cdel=$todo->del('associated_contacts');
251 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('associated_contacts to add must be a ContactSet object') if (defined($cadd) && !Net::DRI::Util::isa_contactset($cadd));
Branch: 1 branch
BranchTrueFalseTotal
if defined $cadd and not Net::DRI::Util::isa_contactset($cadd) 0 0 0
Condition0%0/3
defined $cadd and not Net::DRI::Util::isa_contactset($cadd)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cadd and not Net::DRI::Util::isa_contactset($cadd)
defined $cadd not Net::DRI::Util::isa_contactset($cadd)
Truth table0%0/3
A and not(B)
A= defined $caddB= not Net::DRI::Util::isa_contactset($cadd)
ABresult
0X0
100
111
252 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('associated_contacts to del must be a ContactSet object') if (defined($cdel) && !Net::DRI::Util::isa_contactset($cdel));
Branch: 1 branch
BranchTrueFalseTotal
if defined $cdel and not Net::DRI::Util::isa_contactset($cdel) 0 0 0
Condition0%0/3
defined $cdel and not Net::DRI::Util::isa_contactset($cdel)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cdel and not Net::DRI::Util::isa_contactset($cdel)
defined $cdel not Net::DRI::Util::isa_contactset($cdel)
Truth table0%0/3
A and not(B)
A= defined $cdelB= not Net::DRI::Util::isa_contactset($cdel)
ABresult
0X0
100
111
253  
254 0 my $resp=$todo->set('responsible');
255  
256 0 ▶ return unless (defined($cadd) || defined($cdel) || defined($resp));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cadd or defined $cdel or defined $resp 0 0 0
Condition0%0/6
defined $cadd or defined $cdel or defined $resp
l!l&&r!l&&!r
000
defined $cadd or defined $cdel
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $cadd or defined $cdel or defined $resp
defined $cadd defined $cdel defined $resp
Truth table0%0/4
A or B or C
A= defined $caddB= defined $cdelC= defined $resp
ABCresult
1XX1
01X1
0011
0000
257  
258 0 my @n=(['brorg:organization',$orgid]);
259 0 ▶ push @n,['brorg:add',build_contacts($cadd)] if defined($cadd);
Branch: 1 branch
BranchTrueFalseTotal
if defined $cadd 0 0 0
260 0 ▶ push @n,['brorg:rem',build_contacts($cdel)] if defined($cdel);
Branch: 1 branch
BranchTrueFalseTotal
if defined $cdel 0 0 0
261 0 ▶ push @n,['brorg:chg',['brorg:responsible',Net::DRI::Util::isa_contact($resp,'Net::DRI::Data::Contact::BR')? $resp->responsible() : $resp]] if defined($resp);
Branch: 2 branches
BranchTrueFalseTotal
if defined $resp 0 0 0
Net::DRI::Util::isa_contact($resp, 'Net::DRI::Data::Contact::BR') ? : 0 0 0
262  
263 0 my $mes=$epp->message();
264 0 my $eid=$mes->command_extension_register('brorg','update');
265 0 $mes->command_extension($eid,\@n);
266 0 return;
267 }
268  
269 sub pandata_parse
270 {
271 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine pandata_parse: not called CC=10 SCAR=47.0
Pod undocumented
272 0 my $mes=$po->message();
273 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
274  
275 0 my $pandata=$mes->get_extension('brorg','panData');
276 0 ▶ return unless $pandata;
Branch: 1 branch
BranchTrueFalseTotal
unless $pandata 0 0 0
277  
278 0 my $c=$pandata->firstChild();
279 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
280 {
281 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
282 0 ▶ my $n=$c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
283 0 ▶ next unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 0 0
284 0 ▶ if ($n eq 'organization')
Branch: 2 branches
BranchTrueFalseTotal
if ($n eq 'organization') { } 0 0 0
elsif ($n eq 'reason') { } 0 0 0
285 {
286 0 $rinfo->{$otype}->{$oname}->{orgid}=$c->getFirstChild()->getData();
287 } elsif ($n eq 'reason')
288 {
289 0 $rinfo->{$otype}->{$oname}->{reason}=$c->textContent(); ## this may be empty
290 0 ▶ $rinfo->{$otype}->{$oname}->{reason_lang}=$c->getAttribute('lang') || 'en';
Condition0%0/2
$c->getAttribute('lang') || 'en'
l!l
00
MC/DC0%0/1
$c->getAttribute('lang') || 'en'
$c->getAttribute('lang')
Truth table0%0/2
A
A= $c->getAttribute('lang')
Aresult
11
00
291 }
292 0 } continue { $c=$c->getNextSibling(); }
293 0 return;
294 }
295  
296 ####################################################################################################
297 1 1;
« DRI/Data/Contact/LU.pm ↑ Summary DRI/Protocol/EPP/Extensions/ServiceMessage.pm »