[open-ils-commits] r13493 - in trunk/Open-ILS/src/perlmods/OpenILS/Application: . Circ (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 2 16:31:00 EDT 2009
Author: erickson
Date: 2009-07-02 16:30:56 -0400 (Thu, 02 Jul 2009)
New Revision: 13493
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm
Log:
don't throw exception when auth session is not found. just return undef. updated related code
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-07-02 18:14:16 UTC (rev 13492)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-07-02 20:30:56 UTC (rev 13493)
@@ -134,20 +134,13 @@
# throws an exception on error.
# ---------------------------------------------------------------------------
sub check_user_session {
-
my( $self, $user_session ) = @_;
my $content = $self->simplereq(
'open-ils.auth',
- 'open-ils.auth.session.retrieve', $user_session );
+ 'open-ils.auth.session.retrieve', $user_session);
- if(! $content or $self->event_code($content)) {
- throw OpenSRF::EX::ERROR
- ("Session [$user_session] cannot be authenticated" );
- }
-
- $logger->debug("Fetch user session $user_session found user " . $content->id );
-
+ return undef if (!$content) or $self->event_code($content);
return $content;
}
@@ -331,18 +324,9 @@
sub checkses {
my( $self, $session ) = @_;
- my $user; my $evt; my $e;
-
- $logger->debug("Checking user session $session");
-
- try {
- $user = $self->check_user_session($session);
- } catch Error with { $e = 1; };
-
- $logger->debug("Done checking user session $session " . (($e) ? "error = $e" : "") );
-
- if( $e or !$user ) { $evt = OpenILS::Event->new('NO_SESSION'); }
- return ( $user, $evt );
+ my $user = $self->check_user_session($session) or
+ return (undef, OpenILS::Event->new('NO_SESSION'));
+ return ($user);
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2009-07-02 18:14:16 UTC (rev 13492)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2009-07-02 20:30:56 UTC (rev 13493)
@@ -366,9 +366,9 @@
# grabbing copy trees should be available for everyone..
if(!@org_ids and $user_session) {
- my $user_obj =
- OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error
- @org_ids = ($user_obj->home_ou);
+ my($user_obj, $evt) = OpenILS::Application::AppUtils->checkses($user_session);
+ return $evt if $evt;
+ @org_ids = ($user_obj->home_ou);
}
if( $self->api_name =~ /global/ ) {
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm 2009-07-02 18:14:16 UTC (rev 13492)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm 2009-07-02 20:30:56 UTC (rev 13493)
@@ -50,7 +50,8 @@
$method = "open-ils.storage.fleshed.asset.stat_cat.retrieve.batch.atomic";
}
- my $user_obj = $apputils->check_user_session($user_session);
+ my($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
my $cats = $apputils->simple_scalar_request(
"open-ils.storage", $method, @sc);
@@ -77,7 +78,9 @@
$method = "open-ils.storage.ranged.fleshed.asset.stat_cat.all.atomic";
}
- my $user_obj = $apputils->check_user_session($user_session);
+ my($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
if(!$orgid) { $orgid = $user_obj->home_ou; }
my $cats = $apputils->simple_scalar_request(
"open-ils.storage", $method, $orgid );
@@ -93,7 +96,9 @@
sub retrieve_ranged_intersect_stat_cats {
my( $self, $client, $user_session, $orglist ) = @_;
- my $user_obj = $apputils->check_user_session($user_session);
+ my($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
if(!$orglist) { $orglist = [ $user_obj->home_ou ]; }
# uniquify, yay!
@@ -119,7 +124,9 @@
use Data::Dumper;
warn "Retrieving stat_cats with method $method and orgs " . Dumper($orglist) . "\n";
- my $user_obj = $apputils->check_user_session($user_session);
+ my($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
if(!$orglist) { $orglist = [ $user_obj->home_ou ]; }
# uniquify, yay!
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm 2009-07-02 18:14:16 UTC (rev 13492)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm 2009-07-02 20:30:56 UTC (rev 13493)
@@ -34,7 +34,9 @@
sub add_survey {
my( $self, $client, $user_session, $survey ) = @_;
- my $user_obj = $apputils->check_user_session($user_session);
+ my($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
my $session = $apputils->start_db_session();
my $err = undef; my $id;
@@ -138,7 +140,9 @@
my( $self, $client, $user_session ) = @_;
- my $user_obj = $apputils->check_user_session($user_session);
+ my ($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
my $orgid = $user_obj->ws_ou() ? $user_obj->ws_ou() : $user_obj->home_ou();
my $surveys = $apputils->simple_scalar_request(
"open-ils.storage",
@@ -161,7 +165,8 @@
my( $self, $client, $user_session, $survey_id, $user_id ) = @_;
if(!$user_id) {
- my $user_obj = $apputils->check_user_session($user_session);
+ my ($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
$user_id = $user_obj->id;
}
@@ -184,7 +189,9 @@
sub get_all_surveys {
my( $self, $client, $user_session ) = @_;
- my $user_obj = $apputils->check_user_session($user_session);
+ my ($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
my $orgid = $user_obj->ws_ou() ? $user_obj->ws_ou() : $user_obj->home_ou();
my $surveys = $apputils->simple_scalar_request(
"open-ils.storage",
@@ -295,7 +302,8 @@
if($self->api_name =~ /session/) {
if( ! ($id = $already_seen{$res->usr}) ) {
- my $user_obj = $apputils->check_user_session($res->usr);
+ my ($user_obj, $evt) = $apputils->checkses($res->usr);
+ return $evt if $evt;
$id = $user_obj->id;
$already_seen{$res->usr} = $id;
}
@@ -329,7 +337,9 @@
sub get_random_survey {
my( $self, $client, $user_session ) = @_;
- my $user_obj = $apputils->check_user_session($user_session);
+ my ($user_obj, $evt) = $apputils->checkses($user_session);
+ return $evt if $evt;
+
my $surveys = $apputils->simple_scalar_request(
"open-ils.storage",
"open-ils.storage.action.survey.opac.atomic",
More information about the open-ils-commits
mailing list