From 5788f94868bde660179a183382aad42e9e3b40be Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 8 Jun 2023 13:27:13 -0300 Subject: [PATCH] Bug 34339: (bug 33556 follow-up) Easy ERM-related changes I left the (easy) ERM cases out because it throws this when running the QA script: Processing files before patches |========================>| 51 / 51 (100.00%) An error occurred : Inconsistent hierarchy during C3 merge of class 'Koha::REST::V1::ERM::EHoldings::Titles::Local': current merge results [ Koha::REST::V1::ERM::EHoldings::Titles::Local, ] merging failed on 'Mojolicious::Controller' at /kohadevbox/qa-test-tools/koha-qa.pl line 112. and didn't want this to pollute the rest of the changes. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/ERM/Agreements.pm | 15 +++++++-------- Koha/REST/V1/ERM/Documents.pm | 3 +-- Koha/REST/V1/ERM/EHoldings/Packages.pm | 12 ++++++------ Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm | 6 +++--- Koha/REST/V1/ERM/EHoldings/Packages/Local.pm | 17 +++++++++-------- Koha/REST/V1/ERM/EHoldings/Resources.pm | 6 +++--- Koha/REST/V1/ERM/EHoldings/Resources/Local.pm | 2 +- Koha/REST/V1/ERM/EHoldings/Titles.pm | 10 +++++----- Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm | 5 ++--- Koha/REST/V1/ERM/EHoldings/Titles/Local.pm | 14 ++++++-------- Koha/REST/V1/ERM/Licenses.pm | 15 ++++++--------- 11 files changed, 49 insertions(+), 56 deletions(-) diff --git a/Koha/REST/V1/ERM/Agreements.pm b/Koha/REST/V1/ERM/Agreements.pm index 19ca477e36..d44c8198a4 100644 --- a/Koha/REST/V1/ERM/Agreements.pm +++ b/Koha/REST/V1/ERM/Agreements.pm @@ -35,7 +35,8 @@ use Try::Tiny qw( catch try ); sub list { my $c = shift->openapi->valid_input or return; - my $max_expiration_date = delete $c->validation->output->{max_expiration_date}; + my $max_expiration_date = $c->param('max_expiration_date'); + $c->req->params->remove('max_expiration_date'); return try { my $agreements_set = Koha::ERM::Agreements->new; @@ -61,8 +62,7 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $agreement_id = $c->validation->param('agreement_id'); - my $agreement = $c->objects->find( Koha::ERM::Agreements->search, $agreement_id ); + my $agreement = $c->objects->find( Koha::ERM::Agreements->search, $c->param('agreement_id') ); unless ($agreement) { return $c->render( @@ -94,7 +94,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $periods = delete $body->{periods} // []; my $user_roles = delete $body->{user_roles} // []; @@ -169,8 +169,7 @@ Controller function that handles updating a Koha::ERM::Agreement object sub update { my $c = shift->openapi->valid_input or return; - my $agreement_id = $c->validation->param('agreement_id'); - my $agreement = Koha::ERM::Agreements->find( $agreement_id ); + my $agreement = Koha::ERM::Agreements->find( $c->param('agreement_id') ); unless ($agreement) { return $c->render( @@ -183,7 +182,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $periods = delete $body->{periods} // []; my $user_roles = delete $body->{user_roles} // []; @@ -249,7 +248,7 @@ sub update { sub delete { my $c = shift->openapi->valid_input or return; - my $agreement = Koha::ERM::Agreements->find( $c->validation->param('agreement_id') ); + my $agreement = Koha::ERM::Agreements->find( $c->param('agreement_id') ); unless ($agreement) { return $c->render( status => 404, diff --git a/Koha/REST/V1/ERM/Documents.pm b/Koha/REST/V1/ERM/Documents.pm index 1e0575f87e..a1d824ce95 100644 --- a/Koha/REST/V1/ERM/Documents.pm +++ b/Koha/REST/V1/ERM/Documents.pm @@ -38,10 +38,9 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $document_id = $c->validation->param('document_id'); # Do not use $c->objects->find here, we need the file_content - my $document = Koha::ERM::Documents->find($document_id); + my $document = Koha::ERM::Documents->find( $c->param('document_id') ); if ( !$document ) { return $c->render( diff --git a/Koha/REST/V1/ERM/EHoldings/Packages.pm b/Koha/REST/V1/ERM/EHoldings/Packages.pm index 1dc3e747e8..89ca4c8e3f 100644 --- a/Koha/REST/V1/ERM/EHoldings/Packages.pm +++ b/Koha/REST/V1/ERM/EHoldings/Packages.pm @@ -36,7 +36,7 @@ use Koha::REST::V1::ERM::EHoldings::Packages::EBSCO; sub list { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Packages::EBSCO::list($c); } else { @@ -53,7 +53,7 @@ Controller function that handles retrieving a single Koha::ERM::EHoldings::Packa sub get { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Packages::EBSCO::get($c); } else { @@ -70,7 +70,7 @@ Controller function that handles adding a new Koha::ERM::EHoldings::Package obje sub add { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { @@ -87,7 +87,7 @@ Controller function that handles updating a Koha::ERM::EHoldings::Package object sub update { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { @@ -102,7 +102,7 @@ sub update { sub delete { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { @@ -119,7 +119,7 @@ Controller function that handles editing a single Koha::ERM::EHoldings::Package sub edit { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Packages::EBSCO::edit($c); } else { diff --git a/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm b/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm index 8c65c08706..1d7dfc7cbc 100644 --- a/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm +++ b/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm @@ -93,7 +93,7 @@ sub get { return try { my ( $vendor_id, $package_id ) = split '-', - $c->validation->param('package_id'); + $c->param('package_id'); my $ebsco = Koha::ERM::Providers::EBSCO->new; my $p = $ebsco->request( GET => '/vendors/' . $vendor_id . '/packages/' . $package_id ); @@ -124,10 +124,10 @@ sub edit { my $c = shift or return; return try { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $is_selected = $body->{is_selected}; my ( $vendor_id, $package_id ) = split '-', - $c->validation->param('package_id'); + $c->param('package_id'); my $ebsco = Koha::ERM::Providers::EBSCO->new; my $t = try { diff --git a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm index 538766d640..ff310d6fe1 100644 --- a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm @@ -53,9 +53,11 @@ sub get { my $c = shift or return; return try { - my $package_id = $c->validation->param('package_id'); - my $package = $c->objects->find( Koha::ERM::EHoldings::Packages->search, - $package_id ); + my $package_id = $c->param('package_id'); + my $package = $c->objects->find( + Koha::ERM::EHoldings::Packages->search, + $package_id + ); unless ($package) { return $c->render( @@ -87,7 +89,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $package_agreements = delete $body->{package_agreements} // []; delete $body->{external_id} unless $body->{external_id}; @@ -149,7 +151,7 @@ Controller function that handles updating a Koha::ERM::EHoldings::Package object sub update { my $c = shift or return; - my $package_id = $c->validation->param('package_id'); + my $package_id = $c->param('package_id'); my $package = Koha::ERM::EHoldings::Packages->find( $package_id ); unless ($package) { @@ -163,7 +165,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $package_agreements = delete $body->{package_agreements} // []; delete $body->{external_id} unless $body->{external_id}; @@ -219,7 +221,7 @@ sub update { sub delete { my $c = shift or return; - my $package = Koha::ERM::EHoldings::Packages->find( $c->validation->param('package_id') ); + my $package = Koha::ERM::EHoldings::Packages->find( $c->param('package_id') ); unless ($package) { return $c->render( status => 404, @@ -239,5 +241,4 @@ sub delete { }; } - 1; diff --git a/Koha/REST/V1/ERM/EHoldings/Resources.pm b/Koha/REST/V1/ERM/EHoldings/Resources.pm index 76d6614527..f158a3f94e 100644 --- a/Koha/REST/V1/ERM/EHoldings/Resources.pm +++ b/Koha/REST/V1/ERM/EHoldings/Resources.pm @@ -36,7 +36,7 @@ use Try::Tiny qw( catch try ); sub list { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Resources::EBSCO::list($c); } else { @@ -53,7 +53,7 @@ Controller function that handles retrieving a single Koha::ERM::EHoldings::Resou sub get { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Resources::EBSCO::get($c); } else { @@ -70,7 +70,7 @@ Controller function that handles editing a single Koha::ERM::EHoldings::Resource sub edit { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Resources::EBSCO::edit($c); } else { diff --git a/Koha/REST/V1/ERM/EHoldings/Resources/Local.pm b/Koha/REST/V1/ERM/EHoldings/Resources/Local.pm index e4fa55aeb7..40741f691d 100644 --- a/Koha/REST/V1/ERM/EHoldings/Resources/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Resources/Local.pm @@ -36,7 +36,7 @@ sub list { my $c = shift or return; return try { - my $package_id = $c->validation->param('package_id'); + my $package_id = $c->param('package_id'); my $resources_set = $package_id ? Koha::ERM::EHoldings::Resources->search( { package_id => $package_id } ) diff --git a/Koha/REST/V1/ERM/EHoldings/Titles.pm b/Koha/REST/V1/ERM/EHoldings/Titles.pm index 97a3f0bb2d..8340cee7f1 100644 --- a/Koha/REST/V1/ERM/EHoldings/Titles.pm +++ b/Koha/REST/V1/ERM/EHoldings/Titles.pm @@ -36,7 +36,7 @@ use Koha::REST::V1::ERM::EHoldings::Titles::EBSCO; sub list { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Titles::EBSCO::list($c); } else { @@ -53,7 +53,7 @@ Controller function that handles retrieving a single Koha::ERM::EHoldings::Packa sub get { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider eq 'ebsco' ) { return Koha::REST::V1::ERM::EHoldings::Titles::EBSCO::get($c); } else { @@ -70,7 +70,7 @@ Controller function that handles adding a new Koha::ERM::EHoldings::Title object sub add{ my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { @@ -88,7 +88,7 @@ Controller function that handles updating a Koha::ERM::EHoldings::Title object sub update { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { @@ -103,7 +103,7 @@ sub update { sub delete { my $c = shift->openapi->valid_input or return; - my $provider = $c->validation->param('provider'); + my $provider = $c->param('provider'); if ( $provider && $provider eq 'ebsco' ) { die "invalid action"; } else { diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm b/Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm index 05c672c7fb..ca8743e57b 100644 --- a/Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm +++ b/Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm @@ -119,9 +119,8 @@ sub get { my $c = shift or return; return try { - my $title_id = $c->validation->param('title_id'); - my $ebsco = Koha::ERM::Providers::EBSCO->new; - my $t = $ebsco->request( GET => '/titles/' . $title_id ); + my $ebsco = Koha::ERM::Providers::EBSCO->new; + my $t = $ebsco->request( GET => '/titles/' . $c->param('title_id') ); unless ($t) { return $c->render( status => 404, diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm index 28444f5cc5..0aab8af865 100644 --- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm @@ -57,8 +57,7 @@ sub get { my $c = shift or return; return try { - my $title_id = $c->validation->param('title_id'); - my $title = $c->objects->find( Koha::ERM::EHoldings::Titles->search, $title_id ); + my $title = $c->objects->find( Koha::ERM::EHoldings::Titles->search, $c->param('title_id') ); unless ($title ) { return $c->render( @@ -90,7 +89,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $resources = delete $body->{resources} // []; @@ -152,8 +151,7 @@ Controller function that handles updating a Koha::ERM::EHoldings::Title object sub update { my $c = shift or return; - my $title_id = $c->validation->param('title_id'); - my $title = Koha::ERM::EHoldings::Titles->find( $title_id ); + my $title = Koha::ERM::EHoldings::Titles->find( $c->param('title_id') ); unless ($title) { return $c->render( @@ -166,7 +164,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $resources = delete $body->{resources} // []; @@ -219,7 +217,7 @@ sub update { sub delete { my $c = shift or return; - my $title = Koha::ERM::EHoldings::Titles->find( $c->validation->param('title_id') ); + my $title = Koha::ERM::EHoldings::Titles->find( $c->param('title_id') ); unless ($title) { return $c->render( status => 404, @@ -246,7 +244,7 @@ sub delete { sub import_from_list { my $c = shift or return; - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $list_id = $body->{list_id}; my $package_id = $body->{package_id}; diff --git a/Koha/REST/V1/ERM/Licenses.pm b/Koha/REST/V1/ERM/Licenses.pm index f3e19a697c..9408dfecae 100644 --- a/Koha/REST/V1/ERM/Licenses.pm +++ b/Koha/REST/V1/ERM/Licenses.pm @@ -36,8 +36,7 @@ sub list { my $c = shift->openapi->valid_input or return; return try { - my $licenses_set = Koha::ERM::Licenses->new; - my $licenses = $c->objects->search( $licenses_set ); + my $licenses = $c->objects->search( Koha::ERM::Licenses->new ); return $c->render( status => 200, openapi => $licenses ); } catch { @@ -56,8 +55,7 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $license_id = $c->validation->param('license_id'); - my $license = $c->objects->find( Koha::ERM::Licenses->search, $license_id ); + my $license = $c->objects->find( Koha::ERM::Licenses->new, $c->param('license_id') ); unless ($license) { return $c->render( @@ -89,7 +87,7 @@ sub add { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $user_roles = delete $body->{user_roles} // []; my $documents = delete $body->{documents} // []; @@ -158,8 +156,7 @@ Controller function that handles updating a Koha::ERM::License object sub update { my $c = shift->openapi->valid_input or return; - my $license_id = $c->validation->param('license_id'); - my $license = Koha::ERM::Licenses->find( $license_id ); + my $license = Koha::ERM::Licenses->find( $c->param('license_id') ); unless ($license) { return $c->render( @@ -172,7 +169,7 @@ sub update { Koha::Database->new->schema->txn_do( sub { - my $body = $c->validation->param('body'); + my $body = $c->req->json; my $user_roles = delete $body->{user_roles} // []; my $documents = delete $body->{documents} // []; @@ -232,7 +229,7 @@ sub update { sub delete { my $c = shift->openapi->valid_input or return; - my $license = Koha::ERM::Licenses->find( $c->validation->param('license_id') ); + my $license = Koha::ERM::Licenses->find( $c->param('license_id') ); unless ($license) { return $c->render( status => 404, -- 2.39.5