From 5194cd32646064ea38fd6de882665b6d6f2993de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 6 Oct 2023 12:45:19 +0200 Subject: [PATCH] Bug 30708: Remove c->validation in API controllers Fixed conflict with bug 33556 Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Preservation/Processings.pm | 10 +++---- Koha/REST/V1/Preservation/Trains.pm | 38 ++++++++++++------------ Koha/REST/V1/Preservation/WaitingList.pm | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Koha/REST/V1/Preservation/Processings.pm b/Koha/REST/V1/Preservation/Processings.pm index 98a924b68a..1c0b4f385f 100644 --- a/Koha/REST/V1/Preservation/Processings.pm +++ b/Koha/REST/V1/Preservation/Processings.pm @@ -54,7 +54,7 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $processing_id = $c->validation->param('processing_id'); + my $processing_id = $c->param('processing_id'); my $processing = $c->objects->find( Koha::Preservation::Processings->search, $processing_id ); unless ($processing) { @@ -87,7 +87,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $attributes = delete $body->{attributes} // []; @@ -154,7 +154,7 @@ Controller function that handles updating a Koha::Preservation::Processing objec sub update { my $c = shift->openapi->valid_input or return; - my $processing_id = $c->validation->param('processing_id'); + my $processing_id = $c->param('processing_id'); my $processing = Koha::Preservation::Processings->find( $processing_id ); unless ($processing) { @@ -168,7 +168,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $attributes = delete $body->{attributes} // []; @@ -227,7 +227,7 @@ sub update { sub delete { my $c = shift->openapi->valid_input or return; - my $processing_id = $c->validation->param('processing_id'); + my $processing_id = $c->param('processing_id'); my $processing = Koha::Preservation::Processings->find( $processing_id ); unless ($processing) { return $c->render( diff --git a/Koha/REST/V1/Preservation/Trains.pm b/Koha/REST/V1/Preservation/Trains.pm index 8c79bf4cff..45b03716b3 100644 --- a/Koha/REST/V1/Preservation/Trains.pm +++ b/Koha/REST/V1/Preservation/Trains.pm @@ -58,7 +58,7 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = $c->objects->find( Koha::Preservation::Trains->search, $train_id ); unless ($train) { @@ -91,7 +91,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $train = Koha::Preservation::Train->new_from_api($body)->store; @@ -155,7 +155,7 @@ Controller function that handles updating a Koha::Preservation::Train object sub update { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -169,7 +169,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; $train->set_from_api($body)->store; @@ -226,7 +226,7 @@ Controller function that handles deleting a Koha::Preservation::Train object sub delete { my $c = shift->openapi->valid_input or return; - my $train = Koha::Preservation::Trains->find( $c->validation->param('train_id') ); + my $train = Koha::Preservation::Trains->find( $c->param('train_id') ); unless ($train) { return $c->render( status => 404, @@ -255,7 +255,7 @@ Controller function that handles getting an item from a train sub get_item { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -265,7 +265,7 @@ sub get_item { ); } - my $train_item_id = $c->validation->param('train_item_id'); + my $train_item_id = $c->param('train_item_id'); my $train_item = $c->objects->find(Koha::Preservation::Train::Items->search, { train_item_id => $train_item_id, train_id => $train_id }); @@ -297,7 +297,7 @@ Controller function that handles adding items in batch to a train sub add_items { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -307,7 +307,7 @@ sub add_items { ); } - my $body = $c->validation->every_param('body'); + my $body = $c->req->json; return try { Koha::Database->new->schema->txn_do( sub { @@ -339,7 +339,7 @@ Controller function that handles adding a new item to a train sub add_item { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -349,7 +349,7 @@ sub add_item { ); } - my $body = $c->validation->param('body'); + my $body = $c->req->json; return try { Koha::Database->new->schema->txn_do( sub { @@ -408,7 +408,7 @@ Controller function that handles copying an item from a train to an other sub copy_item { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -418,7 +418,7 @@ sub copy_item { ); } - my $train_item_id = $c->validation->param('train_item_id'); + my $train_item_id = $c->param('train_item_id'); my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single; @@ -429,7 +429,7 @@ sub copy_item { ); } - my $body = $c->validation->param('body'); + my $body = $c->req->json; return try { Koha::Database->new->schema->txn_do( sub { @@ -512,7 +512,7 @@ Controller function that handles updating an item from a train sub update_item { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -522,7 +522,7 @@ sub update_item { ); } - my $train_item_id = $c->validation->param('train_item_id'); + my $train_item_id = $c->param('train_item_id'); my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single; @@ -536,7 +536,7 @@ sub update_item { return try { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $attributes = delete $body->{attributes} // []; $train_item->set_from_api($body)->store; @@ -560,7 +560,7 @@ Controller function that handles removing an item from a train sub remove_item { my $c = shift->openapi->valid_input or return; - my $train_id = $c->validation->param('train_id'); + my $train_id = $c->param('train_id'); my $train = Koha::Preservation::Trains->find( $train_id ); unless ($train) { @@ -570,7 +570,7 @@ sub remove_item { ); } - my $train_item_id = $c->validation->param('train_item_id'); + my $train_item_id = $c->param('train_item_id'); my $train_item = $train->items->find($train_item_id); diff --git a/Koha/REST/V1/Preservation/WaitingList.pm b/Koha/REST/V1/Preservation/WaitingList.pm index cc2c335e27..e43eab3ed9 100644 --- a/Koha/REST/V1/Preservation/WaitingList.pm +++ b/Koha/REST/V1/Preservation/WaitingList.pm @@ -74,7 +74,7 @@ sub add_items { my $c = shift->openapi->valid_input or return; return try { - my $body = $c->validation->every_param('body'); + my $body = $c->req->json; my $new_not_for_loan = C4::Context->preference('PreservationNotForLoanWaitingListIn'); Koha::Exceptions::Preservation::MissingSettings->throw( parameter => 'PreservationNotForLoanWaitingListIn' ) unless $new_not_for_loan; @@ -126,7 +126,7 @@ sub remove_item { my $c = shift->openapi->valid_input or return; return try { - my $item_id = $c->validation->param('item_id'); + my $item_id = $c->param('item_id'); my $item = Koha::Items->find($item_id); -- 2.39.5