From 3bed4385c7cdbdaded6f8d2ebe745a29376b5fe9 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 16 Dec 2005 22:59:23 +0000 Subject: [PATCH] more container creation work git-svn-id: svn://svn.open-ils.org/ILS/trunk@2425 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/ils_events.xml | 8 +++ .../OpenILS/Application/Actor/Container.pm | 49 +++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 5bf22f70fa..768595eb4d 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -75,6 +75,14 @@ + + + Someone attempted to retrieve a transit object from the + system and the object was not found. + + + + A copy needs to be routed to a different location diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm index e430bc7abc..5fcaf084c3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm @@ -144,22 +144,61 @@ __PACKAGE__->register_method( sub bucket_create { my( $self, $client, $authtoken, $class, $bucket ) = @_; - my( $staff, $evt ) = $apputils->checkses($authtoken); + my( $staff, $target, $evt ) = + $apputils->checkses_requestor( + $authtoken, $bucket->owner, 'CREATE_CONTAINER' ); return $evt if $evt; - if( $bucket->owner ne $staff->id ) { - return $evt if ($evt = $apputils->check_perms('CREATE_CONTAINER')); - } - $logger->activity( "User " . $staff->id . " creating a new continer for user " . $bucket->owner ); + $logger->debug("Creating new container object: " . Dumper($bucket)); + my $method = $types{$class} . ".create"; my $id = $apputils->simplreq( $svc, $method, $bucket ); + $logger->debug("Creatined new container with id $id"); + if(!$id) { throw OpenSRF::EX ("Unable to create new bucket object"); } + return $id; +} + + +__PACKAGE__->register_method( + method => "bucket_delete", + api_name => "open-ils.actor.container.bucket.delete", + notes => <<" NOTES"); + Deletes a bucket object. If requestor is different from + bucketOwner, requestor needs DELETE_CONTAINER permissions + PARAMS(authtoken, class, bucketId); + Returns the new bucket object + NOTES + +sub bucket_delete { + my( $self, $client, $authtoken, $class, $bucketid ) = @_; + + my $bucket = $apputils->simplereq( + $svc, $types{$class} . ".retrieve", $bucketid ); + + if(!$bucket) { + return OpenILS::Event->new('CONTAINER_NOT_FOUND'); + } + + my( $staff, $target, $evt ) = $apputils->checkses_requestor( + $authtoken, $bucket->owner, 'DELETE_CONTAINER' ); + return $evt if $evt; + + $logger->activity( "User " . $staff->id . + " deleting continer $bucketid for user " . $bucket->owner ); + + my $method = $types{$class} . ".delete"; + my $resp = $apputils->simplreq( $svc, $method, $bucketid ); + + if(!$resp) { throw OpenSRF::EX + ("Unable to create new bucket object"); } + return $resp; } -- 2.43.2