File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/NO/Result.pm
Criterion Covered Total %
statement 6 36 16.6
branch 0 12 0.0
condition 0 3 0.0
subroutine 2 5 40.0
pod 0 3 0.0
total 8 59 13.5


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, .NO Result extension
2             ##
3             ## Copyright (c) 2008,2010,2013 UNINETT Norid AS, Ehttp://www.norid.noE,
4             ## Trond Haugen Einfo@norid.noE
5             ## All rights reserved.
6             ##
7             ## This file is part of Net::DRI
8             ##
9             ## Net::DRI is free software; you can redistribute it and/or modify
10             ## it under the terms of the GNU General Public License as published by
11             ## the Free Software Foundation; either version 2 of the License, or
12             ## (at your option) any later version.
13             ##
14             ## See the LICENSE file that comes with this distribution for more details.
15             ####################################################################################################
16              
17             package Net::DRI::Protocol::EPP::Extensions::NO::Result;
18              
19 1     1   3 use strict;
  1         1  
  1         23  
20 1     1   4 use warnings;
  1         2  
  1         411  
21              
22             =pod
23              
24             =head1 NAME
25              
26             Net::DRI::Protocol::EPP::Extensions::NO::Result - .NO Result Condition EPP Mapping for Net::DRI
27              
28             =head1 DESCRIPTION
29              
30             Please see the README file for details.
31              
32             =head1 SUPPORT
33              
34             For now, support questions should be sent to:
35              
36             Enetdri@dotandco.comE
37              
38             Please also see the SUPPORT file in the distribution.
39              
40             =head1 SEE ALSO
41              
42             Ehttp://www.dotandco.com/services/software/Net-DRI/E
43              
44             =head1 AUTHOR
45              
46             Trond Haugen, Einfo@norid.noE
47              
48             =head1 COPYRIGHT
49              
50             Copyright (c) 2008,2010,2013 UNINETT Norid AS, Ehttp://www.norid.noE,
51             Trond Haugen, Einfo@norid.noE
52             All rights reserved.
53              
54             This program is free software; you can redistribute it and/or modify
55             it under the terms of the GNU General Public License as published by
56             the Free Software Foundation; either version 2 of the License, or
57             (at your option) any later version.
58              
59             See the LICENSE file that comes with this distribution for more details.
60              
61             =cut
62              
63             ####################################################################################################
64              
65             sub register_commands {
66 0     0 0   my ( $class, $version ) = @_;
67 0           my %tmp = (
68              
69             check => [ undef, \&condition_parse ],
70             info => [ undef, \&condition_parse ],
71             create => [ undef, \&condition_parse ],
72             delete => [ undef, \&condition_parse ],
73             transfer_request => [ undef, \&condition_parse ],
74             transfer_query => [ undef, \&condition_parse ],
75             transfer_cancel => [ undef, \&condition_parse ],
76             transfer_execute => [ undef, \&condition_parse ],
77             update => [ undef, \&condition_parse ],
78             renew => [ undef, \&condition_parse ],
79             withdraw => [ undef, \&condition_parse ],
80             nocommand => [ undef, \&condition_parse ],
81             );
82              
83             return {
84 0           'domain' => \%tmp,
85             'contact' => \%tmp,
86             'host' => \%tmp,
87             'session' => { 'login' => [ undef, \&condition_parse ] },
88             };
89             }
90              
91             sub condition_parse {
92 0     0 0   my ( $po, $otype, $oaction, $oname, $rinfo ) = @_;
93 0           my $mes = $po->message();
94              
95 0           my $condata = $mes->get_extension( 'no_result', 'conditions' );
96 0 0         return unless $condata;
97              
98 0           parse( $mes, $otype, $oname, $rinfo, $condata );
99 0           return 1;
100             }
101              
102             sub parse {
103 0     0 0   my ( $mes, $otype, $oname, $rinfo, $node ) = @_;
104 0           my $NS = $mes->ns('no_result');
105 0           my @conditions;
106              
107 0           foreach my $el ( $node->getElementsByTagNameNS( $NS, 'condition' ) ) {
108 0           my %con;
109 0           my $c = $el->getFirstChild();
110              
111 0 0         $con{code} = $el->getAttribute('code') if $el->getAttribute('code');
112 0 0         $con{severity} = $el->getAttribute('severity')
113             if $el->getAttribute('severity');
114              
115 0           while ($c) {
116 0   0       my $name = $c->localname() || $c->nodeName();
117 0 0         next unless $name;
118 0 0         if ( $name =~ m/^(msg|details)$/mx ) {
    0          
119 0           $con{$1} = $c->getFirstChild()->getData();
120             } elsif ( $name =~ m/^attributes$/mx ) {
121 0           foreach my $attr ( $c->getChildrenByTagNameNS( $NS, 'attr' ) )
122             {
123 0           my $attrname = $attr->getAttribute('name');
124 0           $con{ "attr " . $attrname }
125             = $attr->getFirstChild()->getData();
126             }
127             }
128 0           $c = $c->getNextSibling();
129             }
130 0           push @conditions, \%con;
131 0           $mes->add_to_extra_info({from=>'no',type=>'text',message => $con{msg}, %con});
132             }
133              
134             # Extension results can be returned in all 3 object types
135 0           $rinfo->{$otype}->{$oname}->{conditions} = \@conditions;
136              
137 0           return;
138             }
139             ##############################################################################
140             1;