]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm
adding initial container code.. many methods to be added
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Actor / Container.pm
1 package OpenILS::Application::Actor::Container;
2 use base 'OpenSRF::Application';
3 use strict; use warnings;
4 use OpenILS::Application::AppUtils;
5 use OpenILS::Perm;
6 use Data::Dumper;
7 use OpenSRF::EX qw(:try);
8 use OpenILS::EX;
9
10 my $apputils = "OpenILS::Application::AppUtils";
11 my $logger = "OpenSRF::Utils::Logger";
12
13 sub initialize { return 1; }
14
15 __PACKAGE__->register_method(
16         method  => "bucket_retrieve",
17         api_name        => "open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_name",
18         notes           => <<"  NOTES");
19                 Retrieves a BREB by name.  PARAMS(authtoken, bucketOwnerId, bucketName)
20                 If requestor ID is different than bucketOwnerId, requestor must have
21                 VIEW_CONTAINER permissions.
22         NOTES
23
24
25
26 __PACKAGE__->register_method(
27         method  => "bucket_retrieve",
28         api_name        => "open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_user",
29         notes           => <<"  NOTES");
30                 Returns all BRE Buckets that belong to the given user. 
31                 PARAMS( authtoken, bucketOwnerId )
32                 If requestor ID is different than bucketOwnerId, requestor must have
33                 VIEW_CONTAINER permissions.
34         NOTES
35
36
37 sub bucket_retrieve {
38         my($self, $client, $authtoken, $userid, $name) = @_;
39
40         my ($staff, $user, $perm) = 
41                 $apputils->handle_requestor( $authtoken, $userid, 'VIEW_CONTAINER');
42         return $perm if $perm;
43
44         $logger->activity("User " . $staff->id . " retrieving buckets for user $user");
45
46         my $svc = 'open-ils.storage';
47         my $meth = 'open-ils.storage.direct.container';
48         my $bibmeth = "$meth.biblio_record_entry_bucket";
49         my $cnmeth = "$meth.biblio_record_entry_bucket";
50         my $copymeth = "$meth.biblio_record_entry_bucket";
51         my $usermeth = "$meth.biblio_record_entry_bucket";
52
53         if( $self->api_name =~ /biblio.*retrieve_by_user/ ) {
54                 return $apputils->simplereq( $svc, 
55                         "$bibmeth.search.owner.atomic", $user ); }
56
57         if( $self->api_name =~ /biblio.*retrieve_by_name/ ) {
58                 return $apputils->simplereq( $svc, 
59                         "$bibmeth.search_where", { name => $name, owner => $user } ); }
60
61
62 }
63
64
65
66 1;
67
68