Excise unused code, and port to cstore
authorMike Rylander <mrylander@gmail.com>
Sun, 7 Apr 2013 02:41:45 +0000 (22:41 -0400)
committerMike Rylander <mrylander@gmail.com>
Sun, 7 Apr 2013 02:41:45 +0000 (22:41 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>

src/perl/lib/ShareStuff/Actor.pm
src/perl/lib/ShareStuff/AppUtils.pm

index 289dcdd..122f2d3 100644 (file)
@@ -337,7 +337,6 @@ sub update_patron {
        $evt = check_group_perm($session, $user_obj, $patron);
        return $evt if $evt;
 
-       $apputils->set_audit_info($session, $user_session, $user_obj->id, $user_obj->wsid);
 
        # $new_patron is the patron in progress.  $patron is the original patron
        # passed in with the method.  new_patron will change as the components
@@ -439,21 +438,20 @@ sub _add_patron {
        return (undef, $evt) if $evt;
 
        my $ex = $session->request(
-               'open-ils.storage.direct.actor.user.search.usrname', $patron->usrname())->gather(1);
+               'open-ils.cstore.direct.actor.user.search', { 'usrname' => $patron->usrname() })->gather(1);
        if( $ex and @$ex ) {
                return (undef, ShareStuff::Event->new('USERNAME_EXISTS'));
        }
 
        $logger->info("Creating new user in the DB with username: ".$patron->usrname());
 
-       my $id = $session->request(
-               "open-ils.storage.direct.actor.user.create", $patron)->gather(1);
+       my $usr = $session->request(
+               "open-ils.cstore.direct.actor.user.create", $patron)->gather(1);
        return (undef, $U->DB_UPDATE_FAILED($patron)) unless $id;
 
-       $logger->info("Successfully created new user [$id] in DB");
+       $logger->info("Successfully created new user [".$usr->id."] in DB");
 
-       return ( $session->request( 
-               "open-ils.storage.direct.actor.user.retrieve", $id)->gather(1), undef );
+       return ( $usr, undef );
 }
 
 
@@ -465,7 +463,7 @@ sub check_group_perm {
        # priveleges to update this user in any way
        if( ! $patron->isnew ) {
                my $p = $session->request(
-                       'open-ils.storage.direct.actor.user.retrieve', $patron->id )->gather(1);
+                       'open-ils.cstore.direct.actor.user.retrieve', $patron->id )->gather(1);
 
                # If we are the requestor (trying to update our own account)
                # and we are not trying to change our profile, we're good
@@ -498,7 +496,7 @@ sub group_perm_failed {
 
                $logger->debug("user update looking for group perm for group $grpid");
                $grp = $session->request(
-                       'open-ils.storage.direct.permission.grp_tree.retrieve', $grpid )->gather(1);
+                       'open-ils.cstore.direct.permission.grp_tree.retrieve', $grpid )->gather(1);
                return ShareStuff::Event->new('PERMISSION_GRP_TREE_NOT_FOUND') unless $grp;
 
        } while( !($perm = $grp->application_perm) and ($grpid = $grp->parent) );
@@ -525,25 +523,13 @@ sub _update_patron {
                return (undef, $evt) if $evt;
        }
 
-       # update the password by itself to avoid the password protection magic
-       if( $patron->passwd ) {
-               my $s = $session->request(
-                       'open-ils.storage.direct.actor.user.remote_update',
-                       {id => $patron->id}, {passwd => $patron->passwd})->gather(1);
-               return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($s);
-               $patron->clear_passwd;
-       }
-
        if(!$patron->ident_type) {
                $patron->clear_ident_type;
                $patron->clear_ident_value;
        }
 
-    $evt = verify_last_xact($session, $patron);
-    return (undef, $evt) if $evt;
-
        my $stat = $session->request(
-               "open-ils.storage.direct.actor.user.update",$patron )->gather(1);
+               "open-ils.cstore.direct.actor.user.update",$patron )->gather(1);
        return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($stat);
 
        return ($patron);
@@ -553,7 +539,7 @@ sub verify_last_xact {
     my( $session, $patron ) = @_;
     return undef unless $patron->id and $patron->id > 0;
     my $p = $session->request(
-        'open-ils.storage.direct.actor.user.retrieve', $patron->id)->gather(1);
+        'open-ils.cstore.direct.actor.user.retrieve', $patron->id)->gather(1);
     my $xact = $p->last_xact_id;
     return undef unless $xact;
     $logger->info("user xact = $xact, saving with xact " . $patron->last_xact_id);
@@ -563,303 +549,6 @@ sub verify_last_xact {
 }
 
 
-sub _check_dup_ident {
-       my( $session, $patron ) = @_;
-
-       return undef unless $patron->ident_value;
-
-       my $search = {
-               ident_type      => $patron->ident_type, 
-               ident_value => $patron->ident_value,
-       };
-
-       $logger->debug("patron update searching for dup ident values: " . 
-               $patron->ident_type . ':' . $patron->ident_value);
-
-       $search->{id} = {'!=' => $patron->id} if $patron->id and $patron->id > 0;
-
-       my $dups = $session->request(
-               'open-ils.storage.direct.actor.user.search_where.atomic', $search )->gather(1);
-
-
-       return ShareStuff::Event->new('PATRON_DUP_IDENT1', payload => $patron )
-               if $dups and @$dups;
-
-       return undef;
-}
-
-
-sub _add_update_addresses {
-
-       my $session = shift;
-       my $patron = shift;
-       my $new_patron = shift;
-
-       my $evt;
-
-       my $current_id; # id of the address before creation
-
-       my $addresses = $patron->addresses();
-
-       for my $address (@$addresses) {
-
-               next unless ref $address;
-               $current_id = $address->id();
-
-               if( $patron->billing_address() and
-                       $patron->billing_address() == $current_id ) {
-                       $logger->info("setting billing addr to $current_id");
-                       $new_patron->billing_address($address->id());
-                       $new_patron->ischanged(1);
-               }
-       
-               if( $patron->mailing_address() and
-                       $patron->mailing_address() == $current_id ) {
-                       $new_patron->mailing_address($address->id());
-                       $logger->info("setting mailing addr to $current_id");
-                       $new_patron->ischanged(1);
-               }
-
-
-               if($address->isnew()) {
-
-                       $address->usr($new_patron->id());
-
-                       ($address, $evt) = _add_address($session,$address);
-                       return (undef, $evt) if $evt;
-
-                       # we need to get the new id
-                       if( $patron->billing_address() and 
-                                       $patron->billing_address() == $current_id ) {
-                               $new_patron->billing_address($address->id());
-                               $logger->info("setting billing addr to $current_id");
-                               $new_patron->ischanged(1);
-                       }
-
-                       if( $patron->mailing_address() and
-                                       $patron->mailing_address() == $current_id ) {
-                               $new_patron->mailing_address($address->id());
-                               $logger->info("setting mailing addr to $current_id");
-                               $new_patron->ischanged(1);
-                       }
-
-               } elsif($address->ischanged() ) {
-
-                       ($address, $evt) = _update_address($session, $address);
-                       return (undef, $evt) if $evt;
-
-               } elsif($address->isdeleted() ) {
-
-                       if( $address->id() == $new_patron->mailing_address() ) {
-                               $new_patron->clear_mailing_address();
-                               ($new_patron, $evt) = _update_patron($session, $new_patron);
-                               return (undef, $evt) if $evt;
-                       }
-
-                       if( $address->id() == $new_patron->billing_address() ) {
-                               $new_patron->clear_billing_address();
-                               ($new_patron, $evt) = _update_patron($session, $new_patron);
-                               return (undef, $evt) if $evt;
-                       }
-
-                       $evt = _delete_address($session, $address);
-                       return (undef, $evt) if $evt;
-               } 
-       }
-
-       return ( $new_patron, undef );
-}
-
-
-# adds an address to the db and returns the address with new id
-sub _add_address {
-       my($session, $address) = @_;
-       $address->clear_id();
-
-       $logger->info("Creating new address at street ".$address->street1);
-
-       # put the address into the database
-       my $id = $session->request(
-               "open-ils.storage.direct.actor.user_address.create", $address )->gather(1);
-       return (undef, $U->DB_UPDATE_FAILED($address)) unless $id;
-
-       $address->id( $id );
-       return ($address, undef);
-}
-
-
-sub _update_address {
-       my( $session, $address ) = @_;
-
-       $logger->info("Updating address ".$address->id." in the DB");
-
-       my $stat = $session->request(
-               "open-ils.storage.direct.actor.user_address.update", $address )->gather(1);
-
-       return (undef, $U->DB_UPDATE_FAILED($address)) unless defined($stat);
-       return ($address, undef);
-}
-
-
-
-sub _add_update_cards {
-
-       my $session = shift;
-       my $patron = shift;
-       my $new_patron = shift;
-
-       my $evt;
-
-       my $virtual_id; #id of the card before creation
-
-       my $cards = $patron->cards();
-       for my $card (@$cards) {
-
-               $card->usr($new_patron->id());
-
-               if(ref($card) and $card->isnew()) {
-
-                       $virtual_id = $card->id();
-                       ( $card, $evt ) = _add_card($session,$card);
-                       return (undef, $evt) if $evt;
-
-                       #if(ref($patron->card)) { $patron->card($patron->card->id); }
-                       if($patron->card() == $virtual_id) {
-                               $new_patron->card($card->id());
-                               $new_patron->ischanged(1);
-                       }
-
-               } elsif( ref($card) and $card->ischanged() ) {
-                       $evt = _update_card($session, $card);
-                       return (undef, $evt) if $evt;
-               }
-       }
-
-       return ( $new_patron, undef );
-}
-
-
-# adds an card to the db and returns the card with new id
-sub _add_card {
-       my( $session, $card ) = @_;
-       $card->clear_id();
-
-       $logger->info("Adding new patron card ".$card->barcode);
-
-       my $id = $session->request(
-               "open-ils.storage.direct.actor.card.create", $card )->gather(1);
-       return (undef, $U->DB_UPDATE_FAILED($card)) unless $id;
-       $logger->info("Successfully created patron card $id");
-
-       $card->id($id);
-       return ( $card, undef );
-}
-
-
-# returns event on error.  returns undef otherwise
-sub _update_card {
-       my( $session, $card ) = @_;
-       $logger->info("Updating patron card ".$card->id);
-
-       my $stat = $session->request(
-               "open-ils.storage.direct.actor.card.update", $card )->gather(1);
-       return $U->DB_UPDATE_FAILED($card) unless defined($stat);
-       return undef;
-}
-
-
-
-
-# returns event on error.  returns undef otherwise
-sub _delete_address {
-       my( $session, $address ) = @_;
-
-       $logger->info("Deleting address ".$address->id." from DB");
-
-       my $stat = $session->request(
-               "open-ils.storage.direct.actor.user_address.delete", $address )->gather(1);
-
-       return $U->DB_UPDATE_FAILED($address) unless defined($stat);
-       return undef;
-}
-
-
-
-sub _add_survey_responses {
-       my ($session, $patron, $new_patron) = @_;
-
-       $logger->info( "Updating survey responses for patron ".$new_patron->id );
-
-       my $responses = $patron->survey_responses;
-
-       if($responses) {
-
-               $_->usr($new_patron->id) for (@$responses);
-
-               my $evt = $U->simplereq( "open-ils.circ", 
-                       "open-ils.circ.survey.submit.user_id", $responses );
-
-               return (undef, $evt) if defined($U->event_code($evt));
-
-       }
-
-       return ( $new_patron, undef );
-}
-
-sub _clear_badcontact_penalties {
-    my ($session, $old_patron, $new_patron, $user_obj) = @_;
-
-    return ($new_patron, undef) unless $old_patron;
-
-    my $PNM = $ShareStuff::BadContact::PENALTY_NAME_MAP;
-    my $e = new_editor(xact => 1);
-
-    # This ignores whether the caller of update_patron has any permission
-    # to remove penalties, but these penalties no longer make sense
-    # if an email address field (for example) is changed (and the caller must
-    # have perms to do *that*) so there's no reason not to clear the penalties.
-
-    my $bad_contact_penalties = $e->search_actor_user_standing_penalty([
-        {
-            "+csp" => {"name" => [values(%$PNM)]},
-            "+ausp" => {"stop_date" => undef, "usr" => $new_patron->id}
-        }, {
-            "join" => {"csp" => {}},
-            "flesh" => 1,
-            "flesh_fields" => {"ausp" => ["standing_penalty"]}
-        }
-    ]) or return (undef, $e->die_event);
-
-    return ($new_patron, undef) unless @$bad_contact_penalties;
-
-    my @penalties_to_clear;
-    my ($field, $penalty_name);
-
-    # For each field that might have an associated bad contact penalty, 
-    # check for such penalties and add them to the to-clear list if that
-    # field has changed.
-    while (($field, $penalty_name) = each(%$PNM)) {
-        if ($old_patron->$field ne $new_patron->$field) {
-            push @penalties_to_clear, grep {
-                $_->standing_penalty->name eq $penalty_name
-            } @$bad_contact_penalties;
-        }
-    }
-
-    foreach (@penalties_to_clear) {
-        # Note that this "archives" penalties, in the terminology of the staff
-        # client, instead of just deleting them.  This may assist reporting,
-        # or preserving old contact information when it is still potentially
-        # of interest.
-        $_->standing_penalty($_->standing_penalty->id); # deflesh
-        $_->stop_date('now');
-        $e->update_actor_user_standing_penalty($_) or return (undef, $e->die_event);
-    }
-
-    $e->commit;
-    return ($new_patron, undef);
-}
-
 
 sub _create_stat_maps {
 
@@ -869,13 +558,13 @@ sub _create_stat_maps {
 
        for my $map (@$maps) {
 
-               my $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.update";
+               my $method = "open-ils.cstore.direct.actor.stat_cat_entry_user_map.update";
 
                if ($map->isdeleted()) {
-                       $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.delete";
+                       $method = "open-ils.cstore.direct.actor.stat_cat_entry_user_map.delete";
 
                } elsif ($map->isnew()) {
-                       $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.create";
+                       $method = "open-ils.cstore.direct.actor.stat_cat_entry_user_map.create";
                        $map->clear_id;
                }
 
@@ -901,11 +590,11 @@ sub _create_perm_maps {
 
        for my $map (@$maps) {
 
-               my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
+               my $method = "open-ils.cstore.direct.permission.usr_perm_map.update";
                if ($map->isdeleted()) {
-                       $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
+                       $method = "open-ils.cstore.direct.permission.usr_perm_map.delete";
                } elsif ($map->isnew()) {
-                       $method = "open-ils.storage.direct.permission.usr_perm_map.create";
+                       $method = "open-ils.cstore.direct.permission.usr_perm_map.create";
                        $map->clear_id;
                }
 
@@ -925,47 +614,6 @@ sub _create_perm_maps {
 
 
 __PACKAGE__->register_method(
-    method   => "set_user_work_ous",
-    api_name => "open-ils.actor.user.work_ous.update",
-);
-
-sub set_user_work_ous {
-    my $self   = shift;
-    my $client = shift;
-    my $ses    = shift;
-    my $maps   = shift;
-
-       my( $requestor, $evt ) = $apputils->checksesperm( $ses, 'ASSIGN_WORK_ORG_UNIT' );
-       return $evt if $evt;
-
-       my $session = $apputils->start_db_session();
-       $apputils->set_audit_info($session, $ses, $requestor->id, $requestor->wsid);
-
-       for my $map (@$maps) {
-
-               my $method = "open-ils.storage.direct.permission.usr_work_ou_map.update";
-               if ($map->isdeleted()) {
-                       $method = "open-ils.storage.direct.permission.usr_work_ou_map.delete";
-               } elsif ($map->isnew()) {
-                       $method = "open-ils.storage.direct.permission.usr_work_ou_map.create";
-                       $map->clear_id;
-               }
-
-               #warn( "Updating permissions with method $method and session $ses and map $map" );
-               $logger->info( "Updating work_ou map with method $method and map $map" );
-
-               my $stat = $session->request($method, $map)->gather(1);
-               $logger->warn( "update failed: ".$U->DB_UPDATE_FAILED($map) ) unless defined($stat);
-
-       }
-
-       $apputils->commit_db_session($session);
-
-       return scalar(@$maps);
-}
-
-
-__PACKAGE__->register_method(
     method   => "set_user_perms",
     api_name => "open-ils.actor.user.permissions.update",
 );
@@ -980,9 +628,6 @@ sub set_user_perms {
 
        my( $user_obj, $evt ) = $U->checkses($ses);
        return $evt if $evt;
-       $apputils->set_audit_info($session, $ses, $user_obj->id, $user_obj->wsid);
-
-       my $perms = $session->request('open-ils.storage.permission.user_perms.atomic', $user_obj->id)->gather(1);
 
        my $all = undef;
        $all = 1 if ($U->is_true($user_obj->super_user()));
@@ -990,15 +635,15 @@ sub set_user_perms {
 
        for my $map (@$maps) {
 
-               my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
+               my $method = "open-ils.cstore.direct.permission.usr_perm_map.update";
                if ($map->isdeleted()) {
-                       $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
+                       $method = "open-ils.cstore.direct.permission.usr_perm_map.delete";
                } elsif ($map->isnew()) {
-                       $method = "open-ils.storage.direct.permission.usr_perm_map.create";
+                       $method = "open-ils.cstore.direct.permission.usr_perm_map.create";
                        $map->clear_id;
                }
 
-               next if (!$all and !grep { $_->perm eq $map->perm and $U->is_true($_->grantable) and $_->depth <= $map->depth } @$perms);
+               next if (!$all);
                #warn( "Updating permissions with method $method and session $ses and map $map" );
                $logger->info( "Updating permissions with method $method and map $map" );
 
@@ -1125,110 +770,6 @@ sub get_org_tree {
 
 
 __PACKAGE__->register_method(
-       method  => "get_org_descendants",
-       api_name        => "open-ils.actor.org_tree.descendants.retrieve"
-);
-
-# depth is optional.  org_unit is the id
-sub get_org_descendants {
-       my( $self, $client, $org_unit, $depth ) = @_;
-
-    if(ref $org_unit eq 'ARRAY') {
-        $depth ||= [];
-        my @trees;
-        for my $i (0..scalar(@$org_unit)-1) {
-            my $list = $U->simple_scalar_request(
-                           "open-ils.storage", 
-                           "open-ils.storage.actor.org_unit.descendants.atomic",
-                           $org_unit->[$i], $depth->[$i] );
-            push(@trees, $U->build_org_tree($list));
-        }
-        return \@trees;
-
-    } else {
-           my $orglist = $apputils->simple_scalar_request(
-                           "open-ils.storage", 
-                           "open-ils.storage.actor.org_unit.descendants.atomic",
-                           $org_unit, $depth );
-           return $U->build_org_tree($orglist);
-    }
-}
-
-
-__PACKAGE__->register_method(
-       method  => "get_org_ancestors",
-       api_name        => "open-ils.actor.org_tree.ancestors.retrieve"
-);
-
-# depth is optional.  org_unit is the id
-sub get_org_ancestors {
-       my( $self, $client, $org_unit, $depth ) = @_;
-       my $orglist = $apputils->simple_scalar_request(
-                       "open-ils.storage", 
-                       "open-ils.storage.actor.org_unit.ancestors.atomic",
-                       $org_unit, $depth );
-       return $U->build_org_tree($orglist);
-}
-
-
-__PACKAGE__->register_method(
-       method  => "get_standings",
-       api_name        => "open-ils.actor.standings.retrieve"
-);
-
-my $user_standings;
-sub get_standings {
-       return $user_standings if $user_standings;
-       return $user_standings = 
-               $apputils->simple_scalar_request(
-                       "open-ils.cstore",
-                       "open-ils.cstore.direct.config.standing.search.atomic",
-                       { id => { "!=" => undef } }
-               );
-}
-
-
-__PACKAGE__->register_method(
-    method   => "get_my_org_path",
-    api_name => "open-ils.actor.org_unit.full_path.retrieve"
-);
-
-sub get_my_org_path {
-       my( $self, $client, $auth, $org_id ) = @_;
-       my $e = new_editor(authtoken=>$auth);
-       return $e->event unless $e->checkauth;
-       $org_id = $e->requestor->ws_ou unless defined $org_id;
-
-       return $apputils->simple_scalar_request(
-               "open-ils.storage",
-               "open-ils.storage.actor.org_unit.full_path.atomic",
-               $org_id );
-}
-
-
-__PACKAGE__->register_method(
-    method   => "patron_adv_search",
-    api_name => "open-ils.actor.patron.search.advanced"
-);
-sub patron_adv_search {
-       my( $self, $client, $auth, $search_hash, 
-        $search_limit, $search_sort, $include_inactive, $search_ou ) = @_;
-
-       my $e = new_editor(authtoken=>$auth);
-       return $e->event unless $e->checkauth;
-       return $e->event unless $e->allowed('VIEW_USER');
-
-       # depth boundary outside of which patrons must opt-in, default to 0
-       my $opt_boundary = 0;
-       $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary') if user_opt_in_enabled($self);
-
-       return $U->storagereq(
-               "open-ils.storage.actor.user.crazy_search", $search_hash, 
-            $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_ou, $opt_boundary);
-}
-
-
-__PACKAGE__->register_method(
     method    => "update_passwd",
     api_name  => "open-ils.actor.user.password.update",
     signature => {
@@ -2159,9 +1700,14 @@ sub add_user_to_groups {
                $authtoken, $userid, 'REMOVE_USER_GROUP_LINK' );
        return $evt if $evt;
 
-       $apputils->simplereq(
-               'open-ils.storage',
-               'open-ils.storage.direct.permission.usr_grp_map.mass_delete', { usr => $userid } );
+       my $perms = $apputils->simplereq(
+               'open-ils.cstore',
+               'open-ils.cstore.direct.permission.usr_grp_map.search.atomic', { usr => $userid } );
+    for my $p (@$perms) {
+               $apputils->simplereq(
+               'open-ils.cstore',
+               'open-ils.cstore.direct.permission.usr_grp_map.delete', $p );
+    }
                
        for my $group (@$groups) {
                my $link = Fieldmapper::permission::usr_grp_map->new;
@@ -2169,8 +1715,8 @@ sub add_user_to_groups {
                $link->usr($userid);
 
                my $id = $apputils->simplereq(
-                       'open-ils.storage',
-                       'open-ils.storage.direct.permission.usr_grp_map.create', $link );
+                       'open-ils.cstore',
+                       'open-ils.cstore.direct.permission.usr_grp_map.create', $link );
        }
 
        return 1;
index c86583a..a17329c 100644 (file)
@@ -29,8 +29,8 @@ my $cache_client = "OpenSRF::Utils::Cache";
 sub start_db_session {
 
        my $self = shift;
-       my $session = OpenSRF::AppSession->connect( "open-ils.storage" );
-       my $trans_req = $session->request( "open-ils.storage.transaction.begin" );
+       my $session = OpenSRF::AppSession->connect( "open-ils.cstore" );
+       my $trans_req = $session->request( "open-ils.cstore.transaction.begin" );
 
        my $trans_resp = $trans_req->recv();
        if(ref($trans_resp) and UNIVERSAL::isa($trans_resp,"Error")) { throw $trans_resp; }
@@ -40,24 +40,12 @@ sub start_db_session {
        }
        $trans_req->finish();
 
-       $logger->debug("Setting global storage session to ".
+       $logger->debug("Setting global cstore session to ".
                "session: " . $session->session_id . " : " . $session->app );
 
        return $session;
 }
 
-sub set_audit_info {
-       my $self = shift;
-       my $session = shift;
-       my $authtoken = shift;
-       my $user_id = shift;
-       my $ws_id = shift;
-       
-       my $audit_req = $session->request( "open-ils.storage.set_audit_info", $authtoken, $user_id, $ws_id );
-       my $audit_resp = $audit_req->recv();
-       $audit_req->finish();
-}
-
 my $PERM_QUERY = {
     select => {
         au => [ {
@@ -102,7 +90,7 @@ sub check_perms {
 sub commit_db_session {
        my( $self, $session ) = @_;
 
-       my $req = $session->request( "open-ils.storage.transaction.commit" );
+       my $req = $session->request( "open-ils.cstore.transaction.commit" );
        my $resp = $req->recv();
 
        if(!$resp) {
@@ -125,7 +113,7 @@ sub commit_db_session {
 sub rollback_db_session {
        my( $self, $session ) = @_;
 
-       my $req = $session->request("open-ils.storage.transaction.rollback");
+       my $req = $session->request("open-ils.cstore.transaction.rollback");
        my $resp = $req->recv();
        if(UNIVERSAL::isa($resp,"Error")) { throw $resp;  }
 
@@ -226,24 +214,6 @@ sub build_org_tree {
        return $list[0];
 }
 
-sub fetch_closed_date {
-       my( $self, $cd ) = @_;
-       my $evt;
-       
-       $logger->debug("Fetching closed_date $cd from cstore");
-
-       my $cd_obj = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.actor.org_unit.closed_date.retrieve', $cd );
-
-       if(!$cd_obj) {
-               $logger->info("closed_date $cd not found in the db");
-               $evt = ShareStuff::Event->new('ACTOR_USER_NOT_FOUND');
-       }
-
-       return ($cd_obj, $evt);
-}
-
 sub fetch_user {
        my( $self, $userid ) = @_;
        my( $user, $evt );
@@ -313,243 +283,6 @@ sub checkses_requestor {
        return( $requestor, $target, $evt);
 }
 
-sub fetch_copy {
-       my( $self, $copyid ) = @_;
-       my( $copy, $evt );
-
-       $logger->debug("Fetching copy $copyid from cstore");
-
-       $copy = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.asset.copy.retrieve', $copyid );
-
-       if(!$copy) { $evt = ShareStuff::Event->new('ASSET_COPY_NOT_FOUND'); }
-
-       return( $copy, $evt );
-}
-
-
-# retrieves a circ object by id
-sub fetch_circulation {
-       my( $self, $circid ) = @_;
-       my $circ; my $evt;
-       
-       $logger->debug("Fetching circ $circid from cstore");
-
-       $circ = $self->simplereq(
-               'open-ils.cstore',
-               "open-ils.cstore.direct.action.circulation.retrieve", $circid );
-
-       if(!$circ) {
-               $evt = ShareStuff::Event->new('ACTION_CIRCULATION_NOT_FOUND', circid => $circid );
-       }
-
-       return ( $circ, $evt );
-}
-
-sub fetch_record_by_copy {
-       my( $self, $copyid ) = @_;
-       my( $record, $evt );
-
-       $logger->debug("Fetching record by copy $copyid from cstore");
-
-       $record = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.asset.copy.retrieve', $copyid,
-               { flesh => 3,
-                 flesh_fields => {     bre => [ 'fixed_fields' ],
-                                       acn => [ 'record' ],
-                                       acp => [ 'call_number' ],
-                                 }
-               }
-       );
-
-       if(!$record) {
-               $evt = ShareStuff::Event->new('BIBLIO_RECORD_ENTRY_NOT_FOUND');
-       } else {
-               $record = $record->call_number->record;
-       }
-
-       return ($record, $evt);
-}
-
-sub fetch_hold {
-       my( $self, $holdid ) = @_;
-       my( $hold, $evt );
-
-       $logger->debug("Fetching hold $holdid from cstore");
-
-       $hold = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.action.hold_request.retrieve', $holdid);
-
-       $evt = ShareStuff::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', holdid => $holdid) unless $hold;
-
-       return ($hold, $evt);
-}
-
-
-sub fetch_hold_transit_by_hold {
-       my( $self, $holdid ) = @_;
-       my( $transit, $evt );
-
-       $logger->debug("Fetching transit by hold $holdid from cstore");
-
-       $transit = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.action.hold_transit_copy.search', { hold => $holdid } );
-
-       $evt = ShareStuff::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', holdid => $holdid) unless $transit;
-
-       return ($transit, $evt );
-}
-
-# fetches the captured, but not fulfilled hold attached to a given copy
-sub fetch_open_hold_by_copy {
-       my( $self, $copyid ) = @_;
-       $logger->debug("Searching for active hold for copy $copyid");
-       my( $hold, $evt );
-
-       $hold = $self->cstorereq(
-               'open-ils.cstore.direct.action.hold_request.search',
-               { 
-                       current_copy            => $copyid , 
-                       capture_time            => { "!=" => undef }, 
-                       fulfillment_time        => undef,
-                       cancel_time                     => undef,
-               } );
-
-       $evt = ShareStuff::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', copyid => $copyid) unless $hold;
-       return ($hold, $evt);
-}
-
-sub fetch_hold_transit {
-       my( $self, $transid ) = @_;
-       my( $htransit, $evt );
-       $logger->debug("Fetching hold transit with hold id $transid");
-       $htransit = $self->cstorereq(
-               'open-ils.cstore.direct.action.hold_transit_copy.retrieve', $transid );
-       $evt = ShareStuff::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', id => $transid) unless $htransit;
-       return ($htransit, $evt);
-}
-
-sub fetch_copy_by_barcode {
-       my( $self, $barcode ) = @_;
-       my( $copy, $evt );
-
-       $logger->debug("Fetching copy by barcode $barcode from cstore");
-
-       $copy = $self->simplereq( 'open-ils.cstore',
-               'open-ils.cstore.direct.asset.copy.search', { barcode => $barcode, deleted => 'f'} );
-               #'open-ils.storage.direct.asset.copy.search.barcode', $barcode );
-
-       $evt = ShareStuff::Event->new('ASSET_COPY_NOT_FOUND', barcode => $barcode) unless $copy;
-
-       return ($copy, $evt);
-}
-
-sub fetch_open_billable_transaction {
-       my( $self, $transid ) = @_;
-       my( $transaction, $evt );
-
-       $logger->debug("Fetching open billable transaction $transid from cstore");
-
-       $transaction = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.money.open_billable_transaction_summary.retrieve',  $transid);
-
-       $evt = ShareStuff::Event->new(
-               'MONEY_OPEN_BILLABLE_TRANSACTION_SUMMARY_NOT_FOUND', transid => $transid ) unless $transaction;
-
-       return ($transaction, $evt);
-}
-
-
-
-my %buckets;
-$buckets{'biblio'} = 'biblio_record_entry_bucket';
-$buckets{'callnumber'} = 'call_number_bucket';
-$buckets{'copy'} = 'copy_bucket';
-$buckets{'user'} = 'user_bucket';
-
-sub fetch_container {
-       my( $self, $id, $type ) = @_;
-       my( $bucket, $evt );
-
-       $logger->debug("Fetching container $id with type $type");
-
-       my $e = 'CONTAINER_CALL_NUMBER_BUCKET_NOT_FOUND';
-       $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_NOT_FOUND' if $type eq 'biblio';
-       $e = 'CONTAINER_USER_BUCKET_NOT_FOUND' if $type eq 'user';
-       $e = 'CONTAINER_COPY_BUCKET_NOT_FOUND' if $type eq 'copy';
-
-       my $meth = $buckets{$type};
-       $bucket = $self->simplereq(
-               'open-ils.cstore',
-               "open-ils.cstore.direct.container.$meth.retrieve", $id );
-
-       $evt = ShareStuff::Event->new(
-               $e, container => $id, container_type => $type ) unless $bucket;
-
-       return ($bucket, $evt);
-}
-
-
-sub fetch_container_e {
-       my( $self, $editor, $id, $type ) = @_;
-
-       my( $bucket, $evt );
-       $bucket = $editor->retrieve_container_copy_bucket($id) if $type eq 'copy';
-       $bucket = $editor->retrieve_container_call_number_bucket($id) if $type eq 'callnumber';
-       $bucket = $editor->retrieve_container_biblio_record_entry_bucket($id) if $type eq 'biblio';
-       $bucket = $editor->retrieve_container_user_bucket($id) if $type eq 'user';
-
-       $evt = $editor->event unless $bucket;
-       return ($bucket, $evt);
-}
-
-sub fetch_container_item_e {
-       my( $self, $editor, $id, $type ) = @_;
-
-       my( $bucket, $evt );
-       $bucket = $editor->retrieve_container_copy_bucket_item($id) if $type eq 'copy';
-       $bucket = $editor->retrieve_container_call_number_bucket_item($id) if $type eq 'callnumber';
-       $bucket = $editor->retrieve_container_biblio_record_entry_bucket_item($id) if $type eq 'biblio';
-       $bucket = $editor->retrieve_container_user_bucket_item($id) if $type eq 'user';
-
-       $evt = $editor->event unless $bucket;
-       return ($bucket, $evt);
-}
-
-
-
-
-
-sub fetch_container_item {
-       my( $self, $id, $type ) = @_;
-       my( $bucket, $evt );
-
-       $logger->debug("Fetching container item $id with type $type");
-
-       my $meth = $buckets{$type} . "_item";
-
-       $bucket = $self->simplereq(
-               'open-ils.cstore',
-               "open-ils.cstore.direct.container.$meth.retrieve", $id );
-
-
-       my $e = 'CONTAINER_CALL_NUMBER_BUCKET_ITEM_NOT_FOUND';
-       $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_ITEM_NOT_FOUND' if $type eq 'biblio';
-       $e = 'CONTAINER_USER_BUCKET_ITEM_NOT_FOUND' if $type eq 'user';
-       $e = 'CONTAINER_COPY_BUCKET_ITEM_NOT_FOUND' if $type eq 'copy';
-
-       $evt = ShareStuff::Event->new(
-               $e, itemid => $id, container_type => $type ) unless $bucket;
-
-       return ($bucket, $evt);
-}
-
-
 sub fetch_patron_standings {
        my $self = shift;
        $logger->debug("Fetching patron standings");    
@@ -589,74 +322,6 @@ sub fetch_permission_group_descendants {
     return \@groups;
 }
 
-sub fetch_patron_circ_summary {
-       my( $self, $userid ) = @_;
-       $logger->debug("Fetching patron summary for $userid");
-       my $summary = $self->simplereq(
-               'open-ils.storage', 
-               "open-ils.storage.action.circulation.patron_summary", $userid );
-
-       if( $summary ) {
-               $summary->[0] ||= 0;
-               $summary->[1] ||= 0.0;
-               return $summary;
-       }
-       return undef;
-}
-
-
-sub fetch_copy_statuses {
-       my( $self ) = @_;
-       $logger->debug("Fetching copy statuses");
-       return $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.copy_status.search.atomic', { id => { '!=' => undef } });
-}
-
-sub fetch_copy_location {
-       my( $self, $id ) = @_;
-       my $evt;
-       my $cl = $self->cstorereq(
-               'open-ils.cstore.direct.asset.copy_location.retrieve', $id );
-       $evt = ShareStuff::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
-       return ($cl, $evt);
-}
-
-sub fetch_copy_locations {
-       my $self = shift; 
-       return $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.asset.copy_location.search.atomic', { id => { '!=' => undef } });
-}
-
-sub fetch_copy_location_by_name {
-       my( $self, $name, $org ) = @_;
-       my $evt;
-       my $cl = $self->cstorereq(
-               'open-ils.cstore.direct.asset.copy_location.search',
-                       { name => $name, owning_lib => $org } );
-       $evt = ShareStuff::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
-       return ($cl, $evt);
-}
-
-sub fetch_callnumber {
-       my( $self, $id, $flesh, $e ) = @_;
-
-       $e ||= ShareStuff::CStoreEditor->new;
-
-       my $evt = ShareStuff::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id );
-       return( undef, $evt ) unless $id;
-
-       $logger->debug("Fetching callnumber $id");
-
-    my $cn = $e->retrieve_asset_call_number([
-        $id,
-        { flesh => $flesh, flesh_fields => { acn => [ 'prefix', 'suffix', 'label_class' ] } },
-    ]);
-
-       return ( $cn, $e->event );
-}
-
 my %ORG_CACHE; # - these rarely change, so cache them..
 sub fetch_org_unit {
        my( $self, $id ) = @_;
@@ -749,140 +414,16 @@ sub find_org {
        return undef;
 }
 
-sub fetch_non_cat_type_by_name_and_org {
-       my( $self, $name, $orgId ) = @_;
-       $logger->debug("Fetching non cat type $name at org $orgId");
-       my $types = $self->simplereq(
-               'open-ils.cstore',
-               'open-ils.cstore.direct.config.non_cataloged_type.search.atomic',
-               { name => $name, owning_lib => $orgId } );
-       return ($types->[0], undef) if($types and @$types);
-       return (undef, ShareStuff::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') );
-}
-
-sub fetch_non_cat_type {
-       my( $self, $id ) = @_;
-       $logger->debug("Fetching non cat type $id");
-       my( $type, $evt );
-       $type = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.non_cataloged_type.retrieve', $id );
-       $evt = ShareStuff::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') unless $type;
-       return ($type, $evt);
-}
-
 sub DB_UPDATE_FAILED { 
        my( $self, $payload ) = @_;
        return ShareStuff::Event->new('DATABASE_UPDATE_FAILED', 
                payload => ($payload) ? $payload : undef ); 
 }
 
-sub fetch_booking_reservation {
-       my( $self, $id ) = @_;
-       my( $res, $evt );
-
-       $res = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.booking.reservation.retrieve', $id
-       );
-
-       # simplereq doesn't know how to flesh so ...
-       if ($res) {
-               $res->usr(
-                       $self->simplereq(
-                               'open-ils.cstore', 
-                               'open-ils.cstore.direct.actor.user.retrieve', $res->usr
-                       )
-               );
-
-               $res->target_resource_type(
-                       $self->simplereq(
-                               'open-ils.cstore', 
-                               'open-ils.cstore.direct.booking.resource_type.retrieve', $res->target_resource_type
-                       )
-               );
-
-               if ($res->current_resource) {
-                       $res->current_resource(
-                               $self->simplereq(
-                                       'open-ils.cstore', 
-                                       'open-ils.cstore.direct.booking.resource.retrieve', $res->current_resource
-                               )
-                       );
-
-                       if ($self->is_true( $res->target_resource_type->catalog_item )) {
-                               $res->current_resource->catalog_item( $self->fetch_copy_by_barcode( $res->current_resource->barcode ) );
-                       }
-               }
-
-               if ($res->target_resource) {
-                       $res->target_resource(
-                               $self->simplereq(
-                                       'open-ils.cstore', 
-                                       'open-ils.cstore.direct.booking.resource.retrieve', $res->target_resource
-                               )
-                       );
-
-                       if ($self->is_true( $res->target_resource_type->catalog_item )) {
-                               $res->target_resource->catalog_item( $self->fetch_copy_by_barcode( $res->target_resource->barcode ) );
-                       }
-               }
-
-       } else {
-               $evt = ShareStuff::Event->new('RESERVATION_NOT_FOUND');
-       }
-
-       return ($res, $evt);
-}
-
-sub fetch_circ_duration_by_name {
-       my( $self, $name ) = @_;
-       my( $dur, $evt );
-       $dur = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.rules.circ_duration.search.atomic', { name => $name } );
-       $dur = $dur->[0];
-       $evt = ShareStuff::Event->new('CONFIG_RULES_CIRC_DURATION_NOT_FOUND') unless $dur;
-       return ($dur, $evt);
-}
-
-sub fetch_recurring_fine_by_name {
-       my( $self, $name ) = @_;
-       my( $obj, $evt );
-       $obj = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.rules.recurring_fine.search.atomic', { name => $name } );
-       $obj = $obj->[0];
-       $evt = ShareStuff::Event->new('CONFIG_RULES_RECURRING_FINE_NOT_FOUND') unless $obj;
-       return ($obj, $evt);
-}
-
-sub fetch_max_fine_by_name {
-       my( $self, $name ) = @_;
-       my( $obj, $evt );
-       $obj = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.rules.max_fine.search.atomic', { name => $name } );
-       $obj = $obj->[0];
-       $evt = ShareStuff::Event->new('CONFIG_RULES_MAX_FINE_NOT_FOUND') unless $obj;
-       return ($obj, $evt);
-}
-
-sub fetch_hard_due_date_by_name {
-       my( $self, $name ) = @_;
-       my( $obj, $evt );
-       $obj = $self->simplereq(
-               'open-ils.cstore', 
-               'open-ils.cstore.direct.config.hard_due_date.search.atomic', { name => $name } );
-       $obj = $obj->[0];
-       $evt = ShareStuff::Event->new('CONFIG_RULES_HARD_DUE_DATE_NOT_FOUND') unless $obj;
-       return ($obj, $evt);
-}
-
 sub storagereq {
        my( $self, $method, @params ) = @_;
        return $self->simplereq(
-               'open-ils.storage', $method, @params );
+               'open-ils.cstore', $method, @params );
 }
 
 sub storagereq_xact {
@@ -916,225 +457,6 @@ sub logmark {
        $logger->debug("LOGMARK: $f:$l:$s");
 }
 
-# takes a copy id 
-sub fetch_open_circulation {
-       my( $self, $cid ) = @_;
-       $self->logmark;
-
-       my $e = ShareStuff::CStoreEditor->new;
-    my $circ = $e->search_action_circulation({
-        target_copy => $cid, 
-        stop_fines_time => undef, 
-        checkin_time => undef
-    })->[0];
-    
-    return ($circ, $e->event);
-}
-
-my $copy_statuses;
-sub copy_status_from_name {
-       my( $self, $name ) = @_;
-       $copy_statuses = $self->fetch_copy_statuses unless $copy_statuses;
-       for my $status (@$copy_statuses) { 
-               return $status if( $status->name =~ /$name/i );
-       }
-       return undef;
-}
-
-sub copy_status_to_name {
-       my( $self, $sid ) = @_;
-       $copy_statuses = $self->fetch_copy_statuses unless $copy_statuses;
-       for my $status (@$copy_statuses) { 
-               return $status->name if( $status->id == $sid );
-       }
-       return undef;
-}
-
-
-sub copy_status {
-       my( $self, $arg ) = @_;
-       return $arg if ref $arg;
-       $copy_statuses = $self->fetch_copy_statuses unless $copy_statuses;
-       my ($stat) = grep { $_->id == $arg } @$copy_statuses;
-       return $stat;
-}
-
-sub fetch_open_transit_by_copy {
-       my( $self, $copyid ) = @_;
-       my($transit, $evt);
-       $transit = $self->cstorereq(
-               'open-ils.cstore.direct.action.transit_copy.search',
-               { target_copy => $copyid, dest_recv_time => undef });
-       $evt = ShareStuff::Event->new('ACTION_TRANSIT_COPY_NOT_FOUND') unless $transit;
-       return ($transit, $evt);
-}
-
-sub unflesh_copy {
-       my( $self, $copy ) = @_;
-       return undef unless $copy;
-       $copy->status( $copy->status->id ) if ref($copy->status);
-       $copy->location( $copy->location->id ) if ref($copy->location);
-       $copy->circ_lib( $copy->circ_lib->id ) if ref($copy->circ_lib);
-       return $copy;
-}
-
-sub unflesh_reservation {
-       my( $self, $reservation ) = @_;
-       return undef unless $reservation;
-       $reservation->usr( $reservation->usr->id ) if ref($reservation->usr);
-       $reservation->target_resource_type( $reservation->target_resource_type->id ) if ref($reservation->target_resource_type);
-       $reservation->target_resource( $reservation->target_resource->id ) if ref($reservation->target_resource);
-       $reservation->current_resource( $reservation->current_resource->id ) if ref($reservation->current_resource);
-       return $reservation;
-}
-
-# un-fleshes a copy and updates it in the DB
-# returns a DB_UPDATE_FAILED event on error
-# returns undef on success
-sub update_copy {
-       my( $self, %params ) = @_;
-
-       my $copy                = $params{copy} || die "update_copy(): copy required";
-       my $editor      = $params{editor} || die "update_copy(): copy editor required";
-       my $session = $params{session};
-
-       $logger->debug("Updating copy in the database: " . $copy->id);
-
-       $self->unflesh_copy($copy);
-       $copy->editor( $editor );
-       $copy->edit_date( 'now' );
-
-       my $s;
-       my $meth = 'open-ils.storage.direct.asset.copy.update';
-
-       $s = $session->request( $meth, $copy )->gather(1) if $session;
-       $s = $self->storagereq( $meth, $copy ) unless $session;
-
-       $logger->debug("Update of copy ".$copy->id." returned: $s");
-
-       return $self->DB_UPDATE_FAILED($copy) unless $s;
-       return undef;
-}
-
-sub update_reservation {
-       my( $self, %params ) = @_;
-
-       my $reservation = $params{reservation}  || die "update_reservation(): reservation required";
-       my $editor              = $params{editor} || die "update_reservation(): copy editor required";
-       my $session             = $params{session};
-
-       $logger->debug("Updating copy in the database: " . $reservation->id);
-
-       $self->unflesh_reservation($reservation);
-
-       my $s;
-       my $meth = 'open-ils.cstore.direct.booking.reservation.update';
-
-       $s = $session->request( $meth, $reservation )->gather(1) if $session;
-       $s = $self->cstorereq( $meth, $reservation ) unless $session;
-
-       $logger->debug("Update of copy ".$reservation->id." returned: $s");
-
-       return $self->DB_UPDATE_FAILED($reservation) unless $s;
-       return undef;
-}
-
-sub fetch_billable_xact {
-       my( $self, $id ) = @_;
-       my($xact, $evt);
-       $logger->debug("Fetching billable transaction %id");
-       $xact = $self->cstorereq(
-               'open-ils.cstore.direct.money.billable_transaction.retrieve', $id );
-       $evt = ShareStuff::Event->new('MONEY_BILLABLE_TRANSACTION_NOT_FOUND') unless $xact;
-       return ($xact, $evt);
-}
-
-sub fetch_billable_xact_summary {
-       my( $self, $id ) = @_;
-       my($xact, $evt);
-       $logger->debug("Fetching billable transaction summary %id");
-       $xact = $self->cstorereq(
-               'open-ils.cstore.direct.money.billable_transaction_summary.retrieve', $id );
-       $evt = ShareStuff::Event->new('MONEY_BILLABLE_TRANSACTION_NOT_FOUND') unless $xact;
-       return ($xact, $evt);
-}
-
-sub fetch_fleshed_copy {
-       my( $self, $id ) = @_;
-       my( $copy, $evt );
-       $logger->info("Fetching fleshed copy $id");
-       $copy = $self->cstorereq(
-               "open-ils.cstore.direct.asset.copy.retrieve", $id,
-               { flesh => 1,
-                 flesh_fields => { acp => [ qw/ circ_lib location status stat_cat_entries / ] }
-               }
-       );
-       $evt = ShareStuff::Event->new('ASSET_COPY_NOT_FOUND', id => $id) unless $copy;
-       return ($copy, $evt);
-}
-
-
-# returns the org that owns the callnumber that the copy
-# is attached to
-sub fetch_copy_owner {
-       my( $self, $copyid ) = @_;
-       my( $copy, $cn, $evt );
-       $logger->debug("Fetching copy owner $copyid");
-       ($copy, $evt) = $self->fetch_copy($copyid);
-       return (undef,$evt) if $evt;
-       ($cn, $evt) = $self->fetch_callnumber($copy->call_number);
-       return (undef,$evt) if $evt;
-       return ($cn->owning_lib);
-}
-
-sub fetch_copy_note {
-       my( $self, $id ) = @_;
-       my( $note, $evt );
-       $logger->debug("Fetching copy note $id");
-       $note = $self->cstorereq(
-               'open-ils.cstore.direct.asset.copy_note.retrieve', $id );
-       $evt = ShareStuff::Event->new('ASSET_COPY_NOTE_NOT_FOUND', id => $id ) unless $note;
-       return ($note, $evt);
-}
-
-sub fetch_call_numbers_by_title {
-       my( $self, $titleid ) = @_;
-       $logger->info("Fetching call numbers by title $titleid");
-       return $self->cstorereq(
-               'open-ils.cstore.direct.asset.call_number.search.atomic', 
-               { record => $titleid, deleted => 'f' });
-               #'open-ils.storage.direct.asset.call_number.search.record.atomic', $titleid);
-}
-
-sub fetch_copies_by_call_number {
-       my( $self, $cnid ) = @_;
-       $logger->info("Fetching copies by call number $cnid");
-       return $self->cstorereq(
-               'open-ils.cstore.direct.asset.copy.search.atomic', { call_number => $cnid, deleted => 'f' } );
-               #'open-ils.storage.direct.asset.copy.search.call_number.atomic', $cnid );
-}
-
-sub fetch_user_by_barcode {
-       my( $self, $bc ) = @_;
-       my $cardid = $self->cstorereq(
-               'open-ils.cstore.direct.actor.card.id_list', { barcode => $bc } );
-       return (undef, ShareStuff::Event->new('ACTOR_CARD_NOT_FOUND', barcode => $bc)) unless $cardid;
-       my $user = $self->cstorereq(
-               'open-ils.cstore.direct.actor.user.search', { card => $cardid } );
-       return (undef, ShareStuff::Event->new('ACTOR_USER_NOT_FOUND', card => $cardid)) unless $user;
-       return ($user);
-       
-}
-
-sub fetch_bill {
-       my( $self, $billid ) = @_;
-       $logger->debug("Fetching billing $billid");
-       my $bill = $self->cstorereq(
-               'open-ils.cstore.direct.money.billing.retrieve', $billid );
-       my $evt = ShareStuff::Event->new('MONEY_BILLING_NOT_FOUND') unless $bill;
-       return($bill, $evt);
-}
-
 sub walk_org_tree {
        my( $self, $node, $callback ) = @_;
        return unless $node;
@@ -1180,73 +502,6 @@ sub patientreq {
     return $response->content;
 }
 
-# This logic now lives in storage
-sub __patron_money_owed {
-       my( $self, $patronid ) = @_;
-       my $ses = OpenSRF::AppSession->create('open-ils.storage');
-       my $req = $ses->request(
-               'open-ils.storage.money.billable_transaction.summary.search',
-               { usr => $patronid, xact_finish => undef } );
-
-       my $total = 0;
-       my $data;
-       while( $data = $req->recv ) {
-               $data = $data->content;
-               $total += $data->balance_owed;
-       }
-       return $total;
-}
-
-sub patron_money_owed {
-       my( $self, $userid ) = @_;
-       my $ses = $self->start_db_session();
-       my $val = $ses->request(
-               'open-ils.storage.actor.user.total_owed', $userid)->gather(1);
-       $self->rollback_db_session($ses);
-       return $val;
-}
-
-sub patron_total_items_out {
-       my( $self, $userid ) = @_;
-       my $ses = $self->start_db_session();
-       my $val = $ses->request(
-               'open-ils.storage.actor.user.total_out', $userid)->gather(1);
-       $self->rollback_db_session($ses);
-       return $val;
-}
-
-
-
-
-#---------------------------------------------------------------------
-# Returns  ($summary, $event) 
-#---------------------------------------------------------------------
-sub fetch_mbts {
-       my $self = shift;
-       my $id  = shift;
-       my $e = shift || ShareStuff::CStoreEditor->new;
-       $id = $id->id if ref($id);
-    
-    my $xact = $e->retrieve_money_billable_transaction_summary($id)
-           or return (undef, $e->event);
-
-    return ($xact);
-}
-
-
-#---------------------------------------------------------------------
-# Given a list of money.billable_transaction objects, this creates
-# transaction summary objects for each
-#--------------------------------------------------------------------
-sub make_mbts {
-       my $self = shift;
-    my $e = shift;
-       my @xacts = @_;
-       return () if (!@xacts);
-    return @{$e->search_money_billable_transaction_summary({id => [ map { $_->id } @xacts ]})};
-}
-               
-               
 sub ou_ancestor_setting_value {
     my($self, $org_id, $name, $e) = @_;
     $e = $e || ShareStuff::CStoreEditor->new;