Bugzilla – Attachment 83876 Details for
Bug 17047
Mana Knowledge Base : Data sharing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17047: Koha::SharedContent subs snake casing/renaming
Bug-17047-KohaSharedContent-subs-snake-casingrenam.patch (text/plain), 14.55 KB, created by
Alex Arnaud
on 2019-01-14 10:01:50 UTC
(
hide
)
Description:
Bug 17047: Koha::SharedContent subs snake casing/renaming
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2019-01-14 10:01:50 UTC
Size:
14.55 KB
patch
obsolete
>From 9781e5dfddc7cecf47abbd0abaca9377b70fd184 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 23 Aug 2018 09:27:15 +0000 >Subject: [PATCH] Bug 17047: Koha::SharedContent subs snake casing/renaming > >manaRequest => process_request >manaIncrementRequest => increment_entity_value >manaPostRequest => send_entity >prepareSharedData => prepare_entity_data >manaGetRequestWithId => get_entity_by_id >manaGetRequest => search_entities >buildRequest => build_request >manaUrl => get_sharing_url > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > C4/Serials.pm | 2 +- > Koha/SharedContent.pm | 44 ++++++++++++++++++------------------- > reports/guided_reports.pl | 2 +- > serials/serials-search.pl | 2 +- > serials/subscription-add.pl | 6 ++--- > serials/subscription-detail.pl | 2 +- > svc/mana/increment | 2 +- > svc/mana/search | 2 +- > svc/mana/share | 4 ++-- > svc/mana/token | 2 +- > svc/mana/use | 2 +- > t/db_dependent/Koha/SharedContent.t | 28 +++++++++++------------ > 12 files changed, 49 insertions(+), 49 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 23b67d8..e929e21 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -282,7 +282,7 @@ sub GetSubscription { > $subscription->{additional_fields} = $additional_field_values->{$subscriptionid}; > > if ( my $mana_id = $subscription->{mana_id} ) { >- my $mana_subscription = Koha::SharedContent::manaGetRequestWithId( >+ my $mana_subscription = Koha::SharedContent::get_entity_by_id( > 'subscription', $mana_id, {usecomments => 1}); > $subscription->{comments} = $mana_subscription->{data}->{comments}; > } >diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm >index 1e98add..587285d 100644 >--- a/Koha/SharedContent.pm >+++ b/Koha/SharedContent.pm >@@ -34,11 +34,11 @@ Package for accessing shared content via Mana > > =cut > >-=head3 manaRequest >+=head3 process_request > > =cut > >-sub manaRequest { >+sub process_request { > my $mana_request = shift; > my $result; > $mana_request->content_type('application/json'); >@@ -63,26 +63,26 @@ sub manaRequest { > return $result ; > } > >-=head3 manaIncrementRequest >+=head3 increment_entity_value > > =cut > >-sub manaIncrementRequest { >- return manaRequest(buildRequest('increment', @_)); >+sub increment_entity_value { >+ return process_request(build_request('increment', @_)); > } > >-=head3 manaPostRequest >+=head3 send_entity > > =cut > >-sub manaPostRequest { >+sub send_entity { > my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_; > > unless ( $content ) { >- $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype); >+ $content = prepare_entity_data($lang, $loggedinuser, $resourceid, $resourcetype); > } > >- my $result = manaRequest(buildRequest('post', $resourcetype, $content)); >+ my $result = process_request(build_request('post', $resourcetype, $content)); > > if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) { > my $packages = "Koha::".ucfirst($resourcetype)."s"; >@@ -92,11 +92,11 @@ sub manaPostRequest { > return $result; > } > >-=head3 prepareSharedData >+=head3 prepare_entity_data > > =cut > >-sub prepareSharedData { >+sub prepare_entity_data { > my ($lang, $loggedinuser, $ressourceid, $ressourcetype) = @_; > $lang ||= C4::Context->preference('language'); > >@@ -126,30 +126,30 @@ sub prepareSharedData { > return $ressource_mana_info; > } > >-=head3 manaGetRequestWithId >+=head3 get_entity_by_id > > =cut > >-sub manaGetRequestWithId { >- return manaRequest(buildRequest('getwithid', @_)); >+sub get_entity_by_id { >+ return process_request(build_request('getwithid', @_)); > } > >-=head3 manaGetRequest >+=head3 search_entities > > =cut > >-sub manaGetRequest { >- return manaRequest(buildRequest('get', @_)); >+sub search_entities { >+ return process_request(build_request('get', @_)); > } > >-=head3 buildRequest >+=head3 build_request > > =cut > >-sub buildRequest { >+sub build_request { > my $type = shift; > my $resource = shift; >- my $mana_url = manaUrl(); >+ my $mana_url = get_sharing_url(); > > if ( $type eq 'get' ) { > my $params = shift; >@@ -201,11 +201,11 @@ sub buildRequest { > } > } > >-=head3 manaUrl >+=head3 get_sharing_url > > =cut > >-sub manaUrl { >+sub get_sharing_url { > return C4::Context->config('mana_config'); > } > >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 49b5b47..511d939 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -678,7 +678,7 @@ elsif ( $phase eq 'Save Report' ) { > } > > elsif ($phase eq 'Share'){ >- my $result = Koha::SharedContent::manaPostRequest($input->param('mana_language'), $borrowernumber, scalar $input->param('reportid'), 'report'); >+ my $result = Koha::SharedContent::send_entity($input->param('mana_language'), $borrowernumber, scalar $input->param('reportid'), 'report'); > if ( $result ) { > print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg}); > }else{ >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index d213c92..5d23f21 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -99,7 +99,7 @@ my @subscriptions; > my $mana_statuscode; > if ($searched){ > if ($mana) { >- my $result = Koha::SharedContent::manaGetRequest("subscription",{ >+ my $result = Koha::SharedContent::search_entities("subscription",{ > title => $title, > issn => $ISSN, > ean => $EAN, >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 1c5688c..2edb78d 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -345,7 +345,7 @@ sub redirect_add_subscription { > my $mana_id; > if ( $query->param('mana_id') ne "" ) { > $mana_id = $query->param('mana_id'); >- Koha::SharedContent::manaIncrementRequest("subscription",$mana_id, "nbofusers"); >+ Koha::SharedContent::increment_entity_value("subscription",$mana_id, "nbofusers"); > } > > my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); >@@ -370,7 +370,7 @@ sub redirect_add_subscription { > $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ); > if ( (C4::Context->preference('Mana')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){ >- my $result = Koha::SharedContent::manaPostRequest( $query->param('mana_language'), $loggedinuser, $subscriptionid, 'subscription'); >+ my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription'); > $template->param( mana_msg => $result->{msg} ); > } > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >@@ -443,7 +443,7 @@ sub redirect_mod_subscription { > my $mana_id; > if ( defined( $query->param('mana_id') ) ) { > $mana_id = $query->param('mana_id'); >- Koha::SharedContent::manaIncrementRequest("subscription",$mana_id, "nbofusers"); >+ Koha::SharedContent::increment_entity_value("subscription",$mana_id, "nbofusers"); > } > else { > $mana_id = undef; >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index 1fd4442..451e5a6 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -100,7 +100,7 @@ if ($op eq 'del') { > } > elsif ( $op and $op eq "share" ) { > my $mana_language = $query->param('mana_language'); >- my $result = Koha::SharedContent::manaPostRequest($mana_language, $loggedinuser, $subscriptionid, 'subscription'); >+ my $result = Koha::SharedContent::send_entity($mana_language, $loggedinuser, $subscriptionid, 'subscription'); > $template->param( mana_code => $result->{msg} ); > $subs->{mana_id} = $result->{id}; > } >diff --git a/svc/mana/increment b/svc/mana/increment >index b8e5f8e..5b58496 100755 >--- a/svc/mana/increment >+++ b/svc/mana/increment >@@ -38,7 +38,7 @@ my ( $auth_status, $sessionID ) = > if ( $auth_status ne "ok" ) { > exit 0; > } >-my $result = Koha::SharedContent::manaIncrementRequest( >+my $result = Koha::SharedContent::increment_entity_value( > scalar $input->param('resource'), > scalar $input->param('id'), > scalar $input->param('field'), >diff --git a/svc/mana/search b/svc/mana/search >index 96cb56f..a89e54c 100755 >--- a/svc/mana/search >+++ b/svc/mana/search >@@ -66,7 +66,7 @@ $sub_mana_info = $package->get_search_info($identifier); > > $sub_mana_info->{ usecomments } = $input->param('usecomments'); > my $resourcename = $input->param('resource'); >-my $result = Koha::SharedContent::manaGetRequest( $resourcename, $sub_mana_info); >+my $result = Koha::SharedContent::search_entities( $resourcename, $sub_mana_info); > my $nbofcomment; > foreach my $resource (@{ $result->{data} }){ > $nbofcomment = 0; >diff --git a/svc/mana/share b/svc/mana/share >index cced006..508eec2 100755 >--- a/svc/mana/share >+++ b/svc/mana/share >@@ -44,12 +44,12 @@ my $content; > $content->{resource_id} = $input->param("resource_id"); > $content->{resource_type} = $input->param("resource"); > $content->{message} = $input->param("message"); >-Koha::SharedContent::manaPostRequest('', undef, undef, 'resource_comment', $content); >+Koha::SharedContent::send_entity('', undef, undef, 'resource_comment', $content); > my $package = "Koha::".ucfirst($input->param('resource')); > my $resource; > my $result; > eval{ >- $result = Koha::SharedContent::manaGetRequestWithId( >+ $result = Koha::SharedContent::get_entity_by_id( > scalar $input->param('resource'), > scalar $input->param('id') > ); >diff --git a/svc/mana/token b/svc/mana/token >index e9e89ad..3ea6254 100755 >--- a/svc/mana/token >+++ b/svc/mana/token >@@ -50,6 +50,6 @@ $content->{ lastname }= $input->param("lastname"); > $content->{ email }= $input->param("email"); > my $json = to_json( $content, { utf8 => 1 } ); > $request->content($json); >-my $result = Koha::SharedContent::manaRequest($request); >+my $result = Koha::SharedContent::process_request($request); > > print(to_json($result)); >diff --git a/svc/mana/use b/svc/mana/use >index 42966ec..f08e9d1 100755 >--- a/svc/mana/use >+++ b/svc/mana/use >@@ -40,7 +40,7 @@ if ( $auth_status ne "ok" ) { > exit 0; > } > >-my $result = Koha::SharedContent::manaGetRequestWithId( >+my $result = Koha::SharedContent::get_entity_by_id( > scalar $input->param('resource'), > scalar $input->param('id') > ); >diff --git a/t/db_dependent/Koha/SharedContent.t b/t/db_dependent/Koha/SharedContent.t >index 5e41814..44c9f78 100644 >--- a/t/db_dependent/Koha/SharedContent.t >+++ b/t/db_dependent/Koha/SharedContent.t >@@ -43,9 +43,9 @@ my $query = {}; > > t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar'); > >-is(Koha::SharedContent::manaUrl(), 'https://foo.bar', 'Mana URL'); >+is(Koha::SharedContent::get_sharing_url(), 'https://foo.bar', 'Mana URL'); > >-my $result = Koha::SharedContent::manaGetRequest('report', $query); >+my $result = Koha::SharedContent::search_entities('report', $query); > ok($result->{msg} =~ /Can\'t connect to foo.bar:443$/, 'Unable to connect'); > is($result->{code}, 500, 'Code is 500'); > >@@ -56,17 +56,17 @@ $ua->mock('request', sub { > > $want_error = 1; > $query = {query => 'foo', usecomments => 1}; >-$result = Koha::SharedContent::manaGetRequest('report', $query); >+$result = Koha::SharedContent::search_entities('report', $query); > ok($result->{msg} =~ /^Error thrown by decoded_content/, 'Error in decoded_content'); > is($result->{code}, 500, 'Code is 500'); > > $want_error = 0; > $query = {title => 'foo', usecomments => 1}; >-$result = Koha::SharedContent::manaGetRequest('subscription', $query); >-is($result->{code}, 200, 'manaGetRequest success'); >+$result = Koha::SharedContent::search_entities('subscription', $query); >+is($result->{code}, 200, 'search_entities success'); > >-$result = Koha::SharedContent::manaGetRequestWithId('subscription', 23); >-is($result->{code}, 200, 'manaGetRequestWithId success'); >+$result = Koha::SharedContent::get_entity_by_id('subscription', 23); >+is($result->{code}, 200, 'get_entity_by_id success'); > > my $params = { > title => 'The English historical review', >@@ -76,7 +76,7 @@ my $params = { > }; > > # Search a subscription. >-my $request = Koha::SharedContent::buildRequest('get', 'subscription', $params); >+my $request = Koha::SharedContent::build_request('get', 'subscription', $params); > is($request->method, 'GET', 'Get subscription - Method is get'); > > my %query = $request->uri->query_form; >@@ -88,7 +88,7 @@ is($query{publishercode}, 'Longman', 'Check publisher'); > is($request->uri->path, '/subscription.json', 'Path is subscription'); > > # Get a report by id. >-$request = Koha::SharedContent::buildRequest('getwithid', 'report', 26); >+$request = Koha::SharedContent::build_request('getwithid', 'report', 26); > is($request->method, 'GET', 'Get with id - Method is get'); > > is($request->uri->path, '/report/26.json', 'Path is report/26.json'); >@@ -105,7 +105,7 @@ my $content = { > 'type' => undef > }; > >-$request = Koha::SharedContent::buildRequest('post', 'report', $content); >+$request = Koha::SharedContent::build_request('post', 'report', $content); > is($request->method, 'POST', 'Share report - Method is post'); > > is($request->uri->path, '/report.json', 'Path is report.json'); >@@ -163,13 +163,13 @@ C4::Context->set_userenv(0,0,0, > t::lib::Mocks::mock_preference('language', 'en'); > > $post_request = 1; >-$result = Koha::SharedContent::manaPostRequest('en', $loggedinuser->{borrowernumber}, $subscription->{subscriptionid}, 'subscription'); >-is($result->{code}, 200, 'manaPostRequest success'); >+$result = Koha::SharedContent::send_entity('en', $loggedinuser->{borrowernumber}, $subscription->{subscriptionid}, 'subscription'); >+is($result->{code}, 200, 'send_entity success'); > > my $s = Koha::Subscriptions->find($subscription->{subscriptionid}); > is($s->mana_id, 5, 'Mana id is set'); > >-my $data = Koha::SharedContent::prepareSharedData( >+my $data = Koha::SharedContent::prepare_entity_data( > '', > $loggedinuser->{borrowernumber}, > $subscription->{subscriptionid}, >@@ -235,7 +235,7 @@ sub mock_response { > } > > # Increment request. >-$request = Koha::SharedContent::buildRequest('increment', >+$request = Koha::SharedContent::build_request('increment', > 'subscription', > 12, > 'foo'); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17047
:
56175
|
56176
|
56177
|
56178
|
56179
|
56180
|
56181
|
59728
|
59729
|
59931
|
61905
|
62045
|
62046
|
62047
|
62048
|
62049
|
62050
|
62051
|
62052
|
62053
|
62054
|
62075
|
62465
|
62475
|
62485
|
62540
|
62542
|
62543
|
62544
|
62545
|
62546
|
62547
|
62548
|
62549
|
62550
|
62551
|
62552
|
62553
|
62589
|
62591
|
62592
|
62593
|
62594
|
62595
|
62596
|
62597
|
62598
|
62599
|
62603
|
62604
|
62605
|
62606
|
62607
|
62768
|
63476
|
63601
|
63618
|
63619
|
63620
|
63621
|
63622
|
63623
|
64484
|
64530
|
64618
|
64619
|
64620
|
64621
|
64622
|
64623
|
64624
|
64625
|
64626
|
64627
|
64628
|
64629
|
64630
|
64631
|
64632
|
64633
|
64634
|
64635
|
64636
|
64637
|
64638
|
64639
|
64640
|
64641
|
64642
|
64643
|
64648
|
64649
|
64650
|
64651
|
64652
|
64653
|
64654
|
64706
|
64962
|
65058
|
65059
|
65060
|
65061
|
65062
|
65063
|
65064
|
65065
|
65773
|
66667
|
66668
|
66987
|
67003
|
67004
|
67005
|
67006
|
67009
|
67010
|
67011
|
67012
|
67013
|
67014
|
67015
|
67016
|
67017
|
67018
|
67019
|
67020
|
67021
|
67022
|
67023
|
69034
|
69035
|
69036
|
69037
|
69038
|
69039
|
69040
|
69041
|
69091
|
70203
|
70204
|
70205
|
70206
|
70208
|
70209
|
70210
|
70211
|
70561
|
70874
|
72660
|
72661
|
72662
|
72663
|
72664
|
72665
|
72666
|
72667
|
72668
|
72669
|
72670
|
73699
|
73737
|
73738
|
73739
|
73740
|
73741
|
73742
|
73743
|
73744
|
73745
|
73746
|
73747
|
73748
|
73975
|
73976
|
73977
|
73978
|
73979
|
73980
|
73981
|
73982
|
73983
|
73984
|
73985
|
73986
|
76673
|
76674
|
76675
|
76676
|
76677
|
76678
|
76679
|
76680
|
76681
|
76682
|
76683
|
76684
|
78215
|
78216
|
78217
|
78218
|
78219
|
78220
|
78221
|
78222
|
78223
|
78224
|
78225
|
78226
|
78227
|
78228
|
78229
|
79868
|
79869
|
79870
|
79871
|
79872
|
79874
|
79877
|
79878
|
79879
|
79880
|
79881
|
79882
|
79883
|
79884
|
79885
|
79886
|
79887
|
79888
|
79922
|
79923
|
79924
|
79925
|
79926
|
79927
|
79928
|
79929
|
79930
|
79931
|
79932
|
79933
|
79934
|
79935
|
79936
|
79937
|
79938
|
79939
|
80183
|
80184
|
80185
|
80186
|
80187
|
80188
|
80189
|
80190
|
80191
|
80192
|
80193
|
80194
|
80195
|
80196
|
80197
|
80198
|
80199
|
80200
|
80471
|
80472
|
80473
|
80907
|
80908
|
80909
|
80910
|
80911
|
80912
|
80913
|
80914
|
80915
|
80916
|
80917
|
80918
|
80919
|
80920
|
80921
|
80922
|
80923
|
80924
|
81935
|
81936
|
81937
|
81938
|
81939
|
81940
|
81941
|
81942
|
81943
|
81944
|
81945
|
81946
|
81947
|
81948
|
81949
|
81950
|
81951
|
81952
|
81968
|
83863
|
83864
|
83865
|
83866
|
83867
|
83868
|
83869
|
83870
|
83871
|
83872
|
83873
|
83874
|
83875
|
83876
|
83877
|
83878
|
83879
|
83880
|
83881
|
83892
|
83893
|
83894
|
83895
|
83896
|
83897
|
83898
|
83899
|
83900
|
83901
|
83902
|
83903
|
83904
|
83905
|
83906
|
83907
|
83908
|
83909
|
83910
|
83911
|
83912
|
84142
|
84145
|
84210
|
84260
|
84261
|
84262
|
84263
|
84264
|
84265
|
84323
|
84324
|
84325
|
84326
|
84327
|
84328
|
84329
|
84332