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 2017/06/22 13:32:33 UTC

airavata-php-gateway git commit: Adding TenantProfileServiceProvider

Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 3f1360db6 -> 97dc57e38


Adding TenantProfileServiceProvider


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/97dc57e3
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/97dc57e3
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/97dc57e3

Branch: refs/heads/develop
Commit: 97dc57e384abdef9dafa0b7908a55b7e1bf1f879
Parents: 3f1360d
Author: Marcus Christie <ma...@iu.edu>
Authored: Thu Jun 22 09:32:18 2017 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Thu Jun 22 09:32:18 2017 -0400

----------------------------------------------------------------------
 app/config/app.php                              |  1 +
 .../Airavata/Facades/TenantProfileServices.php  | 16 ++++
 .../Airavata/TenantProfileServiceProvider.php   | 83 ++++++++++++++++++++
 3 files changed, 100 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97dc57e3/app/config/app.php
----------------------------------------------------------------------
diff --git a/app/config/app.php b/app/config/app.php
index a0a9f05..f13aa23 100755
--- a/app/config/app.php
+++ b/app/config/app.php
@@ -126,6 +126,7 @@ return array(
         'Airavata\AiravataServiceProvider',
         'Airavata\IamAdminServiceProvider',
         'Airavata\UserProfileServiceProvider',
+        'Airavata\TenantProfileServiceProvider',
         'Teepluss\Theme\ThemeServiceProvider',
         'GrahamCampbell\Markdown\MarkdownServiceProvider',
     ),

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97dc57e3/app/libraries/Airavata/Facades/TenantProfileServices.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Facades/TenantProfileServices.php b/app/libraries/Airavata/Facades/TenantProfileServices.php
new file mode 100644
index 0000000..42dc53e
--- /dev/null
+++ b/app/libraries/Airavata/Facades/TenantProfileServices.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Airavata\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+class TenantProfileServices extends Facade {
+
+    /**
+     * Get the registered name of the component.
+     *
+     * @return string
+     */
+    protected static function getFacadeAccessor() { return 'tenant_profile_services'; }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97dc57e3/app/libraries/Airavata/TenantProfileServiceProvider.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/TenantProfileServiceProvider.php b/app/libraries/Airavata/TenantProfileServiceProvider.php
new file mode 100644
index 0000000..27f240e
--- /dev/null
+++ b/app/libraries/Airavata/TenantProfileServiceProvider.php
@@ -0,0 +1,83 @@
+<?php namespace Airavata;
+
+use Airavata\Service\Profile\Tenant\CPI\TenantProfileServiceClient;
+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 TenantProfileServiceProvider 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/tenant_profile_services');
+    }
+
+	/**
+	 * Register the service provider.
+	 *
+	 * @return void
+	 */
+	public function register()
+	{
+        //registering service provider
+        $this->app['tenant_profile_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, "TenantProfileService");
+                $transport->open();
+
+                $client = new TenantProfileServiceClient($protocol);
+
+            }catch (\Exception $ex){
+                throw new \Exception("Unable to instantiate Airavata TenantProfileService Client", 0,  $ex);
+            }
+
+            if( is_object( $client))
+                return $client;
+            else
+                throw new \Exception("Unable to instantiate Airavata TenantProfileService Client");
+        });
+
+        //registering alis
+        $this->app->booting(function()
+        {
+            $loader = \Illuminate\Foundation\AliasLoader::getInstance();
+            $loader->alias('TenantProfileService', 'Airavata\Facades\TenantProfileServices');
+        });
+	}
+
+	/**
+	 * Get the services provided by the provider.
+	 *
+	 * @return array
+	 */
+	public function provides()
+	{
+		return array('tenant_profile_services');
+	}
+
+}