You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/08/06 15:19:43 UTC
[airavata-php-gateway] 01/02: AIRAVATA-3086 Facade for accessing
GroupManagerService
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git
commit 3f2192589eb57ae0b5a3a9cde9f5b89c5ce3fbef
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Tue Aug 6 11:01:45 2019 -0400
AIRAVATA-3086 Facade for accessing GroupManagerService
---
.../Airavata/Facades/GroupManagerServices.php | 16 +++++
.../Airavata/GroupManagerServiceProvider.php | 83 ++++++++++++++++++++++
2 files changed, 99 insertions(+)
diff --git a/app/libraries/Airavata/Facades/GroupManagerServices.php b/app/libraries/Airavata/Facades/GroupManagerServices.php
new file mode 100644
index 0000000..0b89b4c
--- /dev/null
+++ b/app/libraries/Airavata/Facades/GroupManagerServices.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Airavata\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+class GroupManagerServices extends Facade {
+
+ /**
+ * Get the registered name of the component.
+ *
+ * @return string
+ */
+ protected static function getFacadeAccessor() { return 'group_manager_services'; }
+
+}
diff --git a/app/libraries/Airavata/GroupManagerServiceProvider.php b/app/libraries/Airavata/GroupManagerServiceProvider.php
new file mode 100644
index 0000000..152aa41
--- /dev/null
+++ b/app/libraries/Airavata/GroupManagerServiceProvider.php
@@ -0,0 +1,83 @@
+<?php namespace Airavata;
+
+use Airavata\Service\Profile\Groupmanager\CPI\GroupManagerServiceClient;
+use Illuminate\Routing\UrlGenerator;
+use Illuminate\Support\ServiceProvider;
+use Illuminate\Support\Facades\Config;
+use Thrift\Transport\TSocket;
+use Thrift\Protocol\TBinaryProtocol;
+use Thrift\Protocol\TMultiplexedProtocol;
+use Illuminate\Routing\Redirector;
+
+class GroupManagerServiceProvider extends ServiceProvider {
+
+ /**
+ * Indicates if loading of the provider is deferred.
+ *
+ * @var bool
+ */
+ protected $defer = false;
+
+ /**
+ * Bootstrap the application events.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ $this->package('airavata/group_manager_services');
+ }
+
+ /**
+ * Register the service provider.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ //registering service provider
+ $this->app['group_manager_services'] = $this->app->share(function($app)
+ {
+ try{
+ $transport = new TSocket(
+ Config::get('pga_config.airavata')['airavata-profile-service-server'],
+ Config::get('pga_config.airavata')['airavata-profile-service-port']
+ );
+ $transport->setRecvTimeout( Config::get('pga_config.airavata')['airavata-timeout']);
+ $transport->setSendTimeout( Config::get('pga_config.airavata')['airavata-timeout']);
+
+ $protocol = new TBinaryProtocol($transport);
+ $protocol = new TMultiplexedProtocol($protocol, "GroupManagerService");
+ $transport->open();
+
+ $client = new GroupManagerServiceClient($protocol);
+
+ }catch (\Exception $ex){
+ throw new \Exception("Unable to instantiate Airavata GroupManagerService Client", 0, $ex);
+ }
+
+ if( is_object( $client))
+ return $client;
+ else
+ throw new \Exception("Unable to instantiate Airavata GroupManagerService Client");
+ });
+
+ //registering alis
+ $this->app->booting(function()
+ {
+ $loader = \Illuminate\Foundation\AliasLoader::getInstance();
+ $loader->alias('GroupManagerService', 'Airavata\Facades\GroupManagerServices');
+ });
+ }
+
+ /**
+ * Get the services provided by the provider.
+ *
+ * @return array
+ */
+ public function provides()
+ {
+ return array('group_manager_services');
+ }
+
+}