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/;
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 );
- my $auth = OpenSRF::DOM::Element::userAuth->new( %auth_args );
+ #my $auth = OpenSRF::DOM::Element::userAuth->new( %auth_args );
my $conf = OpenSRF::Utils::Config->current;
die("No remote id for $app!");
my $self = bless { app_name => $app,
- client_auth => $auth,
+ #client_auth => $auth,
#recv_queue => [],
request_queue => [],
endpoint => CLIENT,
my $self = shift;
my @payload_list = @_; # this is a Domain Object
+
$logger->debug( "In send", INTERNAL );
my $tT;
$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) );
$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;
}
}
}
sub client_auth {
+ return undef;
my $self = shift;
my $new_ua = shift;
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);
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(
-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 {
#
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 );
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;
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");
}
}
-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 = @_;
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 = @_;
$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 {
$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 {
$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;
use OpenSRF::DOM;
use OpenSRF::EX qw/:try/;
use POSIX ":sys_wait_h";
+use OpenSRF::Utils::Config;
use strict;
=head2 Name/Description
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"; }
}
-
-
-
-
# ----------------------------------------------
{
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";