line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## Domain Registry Interface, EPP AusRegistry Domain Variant Extension |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## Copyright (c) 2013 Patrick Mevzek . 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::AusRegistry::Variant; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
666
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
18
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
21
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Exception; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
542
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#################################################################################################### |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register_commands |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
|
my ($class,$version)=@_; |
28
|
0
|
|
|
|
|
|
my %tmp=( |
29
|
|
|
|
|
|
|
info => [ \&info_build, \&info_parse ], |
30
|
|
|
|
|
|
|
create => [ undef, \&create_parse ], |
31
|
|
|
|
|
|
|
update => [ \&update_build, undef ], |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return { 'domain' => \%tmp }; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub setup |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
0
|
0
|
|
my ($class,$po,$version)=@_; |
40
|
0
|
|
|
|
|
|
$po->ns({ 'variant' => [ 'urn:X-ar:params:xml:ns:variant-1.0','variant-1.0.xsd' ], |
41
|
|
|
|
|
|
|
}); |
42
|
0
|
|
|
|
|
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
sub capabilities_add { return ('domain_update','variants',['add','del']); } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#################################################################################################### |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## (This extension is mandatory) |
50
|
|
|
|
|
|
|
## |
51
|
|
|
|
|
|
|
## |
52
|
|
|
|
|
|
|
## |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub info_build |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
57
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $variants='all'; ## default value |
60
|
0
|
0
|
0
|
|
|
|
$variants=$rd->{variants} if Net::DRI::Util::has_key($rd,'variants') && $rd->{variants}=~m/^(?:all|none)$/; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('variant','info',{variants => $variants}); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
## |
68
|
|
|
|
|
|
|
## |
69
|
|
|
|
|
|
|
## xn--4xal.example |
70
|
|
|
|
|
|
|
## |
71
|
|
|
|
|
|
|
## |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub parse_variant |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
0
|
|
my ($rh,$data)=@_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my %variants; |
78
|
0
|
|
|
|
|
|
foreach my $el (Net::DRI::Util::xml_list_children($data)) |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
|
|
|
my ($name,$node)=@$el; |
81
|
0
|
0
|
|
|
|
|
if ($name eq 'variant') |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
|
|
|
$variants{$node->textContent()}=$node->getAttribute('userForm'); ## A-label => U-label |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$rh->{variants}=\%variants; |
88
|
0
|
|
|
|
|
|
return; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub info_parse |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
0
|
|
my ($po,$otype,$oaction,$oname,$rinfo)=@_; |
94
|
0
|
|
|
|
|
|
my $mes=$po->message(); |
95
|
0
|
0
|
|
|
|
|
return unless $mes->is_success(); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $data=$mes->get_extension('variant','infData'); |
98
|
0
|
0
|
|
|
|
|
return unless defined $data; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
parse_variant($rinfo->{domain}->{$oname},$data); |
101
|
0
|
|
|
|
|
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
## |
105
|
|
|
|
|
|
|
## |
106
|
|
|
|
|
|
|
## xn--4xal.example |
107
|
|
|
|
|
|
|
## |
108
|
|
|
|
|
|
|
## |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub create_parse |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
0
|
0
|
|
my ($po,$otype,$oaction,$oname,$rinfo)=@_; |
113
|
0
|
|
|
|
|
|
my $mes=$po->message(); |
114
|
0
|
0
|
|
|
|
|
return unless $mes->is_success(); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $data=$mes->get_extension('variant','creData'); |
117
|
0
|
0
|
|
|
|
|
return unless defined $data; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
parse_variant($rinfo->{domain}->{$oname},$data); |
120
|
0
|
|
|
|
|
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## |
124
|
|
|
|
|
|
|
## |
125
|
|
|
|
|
|
|
## |
126
|
|
|
|
|
|
|
## xn--4xal.example |
127
|
|
|
|
|
|
|
## |
128
|
|
|
|
|
|
|
## |
129
|
|
|
|
|
|
|
## |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
## |
132
|
|
|
|
|
|
|
## |
133
|
|
|
|
|
|
|
## |
134
|
|
|
|
|
|
|
## xn--4xal.example |
135
|
|
|
|
|
|
|
## |
136
|
|
|
|
|
|
|
## |
137
|
|
|
|
|
|
|
## |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub build_variants |
140
|
|
|
|
|
|
|
{ |
141
|
0
|
|
|
0
|
0
|
|
my ($d)=@_; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my @v; |
144
|
0
|
|
|
|
|
|
foreach my $alabel ( sort { $a cmp $b } keys %$d) |
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
{ |
146
|
0
|
|
|
|
|
|
push @v,['variants:variant',{userForm => $d->{$alabel}},$alabel]; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return @v; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub update_build |
153
|
|
|
|
|
|
|
{ |
154
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$todo)=@_; |
155
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
my $toadd=$todo->add('variants'); |
158
|
0
|
|
|
|
|
|
my $todel=$todo->del('variants'); |
159
|
0
|
0
|
0
|
|
|
|
return unless defined $toadd || defined $todel; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('variants','update'); |
162
|
0
|
|
|
|
|
|
my @v; |
163
|
|
|
|
|
|
|
|
164
|
0
|
0
|
|
|
|
|
if (defined $toadd) |
165
|
|
|
|
|
|
|
{ |
166
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters(q{add variants value must be a ref hash, not: }.$toadd) unless ref $toadd eq 'HASH'; |
167
|
0
|
|
|
|
|
|
push @v,['variants:add',build_variants($toadd)]; |
168
|
|
|
|
|
|
|
} |
169
|
0
|
0
|
|
|
|
|
if (defined $todel) |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters(q{del variants value must be a ref hash, not: }.$todel) unless ref $todel eq 'HASH'; |
172
|
0
|
|
|
|
|
|
push @v,['variants:rem',build_variants($todel)]; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@v); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
return; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
#################################################################################################### |
181
|
|
|
|
|
|
|
1; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__END__ |