[open-ils-commits] r10485 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Aug 29 18:22:00 EDT 2008
Author: erickson
Date: 2008-08-29 18:21:55 -0400 (Fri, 29 Aug 2008)
New Revision: 10485
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
added method to retrieve fleshed bib/authority records by queue. abstracted out the queue perm checks
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-08-29 22:20:12 UTC (rev 10484)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-08-29 22:21:55 UTC (rev 10485)
@@ -55,7 +55,7 @@
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
- return $e->die_event unless $e->allowed('CREATE_BIB_IMPORT_QUEUE', $owner);
+ return $e->die_event unless $e->allowed('CREATE_BIB_IMPORT_QUEUE');
$owner ||= $e->requestor->id;
my $queue = new Fieldmapper::vandelay::bib_queue();
@@ -88,7 +88,7 @@
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
- return $e->die_event unless $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', $owner);
+ return $e->die_event unless $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE');
$owner ||= $e->requestor->id;
my $queue = new Fieldmapper::vandelay::authority_queue();
@@ -124,7 +124,7 @@
return $e->die_event unless $e->checkauth;
return $e->die_event unless
($e->allowed('CREATE_BIB_IMPORT_QUEUE', undef, $queue) ||
- $e->allowed('CREATE_BIB_IMPORT_QUEUE', $queue->owner));
+ $e->allowed('CREATE_BIB_IMPORT_QUEUE'));
my $new_rec = _add_bib_rec($e, $marc, $queue->id, $purpose);
@@ -168,7 +168,7 @@
return $e->die_event unless $e->checkauth;
return $e->die_event unless
($e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', undef, $queue) ||
- $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', $queue->owner));
+ $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE'));
my $new_rec = _add_auth_rec($e, $marc, $queue->id, $purpose);
@@ -202,24 +202,16 @@
my $client = shift;
my $auth = shift;
my $fingerprint = shift;
- my $queue = shift;
+ my $queue_id = shift;
my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
+ my $queue = $e->retrieve_vandelay_queue($queue_id) or return $e->die_event;
my $type = ($self->api_name =~ /auth/) ? 'auth' : 'bib';
+ my $evt = check_queue_perms($e, $type, $queue);
+ return $evt if $evt;
- if ($type eq 'bib') {
- return $e->die_event unless $e->checkauth;
- return $e->die_event unless
- ($e->allowed('CREATE_BIB_IMPORT_QUEUE', undef, $queue) ||
- $e->allowed('CREATE_BIB_IMPORT_QUEUE', $queue->owner));
- } else {
- return $e->die_event unless $e->checkauth;
- return $e->die_event unless
- ($e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', undef, $queue) ||
- $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', $queue->owner));
- }
-
my $method = "open-ils.vandelay.queued_${type}_record.create";
$method = $self->method_lookup( $method );
@@ -250,9 +242,9 @@
$xml =~ s/[\x00-\x1f]//go;
if ($self->{record_type} eq 'bib') {
- _add_bib_rec( $e, $xml, $queue, $purpose ) or return $e->die_event;
+ _add_bib_rec( $e, $xml, $queue_id, $purpose ) or return $e->die_event;
} else {
- _add_auth_rec( $e, $xml, $queue, $purpose ) or return $e->die_event;
+ _add_auth_rec( $e, $xml, $queue_id, $purpose ) or return $e->die_event;
}
$count++;
@@ -282,6 +274,78 @@
);
+__PACKAGE__->register_method(
+ api_name => "open-ils.vandelay.bib_queue.records.retrieve",
+ method => 'retrieve_queue',
+ api_level => 1,
+ argc => 2,
+ stream => 1,
+ record_type => 'bib'
+);
+__PACKAGE__->register_method(
+ api_name => "open-ils.vandelay.auth_queue.records.retrieve",
+ method => 'retrieve_queue',
+ api_level => 1,
+ argc => 2,
+ stream => 1,
+ record_type => 'auth'
+);
+sub retrieve_queue {
+ my($self, $conn, $auth, $queue_id, $options) = @_;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+
+ my $queue = $e->retrieve_vandelay_bib_queue($queue_id) or return $e->event;
+ my $type = $self->{record_type};
+ my $evt = check_queue_perms($e, $type, $queue);
+ return $evt if $evt;
+
+ if($type eq 'bib') {
+ my $record_ids = $e->search_vandelay_queued_bib_record({queue => $queue_id}, {idlist => 1});
+ for my $rec_id (@$record_ids) {
+ my $rec = $e->retrieve_vandelay_queued_bib_record([
+ $rec_id,
+ { flesh => 1,
+ flesh_fields => {vqbr => ['attributes']}
+ }
+ ]);
+ $rec->clear_marc if $$options{clear_marc};
+ $conn->respond($rec);
+ }
+ } else {
+ my $record_ids = $e->search_vandelay_queued_authority_record({queue => $queue_id}, {idlist => 1});
+ for my $rec_id (@$record_ids) {
+ for my $rec_id (@$record_ids) {
+ my $rec = $e->retrieve_vandelay_queued_bib_record([
+ $rec_id,
+ { flesh => 1,
+ flesh_fields => {vqar => ['attributes']}
+ }
+ ]);
+ $rec->clear_marc if $$options{clear_marc};
+ $conn->respond($rec);
+ }
+ }
+ }
+ return undef;
+}
+
+sub check_queue_perms {
+ my($e, $type, $queue) = @_;
+ if ($type eq 'bib') {
+ return $e->die_event unless
+ ($e->allowed('CREATE_BIB_IMPORT_QUEUE', undef, $queue) ||
+ $e->allowed('CREATE_BIB_IMPORT_QUEUE'));
+ } else {
+ return $e->die_event unless
+ ($e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', undef, $queue) ||
+ $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE'));
+ }
+
+ return undef;
+}
+
+
1;
More information about the open-ils-commits
mailing list