]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/perlmods/OpenSRF/AppSession.pm
f8b46ee07bf2421ce3d68c91dbddc9c0937fa195
[OpenSRF.git] / src / perlmods / OpenSRF / AppSession.pm
1 package OpenSRF::AppSession;
2 use OpenSRF::DOM;
3 #use OpenSRF::DOM::Element::userAuth;
4 use OpenSRF::DomainObject::oilsMessage;
5 use OpenSRF::DomainObject::oilsMethod;
6 use OpenSRF::DomainObject::oilsResponse qw/:status/;
7 use OpenSRF::Transport::PeerHandle;
8 use OpenSRF::Utils::Config;
9 use OpenSRF::Utils::Logger qw(:level);
10 use OpenSRF::EX;
11 use OpenSRF;
12 use Exporter;
13 use base qw/Exporter OpenSRF/;
14 use Time::HiRes qw( time usleep );
15 use warnings;
16 use strict;
17
18 our @EXPORT_OK = qw/CONNECTING INIT_CONNECTED CONNECTED DISCONNECTED CLIENT SERVER/;
19 our %EXPORT_TAGS = ( state => [ qw/CONNECTING INIT_CONNECTED CONNECTED DISCONNECTED/ ],
20                  endpoint => [ qw/CLIENT SERVER/ ],
21 );
22
23 my $logger = "OpenSRF::Utils::Logger";
24
25 our %_CACHE;
26 our @_CLIENT_CACHE;
27 our @_RESEND_QUEUE;
28
29 sub kill_client_session_cache {
30         for my $session ( @_CLIENT_CACHE ) {
31                 $session->kill_me;
32         }
33 }
34
35 sub CONNECTING { return 3 };
36 sub INIT_CONNECTED { return 4 };
37 sub CONNECTED { return 1 };
38 sub DISCONNECTED { return 2 };
39
40 sub CLIENT { return 2 };
41 sub SERVER { return 1 };
42
43 sub find {
44         return undef unless (defined $_[1]);
45         return $_CACHE{$_[1]} if (exists($_CACHE{$_[1]}));
46 }
47
48 sub find_client {
49         my( $self, $app ) = @_;
50         $logger->debug( "Client Cache contains: " .scalar(@_CLIENT_CACHE), INTERNAL );
51         my ($client) = grep { $_->[0] eq $app and $_->[1] == 1 } @_CLIENT_CACHE;
52         $client->[1] = 0;
53         return $client->[2];
54 }
55
56 sub transport_connected {
57         my $self = shift;
58         if( ! exists $self->{peer_handle} || 
59                                         ! $self->{peer_handle} ) {
60                 return 0;
61         }
62         return $self->{peer_handle}->tcp_connected();
63 }
64
65 # ----------------------------------------------------------------------------
66 # Clears the transport buffers
67 # call this if you are not through with the sesssion, but you want 
68 # to have a clean slate.  You shouldn't have to call this if
69 # you are correctly 'recv'ing all of the data from a request.
70 # however, if you don't want all of the data, this will
71 # slough off any excess
72 #  * * Note: This will delete data for all sessions using this transport
73 # handle.  For example, all client sessions use the same handle.
74 # ----------------------------------------------------------------------------
75 sub buffer_reset {
76
77         my $self = shift;
78         if( ! exists $self->{peer_handle} || ! $self->{peer_handle} ) { 
79                 return 0;
80         }
81         $self->{peer_handle}->buffer_reset();
82 }
83
84
85 sub client_cache {
86         my $self = shift;
87         push @_CLIENT_CACHE, [ $self->app, 1, $self ];
88 }
89
90 # when any incoming data is received, this method is called.
91 sub server_build {
92         my $class = shift;
93         $class = ref($class) || $class;
94
95         my $sess_id = shift;
96         my $remote_id = shift;
97         my $service = shift;
98
99         return undef unless ($sess_id and $remote_id and $service);
100
101         my $conf = OpenSRF::Utils::Config->current;
102         
103         if( ! $conf ) { 
104                 OpenSRF::EX::Config->throw( "No suitable config found" ); 
105         }
106
107         if ( my $thingy = $class->find($sess_id) ) {
108                 $thingy->remote_id( $remote_id );
109                 $logger->debug( "AppSession returning existing session $sess_id", DEBUG );
110                 return $thingy;
111         } else {
112                 $logger->debug( "AppSession building new server session $sess_id", DEBUG );
113         }
114
115         if( $service eq "client" ) {
116                 #throw OpenSRF::EX::PANIC ("Attempting to build a client session as a server" .
117                 #       " Session ID [$sess_id], remote_id [$remote_id]");
118                 $logger->debug("Attempting to build a client session as ".
119                                 "a server Session ID [$sess_id], remote_id [$remote_id]", ERROR );
120         }
121
122
123         my $max_requests = $conf->$service->max_requests;
124         $logger->debug( "Max Requests for $service is $max_requests", INTERNAL );# if $max_requests;
125
126         $logger->transport( "AppSession creating new session: $sess_id", INTERNAL );
127
128         my $self = bless { recv_queue  => [],
129                            request_queue  => [],
130                            requests  => 0,
131                            endpoint    => SERVER,
132                            state       => CONNECTING, 
133                            session_id  => $sess_id,
134                            remote_id    => $remote_id,
135                                 peer_handle => OpenSRF::Transport::PeerHandle->retrieve($service),
136                                 max_requests => $max_requests,
137                                 session_threadTrace => 0,
138                                 service => $service,
139                          } => $class;
140
141         return $_CACHE{$sess_id} = $self;
142 }
143
144 sub service { return shift()->{service}; }
145
146 sub continue_request {
147         my $self = shift;
148         $self->{'requests'}++;
149         return $self->{'requests'} <= $self->{'max_requests'} ? 1 : 0;
150 }
151
152 sub last_sent_payload {
153         my( $self, $payload ) = @_;
154         if( $payload ) {
155                 return $self->{'last_sent_payload'} = $payload;
156         }
157         return $self->{'last_sent_payload'};
158 }
159
160 sub last_sent_type {
161         my( $self, $type ) = @_;
162         if( $type ) {
163                 return $self->{'last_sent_type'} = $type;
164         }
165         return $self->{'last_sent_type'};
166 }
167
168 # When we're a client and we want to connect to a remote service
169 # create( $app, username => $user, secret => $passwd );
170 #    OR
171 # create( $app, sysname => $user, secret => $shared_secret );
172 sub create {
173         my $class = shift;
174         $class = ref($class) || $class;
175
176         my $app = shift;
177         my %auth_args = @_;
178
179
180 #       unless ( $app &&
181 #                exists($auth_args{secret}) &&
182 #                ( exists($auth_args{username}) ||
183 #                  exists($auth_args{sysname}) ) ) {
184 #               throw OpenSRF::EX::User ( 'Insufficient authentication information for session creation');
185 #       }
186
187         if( my $thingy = OpenSRF::AppSession->find_client( $app ) ) {
188                         $logger->debug( "AppSession returning existing client session for $app", DEBUG );
189                         return $thingy;
190         } else {
191                 $logger->debug( "AppSession creating new client session for $app", DEBUG );
192         }
193
194
195         
196         #my $auth = OpenSRF::DOM::Element::userAuth->new( %auth_args );
197
198         my $conf = OpenSRF::Utils::Config->current;
199
200         if( ! $conf ) { 
201                 OpenSRF::EX::Config->throw( "No suitable config found" ); 
202         }
203
204         my $sess_id = time . rand( $$ );
205         while ( $class->find($sess_id) ) {
206                 $sess_id = time . rand( $$ );
207         }
208
209         my $r_id = $conf->$app->transport_target ||
210                         die("No remote id for $app!");
211
212         my $self = bless { app_name    => $app,
213                                 #client_auth => $auth,
214                            #recv_queue  => [],
215                            request_queue  => [],
216                            endpoint    => CLIENT,
217                            state       => DISCONNECTED,#since we're init'ing
218                            session_id  => $sess_id,
219                            remote_id   => $r_id,
220                            orig_remote_id   => $r_id,
221                                 # peer_handle => OpenSRF::Transport::PeerHandle->retrieve($app),
222                                 peer_handle => OpenSRF::Transport::PeerHandle->retrieve("client"),
223                                 session_threadTrace => 0,
224                          } => $class;
225
226         $self->client_cache();
227         $_CACHE{$sess_id} = $self;
228         return $self->find_client( $app );
229 }
230
231 sub app {
232         return shift()->{app_name};
233 }
234
235 sub reset {
236         my $self = shift;
237         $self->remote_id($$self{orig_remote_id});
238 }
239
240 # 'connect' can be used as a constructor if called as a class method,
241 # or used to connect a session that has disconnectd if called against
242 # an existing session that seems to be disconnected, or was just built
243 # using 'create' above.
244
245 # connect( $app, username => $user, secret => $passwd );
246 #    OR
247 # connect( $app, sysname => $user, secret => $shared_secret );
248
249 # --- Returns undef if the connect attempt times out.
250 # --- Returns the OpenSRF::EX object if one is returned by the server
251 # --- Returns self if connected
252 sub connect {
253         my $self = shift;
254         my $class = ref($self) || $self;
255
256         return $self if ( ref( $self ) and  $self->state && $self->state == CONNECTED  );
257
258         my $app = shift;
259
260         $self = $class->create($app, @_) if (!ref($self));
261         return undef unless ($self);
262
263
264         $self->reset;
265         $self->state(CONNECTING);
266         $self->send('CONNECT', "");
267
268         my $time_remaining = OpenSRF::Utils::Config->current->client->connect_timeout;
269
270         while ( $self->state != CONNECTED  and $time_remaining > 0 ) {
271                 my $starttime = time;
272                 $self->queue_wait($time_remaining);
273                 my $endtime = time;
274                 $time_remaining -= ($endtime - $starttime);
275         }
276
277         return undef unless($self->state == CONNECTED);
278
279         return $self;
280 }
281
282 sub finish {
283         my $self = shift;
284         #$self->disconnect if ($self->endpoint == CLIENT);
285         for my $ses ( @_CLIENT_CACHE ) {
286                 if ($ses->[2]->session_id eq $self->session_id) {
287                         $ses->[1] = 1;
288                 }
289         }
290 }
291
292 sub kill_me {
293         my $self = shift;
294         if( ! $self->session_id ) { return 0; }
295         $self->disconnect;
296         $logger->transport( "AppSession killing self: " . $self->session_id(), DEBUG );
297         my @a;
298         for my $ses ( @_CLIENT_CACHE ) {
299                 push @a, $ses 
300                         if ($ses->[2]->session_id ne $self->session_id);
301         }
302         @_CLIENT_CACHE = @a;
303         delete $_CACHE{$self->session_id};
304         delete($$self{$_}) for (keys %$self);
305 }
306
307 sub disconnect {
308         my $self = shift;
309         unless( $self->state == DISCONNECTED ) {
310                 $self->send('DISCONNECT', "") if ($self->endpoint == CLIENT);;
311                 $self->state( DISCONNECTED ); 
312         }
313         $self->reset;
314 }
315
316 sub request {
317         my $self = shift;
318         my $meth = shift;
319
320         my $method;
321         if (!ref $meth) {
322                 $method = new OpenSRF::DomainObject::oilsMethod ( method => $meth );
323         } else {
324                 $method = $meth;
325         }
326         
327         $method->params( @_ );
328
329         $self->send('REQUEST',$method);
330 }
331
332
333 sub send {
334         my $self = shift;
335         my @payload_list = @_; # this is a Domain Object
336
337
338         $logger->debug( "In send", INTERNAL );
339         
340         my $tT;
341
342         if( @payload_list % 2 ) { $tT = pop @payload_list; }
343
344         if( ! @payload_list ) {
345                 $logger->debug( "payload_list param is incomplete in AppSession::send()", ERROR );
346                 return undef; 
347         }
348
349         my $doc = OpenSRF::DOM->createDocument();
350
351         $logger->debug( "In send2", INTERNAL );
352
353         my $disconnect = 0;
354         my $connecting = 0;
355
356         while( @payload_list ) {
357
358                 my ($msg_type, $payload) = ( shift(@payload_list), shift(@payload_list) ); 
359
360                 if ($msg_type eq 'DISCONNECT' ) {
361                         $disconnect++;
362                         if( $self->state == DISCONNECTED) {
363                                 next;
364                         }
365                 }
366
367                 if( $msg_type eq "CONNECT" ) { $connecting++; }
368
369
370                 if( $payload ) {
371                         $logger->debug( "Payload is ".$payload->toString, INTERNAL );
372                 }
373         
374         
375                 my $msg = OpenSRF::DomainObject::oilsMessage->new();
376                 $logger->debug( "AppSession after creating oilsMessage $msg", INTERNAL );
377                 
378                 $msg->type($msg_type);
379                 $logger->debug( "AppSession after adding type" . $msg->toString(), INTERNAL );
380         
381                 #$msg->userAuth($self->client_auth) if ($self->endpoint == CLIENT && $msg_type eq 'CONNECT');
382         
383                 no warnings;
384                 $msg->threadTrace( $tT || int($self->session_threadTrace) || int($self->last_threadTrace) );
385                 use warnings;
386         
387                 if ($msg->type eq 'REQUEST') {
388                         if ( !defined($tT) || $self->last_threadTrace != $tT ) {
389                                 $msg->update_threadTrace;
390                                 $self->session_threadTrace( $msg->threadTrace );
391                                 $tT = $self->session_threadTrace;
392                                 OpenSRF::AppRequest->new($self, $payload);
393                         }
394                 }
395         
396                 $msg->protocol(1);
397                 $msg->payload($payload) if $payload;
398         
399                 $doc->documentElement->appendChild( $msg );
400
401         
402                 $logger->debug( "AppSession sending ".$msg->type." to ".$self->remote_id.
403                         " with threadTrace [".$msg->threadTrace."]", INFO );
404
405         }
406         
407         if ($self->endpoint == CLIENT and ! $disconnect) {
408                 $self->queue_wait(0);
409                 unless ($self->state == CONNECTED || ($self->state == CONNECTING && $connecting )) {
410                         my $v = $self->connect();
411                         if( ! $v ) {
412                                 $logger->debug( "Unable to connect to remote service in AppSession::send()", ERROR );
413                                 return undef;
414                         }
415                         if( $v and $v->can("class") and $v->class->isa( "OpenSRF::EX" ) ) {
416                                 return $v;
417                         }
418                 }
419         } 
420
421         $logger->debug( "AppSession sending doc: " . $doc->toString(), INTERNAL );
422
423
424         $self->{peer_handle}->send( 
425                                         to     => $self->remote_id,
426                                    thread => $self->session_id,
427                                    body   => $doc->toString );
428
429         return $self->app_request( $tT );
430 }
431
432 sub app_request {
433         my $self = shift;
434         my $tT = shift;
435         
436         return undef unless (defined $tT);
437         my ($req) = grep { $_->threadTrace == $tT } @{ $self->{request_queue} };
438
439         return $req;
440 }
441
442 sub remove_app_request {
443         my $self = shift;
444         my $req = shift;
445         
446         my @list = grep { $_->threadTrace != $req->threadTrace } @{ $self->{request_queue} };
447
448         $self->{request_queue} = \@list;
449 }
450
451 sub endpoint {
452         return $_[0]->{endpoint};
453 }
454
455
456 sub session_id {
457         my $self = shift;
458         return $self->{session_id};
459 }
460
461 sub push_queue {
462         my $self = shift;
463         my $resp = shift;
464         my $req = $self->app_request($resp->[1]);
465         return $req->push_queue( $resp->[0] ) if ($req);
466         push @{ $self->{recv_queue} }, $resp->[0];
467 }
468
469 sub last_threadTrace {
470         my $self = shift;
471         my $new_last_threadTrace = shift;
472
473         my $old_last_threadTrace = $self->{last_threadTrace};
474         if (defined $new_last_threadTrace) {
475                 $self->{last_threadTrace} = $new_last_threadTrace;
476                 return $new_last_threadTrace unless ($old_last_threadTrace);
477         }
478
479         return $old_last_threadTrace;
480 }
481
482 sub session_threadTrace {
483         my $self = shift;
484         my $new_last_threadTrace = shift;
485
486         my $old_last_threadTrace = $self->{session_threadTrace};
487         if (defined $new_last_threadTrace) {
488                 $self->{session_threadTrace} = $new_last_threadTrace;
489                 return $new_last_threadTrace unless ($old_last_threadTrace);
490         }
491
492         return $old_last_threadTrace;
493 }
494
495 sub last_message_type {
496         my $self = shift;
497         my $new_last_message_type = shift;
498
499         my $old_last_message_type = $self->{last_message_type};
500         if (defined $new_last_message_type) {
501                 $self->{last_message_type} = $new_last_message_type;
502                 return $new_last_message_type unless ($old_last_message_type);
503         }
504
505         return $old_last_message_type;
506 }
507
508 sub last_message_protocol {
509         my $self = shift;
510         my $new_last_message_protocol = shift;
511
512         my $old_last_message_protocol = $self->{last_message_protocol};
513         if (defined $new_last_message_protocol) {
514                 $self->{last_message_protocol} = $new_last_message_protocol;
515                 return $new_last_message_protocol unless ($old_last_message_protocol);
516         }
517
518         return $old_last_message_protocol;
519 }
520
521 sub remote_id {
522         my $self = shift;
523         my $new_remote_id = shift;
524
525         my $old_remote_id = $self->{remote_id};
526         if (defined $new_remote_id) {
527                 $self->{remote_id} = $new_remote_id;
528                 return $new_remote_id unless ($old_remote_id);
529         }
530
531         return $old_remote_id;
532 }
533
534 sub client_auth {
535         return undef;
536         my $self = shift;
537         my $new_ua = shift;
538
539         my $old_ua = $self->{client_auth};
540         if (defined $new_ua) {
541                 $self->{client_auth} = $new_ua;
542                 return $new_ua unless ($old_ua);
543         }
544
545         return $old_ua->cloneNode(1);
546 }
547
548 sub state {
549         my $self = shift;
550         my $new_state = shift;
551
552         my $old_state = $self->{state};
553         if (defined $new_state) {
554                 $self->{state} = $new_state;
555                 return $new_state unless ($old_state);
556         }
557
558         return $old_state;
559 }
560
561 sub DESTROY {
562         my $self = shift;
563         delete $$self{$_} for keys %$self;
564         return undef;
565 }
566
567 sub recv {
568         my $self = shift;
569         my @proto_args = @_;
570         my %args;
571
572         if ( @proto_args ) {
573                 if ( !(@proto_args % 2) ) {
574                         %args = @proto_args;
575                 } elsif (@proto_args == 1) {
576                         %args = ( timeout => @proto_args );
577                 }
578         }
579
580         #$logger->debug( ref($self). " recv_queue before wait: " . $self->_print_queue(), INTERNAL );
581
582         if( exists( $args{timeout} ) ) {
583                 $args{timeout} = int($args{timeout});
584         } else {
585                 $args{timeout} = 10;
586         }
587
588         #$args{timeout} = 0 if ($self->complete);
589
590         $logger->debug( ref($self) ."->recv with timeout " . $args{timeout}, INTERNAL );
591
592         $args{count} ||= 1;
593
594         my $avail = @{ $self->{recv_queue} };
595         my $time_remaining = $args{timeout};
596
597         while ( $avail < $args{count} and $time_remaining > 0 ) {
598                 last if $self->complete;
599                 my $starttime = time;
600                 $self->queue_wait($time_remaining);
601                 my $endtime = time;
602                 $time_remaining -= ($endtime - $starttime);
603                 $avail = @{ $self->{recv_queue} };
604         }
605
606         #$logger->debug( ref($self)." queue after wait: " . $self->_print_queue(), INTERNAL );
607                 
608         my @list;
609         while ( my $msg = shift @{ $self->{recv_queue} } ) {
610                 push @list, $msg;
611                 last if (scalar(@list) >= $args{count});
612         }
613
614 #       $self->{recv_queue} = [@unlist, @{ $self->{recv_queue} }];
615         $logger->debug( "Number of matched responses: " . @list, DEBUG );
616
617         $self->queue_wait(0); # check for statuses
618         
619         return $list[0] unless (wantarray);
620         return @list;
621 }
622
623 sub push_resend {
624         my $self = shift;
625         push @OpenSRF::AppSession::_RESEND_QUEUE, @_;
626 }
627
628 sub flush_resend {
629         my $self = shift;
630         $logger->debug( "Resending..." . @_RESEND_QUEUE, DEBUG );
631         while ( my $req = shift @OpenSRF::AppSession::_RESEND_QUEUE ) {
632                 $req->resend;
633         }
634 }
635
636
637 sub queue_wait {
638         my $self = shift;
639         if( ! $self->{peer_handle} ) { return 0; }
640         my $timeout = shift || 0;
641         $logger->debug( "Calling queue_wait($timeout)" , DEBUG );
642         $logger->debug( "Timestamp before process($timeout) : " . $logger->format_time(), INTERNAL );
643         my $o = $self->{peer_handle}->process($timeout);
644         $logger->debug( "Timestamp after  process($timeout) : " . $logger->format_time(), INTERNAL );
645         $self->flush_resend;
646         return $o;
647 }
648
649 sub _print_queue {
650         my( $self ) = @_;
651         my $string = "";
652         foreach my $msg ( @{$self->{recv_queue}} ) {
653                 $string = $string . $msg->toString(1) . "\n";
654         }
655         return $string;
656 }
657
658 sub status {
659         my $self = shift;
660         $self->send( 'STATUS', @_ );
661 }
662
663 #-------------------------------------------------------------------------------
664
665 package OpenSRF::AppRequest;
666 use base qw/OpenSRF::AppSession/;
667 use OpenSRF::Utils::Logger qw/:level/;
668 use OpenSRF::DomainObject::oilsResponse qw/:status/;
669
670 sub new {
671         my $class = shift;
672         $class = ref($class) || $class;
673
674         my $session = shift;
675         my $threadTrace = $session->session_threadTrace || $session->last_threadTrace;
676         my $payload = shift;
677         
678         my $self = {    session     => $session,
679                         threadTrace => $threadTrace,
680                         payload     => $payload,
681                         complete    => 0,
682                         recv_queue  => [],
683         };
684
685         bless $self => $class;
686
687         push @{ $self->session->{request_queue} }, $self;
688
689         return $self;
690 }
691
692 sub queue_size {
693         my $size = @{$_[0]->{recv_queue}};
694         return $size;
695 }
696         
697 sub send {
698         shift()->session->send(@_);
699 }
700
701 sub finish {
702         my $self = shift;
703         $self->session->remove_app_request($self);
704         delete($$self{$_}) for (keys %$self);
705 }
706
707 sub session {
708         return shift()->{session};
709 }
710
711 sub complete {
712         my $self = shift;
713         my $complete = shift;
714         return $self->{complete} if ($self->{complete});
715         if (defined $complete) {
716                 $self->{complete} = $complete;
717         } else {
718                 $self->session->queue_wait(0);
719         }
720         return $self->{complete};
721 }
722
723 sub wait_complete {
724         my $self = shift;
725         my $timeout = shift || 1;
726         my $time_remaining = $timeout;
727
728         while ( ! $self->complete  and $time_remaining > 0 ) {
729                 my $starttime = time;
730                 $self->queue_wait($time_remaining);
731                 my $endtime = time;
732                 $time_remaining -= ($endtime - $starttime);
733         }
734
735         return $self->complete;
736 }
737
738 sub threadTrace {
739         return shift()->{threadTrace};
740 }
741
742 sub push_queue {
743         my $self = shift;
744         my $resp = shift;
745         push @{ $self->{recv_queue} }, $resp;
746         OpenSRF::Utils::Logger->debug( "AppRequest pushed ".$resp->toString(), INTERNAL );
747 }
748
749 sub queue_wait {
750         my $self = shift;
751         OpenSRF::Utils::Logger->debug( "Calling queue_wait(@_)", DEBUG );
752         return $self->session->queue_wait(@_)
753 }
754
755 sub payload { return shift()->{payload}; }
756
757 sub resend {
758         my $self = shift;
759         OpenSRF::Utils::Logger->debug(
760                 "I'm resending the request for threadTrace ". $self->threadTrace, DEBUG);
761         OpenSRF::Utils::Logger->debug($self->payload->toString,INTERNAL);
762         return $self->session->send('REQUEST', $self->payload, $self->threadTrace );
763 }
764
765 sub status {
766         my $self = shift;
767         my $msg = shift;
768         $self->session->send( 'STATUS',$msg, $self->threadTrace );
769 }
770
771 sub respond {
772         my $self = shift;
773         my $msg = shift;
774
775         my $response;
776         if (ref($msg) && $msg->can('getAttribute') && $msg->getAttribute('name') =~ /oilsResult/) {
777                 $response = $msg;
778         } else {
779                 $response = new OpenSRF::DomainObject::oilsResult;
780                 $response->content($msg);
781         }
782
783         $self->session->send('RESULT', $response, $self->threadTrace);
784 }
785
786 sub respond_complete {
787         my $self = shift;
788         my $msg = shift;
789
790         my $response;
791         if (ref($msg) && $msg->can('getAttribute') && $msg->getAttribute('name') =~ /oilsResult/) {
792                 $response = $msg;
793         } else {
794                 $response = new OpenSRF::DomainObject::oilsResult;
795                 $response->content($msg);
796         }
797
798         my $stat = OpenSRF::DomainObject::oilsConnectStatus->new(
799                 statusCode => STATUS_COMPLETE(),
800                 status => 'Request Complete' );
801
802         $self->session->send( 'RESULT' => $response, 'STATUS' => $stat, $self->threadTrace);
803
804 }
805
806
807 1;
808
809
810 __END__
811
812 [client]
813 interval:connect_timeout = 2 seconds
814
815 [servers]
816 subsection:StorageServer = Storage_config
817
818 [Storage_config]
819 #transport = xmlrpc
820 #transport_target = http://open-ils.org/RPC2/services/Storage
821
822 transport = jabber
823 transport_target = Storage@open-ils.org/SERVICE_RECEIVER
824 method_class = OpenSRF::App::Storage::PGStore;
825
826
827
828
829