[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. 7e459294d1e49c0e3397b897fb4d4b733a23bb99

Evergreen Git git at git.evergreen-ils.org
Tue Feb 18 10:01:59 EST 2014


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  7e459294d1e49c0e3397b897fb4d4b733a23bb99 (commit)
       via  8eda1c2ab441ca2e26c6b8b18675860e890746e4 (commit)
       via  bb222e7580187965e3e722a76505ee634beb5987 (commit)
       via  0199ecdf97d6651bfb423310e7f20e10b20e151b (commit)
      from  1fefe2cecb464ea10ff4a2d0e673c2663bab086a (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 7e459294d1e49c0e3397b897fb4d4b733a23bb99
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Feb 18 08:53:59 2014 -0500

    LP#1187035 Remove OpenILS::Utils::Editor part 4.
    
    Make sure all CStoreEditors in ClosedDates run updates in transactions,
    roll back transactions on error, and commit the transactions on success.
    
    Added a live test for closed data updating.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Jeff Godin <jgodin at tadl.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
index 28cd123..46337f5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
@@ -67,12 +67,13 @@ __PACKAGE__->register_method(
 
 sub delete_date {
     my( $self, $conn, $auth, $id ) = @_;
-    my $e = new_editor(authtoken=>$auth);
-    return $e->event unless $e->checkauth;
-    my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->event;
-    return $e->event unless $e->allowed( # rely on the editor perm eventually
+    my $e = new_editor(authtoken=>$auth, xact => 1);
+    return $e->die_event unless $e->checkauth;
+    my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->die_event;
+    return $e->die_event unless $e->allowed(
         'actor.org_unit.closed_date.delete', $date->org_unit);
-    $e->delete_actor_org_unit_closed_date($date) or return $e->event;
+    $e->delete_actor_org_unit_closed_date($date) or return $e->die_event;
+    $e->commit;
     return 1;
 }
 
@@ -91,15 +92,15 @@ sub create_date {
     my( $self, $conn, $auth, $date ) = @_;
 
     my $e = new_editor(authtoken=>$auth, xact =>1);
-    return $e->event unless $e->checkauth;
+    return $e->die_event unless $e->checkauth;
     
-    return $e->event unless $e->allowed( # rely on the editor perm eventually
+    return $e->die_event unless $e->allowed(
         'actor.org_unit.closed_date.create', $date->org_unit);
 
-    $e->create_actor_org_unit_closed_date($date) or return $e->event;
+    $e->create_actor_org_unit_closed_date($date) or return $e->die_event;
 
     my $newobj = $e->retrieve_actor_org_unit_closed_date($date->id)
-        or return $e->event;
+        or return $e->die_event;
 
     $e->commit;
     return $newobj;
@@ -117,16 +118,17 @@ __PACKAGE__->register_method(
 sub edit_date {
     my( $self, $conn, $auth, $date ) = @_;
     my $e = new_editor(authtoken=>$auth, xact =>1);
-    return $e->event unless $e->checkauth;
+    return $e->die_event unless $e->checkauth;
     
     # First make sure they have the right to update the selected date object
     my $odate = $e->retrieve_actor_org_unit_closed_date($date->id) 
-        or return $e->event;
+        or return $e->die_event;
 
-    return $e->event unless $e->allowed( # rely on the editor perm eventually
+    return $e->die_event unless $e->allowed(
         'actor.org_unit.closed_date.update', $odate->org_unit);
 
-    $e->update_actor_org_unit_closed_date($date) or return $e->event;
+    $e->update_actor_org_unit_closed_date($date) or return $e->die_event;
+    $e->commit;
 
     return 1;
 }
diff --git a/Open-ILS/src/perlmods/live_t/04-overdue_with_closed_dates.t b/Open-ILS/src/perlmods/live_t/04-overdue_with_closed_dates.t
index 3f9f3f5..e00496e 100644
--- a/Open-ILS/src/perlmods/live_t/04-overdue_with_closed_dates.t
+++ b/Open-ILS/src/perlmods/live_t/04-overdue_with_closed_dates.t
@@ -1,6 +1,6 @@
 #!perl
 
-use Test::More tests => 22;
+use Test::More tests => 23;
 
 diag("Test fine generation with closed date on checkin against the admin user.");
 
@@ -45,6 +45,16 @@ sub create_closed_date {
     return $resp;
 }
 
+# returns "1" on success, event on error
+sub update_closed_date {
+    my $aoucd = shift;
+    $aoucd->reason($aoucd->reason . ' modified');
+    return $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.org_unit.closed.update',
+        $script->authtoken, $aoucd);
+}
+
 sub delete_closed_date {
     my $aoucd = shift;
     my $resp = $apputils->simplereq(
@@ -131,6 +141,12 @@ is(
     'Created a closed date for 10 days ago'
 );
 
+is(
+    update_closed_date($closed_date_obj),
+    '1',
+    'Updated closed date reason'
+);
+
 my $checkout_resp = $script->do_checkout({
     patron => 1,
     barcode => ITEM_BARCODE});

commit 8eda1c2ab441ca2e26c6b8b18675860e890746e4
Author: Jeff Godin <jgodin at tadl.org>
Date:   Mon Feb 17 22:31:28 2014 -0500

    LP#1187035 Remove OpenILS::Utils::Editor part 3.
    
    Remove obsolete lib/OpenILS/Utils/Editor.pm from MANIFEST.
    
    Signed-off-by: Jeff Godin <jgodin at tadl.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/MANIFEST b/Open-ILS/src/perlmods/MANIFEST
index 70f80d3..ba2ac1e 100644
--- a/Open-ILS/src/perlmods/MANIFEST
+++ b/Open-ILS/src/perlmods/MANIFEST
@@ -133,7 +133,6 @@ lib/OpenILS/Utils/Configure.pm
 lib/OpenILS/Utils/Cronscript.pm
 lib/OpenILS/Utils/Cronscript.pm.in
 lib/OpenILS/Utils/CStoreEditor.pm
-lib/OpenILS/Utils/Editor.pm
 lib/OpenILS/Utils/Fieldmapper.pm
 lib/OpenILS/Utils/ISBN.pm
 lib/OpenILS/Utils/Lockfile.pm

commit bb222e7580187965e3e722a76505ee634beb5987
Author: Bill Erickson <berick at esilibrary.com>
Date:   Thu Jun 6 09:21:37 2013 -0400

    LP#1187035 Remove OpenILS::Utils::Editor part 2.
    
    * Address 2 places where we were calling $e->request with a
     CStoreEditor for a storage method.  Since CStoreEditor assumes all
     calls go to open-ils.cstore, these would have failed.
    
    * While we're in a cleaning mood, remove some obsolete commented code.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Jeff Godin <jgodin at tadl.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
index ad848fd..c82a695 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
@@ -743,8 +743,12 @@ __PACKAGE__->register_method(
 
 sub circ_count {
     my( $self, $client, $copyid, $range ) = @_; 
-    my $e = new_editor();
-    return $e->request('open-ils.storage.asset.copy.circ_count', $copyid, $range);
+
+    return $U->simplereq(
+        'open-ils.storage',
+        'open-ils.storage.asset.copy.circ_count',
+        $copyid, $range
+    );
 }
 
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
index 8da4acb..26b85d2 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
@@ -231,8 +231,12 @@ sub fetch_open_noncats {
     if( $e->requestor->id ne $userid ) {
         return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); # XXX rely on editor perm
     }
-    return $e->request(
-        'open-ils.storage.action.open_non_cataloged_circulation.user', $userid );
+
+    return $U->simplereq(
+        'open-ils.storage',
+        'open-ils.storage.action.open_non_cataloged_circulation.user',
+        $userid
+    );
 }
 
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
index 4cfa23a..9baa9cd 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
@@ -60,10 +60,6 @@ __PACKAGE__->register_method(
     /
 );
 sub search_zip {
-    #my( $self, $conn, $auth, $zip ) = @_;
-    #my $e = new_editor(authtoken=>$auth);
-    #return $e->event unless $e->checkauth;
-    #return $e->event unless $e->allowed('VIEW_ZIP_DATA');
     my( $self, $conn, $zip ) = @_;
     $zip =~ s/(^\d{5}).*/$1/; # we don't care about the last 4 digits if they exist 
     return $zips{$zip};

commit 0199ecdf97d6651bfb423310e7f20e10b20e151b
Author: Jeff Godin <jgodin at tadl.org>
Date:   Sat Jun 1 00:35:37 2013 -0400

    LP#1187035 Remove OpenILS::Utils::Editor
    
    OpenILS::Utils::Editor is obsolete, yet still referenced in a number
    of places. Let's remove it.
    
    Signed-off-by: Jeff Godin <jgodin at tadl.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
index 93167f3..28cd123 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/ClosedDates.pm
@@ -2,7 +2,7 @@ package OpenILS::Application::Actor::ClosedDates;
 use base 'OpenILS::Application';
 use strict; use warnings;
 use OpenSRF::EX qw(:try);
-use OpenILS::Utils::Editor q/:funcs/;
+use OpenILS::Utils::CStoreEditor q/:funcs/;
 
 sub initialize { return 1; }
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
index 76f1cb0..ad848fd 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
@@ -26,7 +26,6 @@ use OpenILS::Event;
 use OpenSRF::EX qw(:try);
 use OpenSRF::Utils::Logger qw(:logger);
 use OpenILS::Utils::Fieldmapper;
-use OpenILS::Utils::Editor;
 use OpenILS::Utils::CStoreEditor q/:funcs/;
 use OpenILS::Const qw/:const/;
 use OpenSRF::Utils::SettingsClient;
@@ -195,7 +194,7 @@ __PACKAGE__->register_method(
 sub checkouts_by_user_opac {
     my( $self, $client, $auth, $user_id ) = @_;
 
-    my $e = OpenILS::Utils::Editor->new( authtoken => $auth );
+    my $e = new_editor( authtoken => $auth );
     return $e->event unless $e->checkauth;
     $user_id ||= $e->requestor->id;
     return $e->event unless 
@@ -744,7 +743,7 @@ __PACKAGE__->register_method(
 
 sub circ_count {
     my( $self, $client, $copyid, $range ) = @_; 
-    my $e = OpenILS::Utils::Editor->new;
+    my $e = new_editor();
     return $e->request('open-ils.storage.asset.copy.circ_count', $copyid, $range);
 }
 
@@ -835,7 +834,7 @@ __PACKAGE__->register_method(
 
 sub has_notes {
     my( $self, $conn, $authtoken, $id ) = @_;
-    my $editor = OpenILS::Utils::Editor->new(authtoken => $authtoken);
+    my $editor = new_editor(authtoken => $authtoken);
     return $editor->event unless $editor->checkauth;
 
     my $n = $editor->search_asset_copy_note(
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
index 8ec6852..8da4acb 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm
@@ -9,7 +9,6 @@ use OpenSRF::Utils qw/:datetime/;
 use OpenSRF::Utils::Logger qw(:logger);
 use OpenILS::Application::AppUtils;
 use OpenILS::Utils::Fieldmapper;
-use OpenILS::Utils::Editor;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 $Data::Dumper::Indent = 0;
 
@@ -226,7 +225,7 @@ __PACKAGE__->register_method(
 
 sub fetch_open_noncats {
     my( $self, $conn, $auth, $userid ) = @_;
-    my $e = OpenILS::Utils::Editor->new( authtoken => $auth );
+    my $e = new_editor( authtoken => $auth );
     return $e->event unless $e->checkauth;
     $userid ||= $e->requestor->id;
     if( $e->requestor->id ne $userid ) {
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
index 0c0d649..25cf4e5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
@@ -1778,7 +1778,6 @@ sub biblio_mrid_check_mvr {
 
 sub _grab_metarecord {
     my $mrid = shift;
-    #my $e = OpenILS::Utils::Editor->new;
     my $e = new_editor();
     my $mr = $e->retrieve_metabib_metarecord($mrid) or return ( undef, $e->event );
     return ($mr);
@@ -1796,7 +1795,6 @@ __PACKAGE__->register_method(
 sub biblio_mrid_make_modsbatch {
     my( $self, $client, $mrid ) = @_;
 
-    #my $e = OpenILS::Utils::Editor->new;
     my $e = new_editor();
 
     my $mr;
@@ -1850,7 +1848,6 @@ sub biblio_mrid_make_modsbatch {
     my $string = OpenSRF::Utils::JSON->perl2JSON($mods->decast);
     $mr->mods($string);
 
-    #$e = OpenILS::Utils::Editor->new(xact => 1);
     $e = new_editor(xact => 1);
     $e->update_metabib_metarecord($mr) 
         or $logger->error("Error setting mods text on metarecord $mrid : " . Dumper($e->event));
@@ -2597,7 +2594,6 @@ __PACKAGE__->register_method(
 sub fetch_slim_record {
     my( $self, $conn, $ids ) = @_;
 
-#my $editor = OpenILS::Utils::Editor->new;
     my $editor = new_editor();
     my @res;
     for( @$ids ) {
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
index 57f468b..4cfa23a 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Zips.pm
@@ -5,7 +5,6 @@ use strict; use warnings;
 use OpenSRF::EX qw(:try);
 use OpenSRF::Utils::Logger qw/$logger/;
 use OpenILS::Application::AppUtils;
-use OpenILS::Utils::Editor;
 use OpenSRF::Utils::SettingsClient;
 
 use open ':utf8';
@@ -62,7 +61,7 @@ __PACKAGE__->register_method(
 );
 sub search_zip {
     #my( $self, $conn, $auth, $zip ) = @_;
-    #my $e = OpenILS::Utils::Editor->new(authtoken=>$auth);
+    #my $e = new_editor(authtoken=>$auth);
     #return $e->event unless $e->checkauth;
     #return $e->event unless $e->allowed('VIEW_ZIP_DATA');
     my( $self, $conn, $zip ) = @_;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/Editor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/Editor.pm
deleted file mode 100644
index 2a6b7e6..0000000
--- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/Editor.pm
+++ /dev/null
@@ -1,544 +0,0 @@
-use strict; use warnings;
-package OpenILS::Utils::Editor;
-use OpenILS::Application::AppUtils;
-use OpenSRF::AppSession;
-use OpenSRF::EX qw(:try);
-use OpenILS::Utils::Fieldmapper;
-use OpenILS::Event;
-use Data::Dumper;
-use OpenSRF::Utils::JSON;
-use OpenSRF::Utils::Logger qw($logger);
-my $U = "OpenILS::Application::AppUtils";
-
-
-# -----------------------------------------------------------------------------
-# Export some useful functions
-# -----------------------------------------------------------------------------
-use vars qw(@EXPORT_OK %EXPORT_TAGS);
-use Exporter;
-use base qw/Exporter/;
-push @EXPORT_OK, 'new_editor';
-%EXPORT_TAGS = ( funcs => [ qw/ new_editor / ] );
-
-sub new_editor { return OpenILS::Utils::Editor->new(@_); }
-
-
-# -----------------------------------------------------------------------------
-# These need to be auto-generated
-# -----------------------------------------------------------------------------
-my %PERMS = (
-    'biblio.record_entry' => { update   => 'UPDATE_MARC'       },
-    'asset.copy'          => { update   => 'UPDATE_COPY'       },
-    'asset.call_number'   => { update   => 'UPDATE_VOLUME'     },
-    'action.circulation'  => { retrieve => 'VIEW_CIRCULATIONS' },
-);
-
-use constant E => 'error';
-use constant W => 'warn';
-use constant I => 'info';
-use constant D => 'debug';
-use constant A => 'activity';
-
-
-
-# -----------------------------------------------------------------------------
-# Params include:
-#   xact=><true> : creates a storage transaction
-#   authtoken=>$token : the login session key
-# -----------------------------------------------------------------------------
-sub new {
-    my( $class, %params ) = @_;
-    $class = ref($class) || $class;
-    my $self = bless( \%params, $class );
-    $self->{checked_perms} = {};
-    return $self;
-}
-
-# -----------------------------------------------------------------------------
-# Log the editor metadata along with the log string
-# -----------------------------------------------------------------------------
-sub log {
-    my( $self, $lev, $str ) = @_;
-    my $s = "editor[";
-    $s .= "0|" unless $self->{xact};
-    $s .= "1|" if $self->{xact};
-    $s .= "0" unless $self->requestor;
-    $s .= $self->requestor->id if $self->requestor;
-    $s .= "]";
-    $logger->$lev("$s $str");
-}
-
-# -----------------------------------------------------------------------------
-# Verifies the auth token and fetches the requestor object
-# -----------------------------------------------------------------------------
-sub checkauth {
-    my $self = shift;
-    $self->log(D, "checking auth token ".$self->authtoken);
-    my ($reqr, $evt) = $U->checkses($self->authtoken);
-    $self->event($evt) if $evt;
-    return $self->{requestor} = $reqr;
-}
-
-
-# -----------------------------------------------------------------------------
-# Returns the last generated event
-# -----------------------------------------------------------------------------
-sub event {
-    my( $self, $evt ) = @_;
-    $self->{event} = $evt if $evt;
-    return $self->{event};
-}
-
-# -----------------------------------------------------------------------------
-# Clears the last caught event
-# -----------------------------------------------------------------------------
-sub clear_event {
-    my $self = shift;
-    $self->{event} = undef;
-}
-
-sub authtoken {
-    my( $self, $auth ) = @_;
-    $self->{authtoken} = $auth if $auth;
-    return $self->{authtoken};
-}
-
-# -----------------------------------------------------------------------------
-# fetches the session, creating if necessary.  If 'xact' is true on this
-# object, a db session is created
-# -----------------------------------------------------------------------------
-sub session {
-    my( $self, $session ) = @_;
-    $self->{session} = $session if $session;
-
-    if(!$self->{session}) {
-        $self->{session} = OpenSRF::AppSession->create('open-ils.storage');
-
-        if( ! $self->{session} ) {
-            my $str = "Error creating storage session with OpenSRF::AppSession->create()!";
-            $self->log(E, $str);
-            throw OpenSRF::EX::ERROR ($str);
-        }
-
-        $self->{session}->connect if $self->{xact} or $self->{connect};
-        $self->xact_start if $self->{xact};
-    }
-    return $self->{session};
-}
-
-
-# -----------------------------------------------------------------------------
-# Starts a storage transaction
-# -----------------------------------------------------------------------------
-sub xact_start {
-    my $self = shift;
-    $self->log(D, "starting new db session");
-    my $stat = $self->request('open-ils.storage.transaction.begin');
-    $self->log(E, "error starting database transaction") unless $stat;
-    if($self->authtoken) {
-        if(!$self->requestor) {
-            $self->checkauth;
-        }
-        my $user_id = undef;
-        my $ws_id = undef;
-        if($self->requestor) {
-            $user_id = $self->requestor->id;
-            $ws_id = $self->requestor->wsid;
-        }
-        $self->request('open-ils.storage.set_audit_info', $self->authtoken, $user_id, $ws_id);
-    }
-    return $stat;
-}
-
-# -----------------------------------------------------------------------------
-# Commits a storage transaction
-# -----------------------------------------------------------------------------
-sub xact_commit {
-    my $self = shift;
-    $self->log(D, "comitting db session");
-    my $stat = $self->request('open-ils.storage.transaction.commit');
-    $self->log(E, "error comitting database transaction") unless $stat;
-    return $stat;
-}
-
-# -----------------------------------------------------------------------------
-# Rolls back a storage stransaction
-# -----------------------------------------------------------------------------
-sub xact_rollback {
-    my $self = shift;
-    $self->log(I, "rolling back db session");
-    return $self->request("open-ils.storage.transaction.rollback");
-}
-
-
-# -----------------------------------------------------------------------------
-# commits the db session and destroys the session
-# -----------------------------------------------------------------------------
-sub commit {
-    my $self = shift;
-    return unless $self->{xact};
-    $self->xact_commit;
-    $self->session->disconnect;
-    $self->{session} = undef;
-}
-
-# -----------------------------------------------------------------------------
-# clears all object data. Does not commit the db transaction.
-# -----------------------------------------------------------------------------
-sub reset {
-    my $self = shift;
-    $self->session->disconnect if $self->{session};
-    $$self{$_} = undef for (keys %$self);
-}
-
-
-# -----------------------------------------------------------------------------
-# commits and resets
-# -----------------------------------------------------------------------------
-sub finish {
-    my $self = shift;
-    $self->commit;
-    $self->reset;
-}
-
-
-
-# -----------------------------------------------------------------------------
-# Does a simple storage request
-# -----------------------------------------------------------------------------
-sub request {
-    my( $self, $method, @params ) = @_;
-
-    my $val;
-    my $err;
-    my $argstr = __arg_to_string( (scalar(@params)) == 1 ? $params[0] : \@params);
-
-    $self->log(I, "request $method : $argstr");
-    
-    try {
-        $val = $self->session->request($method, @params)->gather(1);
-
-    } catch Error with {
-        $err = shift;
-        $self->log(E, "request error $method : $argstr : $err");
-    };
-
-    throw $err if $err;
-    return $val;
-}
-
-
-# -----------------------------------------------------------------------------
-# Sets / Returns the requstor object.  This is set when checkauth succeeds.
-# -----------------------------------------------------------------------------
-sub requestor {
-    my($self, $requestor) = @_;
-    $self->{requestor} = $requestor if $requestor;
-    return $self->{requestor};
-}
-
-
-
-# -----------------------------------------------------------------------------
-# Holds the last data received from a storage call
-# -----------------------------------------------------------------------------
-sub data {
-    my( $self, $data ) = @_;
-    $self->{data} = $data if defined $data;
-    return $self->{data};
-}
-
-
-# -----------------------------------------------------------------------------
-# True if this perm has already been checked at this org
-# -----------------------------------------------------------------------------
-sub perm_checked {
-    my( $self, $perm, $org ) = @_;
-    $self->{checked_perms}->{$org} = {}
-        unless $self->{checked_perms}->{$org};
-    my $checked = $self->{checked_perms}->{$org}->{$perm};
-    if(!$checked) {
-        $self->{checked_perms}->{$org}->{$perm} = 1;
-        return 0;
-    }
-    return 1;
-}
-
-
-
-# -----------------------------------------------------------------------------
-# Returns true if the requested perm is allowed.  If the perm check fails,
-# $e->event is set and undef is returned
-# The perm user is $e->requestor->id and perm org defaults to the requestor's
-# ws_ou
-# If this perm at the given org has already been verified, true is returned
-# and the perm is not re-checked
-# -----------------------------------------------------------------------------
-sub allowed {
-    my( $self, $perm, $org ) = @_;
-    my $uid = $self->requestor->id;
-    $org ||= $self->requestor->ws_ou;
-    $self->log(I, "checking perms user=$uid, org=$org, perm=$perm");
-    return 1 if $self->perm_checked($perm, $org); 
-    return $self->checkperm($uid, $org, $perm);
-}
-
-sub checkperm {
-    my($self, $userid, $org, $perm) = @_;
-    my $s = $self->request(
-        "open-ils.storage.permission.user_has_perm", $userid, $perm, $org );
-
-    if(!$s) {
-        my $e = OpenILS::Event->new('PERM_FAILURE', ilsperm => $perm, ilspermloc => $org);
-        $self->event($e);
-        return undef;
-    }
-
-    return 1;
-}
-
-
-
-# -----------------------------------------------------------------------------
-# checks the appropriate perm for the operation
-# -----------------------------------------------------------------------------
-sub _checkperm {
-    my( $self, $ptype, $action, $org ) = @_;
-    $org ||= $self->requestor->ws_ou;
-    my $perm = $PERMS{$ptype}{$action};
-    if( $perm ) {
-        return undef if $self->perm_checked($perm, $org);
-        return $self->event unless $self->allowed($perm, $org);
-    } else {
-        $self->log(E, "no perm provided for $ptype.$action");
-    }
-    return undef;
-}
-
-
-
-# -----------------------------------------------------------------------------
-# Logs update actions to the activity log
-# -----------------------------------------------------------------------------
-sub log_activity {
-    my( $self, $type, $action, $arg ) = @_;
-    my $str = "$type.$action";
-    $str .= _prop_string($arg);
-    $self->log(A, $str);
-}
-
-
-
-sub _prop_string {
-    my $obj = shift;
-    my @props = $obj->properties;
-    my $str = "";
-    for(@props) {
-        my $prop = $obj->$_() || "";
-        $prop = substr($prop, 0, 128) . "..." if length $prop > 131;
-        $str .= " $_=$prop";
-    }
-    return $str;
-}
-
-
-sub __arg_to_string {
-    my $arg = shift;
-    return "" unless defined $arg;
-    return $arg->id if UNIVERSAL::isa($arg, "Fieldmapper");
-    return OpenSRF::Utils::JSON->perl2JSON($arg);
-}
-
-
-# -----------------------------------------------------------------------------
-# This does the actual storage query.
-#
-# 'search' calls become search_where calls and $arg can be a search hash or
-# an array-ref of storage search options.  
-#
-# 'retrieve' expects an id
-# 'update' expects an object
-# 'create' expects an object
-# 'delete' expects an object
-#
-# All methods return true on success and undef on failure.  On failure, 
-# $e->event is set to the generated event.  
-# Note: this method assumes that updating a non-changed object and 
-# thereby receiving a 0 from storage, is a successful update.  
-#
-# The method will therefore return true so the caller can just do 
-# $e->update_blah($x) or return $e->event;
-# The true value returned from storage for all methods will be stored in 
-# $e->data, until the next method is called.
-#
-# not-found events are generated on retrieve and serach methods.
-# action=search methods will return [] (==true) if no data is found.  If the
-# caller is interested in the not found event, they can do:  
-# return $e->event unless @$results; 
-# -----------------------------------------------------------------------------
-sub runmethod {
-    my( $self, $action, $type, $arg, $options ) = @_;
-
-    my @arg = ($arg);
-    my $method = "open-ils.storage.direct.$type.$action";
-
-    if( $action eq 'search' ) {
-        $method =~ s/search/search_where/o;
-        $method =~ s/direct/id_list/o if $options->{idlist};
-        $method = "$method.atomic";
-        @arg = @$arg if ref($arg) eq 'ARRAY';
-
-    } elsif( $action eq 'batch_retrieve' ) {
-        $method =~ s/batch_retrieve/batch.retrieve/o;
-        $method = "$method.atomic";
-        @arg = @$arg if ref($arg) eq 'ARRAY';
-
-    } elsif( $action eq 'retrieve_all' ) {
-        $method =~ s/retrieve_all/retrieve.all.atomic/o;
-    }
-
-    # remove any stale events
-    $self->clear_event;
-
-    if( $action eq 'update' or $action eq 'delete' or $action eq 'create' ) {
-        $self->log_activity($type, $action, $arg);
-    }
-
-    if($$options{checkperm}) {
-        my $a = ($action eq 'search' or 
-            $action eq 'batch_retrieve' or $action eq 'retrieve_all') ? 'retrieve' : $action;
-        my $e = $self->_checkperm($type, $a, $$options{permorg});
-        if($e) {
-            $self->event($e);
-            return undef;
-        }
-    }
-
-    my $obj; 
-    my $err;
-
-    try {
-        $obj = $self->request($method, @arg);
-    } catch Error with { $err = shift; };
-    
-
-    if(!defined $obj) {
-        $self->log(I, "request returned no data");
-
-        if( $action eq 'retrieve' ) {
-            $self->event(_mk_not_found($type, $arg));
-
-        } elsif( $action eq 'update' or 
-                $action eq 'delete' or $action eq 'create' ) {
-            my $evt = OpenILS::Event->new(
-                'DATABASE_UPDATE_FAILED', payload => $arg, debug => "$err" );
-            $self->event($evt);
-        }
-
-        if( $err ) {
-            $self->event( 
-                OpenILS::Event->new( 'DATABASE_QUERY_FAILED', 
-                    payload => $arg, debug => "$err" ));
-            return undef;
-        }
-
-        return undef;
-    }
-
-    if( $action eq 'create' and $obj == 0 ) {
-        my $evt = OpenILS::Event->new(
-            'DATABASE_UPDATE_FAILED', payload => $arg, debug => "$err" );
-        $self->event($evt);
-        return undef;
-    }
-
-    # If we havn't dealt with the error in a nice way, go ahead and throw it
-    if( $err ) {
-        $self->event( 
-            OpenILS::Event->new( 'DATABASE_QUERY_FAILED', 
-                payload => $arg, debug => "$err" ));
-        return undef;
-    }
-
-    if( $action eq 'search' or $action eq 'batch_retrieve' or $action eq 'retrieve_all') {
-        $self->log(I, "$type.$action : returned ".scalar(@$obj). " result(s)");
-        $self->event(_mk_not_found($type, $arg)) unless @$obj;
-    }
-
-    $arg->id($obj) if $action eq 'create'; # grabs the id on create
-    $self->data($obj); # cache the data for convenience
-
-    return ($obj) ? $obj : 1;
-}
-
-
-sub _mk_not_found {
-    my( $type, $arg ) = @_;
-    (my $t = $type) =~ s/\./_/og;
-    $t = uc($t);
-    return OpenILS::Event->new("${t}_NOT_FOUND", payload => $arg);
-}
-
-
-
-# utility method for loading
-sub __fm2meth { 
-    my $str = shift;
-    my $sep = shift;
-    $str =~ s/Fieldmapper:://o;
-    $str =~ s/::/$sep/g;
-    return $str;
-}
-
-
-# -------------------------------------------------------------
-# Load up the methods from the FM classes
-# -------------------------------------------------------------
-my $map = $Fieldmapper::fieldmap;
-for my $object (keys %$map) {
-    my $obj = __fm2meth($object,'_');
-    my $type = __fm2meth($object, '.');
-
-    my $update = "update_$obj";
-    my $updatef = 
-        "sub $update {return shift()->runmethod('update', '$type', \@_);}";
-    eval $updatef;
-
-    my $retrieve = "retrieve_$obj";
-    my $retrievef = 
-        "sub $retrieve {return shift()->runmethod('retrieve', '$type', \@_);}";
-    eval $retrievef;
-
-    my $search = "search_$obj";
-    my $searchf = 
-        "sub $search {return shift()->runmethod('search', '$type', \@_);}";
-    eval $searchf;
-
-    my $create = "create_$obj";
-    my $createf = 
-        "sub $create {return shift()->runmethod('create', '$type', \@_);}";
-    eval $createf;
-
-    my $delete = "delete_$obj";
-    my $deletef = 
-        "sub $delete {return shift()->runmethod('delete', '$type', \@_);}";
-    eval $deletef;
-
-    my $bretrieve = "batch_retrieve_$obj";
-    my $bretrievef = 
-        "sub $bretrieve {return shift()->runmethod('batch_retrieve', '$type', \@_);}";
-    eval $bretrievef;
-
-    my $retrieveall = "retrieve_all_$obj";
-    my $retrieveallf = 
-        "sub $retrieveall {return shift()->runmethod('retrieve_all', '$type', \@_);}";
-    eval $retrieveallf;
-
-
-}
-
-
-
-1;
-
-
diff --git a/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t b/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t
index c9de288..e02a8e2 100644
--- a/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t
+++ b/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t
@@ -1,13 +1,12 @@
 #!perl -T
 
-use Test::More tests => 32;
+use Test::More tests => 31;
 use Test::Warn;
 use utf8;
 
 use_ok( 'OpenILS::Utils::Configure' );
 use_ok( 'OpenILS::Utils::Cronscript' );
 use_ok( 'OpenILS::Utils::CStoreEditor' );
-use_ok( 'OpenILS::Utils::Editor' );
 use_ok( 'OpenILS::Utils::Fieldmapper' );
 use_ok( 'OpenILS::Utils::ISBN' );
 use_ok( 'OpenILS::Utils::Lockfile' );

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

Summary of changes:
 Open-ILS/src/perlmods/MANIFEST                     |    1 -
 .../lib/OpenILS/Application/Actor/ClosedDates.pm   |   30 +-
 .../src/perlmods/lib/OpenILS/Application/Circ.pm   |   13 +-
 .../lib/OpenILS/Application/Circ/NonCat.pm         |   11 +-
 .../lib/OpenILS/Application/Search/Biblio.pm       |    4 -
 .../lib/OpenILS/Application/Search/Zips.pm         |    5 -
 Open-ILS/src/perlmods/lib/OpenILS/Utils/Editor.pm  |  544 --------------------
 .../perlmods/live_t/04-overdue_with_closed_dates.t |   18 +-
 Open-ILS/src/perlmods/t/14-OpenILS-Utils.t         |    3 +-
 9 files changed, 49 insertions(+), 580 deletions(-)
 delete mode 100644 Open-ILS/src/perlmods/lib/OpenILS/Utils/Editor.pm


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list