1 package OpenILS::Application::Actor::Container;
2 use base 'OpenSRF::Application';
3 use strict; use warnings;
4 use OpenILS::Application::AppUtils;
7 use OpenSRF::EX qw(:try);
10 my $apputils = "OpenILS::Application::AppUtils";
11 my $logger = "OpenSRF::Utils::Logger";
13 sub initialize { return 1; }
15 __PACKAGE__->register_method(
16 method => "bucket_retrieve",
17 api_name => "open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_name",
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.
24 __PACKAGE__->register_method(
25 method => "bucket_retrieve",
26 api_name => "open-ils.actor.container.biblio_record_entry_bucket.fleshed.retrieve_by_name",
28 see: open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_name
29 Returns an array of { bucket : <bucketObj>, items : [ <I1>, <I2>, ...] } objects
32 __PACKAGE__->register_method(
33 method => "bucket_retrieve",
34 api_name => "open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_user",
36 Returns all BRE Buckets that belong to the given user.
37 PARAMS( authtoken, bucketOwnerId )
38 If requestor ID is different than bucketOwnerId, requestor must have
39 VIEW_CONTAINER permissions.
42 __PACKAGE__->register_method(
43 method => "bucket_retrieve",
44 api_name => "open-ils.actor.container.biblio_record_entry_bucket.fleshed.retrieve_by_user",
46 see: open-ils.actor.container.biblio_record_entry_bucket.retrieve_by_user
47 Returns an array of { bucket : <bucketObj>, items : [ <I1>, <I2>, ...] } objects
53 my($self, $client, $authtoken, $userid, $name) = @_;
55 my ($staff, $user, $perm) =
56 $apputils->handle_requestor( $authtoken, $userid, 'VIEW_CONTAINER');
57 return $perm if $perm;
59 $logger->activity("User " . $staff->id . " retrieving buckets for user $user");
61 my $svc = 'open-ils.storage';
62 my $meth = 'open-ils.storage.direct.container';
63 my $bibmeth = "$meth.biblio_record_entry_bucket";
64 my $cnmeth = "$meth.biblio_record_entry_bucket";
65 my $copymeth = "$meth.biblio_record_entry_bucket";
66 my $usermeth = "$meth.biblio_record_entry_bucket";
72 if( $self->api_name =~ /biblio/ ) {
74 if( $self->api_name =~ /retrieve_by_user/ ) {
75 $buckets = $apputils->simplereq( $svc,
76 "$bibmeth.search.owner.atomic", $user ); }
78 if( $self->api_name =~ /retrieve_by_name/ ) {
79 $buckets = $apputils->simplereq( $svc,
80 "$bibmeth.search_where.atomic", { name => $name, owner => $user } ); }
82 if( $self->api_name =~ /fleshed/ ) {
83 for my $b (@$buckets) {
85 $items = $apputils->simplereq( $svc,
86 "$bibmeth"."_item.search.bucket.atomic", $b->id );
87 push( @$resp, { bucket => $b , items => $items });
92 return $resp if ($self->api_name =~ /fleshed/);