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

filter: Statementstmt 13.1% 19 / 145 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.2% 25 / 302 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,2019 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,2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my ($class,$version)=@_;
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 0 ▶{
Subroutine check: not called CC=6 SCAR=37.4
Pod undocumented
87 0 my ($epp,$contact,$rd)=@_;
88  
89 0 my @n;
90 0 ▶ foreach my $c ((ref($contact) eq 'ARRAY')? @$contact : ($contact))
Branch: 1 branch
BranchTrueFalseTotal
ref $contact eq 'ARRAY' ? : 0 0 0
91 {
92 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
93 0 my $orgid=$c->orgid();
94 0 ▶ if (defined($orgid))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $orgid) { } 0 0 0
95 {
96 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
97 0 push @n,['cd', ['id', $c->srid()], ['organization', $orgid]];
98 } else
99 {
100 0 push @n,['cd', ['id', $c->srid()]];
101 }
102 }
103  
104 0 $epp->message()->command_extension('brorg', ['check', @n]);
105 0 return;
106 }
107  
108 sub check_parse
109 0 ▶{
Subroutine check_parse: not called CC=10 SCAR=47.0
Pod undocumented
110 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
111 0 my $mes=$po->message();
112 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
113  
114 0 my $chkdata=$mes->get_extension('brorg','chkData');
115 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
116  
117 0 foreach my $cd ($chkdata->getChildrenByTagNameNS($mes->ns('brorg'),'ticketInfo'))
118 {
119 0 my $c=$cd->getFirstChild();
120 0 my ($orgid,$ticket,$domain);
121 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
122 {
123 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
124 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
125 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
126 {
127 0 $orgid=$c->getFirstChild()->getData();
128 } elsif ($n eq 'ticketNumber')
129 {
130 0 $ticket=$c->getFirstChild()->getData();
131 } elsif ($n eq 'domainName')
132 {
133 0 $domain=$c->getFirstChild()->getData();
134 }
135 0 } continue { $c=$c->getNextSibling(); }
136  
137 0 $rinfo->{orgid}->{$orgid}->{ticket}=$ticket;
138 0 $rinfo->{orgid}->{$orgid}->{domain}=$domain;
139 0 $rinfo->{domain}->{$domain}->{ticket}=$ticket;
140 0 $rinfo->{domain}->{$domain}->{orgid}=$orgid;
141 }
142 0 return;
143 }
144  
145 sub info
146 0 ▶{
Subroutine info: not called CC=4 SCAR=30.0
Pod undocumented
147 0 my ($epp,$contact,$rd)=@_;
148  
149 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
150 0 my $orgid=$contact->orgid();
151 0 ▶ return unless defined($orgid); ## to be able to create pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
152 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
153  
154 0 $epp->message()->command_extension('brorg', ['info', ['organization', $orgid]]);
155 0 return;
156 }
157  
158 sub info_parse
159 0 ▶{
Subroutine info_parse: not called CC=13 SCAR=52.0
Pod undocumented
160 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
161 0 my $mes=$po->message();
162 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
163  
164 0 my $infdata=$mes->get_extension('brorg','infData');
165 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
166  
167 0 my $id=(keys(%{$rinfo->{contact}}))[0];
168 0 my $co=$rinfo->{contact}->{$id}->{self};
169 0 my $cs=Net::DRI::Data::ContactSet->new();
170 0 my ($orgid,@d);
171 0 my $c=$infdata->getFirstChild();
172 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
173 {
174 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
175 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
176 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
177 {
178 0 $orgid=$c->getFirstChild()->getData();
179 0 $co->orgid($orgid);
180 0 $rinfo->{contact}->{$id}->{orgid}=$orgid;
181 } elsif ($n eq 'contact')
182 {
183 0 my $co=Net::DRI::Data::Contact::BR->new();
184 0 $co->srid($c->getFirstChild()->getData());
185 0 $co->orgid($orgid);
186 0 my $type=$c->getAttribute('type');
187 0 $co->type($type);
188 0 $cs->add($co,$type);
189 } elsif ($n eq 'responsible')
190 {
191 0 $co->responsible($c->getFirstChild()->getData());
192 } elsif ($n eq 'proxy')
193 {
194 0 $co->proxy($c->getFirstChild()->getData());
195 } elsif ($n eq 'domainName')
196 {
197 0 push @d,$c->getFirstChild()->getData();
198 }
199 0 } continue { $c=$c->getNextSibling(); }
200 0 ▶ $co->associated_contacts($cs) unless $cs->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
unless $cs->is_empty 0 0 0
201 0 ▶ $co->associated_domains(\@d) if @d;
Branch: 1 branch
BranchTrueFalseTotal
if @d 0 0 0
202 0 return;
203 }
204  
205 sub build_contacts
206 0 ▶{
Subroutine build_contacts: not called CC=2 SCAR=17.9
Pod undocumented
207 0 my $cs=shift;
208 0 my @n;
209 0 foreach my $t (sort($cs->types()))
210 {
211 0 push @n,map { ['contact',$_->srid(),{'type'=>$t}] } ($cs->get($t));
212 }
213 0 return @n;
214 }
215  
216 sub create
217 0 ▶{
Subroutine create: not called CC=7 SCAR=40.3
Pod undocumented
218 0 my ($epp,$contact,$rd)=@_;
219  
220 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
221 0 my $orgid=$contact->orgid();
222 0 ▶ return unless defined($orgid); ## to be able to create pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
223 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
224 0 my $cs=$contact->associated_contacts();
225 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
226 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
227  
228 0 my @n=(['organization',$orgid]);
229 0 push @n,build_contacts($cs);
230 0 ▶ push @n,['responsible',$contact->responsible()] if $contact->responsible();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->responsible 0 0 0
231 0 $epp->message()->command_extension('brorg', ['create', @n]);
232 0 return;
233 }
234  
235 sub update
236 0 ▶{
Subroutine update: not called CC=15 SCAR=54.8
Pod undocumented
237 0 my ($epp,$contact,$todo)=@_;
238  
239 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
240 0 my $orgid=$contact->orgid();
241 0 ▶ return unless defined($orgid); ## to be able to update pure contacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orgid 0 0 0
242 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
243  
244 0 my $cadd=$todo->add('associated_contacts');
245 0 my $cdel=$todo->del('associated_contacts');
246 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
247 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
248  
249 0 my $resp=$todo->set('responsible');
250  
251 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
252  
253 0 my @n=(['organization', $orgid]);
254 0 ▶ push @n,['add', build_contacts($cadd)] if defined $cadd;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cadd 0 0 0
255 0 ▶ push @n,['rem', build_contacts($cdel)] if defined $cdel;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cdel 0 0 0
256 0 ▶ push @n,['chg', ['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
257  
258 0 $epp->message()->command_extension('brorg', ['update', @n]);
259 0 return;
260 }
261  
262 sub pandata_parse
263 0 ▶{
Subroutine pandata_parse: not called CC=10 SCAR=47.0
Pod undocumented
264 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
265 0 my $mes=$po->message();
266 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
267  
268 0 my $pandata=$mes->get_extension('brorg','panData');
269 0 ▶ return unless $pandata;
Branch: 1 branch
BranchTrueFalseTotal
unless $pandata 0 0 0
270  
271 0 my $c=$pandata->firstChild();
272 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
273 {
274 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
275 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
276 0 ▶ next unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 0 0
277 0 ▶ if ($n eq 'organization')
Branch: 2 branches
BranchTrueFalseTotal
if ($n eq 'organization') { } 0 0 0
elsif ($n eq 'reason') { } 0 0 0
278 {
279 0 $rinfo->{$otype}->{$oname}->{orgid}=$c->getFirstChild()->getData();
280 } elsif ($n eq 'reason')
281 {
282 0 $rinfo->{$otype}->{$oname}->{reason}=$c->textContent(); ## this may be empty
283 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
284 }
285 0 } continue { $c=$c->getNextSibling(); }
286 0 return;
287 }
288  
289 ####################################################################################################
290 1 1;
« DRI/Data/Contact/LU.pm ↑ Summary DRI/Protocol/EPP/Extensions/ServiceMessage.pm »