| 1 | ## Domain Registry Interface, AFNIC WS Message | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2005,2008-2010,2013 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::AFNIC::WS::Message; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Net::DRI::Protocol::ResultStatus; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | __PACKAGE__->mk_accessors(qw(version service method params result errcode)); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | Net::DRI::Protocol::AFNIC::WS::Message - AFNIC Web Services Message 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) 2005,2008-2010,2013 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 new | ||||||||||||||||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | ▶ | my $class=shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $self={errcode => undef}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | bless($self,$class); | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | $self->params([]); ## default | |||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | if (defined($rh) && (ref($rh) eq 'HASH')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rh and ref $rh eq "HASH"
MC/DC0%0/2
defined $rh and ref $rh eq "HASH"
defined $rh
ref $rh eq "HASH"
Truth table33%1/3
A and B
A= defined $rhB= ref $rh eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->service($rh->{service}) if exists($rh->{service}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->method($rh->{method}) if exists($rh->{method}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $self->params($rh->{params}) if exists($rh->{params}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my @p=@{$self->params()}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my @pr; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | foreach my $i (0..$#p) | |||||||||||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | push @pr,sprintf 'PARAM%d=%s',$i+1,$p[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return sprintf "SERVICE=%s\nMETHOD=%s\n%s\n",$self->service(),$self->method(),join("\n",@pr); | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | sub parse | ||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | my ($self,$r)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $self->result($r); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | my $c; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | $c=$r->{reason} if (defined($r) && ref($r) && exists($r->{reason})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $r and ref $r and exists $r->{"reason"}
defined $r and ref $r
MC/DC33%1/3
defined $r and ref $r and exists $r->{"reason"}
defined $r
ref $r
exists $r->{"reason"}
Truth table50%2/4
A and B and C
A= defined $rB= ref $rC= exists $r->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $self->errcode($c); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | ## Warning: when we handle multiple web services, we will need a way to retrieve the method name called, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | ## to find the correct errcode, as it will obviously not be done the same way accross all services. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | ## We handle all non free cases as errors, even if we should not | ||||||||||||||||||||||||||||||||||||||||||
| 113 | sub is_success | ||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | my $self=shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_success: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | my $r=$self->result(); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | my $code=$self->errcode(); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | return 1 if ($r->{free}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | sub result_status | ||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | my $self=shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_status: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | my $r=$self->result(); | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | return Net::DRI::Protocol::ResultStatus->new_success($r->{message}) if $r->{free}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my %codes=( 0 => 2400, # problème de connexion à la base de données => Command failed | |||||||||||||||||||||||||||||||||||||||||
| 131 | 1 => 2302, # le nom de domaine est déjà enregistré => Object exists | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 => 2308, # un nom de domaine est déjà enregistré à l'identique dans l'une des extensions du domaine public => Data management policy violation | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 => 2304, # une opération est en cours pour ce nom de domaine => Object status prohibits operation | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 => 2308, # nom de domaine interdit (termes fondamentaux) => Data management policy violation | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 51 => 2308, # nom de domaine réservé pour les communes => Data management policy violation | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 100 => 2005, # mauvaise syntaxe du nom de domaine => Parameter value syntax error | ||||||||||||||||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my $code=$self->errcode(); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | my $eppcode=(defined $code && exists $codes{$code})? $codes{$code} : 'COMMAND_FAILED'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $code and exists $codes{$code}
MC/DC0%0/2
defined $code and exists $codes{$code}
defined $code
exists $codes{$code}
Truth table33%1/3
A and B
A= defined $codeB= exists $codes{$code}
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | return Net::DRI::Protocol::ResultStatus->new('afnic_ws_check_domain',$code,$eppcode,$self->is_success(),$r->{message}); | |||||||||||||||||||||||||||||||||||||||||
| 142 | ## Warning: when we handle multiple web services, we will need a way to retrieve the method name called, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ## to find the correct key of the hash (and special case of free <=> 2303) | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||