DRI/Protocol/EPP/Extensions/ArtRecord.pm

filter: Statementstmt 22.5% 16 / 71 Branchbran 0.0% 0 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 6 totaltotal 16.4% 21 / 128 CC 22 SCAR 52.9
CC
22
Cov
14%
command
342.0
info_parse
30.0
register_commands
2.0
CRAP 197.5
« DRI/Protocol/Gandi/WS/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/LU/Contact.pm »
1 ## EPP Mapping for Art Record Extension (draft-brown-epp-artRecord-00)
2 ##
3 ## Copyright (c) 2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::ArtRecord;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 ####################################################################################################
25  
26 sub register_commands
27 {
28 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
29  
30 0 state $rd={ 'domain' => {
31 info => [ undef, \&info_parse ],
32 create => [ \&command, undef ],
33 update => [ \&command, undef ],
34 },
35 };
36  
37 0 return $rd;
38 }
39  
40 0 ▶sub capabilities_add { return ['domain_update','art_record',['set']]; }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
41  
42 sub setup
43 {
44 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 0 state $ns = { 'artRecord' => 'urn:ietf:params:xml:ns:artRecord-0.1' };
47 0 $po->ns($ns);
48 0 return;
49 }
50  
51 0 ▶sub implements { return 'https://gitlab.centralnic.com/centralnic/epp-artrecord-extension/raw/fd935a927252f4420e233adce877830782a22ba4/draft-brown-artRecord.txt'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
52  
53 ####################################################################################################
54  
55 sub command
56 {
57 0 ▶ my ($epp,$domain,$data)=@_;
Subroutine command: not called CC=18 SCAR=58.3
Pod undocumented
58 0 my $mes=$epp->message();
59 0 my $operation=$mes->operation()->[1];
60 0 my $art;
61 0 ▶ if ($operation eq 'update')
Branch: 1 branch
BranchTrueFalseTotal
if ($operation eq 'update') { } 0 0 0
62 {
63 0 $art=$data->set('art_record');
64 0 ▶ return unless defined $art;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $art 0 0 0
65 } else
66 {
67 0 ▶ return unless Net::DRI::Util::has_key($data, 'art_record');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($data, "art_record") 0 0 0
68 0 $art=$data->{art_record};
69 }
70  
71 0 my @art;
72 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "object_type"') unless exists $art->{object_type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"object_type"} 0 0 0
73 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "object_type": '.$art->{object_type}) unless Net::DRI::Util::xml_is_token($art->{object_type}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"object_type"}, 0, 255) 0 0 0
74 0 push @art, ['artRecord:objectType',$art->{object_type}];
75 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "materials_and_techniques"') unless exists $art->{materials_and_techniques};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"materials_and_techniques"} 0 0 0
76 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "materials_and_techniques": '.$art->{materials_and_techniques}) unless Net::DRI::Util::xml_is_token($art->{materials_and_techniques}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"materials_and_techniques"}, 0, 255) 0 0 0
77 0 push @art, ['artRecord:materialsAndTechniques',$art->{materials_and_techniques}];
78 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "dimensions"') unless exists $art->{dimensions};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"dimensions"} 0 0 0
79 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "dimensions": '.$art->{dimensions}) unless Net::DRI::Util::xml_is_token($art->{dimensions}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"dimensions"}, 0, 255) 0 0 0
80 0 push @art, ['artRecord:dimensions',$art->{dimensions}];
81 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "title"') unless exists $art->{title};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"title"} 0 0 0
82 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "title": '.$art->{title}) unless Net::DRI::Util::xml_is_token($art->{title}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"title"}, 0, 255) 0 0 0
83 0 push @art, ['artRecord:title',$art->{title}];
84 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "date_or_period"') unless exists $art->{date_or_period};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"date_or_period"} 0 0 0
85 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "date_or_period": '.$art->{date_or_period}) unless Net::DRI::Util::xml_is_token($art->{date_or_period}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"date_or_period"}, 0, 255) 0 0 0
86 0 push @art, ['artRecord:dateOrPeriod',$art->{date_or_period}];
87 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "maker"') unless exists $art->{maker};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"maker"} 0 0 0
88 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "maker": '.$art->{maker}) unless Net::DRI::Util::xml_is_token($art->{maker}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"maker"}, 0, 255) 0 0 0
89 0 push @art, ['artRecord:maker',$art->{maker}];
90 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Missing art record "reference"') unless exists $art->{reference};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $art->{"reference"} 0 0 0
91 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid syntax for art record "reference": '.$art->{reference}) unless Net::DRI::Util::xml_is_token($art->{reference}, 0, 255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($art->{"reference"}, 0, 255) 0 0 0
92 0 push @art, ['artRecord:reference',$art->{reference}];
93  
94 0 my $eid=$mes->command_extension_register('artRecord',$operation);
95 0 $mes->command_extension($eid,\@art);
96  
97 0 return;
98 }
99  
100 sub info_parse
101 {
102 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=5 SCAR=34.0
Pod undocumented
103 0 my $mes=$po->message();
104 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
105  
106 0 my $data=$mes->get_extension('artRecord','infData');
107 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
108  
109 0 my %art;
110 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
111 {
112 0 my ($name,$c)=@$el;
113  
114 0 ▶ if ($name=~m/^(objectType|materialsAndTechniques|dimensions|title|dateOrPeriod|maker|reference)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(objectType|materialsAndTechniques|dimensions|title|dateOrPeriod|maker|reference)$/) 0 0 0
115 0 $art{Net::DRI::Util::remcam($name)}=$c->textContent();
116 }
117 }
118  
119 0 $rinfo->{domain}->{$oname}->{art_record}=\%art;
120  
121 0 return;
122 }
123  
124 ####################################################################################################
125 1 1;
126  
127 __END__
128  
129 =pod
130  
131 =head1 NAME
132  
133 Net::DRI::Protocol::EPP::Extensions::ArtRecord - EPP Mapping for Art Record Extension (draft-brown-epp-artRecord-00) for Net::DRI
134  
135 =head1 DESCRIPTION
136  
137 Please see the README file for details.
138  
139 =head1 SUPPORT
140  
141 For now, support questions should be sent to:
142  
143 E<lt>netdri@dotandco.comE<gt>
144  
145 Please also see the SUPPORT file in the distribution.
146  
147 =head1 SEE ALSO
148  
149 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
150  
151 =head1 AUTHOR
152  
153 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
154  
155 =head1 COPYRIGHT
156  
157 Copyright (c) 2018 Patrick Mevzek <netdri@dotandco.com>.
158 All rights reserved.
159  
160 This program is free software; you can redistribute it and/or modify
161 it under the terms of the GNU General Public License as published by
162 the Free Software Foundation; either version 2 of the License, or
163 (at your option) any later version.
164  
165 See the LICENSE file that comes with this distribution for more details.
166  
167 =cut
« DRI/Protocol/Gandi/WS/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/LU/Contact.pm »