TT#26652 addditional subscriberregistrations error checks

* return HTTP_UNPROCESSABLE_ENTRY if form data is not valid
      or a susbcriber is not found
    * POST: do not commit transaction if update_item fails

Change-Id: I7149922d4e4d701213ce351112cc67e611c3d910
changes/17/19417/9
Kirill Solomko 8 years ago
parent 5e76543664
commit ad04649ece

@ -139,7 +139,7 @@ sub POST :Allow {
my ($guard, $txn_ok) = ($c->model('DB')->txn_scope_guard, 0);
{
$self->update_item($c, undef, undef, $resource, $form, $create);
last unless $self->update_item($c, "new", undef, $resource, $form, $create);
$guard->commit;
$txn_ok = 1;

@ -187,8 +187,11 @@ sub update_item {
);
my $sub = $self->subscriber_from_id($c, $resource->{subscriber_id});
return unless $sub;
unless($create) {
unless ($sub) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Could not find a subscriber with the provided subscriber_id");
return;
}
if ($item && ref $item && !$create) {
$self->delete_item($c, $item);
}
my $cflags = 0;
@ -211,10 +214,16 @@ sub update_item {
sub fetch_item {
my ($self, $c, $resource, $form, $old_item) = @_;
return unless $form;
unless ($form) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Missing data values");
return;
}
my $sub = $self->subscriber_from_id($c, $resource->{subscriber_id});
return unless $sub;
unless ($sub) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Could not find a subscriber with the provided subscriber_id");
return;
}
my $item;
my $flush_timeout = 30;

Loading…
Cancel
Save