From 860c06e97c7bdbbb2c78eb186a799aafd4bf1767 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 7 Feb 2005 15:53:44 +0000 Subject: [PATCH] updating to work with the new cvs layout git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@18 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/AppSession.pm | 36 ++++++----- src/perlmods/OpenSRF/Application/Demo/Math.pm | 27 ++++---- src/perlmods/OpenSRF/Application/Demo/MathDB.pm | 72 +++------------------- src/perlmods/OpenSRF/System.pm | 9 ++- .../OpenSRF/Transport/SlimJabber/Inbound.pm | 2 +- 5 files changed, 48 insertions(+), 98 deletions(-) diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 0fa3d45..f8b46ee 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -1,6 +1,6 @@ package OpenSRF::AppSession; use OpenSRF::DOM; -use OpenSRF::DOM::Element::userAuth; +#use OpenSRF::DOM::Element::userAuth; use OpenSRF::DomainObject::oilsMessage; use OpenSRF::DomainObject::oilsMethod; use OpenSRF::DomainObject::oilsResponse qw/:status/; @@ -177,12 +177,12 @@ sub create { my %auth_args = @_; - unless ( $app && - exists($auth_args{secret}) && - ( exists($auth_args{username}) || - exists($auth_args{sysname}) ) ) { - throw OpenSRF::EX::User ( 'Insufficient authentication information for session creation'); - } +# unless ( $app && +# exists($auth_args{secret}) && +# ( exists($auth_args{username}) || +# exists($auth_args{sysname}) ) ) { +# throw OpenSRF::EX::User ( 'Insufficient authentication information for session creation'); +# } if( my $thingy = OpenSRF::AppSession->find_client( $app ) ) { $logger->debug( "AppSession returning existing client session for $app", DEBUG ); @@ -193,7 +193,7 @@ sub create { - my $auth = OpenSRF::DOM::Element::userAuth->new( %auth_args ); + #my $auth = OpenSRF::DOM::Element::userAuth->new( %auth_args ); my $conf = OpenSRF::Utils::Config->current; @@ -210,7 +210,7 @@ sub create { die("No remote id for $app!"); my $self = bless { app_name => $app, - client_auth => $auth, + #client_auth => $auth, #recv_queue => [], request_queue => [], endpoint => CLIENT, @@ -334,6 +334,7 @@ sub send { my $self = shift; my @payload_list = @_; # this is a Domain Object + $logger->debug( "In send", INTERNAL ); my $tT; @@ -377,7 +378,7 @@ sub send { $msg->type($msg_type); $logger->debug( "AppSession after adding type" . $msg->toString(), INTERNAL ); - $msg->userAuth($self->client_auth) if ($self->endpoint == CLIENT && $msg_type eq 'CONNECT'); + #$msg->userAuth($self->client_auth) if ($self->endpoint == CLIENT && $msg_type eq 'CONNECT'); no warnings; $msg->threadTrace( $tT || int($self->session_threadTrace) || int($self->last_threadTrace) ); @@ -411,7 +412,7 @@ sub send { $logger->debug( "Unable to connect to remote service in AppSession::send()", ERROR ); return undef; } - if( $v and $v->class->isa( "OpenSRF::EX" ) ) { + if( $v and $v->can("class") and $v->class->isa( "OpenSRF::EX" ) ) { return $v; } } @@ -531,6 +532,7 @@ sub remote_id { } sub client_auth { + return undef; my $self = shift; my $new_ua = shift; @@ -771,11 +773,11 @@ sub respond { my $msg = shift; my $response; - if (!ref($msg) || ($msg->can('getAttribute') && $msg->getAttribute('name') !~ /oilsResult/)) { + if (ref($msg) && $msg->can('getAttribute') && $msg->getAttribute('name') =~ /oilsResult/) { + $response = $msg; + } else { $response = new OpenSRF::DomainObject::oilsResult; $response->content($msg); - } else { - $response = $msg; } $self->session->send('RESULT', $response, $self->threadTrace); @@ -786,11 +788,11 @@ sub respond_complete { my $msg = shift; my $response; - if (!ref($msg) || ($msg->can('getAttribute') && $msg->getAttribute('name') !~ /oilsResult/)) { + if (ref($msg) && $msg->can('getAttribute') && $msg->getAttribute('name') =~ /oilsResult/) { + $response = $msg; + } else { $response = new OpenSRF::DomainObject::oilsResult; $response->content($msg); - } else { - $response = $msg; } my $stat = OpenSRF::DomainObject::oilsConnectStatus->new( diff --git a/src/perlmods/OpenSRF/Application/Demo/Math.pm b/src/perlmods/OpenSRF/Application/Demo/Math.pm index 952a9ef..2e240b8 100644 --- a/src/perlmods/OpenSRF/Application/Demo/Math.pm +++ b/src/perlmods/OpenSRF/Application/Demo/Math.pm @@ -1,15 +1,16 @@ -package OpenILS::App::Math; -use base qw/OpenILS::Application/; -use OpenILS::Application; -use OpenILS::Utils::Logger qw/:level/; -use OpenILS::DomainObject::oilsResponse; -use OpenILS::EX qw/:try/; +package OpenSRF::Application::Demo::Math; +use base qw/OpenSRF::Application/; +use OpenSRF::Application; +use OpenSRF::Utils::Logger qw/:level/; +use OpenSRF::DomainObject::oilsResponse; +use OpenSRF::DomainObject::oilsPrimitive; +use OpenSRF::EX qw/:try/; use strict; use warnings; sub DESTROY{} -our $log = 'OpenILS::Utils::Logger'; +our $log = 'OpenSRF::Utils::Logger'; #sub method_lookup { # @@ -41,12 +42,12 @@ sub send_request { my @params = @_; $log->debug( "Creating a client environment", DEBUG ); - my $session = OpenILS::AppSession->create( + my $session = OpenSRF::AppSession->create( "dbmath", sysname => 'math', secret => '12345' ); $log->debug( "Sending request to math server", INTERNAL ); - my $method = OpenILS::DomainObject::oilsMethod->new( method => $method_name ); + my $method = OpenSRF::DomainObject::oilsMethod->new( method => $method_name ); $method->params( @params ); @@ -61,20 +62,20 @@ sub send_request { my $vv = $session->connect(); if($vv) { last; } if( $nn and !$vv ) { - throw OpenILS::EX::CRITICAL ("DBMath connect attempt timed out"); + throw OpenSRF::EX::CRITICAL ("DBMath connect attempt timed out"); } } $req = $session->request( $method ); $resp = $req->recv(10); - } catch OpenILS::DomainObject::oilsAuthException with { + } catch OpenSRF::DomainObject::oilsAuthException with { my $e = shift; $e->throw(); }; $log->error("response is $resp"); - if ( defined($resp) and $resp and $resp->class->isa('OpenILS::DomainObject::oilsResult') ){ + if ( defined($resp) and $resp and $resp->class->isa('OpenSRF::DomainObject::oilsResult') ){ $log->debug( "Math server returned " . $resp->toString(1), INTERNAL ); $req->finish; @@ -87,7 +88,7 @@ sub send_request { else{ $log->debug( "Math received empty value", ERROR ); } $req->finish; $session->finish; - throw OpenILS::EX::ERROR ("Did not receive expected data from MathDB"); + throw OpenSRF::EX::ERROR ("Did not receive expected data from MathDB"); } } diff --git a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm index 24c9ff1..d4f7c36 100644 --- a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm +++ b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm @@ -1,40 +1,16 @@ -package OpenILS::App::MathDB; +package OpenSRF::Application::Demo::MathDB; use JSON; -use base qw/OpenILS::Application/; -use OpenILS::Application; -use OpenILS::DomainObject::oilsResponse qw/:status/; -use OpenILS::DomainObject::oilsPrimitive; -use OpenILS::Utils::Logger qw/:level/; +use base qw/OpenSRF::Application/; +use OpenSRF::Application; +use OpenSRF::DomainObject::oilsResponse qw/:status/; +use OpenSRF::DomainObject::oilsPrimitive; +use OpenSRF::Utils::Logger qw/:level/; use strict; use warnings; sub DESTROY{} -our $log = 'OpenILS::Utils::Logger'; +our $log = 'OpenSRF::Utils::Logger'; sub initialize {} -#sub method_lookup { -# -# my( $class, $method_name, $method_proto ) = @_; -# -# if( $method_name eq "add" ) { -# return \&add; -# } -# -# if( $method_name eq "sub" ) { -# return \⊂ -# } -# -# if( $method_name eq "mult" ) { -# return \&mult; -# } -# -# if( $method_name eq "div" ) { -# return \÷ -# } -# -# return undef; -# -#} - sub add_1 { my $client = shift; my @args = @_; @@ -45,14 +21,8 @@ sub add_1 { my $a = $n1 + $n2; return JSON::number::new($a); - - - my $result = new OpenILS::DomainObject::oilsResult; - $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); - return $a; - $client->respond($result); - return 1; } + sub sub_1 { my $client = shift; my @args = @_; @@ -62,14 +32,6 @@ sub sub_1 { $n1 =~ s/\s+//; $n2 =~ s/\s+//; my $a = $n1 - $n2; return JSON::number::new($a); - - - - my $result = new OpenILS::DomainObject::oilsResult; - $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); - return $a; - $client->respond($result); - return 1; } sub mult_1 { @@ -79,15 +41,8 @@ sub mult_1 { $log->debug("AppRequest is $client", INTERNAL); my $n1 = shift; my $n2 = shift; $n1 =~ s/\s+//; $n2 =~ s/\s+//; - my $a = JSON::number::new($n1 * $n2); - return $a; - - - - my $result = new OpenILS::DomainObject::oilsResult; - $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); -# $client->respond($result); - return $a; + my $a = $n1 * $n2; + return JSON::number::new($a); } sub div_1 { @@ -99,13 +54,6 @@ sub div_1 { $n1 =~ s/\s+//; $n2 =~ s/\s+//; my $a = $n1 / $n2; return JSON::number::new($a); - - - my $result = new OpenILS::DomainObject::oilsResult; - $result->content( JSON::number::new($a) ); - return $result; - $client->respond($a); - return 1; } 1; diff --git a/src/perlmods/OpenSRF/System.pm b/src/perlmods/OpenSRF/System.pm index d78e422..e746c8d 100644 --- a/src/perlmods/OpenSRF/System.pm +++ b/src/perlmods/OpenSRF/System.pm @@ -10,6 +10,7 @@ use OpenSRF::Utils::LogServer; use OpenSRF::DOM; use OpenSRF::EX qw/:try/; use POSIX ":sys_wait_h"; +use OpenSRF::Utils::Config; use strict; =head2 Name/Description @@ -59,7 +60,9 @@ set_config(); sub set_config { my $config = OpenSRF::Utils::Config->load( - config_file => "/pines/conf/oils.conf" ); + config_file => "/pines/conf/opensrf.conf" ); + + warn "Setting config " . $config->transport->implementation ."\n"; if( ! $config ) { throw OpenSRF::EX::Config "System could not load config"; } @@ -78,10 +81,6 @@ sub set_config { } - - - - # ---------------------------------------------- { diff --git a/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm b/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm index 9dc5ad0..931b6fc 100644 --- a/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm +++ b/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm @@ -2,7 +2,7 @@ package OpenSRF::Transport::SlimJabber::Inbound; use strict;use warnings; use base qw/OpenSRF::Transport::SlimJabber::Client/; use OpenSRF::EX; -use OpenSRF::Utils::Config; +use OpenSRF::Utils::Config; use OpenSRF::Utils::Logger qw(:level); my $logger = "OpenSRF::Utils::Logger"; -- 2.11.0