somehow forgot to add the billing_type field
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Proxy.pm
1 package OpenILS::Application::Proxy;
2 use strict; use warnings;
3 use base qw/OpenSRF::Application/;
4 use OpenSRF::EX qw(:try);
5
6
7 __PACKAGE__->register_method(
8         method  => "proxy",
9         api_name        => "open-ils.proxy.proxy",
10         stream  => 1,
11 );
12
13
14 sub proxy {
15         my($self, $client, $user_session, 
16                         $server, $method, @params) = @_;
17
18         warn "$user_session - $server - $method\n";
19
20         throw OpenSRF::EX::ERROR ("Not enough args to proxy")
21                 unless ($user_session and $server and $method);
22
23
24         my $session = OpenSRF::AppSession->create($server);
25         my $request = $session->request( $method, @params );
26         if(!$request) {
27                 throw OpenSRF::EX::ERROR 
28                         ("No request built on call to session->request( $method, @params )");
29         }
30         
31         $request->wait_complete;
32
33         if( $request->failed() ) { 
34
35                 throw OpenSRF::EX::ERROR
36                         ($request->failed()->stringify());
37
38         } else {
39
40                 while( my $response = $request->recv ) {
41                         $client->respond( $response->content );
42                 }
43         }
44
45         $request->finish();
46         $session->finish();
47         $session->disconnect();
48
49         return undef;
50 }
51
52 1;