DRI/Protocol/EPP/Extensions/ArtRecord.pm

filter: Statementstmt 22.8% 16 / 70 Branchbran 0.0% 0 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 6 totaltotal 16.5% 21 / 127 CC 22 SCAR 52.9
CC
22
Cov
15%
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-2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($class,$version)=@_;
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 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ($class,$po,$version)=@_;
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 0 ▶{
Subroutine command: not called CC=18 SCAR=58.3
Pod undocumented
57 0 my ($epp,$domain,$data)=@_;
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 $mes->command_extension('artRecord', [$operation, @art]);
95  
96 0 return;
97 }
98  
99 sub info_parse
100 0 ▶{
Subroutine info_parse: not called CC=5 SCAR=34.0
Pod undocumented
101 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
102 0 my $mes=$po->message();
103 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
104  
105 0 my $data=$mes->get_extension('artRecord','infData');
106 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
107  
108 0 my %art;
109 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
110 {
111 0 my ($name,$c)=@$el;
112  
113 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
114 0 $art{Net::DRI::Util::remcam($name)}=$c->textContent();
115 }
116 }
117  
118 0 $rinfo->{domain}->{$oname}->{art_record}=\%art;
119  
120 0 return;
121 }
122  
123 ####################################################################################################
124 1 1;
125  
126 __END__
« DRI/Protocol/Gandi/WS/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/LU/Contact.pm »