| 1 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Business::cXML - Perl implementation of cXML messaging | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | B<Respond to an incoming request:> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | use Business::cXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | $cxml = new Business::cXML ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | local => 'https://example.com/our/cxml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | handlers => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | PunchOutSetup => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | __handler => sub { ... }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | operationAllowed => 'create', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Calls $res->reply_to($req), so to/from/sender are probably OK. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | $output_xml_string = $cxml->process($input_xml_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Send output to requestor... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | B<Send a request to a server:> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | use Business::cXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $cxml = new Business::cXML ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | remote => 'https://example.com/rest/cxml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | secret => 'somesecrettoken', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $req = $cxml->new_request('PunchOutSetup'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $req->from(id => '123456', domain => 'DUNS'); # Also sets Sender by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $req->to(id => '654321', domain => 'NetworkId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Populate request, see Business::cXML::Transmission documentation... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $res = $cxml->send($req); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # Do something with $res, the Business::cXML::Transmission response received... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | B<Create a one-way message:> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | use Business::cXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $cxml = new Business::cXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $msg = $cxml->new_message('PunchOutOrder'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $msg->from(id => '123456', domain => 'DUNS'); # Also sets Sender by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $msg->to(id => '654321', domain => 'NetworkId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # Populate message, see Business::cXML::Transmission documentation... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | print $cxml->stringify($msg, url => '...'); # Transmission in cXML-Base64 in an HTML FORM | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | Dispatch incoming HTTP/HTTPS requests and respond to them. Send outgoing | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | requests and parse responses. Prepare and parse one-way messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | As a convention, cXML refers to overall messages as "transmissions" to | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | distinguish from C<Message> type payloads. This library includes native Perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | modules for the following transmission types: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | =item * L<Business::cXML::Request::PunchOutSetup> / L<Business::cXML::Response::PunchOutSetup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | =item * L<Business::cXML::Message::PunchOutOrder> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =item * Planned: Request::Order / Response::Order | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Specifically B<NOT> implemented are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =item * Attachments | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | =item * Cryptographic signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =item * Requesting the remote side's capabilities profile and restricting ourselves to it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =head2 Motivation & Future Development | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | While the above may implement a relatively small portion of the whole cXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | specification, which is designed to describe every business-to-business | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | transaction imaginable world-wide, it does fully satisfy our need (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | L</ACKNOWLEDGEMENTS>) to act as a "punch-out" supplier to our | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | Ariba/PeopleSoft/SAP/etc corporate clients. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | The design is completely modular (see L<Business::cXML::Object>) and uses | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | L<XML::LibXML> under the hood, to help simplify future efforts to cover more | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | of the standard. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | package Business::cXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | use Business::cXML::Transmission; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | our $VERSION = 'v0.6.12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | our $CXML_VERSION = '1.2.036'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | our $USERAGENT = "Business::cXML.pm $VERSION"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | our @EXPORT = qw(CXML_LOG_NOTHING CXML_LOG_ERR CXML_LOG_ERROR CXML_LOG_WARN CXML_LOG_WARNING CXML_LOG_INFO CXML_LOG_DEBUG, CXML_LOG_TRACE); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | CXML_LOG_NOTHING => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | CXML_LOG_ERR => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | CXML_LOG_ERROR => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | CXML_LOG_WARN => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | CXML_LOG_WARNING => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | CXML_LOG_INFO => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | CXML_LOG_DEBUG => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | CXML_LOG_TRACE => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | =item C<B<new>( I<%options> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | Returns a fresh cXML handler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | Options useful to send requests and receive responses: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =item C<B<remote>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | HTTP/HTTPS URL where to POST requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Options useful to process requests and emit responses: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | =item C<B<local>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | HTTP/HTTPS URL to publish where clients can reach this handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | =item C<B<secret>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | Secret keyword expected by remote server | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | =item C<B<sender_callback>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | Subroutine, passed to L</sender_callback()>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =item B<log_level> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | One of: C<CXML_LOG_NOTHING> (default), C<CXML_LOG_ERR>, C<CXML_LOG_WARN>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | C<CXML_LOG_INFO>, C<CXML_LOG_DEBUG>, C<CXML_LOG_TRACE>. Alternates | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | C<CXML_LOG_ERROR> and C<CXML_LOG_WARNING> are also available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | =item B<log_callback> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | Subroutine, passed to L</log_callback()>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | =item B<handlers> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | Hash of handlers, dereferenced and passed to L</on()>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 11 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | local => ($options{local} || ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | remote => ($options{remote} || undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | secret => ($options{secret} || undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | sender_callback => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | log_level => ($options{log_level} || CXML_LOG_NOTHING), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 11 | ▶ | log_callback => ($options{log_callback} || \&_log_default), | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%10/10
$options{'local'} || ''
$options{'remote'} || undef
$options{'secret'} || undef
$options{'log_level'} || 0
$options{'log_callback'} || \&Business::cXML::_log_default
MC/DC100%1/1
$options{'local'} || ''
$options{'local'}
MC/DC100%1/1
$options{'remote'} || undef
$options{'remote'}
MC/DC100%1/1
$options{'secret'} || undef
$options{'secret'}
MC/DC100%1/1
$options{'log_level'} || 0
$options{'log_level'}
MC/DC100%1/1
$options{'log_callback'} || \&Business::cXML::_log_default
$options{'log_callback'}
Truth table100%2/2
A
A= $options{'local'}
Truth table100%2/2
A
A= $options{'remote'}
Truth table100%2/2
A
A= $options{'secret'}
Truth table100%2/2
A
A= $options{'log_level'}
Truth table100%2/2
A
A= $options{'log_callback'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | routes => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Profile => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | __handler => \&_handle_profile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 11 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | ▶ | $self->sender_callback($options{sender_callback}) if exists $options{sender_callback}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 11 | ▶ | $self->on(%{ $options{handlers} }) if exists $options{handlers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub _handle_profile { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_profile: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($self, $req, $res) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $res->status(200); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $data = $res->xml_payload; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $data->attr(effectiveDate => $res->timestamp); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # UNIMPLEMENTED: lastRefresh? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # UNIMPLEMENTED: service-level (outside Transaction blocks) options: service, attachments, changes, requestNames | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # Possibly also: Locale (found in an example, but not in any documentation) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # There was no documentation about these in the cXML 1.2.036 PDF manual nor in the DTD comments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | foreach my $route (keys (%{ $self->{routes} })) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $tx = $data->add('Transaction', undef, requestName => ($route . 'Request')); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $tx->add(URL => $self->{local}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | foreach my $opt (grep { $_ ne '__handler' } keys (%{ $self->{routes}{$route} })) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $tx->add('Option', $self->{routes}{$route}{$opt}, name => $opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | =item C<B<sender_callback>( I<$sub> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | By default, a request's From/Sender credentials are only used to guess | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | response credentials. If you specify a callback here, it will be invoked | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | immediately after XML parsing, before passing to transaction handlers, giving | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | you an opportunity to authenticate the caller. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | Your subroutine will be passed 3 arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | =item 1. The current L<Business::cXML> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | =item 2. The Sender L<Business::cXML::Credential> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | =item 3. The From L<Business::cXML::Credential> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | If you return a false value, the request will be deemed unauthorized and no | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | handler will be invoked. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | If you return anything else, it will be stored and available in the request | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sender's C<_note> property. (See L<Business::cXML::Credential> for details.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | Note that cXML From/Sender headers contain information about an entire company | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | you're doing business with. The identity of the specific person triggering | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | the request, if applicable, will be somewhere in contact or extrinsic data in | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | the payload itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | sub sender_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sender_callback: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | my ($self, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | $self->{sender_callback} = $callback if ref($callback) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =item C<B<log_callback>( I<$sub> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | By default, basic details about log-worthy events are dumped to C<STDERR> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | (filtered according to the current log level). By specifying your own | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | handler, you can do anything else you'd like when informative events occur. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | Your subroutine will be passed 5 arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | =item 1. The current L<Business::cXML> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =item 2. The level | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | =item CXML_LOG_ERR = 1 = fatal error (on our side) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =item CXML_LOG_WARN = 2 = warning (errors on the other end, network issues, etc.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | =item CXML_LOG_INFO = 3 = normal operations like receiving or sending transmissions | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | =item CXML_LOG_DEBUG = 4 = additional debugging information about processing requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | =item CXML_LOG_TRACE = 5 = full trace logging in some areas | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | =item 3. A possible long-form message describing the event | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | =item 4. A possible cXML transmission string (untouched if input) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | =item 5. A possible L<Business::cXML::Transmission> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | Successful parsing of a new transmission triggers a level 3 log, whereas | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | failure is a level 2. Failure to produce valid XML from our internal data | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | (which should never occur) is a level 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | NOTE: Logging is limited to this module. Thus, be sure to use L<process()>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | L<send()> and L<stringify()> to trap interesting events in the handling of | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | C<Request>, C<Response> and C<Message> transmissions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub _log_default { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_default: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my ($cxml, $level, $desc, $xml, $tx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return unless $level <= $cxml->{log_level}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $level = ('error', 'warning', 'info', 'debug', 'trace')[$level-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # print STDERR "cXML[$level]: ", $desc, " -- ", $xml, " -- ", Dumper($cxml), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $xml =~ s/>\s+</> </g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | print STDERR "cXML[$level]: ", $desc, " -- ", $xml, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | sub log_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_callback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my ($self, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | $self->{log_callback} = $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub _error { my $l = shift; $l->{log_callback}->($l, CXML_LOG_ERR, @_); return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub _warning { my $l = shift; $l->{log_callback}->($l, CXML_LOG_WARN, @_); return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_warning: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub _notice { my $l = shift; $l->{log_callback}->($l, CXML_LOG_INFO, @_); return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_notice: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub _debug { my $l = shift; $l->{log_callback}->($l, CXML_LOG_DEBUG, @_); return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub _trace { my $l = shift; $l->{log_callback}->($l, CXML_LOG_TRACE, @_); return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trace: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | =item C<B<on>( I<%handlers> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | Each key in I<C<%handlers>> is the bare name of a supported transaction type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | For example, if you want to support C<PunchOutSetupRequest>, the key is | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | C<PunchOutSetup>. Each key should point to a hashref specifying any options | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | to declare in our C<Profile>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | Special key C<__handler> is mandatory and should point to a sub which will | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | be called if its type of request is received, valid and optionally | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | authenticated. Your handler will be passed 3 arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | =item 1. The current L<Business::cXML> object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | =item 2. The L<Business::cXML::Transmission> request | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | =item 3. A ready-to-fill L<Business::cXML::Transmission> response | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | Be sure to change the response's status, which is a 500 error by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | The response's to/from/sender is initialized in reciprocity to the request's, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | so your handler might not need to change much in those. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Keys represent the case-sensitive name of the cXML request without the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | redundant suffix. For example, a C<PunchOutSetupRequest> is our type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | C<PunchOutSetup>. Possible keys include: C<Order>, C<PunchOutSetup>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | C<StatusUpdate>, C<GetPending>, C<Confirmation>, C<ShipNotice>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | C<ProviderSetup>, C<PaymentRemittance>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | Pings and C<Profile> requests are built-in, although you can override the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | handling of the latter with your own handler if you'd like. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 5 | ▶ | sub on { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 5 | my ($self, %routes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 5 | foreach (keys %routes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 5 | $self->{routes}{$_} = $routes{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | =item C<B<process>( [I<$input>] )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | Decodes the I<C<$input>> XML string which is expected to be a complete cXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | transmission. May invoke one of your handlers declared with L<on()> if | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | appropriate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Returns a string containing a valid cXML document at all times. This document | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | includes any relevant status information determined during processing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | Note that an omitted or empty I<C<$input>> is actually valid and results in a | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | "pong" response. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 7 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=16 SCAR=55.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 7 | my ($self, $input) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 7 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | my $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 7 | my $res = new Business::cXML::Transmission; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $res->is_response(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | unless ($input) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $self->_notice("process(10) ping-pong"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $res->status(200, "Pong!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $self->_error("process(12) $err", $str) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->_trace("process(15) ping-pong returning", $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $req = new Business::cXML::Transmission $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | unless (defined blessed($req)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # We have an error status code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $desc = "XML validation failure:\n" . $req->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $self->_warning("process(21) $desc", $input); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $res->status($req->[0], $desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | $self->_error("process(22) $err", $str) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $self->_trace("process(25) error returning", $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $res->status(500, "Handler did not set a response status."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $res->reply_to($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $res->payload; # Trigger creation of payload now that it has a class/type. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if (defined $self->{sender_callback}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $self->_trace("process(30) sender_callback..."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $note; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $note = $self->{sender_callback}->($self, $req->sender, $req->from); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $self->_error("process(31) sender_callback crashed!!!", $@); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $res->status(500, "Sender validation encountered an irrecoverable error."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $self->_error("process(32) $err", $str) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if ($note) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $self->_debug("process(33) sender_callback successful"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $req->sender->_note($note); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $self->_warning("process(34) sender validation failed", $input, $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $res->status(401, "Invalid sender."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | $self->_error("process(35) $err", $str) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | unless (exists $self->{routes}{$req->type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $desc = "Type '" . $req->type . "' is not implemented."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->_warning("process(41) $desc", $input, $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $res->status(450, $desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $self->_error("process(45) $err", $str) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->_notice("process() received request", $input, $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $self->{routes}{$req->type}{__handler}->($self, $req, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $self->_error("process(50) handler for type '" . $req->type . "' crashed!!!", $@); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $res->status(500, "Processing for type '" . $req->type . "' encountered an irrecoverable error."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ($err, $str) = $res->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | $self->_error("process(51): $err", $str, $res) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | if ($res->status >= 500) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $self->_error("process(55) responding with 5xx", $str, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } elsif ($res->status >= 400) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $self->_warning("process(54) responding with 4xx", $str, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $self->_notice("process(52) responding with 2xx", $str, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->_debug("process(60) returning", $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | =item C<B<new_request>( [I<$type>] )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | Returns a fresh L<Business::cXML::Transmission> ready to be used as a request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | Optional I<C<$type>> is a convenience shortcut to | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | L<Business::cXML::Transmission::type()|cXML::Transmission/type>. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | request's sender secret will be pre-filled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | ▶ | sub new_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_request: called CC=3 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | my $req = new Business::cXML::Transmission; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $req->is_request(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | $req->type($type) if defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | $req->sender->secret($self->{secret}) if defined $self->{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | =item C<B<send>( I<$request> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | Freeze I<C<$request>>, a L<Business::cXML::Transmission>, and attempt sending | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | it to the configured remote server. Returns the received response | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | L<Business::cXML::Transmission> on success, C<undef> on failure. Note that as | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | per L<Business::cXML::Transmission::new()|Business::cXML::Transmission/new>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | it is also possible that an error arrayref be returned instead of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | transmission if parsing failed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | In case of failure, you may want to wait a certain amount of time and try | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | again. To give you more options to that effect, I<C<$request>> can be either | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | a L<Business::cXML::Transmission> or a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 7 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | sub send { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my ($self, $req) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | my $obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if (ref($req)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $obj = $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ($err, $req) = $req->freeze(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | return $self->_error("send(11): $err", $req, $obj) if defined $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $self->_notice("send() making HTTP request", $req, $obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $ua = new LWP::UserAgent; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $ua->agent($Business::cXML::USERAGENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $ua->timeout(30); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | my $res = $ua->post( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | $self->{remote}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | 'Content-Type' => 'text/xml; charset="UTF-8"', | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 'Content' => $req, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | if ($res->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $res = $res->decoded_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $msg = new Business::cXML::Transmission $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | unless (defined blessed($msg)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # We have an error status code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | return $self->_warning('send(21) ' . ($msg->[0] == 406 ? 'response XML validation' : 'response cXML traversal') . ' failure', $res); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $self->_notice("send() received HTTP response", $res, $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return $self->_warning("send(22) had network failure", $req, $obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | =item C<B<new_message>( [I<$type>] )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | Returns a fresh L<Business::cXML::Transmission> ready to be used as a | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | stand-alone message. Optional I<C<$type>> is passed on to | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | L<Business::cXML::Transmission::type()|Business::cXML::Transmission/type>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | ▶ | sub new_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_message: called CC=2 SCAR=12.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1 | my $msg = new Business::cXML::Transmission; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $msg->is_message(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | $msg->type($type) if defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | =item C<B<stringify>( I<$message>, I<%args> )> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | Convenience wrapper around | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | L<Business::cXML::Transmission::toForm()|Business::cXML::Transmission/toForm> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | which allows you to trap logging events. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my ($self, $msg, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my ($err, $str) = $msg->toForm(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | $self->_error("stringify(): $err", $str, $msg) if defined $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0.6.12 based on cXML DTD 1.2.036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | Stéphane Lavergne L<https://github.com/vphantom> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | of this software and associated documentation files (the "Software"), to deal | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | in the Software without restriction, including without limitation the rights | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | copies of the Software, and to permit persons to whom the Software is | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | furnished to do so, subject to the following conditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | The above copyright notice and this permission notice shall be included in all | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | copies or substantial portions of the Software. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | SOFTWARE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||