From 0f9cb5b1de40b5351d87cf565c6540a8c38b422d Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 3 Aug 2018 13:49:47 +0200
Subject: [PATCH] rename class, for less ambiguity

---
 bin/access-check-manager.pl.in                    | 10 +++++-----
 lib/AccountManager/App.pm                         |  6 +++---
 lib/AccountManager/Service/Manager.pm             | 15 ---------------
 .../{Service.pm => ServiceProvider.pm}            |  2 +-
 lib/AccountManager/ServiceProvider/Manager.pm     | 15 +++++++++++++++
 lib/Makefile.am                                   |  4 ++--
 6 files changed, 26 insertions(+), 26 deletions(-)
 delete mode 100644 lib/AccountManager/Service/Manager.pm
 rename lib/AccountManager/{Service.pm => ServiceProvider.pm} (95%)
 create mode 100644 lib/AccountManager/ServiceProvider/Manager.pm

diff --git a/bin/access-check-manager.pl.in b/bin/access-check-manager.pl.in
index 570172f..33cc363 100755
--- a/bin/access-check-manager.pl.in
+++ b/bin/access-check-manager.pl.in
@@ -16,8 +16,8 @@ use Pod::Usage;
 use AccountManager::Account;
 use AccountManager::Account::Manager;
 use AccountManager::Metadata;
-use AccountManager::Service;
-use AccountManager::Service::Manager;
+use AccountManager::ServiceProvider;
+use AccountManager::ServiceProvider::Manager;
 use AccountManager::Token;
 use AccountManager::Token::Manager;
 use AccountManager::Tools;
@@ -198,7 +198,7 @@ sub add_service {
     ) unless $options{contacts};
 
     ## Check if entry already exists in DB first
-    my $provider = AccountManager::Service->new(
+    my $provider = AccountManager::ServiceProvider->new(
         db       => $db,
         entityid => $options{sp_entityid}
     );
@@ -209,7 +209,7 @@ sub add_service {
         $provider->contacts($options{contacts});
         $provider->displayname($options{displayname}) if $options{displayname};
     } else {
-        $provider = AccountManager::Service->new(
+        $provider = AccountManager::ServiceProvider->new(
             db          => $db,
             entityid    => $options{sp_entityid},
             contacts    => $options{contacts},
@@ -226,7 +226,7 @@ sub add_service {
 sub list_services {
     my %args;
 
-    my $providers = AccountManager::Service::Manager->get_services(db => $db, %args);
+    my $providers = AccountManager::ServiceProvider::Manager->get_service_providers(db => $db, %args);
 
     if (! @$providers) {
         printf "No service provider in DB\n";
diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index aa24eb1..5409539 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -13,7 +13,7 @@ use Template::Constants qw(:chomp);
 use AccountManager::Account;
 use AccountManager::Account::Manager;
 use AccountManager::Metadata;
-use AccountManager::Service;
+use AccountManager::ServiceProvider;
 use AccountManager::Token;
 use AccountManager::Tools;
 use AccountManager::L10N;
@@ -302,7 +302,7 @@ sub req_select_email {
     ) if $entityid !~ $entity_id_pattern;
 
     # Create a persistent service provider object
-    my $sp = AccountManager::Service->new(
+    my $sp = AccountManager::ServiceProvider->new(
         db       => $self->{db},
         entityid => $entityid
     );
@@ -398,7 +398,7 @@ sub req_complete_challenge {
         user => "missing_email"
     ) if !$email;
 
-    my $provider = AccountManager::Service->new(
+    my $provider = AccountManager::ServiceProvider->new(
         db       => $self->{db},
         entityid => $entityid,
     );
diff --git a/lib/AccountManager/Service/Manager.pm b/lib/AccountManager/Service/Manager.pm
deleted file mode 100644
index dfab75b..0000000
--- a/lib/AccountManager/Service/Manager.pm
+++ /dev/null
@@ -1,15 +0,0 @@
-package AccountManager::Service::Manager;
-
-use strict;
-use warnings;
-
-use base qw(Rose::DB::Object::Manager);
-
-use AccountManager::Service;
-
-sub object_class { 'AccountManager::Service' }
-
-__PACKAGE__->make_manager_methods('services');
-
-1;
-
diff --git a/lib/AccountManager/Service.pm b/lib/AccountManager/ServiceProvider.pm
similarity index 95%
rename from lib/AccountManager/Service.pm
rename to lib/AccountManager/ServiceProvider.pm
index 539df49..fb2c8d7 100644
--- a/lib/AccountManager/Service.pm
+++ b/lib/AccountManager/ServiceProvider.pm
@@ -1,4 +1,4 @@
-package AccountManager::Service;
+package AccountManager::ServiceProvider;
 
 use strict;
 use warnings;
diff --git a/lib/AccountManager/ServiceProvider/Manager.pm b/lib/AccountManager/ServiceProvider/Manager.pm
new file mode 100644
index 0000000..3177a9b
--- /dev/null
+++ b/lib/AccountManager/ServiceProvider/Manager.pm
@@ -0,0 +1,15 @@
+package AccountManager::ServiceProvider::Manager;
+
+use strict;
+use warnings;
+
+use base qw(Rose::DB::Object::Manager);
+
+use AccountManager::ServiceProvider;
+
+sub object_class { 'AccountManager::ServiceProvider' }
+
+__PACKAGE__->make_manager_methods('service_providers');
+
+1;
+
diff --git a/lib/Makefile.am b/lib/Makefile.am
index ff9df00..84e581b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -6,8 +6,8 @@ nobase_modules_DATA = \
 	AccountManager/DB.pm \
 	AccountManager/DB/Object.pm \
 	AccountManager/Metadata.pm \
-	AccountManager/Service.pm \
-	AccountManager/Service/Manager.pm \
+	AccountManager/ServiceProvider.pm \
+	AccountManager/ServiceProvider/Manager.pm \
 	AccountManager/Account.pm \
 	AccountManager/Account/Manager.pm \
 	AccountManager/Tools.pm \
-- 
GitLab