From 53532fd5e8f4b0e140be7ab8a0c57ff4aaecbc82 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Tue, 16 Jan 2018 12:38:05 +0100 Subject: [PATCH] TT#30500 Fix /api/subscriberregistrations POST method * POST method is adapted to the new behaviour of update_item() and fetch_item() Change-Id: I35cc5d4e8c97cd415e9d6d31a6811d1f8cce84a9 --- .../Controller/API/SubscriberRegistrations.pm | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm b/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm index 8d4fa8a7f0..33dfd9ff19 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm @@ -169,17 +169,29 @@ sub POST :Allow { my ($self, $c) = @_; { - my $resource = $self->get_valid_post_data( - c => $c, + my ($item, $resource); + + $resource = $self->get_valid_post_data( + c => $c, media_type => 'application/json', ); last unless $resource; my $form = $self->get_form($c); my $create = 1; - my $item = $self->update_item($c, undef, undef, $resource, $form, $create); + + my ($guard, $txn_ok) = ($c->model('DB')->txn_scope_guard, 0); + { + $self->update_item($c, undef, undef, $resource, $form, $create); + + $guard->commit; + $txn_ok = 1; + } + last unless $txn_ok; + + $item = $self->fetch_item($c, $resource, $form, $item); last unless $item; - + $c->response->status(HTTP_CREATED); $c->response->header(Location => sprintf('/%s%d', $c->request->path, $item->id)); $c->response->body(q()); @@ -193,5 +205,6 @@ sub end : Private { $self->log_response($c); } +1; # vim: set tabstop=4 expandtab: