[open-ils-commits] [GIT] Evergreen ILS branch master updated. 415945711f0888eff19750df18dc0953dc012a01

Evergreen Git git at git.evergreen-ils.org
Fri Jul 1 09:49:16 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  415945711f0888eff19750df18dc0953dc012a01 (commit)
      from  ff083d56923e2314143a257a6554bf8f773cffcf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 415945711f0888eff19750df18dc0953dc012a01
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Wed Jun 29 11:34:29 2011 -0400

    Use open-ils.circ.checkout.full in SIP2.
    
    Change the SIP2 checkout code to use a single call to open-ils.
    circ.checkout.full instead of doing the whole checkout.permit
    checkout dance.
    
    Further simplify the checkout logic in O::SIP::Transaction::Checkout.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm
index bede75d..bb751b2 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm
@@ -77,76 +77,54 @@ sub do_checkout {
 
     my $override = 0;
 
+    if ($is_renew) {
+        $method = 'open-ils.circ.renew';
+    } else {
+        $method = 'open-ils.circ.checkout.full';
+    }
+
     while (1) {
-        if ($is_renew) {
-            $method = 'open-ils.circ.renew';
-            $method .= '.override' if ($override);
-            $resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $args);
-        } else {
-            $method = 'open-ils.circ.checkout.permit';
-            $method .= '.override' if ($override);
-            $resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $args);
-
-            $resp = [$resp] unless ref $resp eq 'ARRAY';
-
-            syslog('LOG_DEBUG', "OILS: $method returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
-
-            if (@$resp == 1 && !$U->event_code($$resp[0])) {
-                my $key = $$resp[0]->{payload};
-                syslog('LOG_INFO', "OILS: circ permit key => $key");
-                # --------------------------------------------------------------------
-                # Now do the actual checkout
-                # --------------------------------------------------------------------
-                my $cko_args = $args;
-                $cko_args->{permit_key} = $key;
-                $method = 'open-ils.circ.checkout';
-                $resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $cko_args);
-            } else {
-                # We got one or more non-success events
-                $self->screen_msg('');
-                for my $r (@$resp) {
-                    if ( my $code = $U->event_code($r) ) {
-                        my $txt = $r->{textcode};
-                        syslog('LOG_INFO', "OILS: $method failed with event $code : $txt");
-
-                        if ($override_events{$txt} && $method !~ /override$/) {
-                            # Found an event we've been configured to override.
-                            $override = 1;
-                        } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
-                            $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
-                            return 0;
-                        } else {
-                            $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED);
-                            return 0;
-                        }
+        $method .= '.override' if ($override);
+        $resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $args);
+
+        $resp = [$resp] unless ref $resp eq 'ARRAY';
+
+        syslog('LOG_DEBUG', "OILS: $method returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
+
+        if (@$resp > 1 || $U->event_code($$resp[0])) {
+            # We got one or more non-success events
+            $self->screen_msg('');
+            for my $r (@$resp) {
+                if ( my $code = $U->event_code($r) ) {
+                    my $txt = $r->{textcode};
+                    syslog('LOG_INFO', "OILS: $method failed with event $code : $txt");
+
+                    if ($override_events{$txt} && $method !~ /override$/) {
+                        # Found an event we've been configured to override.
+                        $override = 1;
+                    } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
+                        $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
+                        return 0;
+                    } else {
+                        $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED);
+                        return 0;
                     }
                 }
-                # This looks potentially dangerous, but we shouldn't
-                # end up here if the loop iterated with $override = 1;
-                next if ($override && $method !~ /override$/);
             }
-        }
-        syslog('LOG_INFO', "OILS: $method returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
-        # XXX Check for events
-        if ( $resp ) {
-
-            if ( my $code = $U->event_code($resp) ) {
-                my $txt = $resp->{textcode};
-                if ($override_events{$txt} && $method !~ /override$/) {
-                    $override = 1;
-                } else {
-                    syslog('LOG_INFO', "OILS: $method failed with event $code : $txt");
-                    $self->screen_msg('Checkout failed.  Please contact a librarian');
-                    last;
-                }
-            } else {
-                syslog('LOG_INFO', "OILS: $method succeeded");
+            # This looks potentially dangerous, but we shouldn't
+            # end up here if the loop iterated with $override = 1;
+            next if ($override && $method !~ /override$/);
+        } else {
+            # We appear to have success.
+            # De-arrayify the response.
+            $resp = $$resp[0];
 
-                my $circ = $resp->{payload}->{circ};
-                $self->{'due'} = OpenILS::SIP->format_date($circ->due_date, 'due');
-                $self->ok(1);
-                last;
-            }
+            syslog('LOG_INFO', "OILS: $method succeeded");
+
+            my $circ = $resp->{payload}->{circ};
+            $self->{'due'} = OpenILS::SIP->format_date($circ->due_date, 'due');
+            $self->ok(1);
+            last;
 
         }
         last if ($method =~ /override$/);

-----------------------------------------------------------------------

Summary of changes:
 .../lib/OpenILS/SIP/Transaction/Checkout.pm        |  108 ++++++++------------
 1 files changed, 43 insertions(+), 65 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list