| 1 | ## Domain Registry Interface, OpenSRS XCP Message | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008-2010,2012-2014 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::OpenSRS::XCP::Message; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use XML::LibXML (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Net::DRI::Protocol::ResultStatus; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | __PACKAGE__->mk_accessors(qw(version client_auth command command_attributes response_attributes response_code response_text response_is_success)); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | Net::DRI::Protocol::OpenSRS::XCP::Message - OpenSRS XCP Message for Net::DRI | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | Please see the README file for details. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | Copyright (c) 2008-2010,2012-2014 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 61 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 62 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 63 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my ($class,$trid)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $self={ results => [], _body => '', command => {}}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | bless($self,$class); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $self->version('0.9'); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | our %CODES=( 200 => 1000, | |||||||||||||||||||||||||||||||||||||||||
| 82 | 210 => 2303, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 211 => 2302, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 212 => 1000, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 221 => 2302, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 250 => 1001, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 300 => 1001, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 310 => 2502, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 350 => 2502, ## A maximum of 100 commands can be sent through one connection/session. After 100 commands have been submitted, the connection is closed and a new connection must be opened to submit outstanding requests. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 400 => 2400, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 404 => 2400, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 405 => 2400, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 410 => 2200, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 415 => 2200, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 430 => 2000, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 435 => 2201, | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 436 => 2400, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 437 => 2304, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 440 => 2201, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 445 => 2201, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 447 => 2201, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 460 => 2003, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 465 => 2005, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 480 => 2306, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 485 => 2302, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 486 => 2304, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 487 => 2106, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 541 => 2004, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 552 => 2304, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 555 => 2306, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 557 => 2305, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 705 => 2400, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | sub result_status | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_status: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | return Net::DRI::Protocol::ResultStatus->new_success($self->response_text()) if $self->response_is_success(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $code=$self->response_code(); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my $eppcode=(defined $code && exists $CODES{$code})? $CODES{$code} : 'COMMAND_FAILED'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $code and exists $Net::DRI::Protocol::OpenSRS::XCP::Message::CODES{$code}
MC/DC0%0/2
defined $code and exists $Net::DRI::Protocol::OpenSRS::XCP::Message::CODES{$code}
defined $code
exists $Net::DRI::Protocol::OpenSRS::XCP::Message::CODES{$code}
Truth table0%0/3
A and B
A= defined $codeB= exists $Net::DRI::Protocol::OpenSRS::XCP::Message::CODES{$code}
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | return Net::DRI::Protocol::ResultStatus->new('opensrs_xcp',$code,$eppcode,$self->response_is_success(),$self->response_text(),'en'); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub is_success { return shift->response_is_success(); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_success: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub as_string { return shift->get_body(); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub get_body | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return $self->{_body} if length($self->{_body}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my @d; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | push @d,q{<?xml version='1.0' encoding='UTF-8' standalone='no' ?>}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | push @d,q{<!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | push @d,'<OPS_envelope>'; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | push @d,'<header><version>',$self->version(),'</version></header>'; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push @d,'<body>'; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | push @d,'<data_block>'; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | push @d,'<dt_assoc>'; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $d=$self->command(); ## ref hash with at least action & object keys, maybe more (such as cookie) | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $d->{protocol}='XCP'; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | foreach my $k (sort { $a cmp $b } keys %$d) | |||||||||||||||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | push @d,'<item key="',$k,'">',$d->{$k},'</item>'; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | push @d,'<item key="attributes">',_obj2dt($self->command_attributes()),'</item>' if defined($self->command_attributes()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | push @d,'</dt_assoc>'; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | push @d,'</data_block>'; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | push @d,'</body>'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | push @d,'</OPS_envelope>'; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->{_body}=join('',@d); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return $self->{_body}; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | sub _obj2dt | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_obj2dt: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my ($in)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | foreach my $el ($in) | |||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $ref=ref($el); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (!$ref) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | push @r,sprintf('<dt_scalar>%s</dt_scalar>',Net::DRI::Util::xml_escape($el)); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } elsif ($ref eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my @c; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | foreach my $k (sort { $a cmp $b } keys %$el) | |||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $k=~s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $v=$el->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (!defined($v)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | push @c,sprintf('<item key="%s" />',$k); | |||||||||||||||||||||||||||||||||||||||||
| 174 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | push @c,sprintf('<item key="%s">%s</item>',$k,ref($v)? _obj2dt($v) : Net::DRI::Util::xml_escape($v)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | push @r,sprintf('<dt_assoc>%s</dt_assoc>',join('',@c)); | |||||||||||||||||||||||||||||||||||||||||
| 179 | } elsif ($ref eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my @c; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | foreach my $i (0..$#$el) | |||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | push @c,sprintf('<item key="%d">%s</item>',$i,ref($el->[$i])? _obj2dt($el->[$i]) : Net::DRI::Util::xml_escape($el->[$i])); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | push @r,sprintf('<dt_array>%s</dt_array>',join('',@c)); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } elsif ($ref eq 'SCALAR') | ||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | push @r,sprintf('<dt_scalarref>%s</dt_scalarref>',Net::DRI::Util::xml_escape($$el)); ## defined in specifications, but not really used ? | |||||||||||||||||||||||||||||||||||||||||
| 190 | } else | ||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | Net::DRI::Exception::err_assert('_obj2dt cannot deal with data '.$el); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return @r; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | sub _dt2obj ## no critic (Subroutines::RequireFinalReturn) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dt2obj: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($doc)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $c=$doc->getFirstChild(); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return unless defined($c); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | while (defined($c) && $c->nodeType()!=1) { $c=$c->getNextSibling(); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $c and $c->nodeType != 1
MC/DC0%0/2
defined $c and $c->nodeType != 1
defined $c
$c->nodeType != 1
Truth table0%0/3
A and B
A= defined $cB= $c->nodeType != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return $doc->textContent() unless (defined($c) && $c->nodeType()==1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $c and $c->nodeType == 1
MC/DC0%0/2
defined $c and $c->nodeType == 1
defined $c
$c->nodeType == 1
Truth table0%0/3
A and B
A= defined $cB= $c->nodeType == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $n=$c->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($n eq 'dt_scalar') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return $c->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 209 | } elsif ($n eq 'dt_assoc') | ||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my %r; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | foreach my $item ($c->getChildrenByTagName('item')) | |||||||||||||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $r{$item->getAttribute('key')}=_dt2obj($item); | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return \%r; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } elsif ($n eq 'dt_array') | ||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $item ($c->getChildrenByTagName('item')) | |||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $r[$item->getAttribute('key')]=_dt2obj($item); | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return \@r; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | Net::DRI::Exception::err_assert('_dt2obj ca not deal with node name '.$n); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | sub parse | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ($self,$dr,$rinfo,$otype,$oaction,$msgsent)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->command($msgsent->command()); ## Copy over for reference from message sent | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $parser=XML::LibXML->new(); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $doc=$parser->parse_string($dr->as_string()); | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $root=$doc->getDocumentElement(); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | Net::DRI::Exception->die(0,'protocol/OpenSRS/XCP',1,'Unsuccessful parse, root element is not OPS_envelope but '.$root->getName()) unless ($root->getName() eq 'OPS_envelope'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $db=$root->getElementsByTagName('data_block'); | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | Net::DRI::Exception->die(0,'protocol/OpenSRS/XCP',1,'Unsuccessful parse, expected only one data_block node below root, found '.$db->size()) unless ($db->size()==1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $db=$db->get_node(1)->getChildrenByTagName('dt_assoc'); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | Net::DRI::Exception->die(0,'protocol/OpenSRS/XCP',1,'Unsuccessful parse, expected one dt_assoc node directly below data_block, found '.$db->size()) unless ($db->size()==1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | foreach my $item ($db->get_node(1)->getChildrenByTagName('item')) | |||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $key=$item->getAttribute('key'); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | next if ($key eq 'protocol' || $key eq 'action' || $key eq 'object'); ## protocol is XCP, action is always REPLY, and we already have object in command() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$key eq "protocol" or $key eq "action" or $key eq "object"
$key eq "protocol" or $key eq "action"
MC/DC0%0/3
$key eq "protocol" or $key eq "action" or $key eq "object"
$key eq "protocol"
$key eq "action"
$key eq "object"
Truth table0%0/4
A or B or C
A= $key eq "protocol"B= $key eq "action"C= $key eq "object"
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($key eq 'attributes') ## specific data about requested action, should always be an hash based on documentation | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->response_attributes(_dt2obj($item)); | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ($key eq 'response_code') ## meaning is action-specific | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->response_code($item->textContent()); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($key eq 'response_text') ## meaning is action-specific | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->response_text($item->textContent()); | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ($key eq 'is_success') ## 0 if not successful, 1 if action was successful | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->response_is_success($item->textContent()); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||