[open-ils-commits] r18095 - trunk/Open-ILS/src/perlmods/OpenILS/Application (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Sep 28 19:12:59 EDT 2010
Author: miker
Date: 2010-09-28 19:12:58 -0400 (Tue, 28 Sep 2010)
New Revision: 18095
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
Use transactions everywhere in Vandelay
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-09-28 21:12:47 UTC (rev 18094)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-09-28 23:12:58 UTC (rev 18095)
@@ -68,9 +68,10 @@
return $e->die_event unless $e->allowed('CREATE_BIB_IMPORT_QUEUE');
$owner ||= $e->requestor->id;
- return OpenILS::Event->new('BIB_QUEUE_EXISTS')
- if $e->search_vandelay_bib_queue(
- {name => $name, owner => $owner, queue_type => $type})->[0];
+ if ($e->search_vandelay_bib_queue( {name => $name, owner => $owner, queue_type => $type})->[0]) {
+ $e->rollback;
+ return OpenILS::Event->new('BIB_QUEUE_EXISTS')
+ }
my $queue = new Fieldmapper::vandelay::bib_queue();
$queue->name( $name );
@@ -106,9 +107,10 @@
return $e->die_event unless $e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE');
$owner ||= $e->requestor->id;
- return OpenILS::Event->new('AUTH_QUEUE_EXISTS')
- if $e->search_vandelay_bib_queue(
- {name => $name, owner => $owner, queue_type => $type})->[0];
+ if ($e->search_vandelay_bib_queue({name => $name, owner => $owner, queue_type => $type})->[0]) {
+ $e->rollback;
+ return OpenILS::Event->new('AUTH_QUEUE_EXISTS')
+ }
my $queue = new Fieldmapper::vandelay::authority_queue();
$queue->name( $name );
@@ -242,7 +244,7 @@
}
my $evt = check_queue_perms($e, $type, $queue);
- return $evt if $evt;
+ return $evt if ($evt);
my $cache = new OpenSRF::Utils::Cache();
@@ -409,10 +411,7 @@
$queue = $e->retrieve_vandelay_authority_queue($queue_id) or return $e->die_event;
}
my $evt = check_queue_perms($e, $type, $queue);
- if ($evt) {;
- $e->rollback;
- return $evt;
- }
+ return $evt if ($evt);
my $class = ($type eq 'bib') ? 'vqbr' : 'vqar';
my $search = ($type eq 'bib') ?
@@ -485,10 +484,11 @@
sub import_record_list {
my($self, $conn, $auth, $rec_ids, $args) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
$args ||= {};
my $err = import_record_list_impl($self, $conn, $rec_ids, $e->requestor, $args);
+ $e->rollback;
return $err if $err;
return {complete => 1};
}
@@ -536,8 +536,8 @@
);
sub import_queue {
my($self, $conn, $auth, $q_id, $options) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
$options ||= {};
my $type = $self->{record_type};
my $class = ($type eq 'bib') ? 'vqbr' : 'vqar';
@@ -553,6 +553,7 @@
'search_vandelay_queued_bib_record' : 'search_vandelay_queued_authority_record';
my $rec_ids = $e->$search($query, {idlist => 1});
my $err = import_record_list_impl($self, $conn, $rec_ids, $e->requestor, $options);
+ $e->rollback;
return $err if $err;
return {complete => 1};
}
@@ -624,6 +625,7 @@
my %bib_sources;
my $editor = new_editor();
my $sources = $editor->search_config_bib_source({id => {'!=' => undef}});
+
foreach my $src (@$sources) {
$bib_sources{$src->id} = $src->source;
}
@@ -750,6 +752,7 @@
if($U->event_code($record)) {
$e->event($record);
+ $e->rollback;
} else {
@@ -765,7 +768,6 @@
if($imported) {
$e->commit;
} else {
- # die_event inside of biblio_record_xml_import or import_authority_record has taken care of $e->rollback;
# Send an update whenever there's an error
$conn->respond({total => $total, progress => ++$count, imported => $rec_id, err_event => $e->event});
}
@@ -817,7 +819,7 @@
sub owner_queue_retrieve {
my($self, $conn, $auth, $owner_id, $filters) = @_;
- my $e = new_editor(authtoken => $auth);
+ my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
$owner_id = $e->requestor->id; # XXX add support for viewing other's queues?
my $queues;
@@ -833,6 +835,7 @@
[$search, {order_by => {vaq => 'lower(name)'}}]);
}
$conn->respond($_) for @$queues;
+ $e->rollback;
return undef;
}
@@ -892,17 +895,18 @@
sub queued_record_html {
my($self, $conn, $auth, $rec_id) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1,authtoken => $auth);
+ return $e->die_event unless $e->checkauth;
my $rec;
if($self->{record_type} eq 'bib') {
$rec = $e->retrieve_vandelay_queued_bib_record($rec_id)
- or return $e->event;
+ or return $e->die_event;
} else {
$rec = $e->retrieve_vandelay_queued_authority_record($rec_id)
- or return $e->event;
+ or return $e->die_event;
}
+ $e->rollback;
return $U->simplereq(
'open-ils.search',
'open-ils.search.biblio.record.html', undef, 1, $rec->marc);
@@ -928,17 +932,17 @@
sub retrieve_queue_summary {
my($self, $conn, $auth, $queue_id) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken => $auth);
+ return $e->die_event unless $e->checkauth;
my $queue;
my $type = $self->{record_type};
if($type eq 'bib') {
$queue = $e->retrieve_vandelay_bib_queue($queue_id)
- or return $e->event;
+ or return $e->die_event;
} else {
$queue = $e->retrieve_vandelay_authority_queue($queue_id)
- or return $e->event;
+ or return $e->die_event;
}
my $evt = check_queue_perms($e, $type, $queue);
@@ -974,20 +978,22 @@
sub import_record_list_assets {
my($self, $conn, $auth, $import_def, $rec_ids) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken => $auth);
+ return $e->die_event unless $e->checkauth;
my $err = import_record_asset_list_impl($conn, $import_def, $rec_ids, $e->requestor);
+ $e->rollback;
return $err if $err;
return {complete => 1};
}
sub import_record_queue_assets {
my($self, $conn, $auth, $import_def, $q_id) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken => $auth);
+ return $e->die_event unless $e->checkauth;
my $rec_ids = $e->search_vandelay_queued_bib_record(
{queue => $q_id, import_time => {'!=' => undef}}, {idlist => 1});
my $err = import_record_asset_list_impl($conn, $import_def, $rec_ids, $e->requestor);
+ $e->rollback;
return $err if $err;
return {complete => 1};
}
@@ -1001,7 +1007,7 @@
my $total = @$rec_ids;
my $try_count = 0;
my $in_count = 0;
- my $roe = new_editor(requestor => $requestor);
+ my $roe = new_editor(xact=> 1, requestor => $requestor);
for my $rec_id (@$rec_ids) {
my $rec = $roe->retrieve_vandelay_queued_bib_record($rec_id);
@@ -1091,6 +1097,7 @@
respond_with_status($conn, $total, $try_count, ++$in_count, undef, imported_as => $copy->id);
}
}
+ $roe->rollback;
return undef;
}
More information about the open-ils-commits
mailing list