airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [5/8] airavata-php-gateway git commit: wrapping Airavata and WSIS code as laravel library component and service providers
Date Sat, 09 May 2015 13:11:57 GMT
wrapping Airavata and WSIS code as laravel library component and service providers


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/3ca02155
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/3ca02155
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/3ca02155

Branch: refs/heads/master
Commit: 3ca02155c67493ff295638e5fc2a2d74a0f0d4cb
Parents: b70ad13
Author: Supun Nakandala <supun.nakandala@gmail.com>
Authored: Sat May 9 13:54:23 2015 +0530
Committer: Supun Nakandala <supun.nakandala@gmail.com>
Committed: Sat May 9 13:54:23 2015 +0530

----------------------------------------------------------------------
 app/config/app.php                              |    6 +-
 app/config/packages/airavata/wsis/config.php    |   52 -
 app/controllers/AccountController.php           |    2 +-
 app/filters.php                                 |    6 +-
 app/libraries/AdminUtilities.php                |    3 +-
 app/libraries/AiravataClientFactory.php         |   23 -
 app/libraries/AppUtilities.php                  |   53 +-
 app/libraries/CRUtilities.php                   |  117 +-
 app/libraries/ExpUtilities.php                  |   53 +-
 app/libraries/IdUtilities.php                   |  172 ++
 app/libraries/Utilities.php                     |  391 ++-
 app/libraries/WSISUtilities.php                 |  318 +++
 app/libraries/Wsis/Facades/Wsis.php             |   16 +
 .../Wsis/Stubs/AuthenticationAdmin.php          |   55 +
 .../Wsis/Stubs/AuthenticationAdminStub.php      | 1016 ++++++++
 app/libraries/Wsis/Stubs/TenantManager.php      |  139 ++
 app/libraries/Wsis/Stubs/TenantMgtAdminStub.php |  306 +++
 app/libraries/Wsis/Stubs/UserStoreManager.php   |  203 ++
 .../Wsis/Stubs/UserStoreManagerStub.php         | 1570 ++++++++++++
 app/libraries/Wsis/Wsis.php                     |  280 +++
 app/libraries/Wsis/WsisServiceProvider.php      |   64 +
 app/libraries/XmlIdUtilities.php                |  292 +++
 app/libraries/id_utilities.php                  |  172 --
 app/libraries/utilities.php                     | 2337 ------------------
 app/libraries/wsis_utilities.php                |  320 ---
 app/libraries/xml_id_utilities.php              |  294 ---
 workbench/airavata/wsis/.gitignore              |    4 -
 workbench/airavata/wsis/.travis.yml             |   13 -
 workbench/airavata/wsis/composer.json           |   20 -
 workbench/airavata/wsis/phpunit.xml             |   18 -
 .../wsis/src/Airavata/Wsis/Facades/Wsis.php     |   16 -
 .../src/Airavata/Wsis/Stubs/TenantManager.php   |  139 --
 .../Airavata/Wsis/Stubs/TenantMgtAdminStub.php  |  306 ---
 .../Airavata/Wsis/Stubs/UserStoreManager.php    |  203 --
 .../Wsis/Stubs/UserStoreManagerStub.php         | 1570 ------------
 .../airavata/wsis/src/Airavata/Wsis/Wsis.php    |  280 ---
 .../src/Airavata/Wsis/WsisServiceProvider.php   |   64 -
 workbench/airavata/wsis/src/config/config.php   |   52 -
 workbench/airavata/wsis/tests/.gitkeep          |    0
 39 files changed, 4787 insertions(+), 6158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/config/app.php
----------------------------------------------------------------------
diff --git a/app/config/app.php b/app/config/app.php
index 1b4c90f..93d1421 100755
--- a/app/config/app.php
+++ b/app/config/app.php
@@ -121,7 +121,8 @@ return array(
 		'Illuminate\Validation\ValidationServiceProvider',
 		'Illuminate\View\ViewServiceProvider',
 		'Illuminate\Workbench\WorkbenchServiceProvider',
-        'Airavata\Wsis\WsisServiceProvider',
+        'Wsis\WsisServiceProvider',
+        'Airavata\AiravataServiceProvider',
 	),
 
 	/*
@@ -188,7 +189,8 @@ return array(
 		'URL'             => 'Illuminate\Support\Facades\URL',
 		'Validator'       => 'Illuminate\Support\Facades\Validator',
 		'View'            => 'Illuminate\Support\Facades\View',
-        'WSIS'            => 'Airavata\Wsis\Facades\Wsis',
+        'WSIS'            => 'Wsis\Facades\Wsis',
+        'Airavata'        => 'Airavata\Facades\Airavata',
 	),
 
 );

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/config/packages/airavata/wsis/config.php
----------------------------------------------------------------------
diff --git a/app/config/packages/airavata/wsis/config.php b/app/config/packages/airavata/wsis/config.php
deleted file mode 100644
index 9041036..0000000
--- a/app/config/packages/airavata/wsis/config.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-return array(
-    /**
-     * Admin Role Name
-     */
-    'admin-role-name' => 'admin',
-
-    /**
-     * Gateway user role
-     */
-    'gateway-admin' => 'Internal/everyone',
-
-    /**
-     * Tenant admin's username
-     */
-    'admin-username' => 'test@testphprg.scigap.org',
-
-    /**
-     * Tenant admin's password
-     */
-    'admin-password' => 'testadmin@scigap.org',
-
-    /**
-     * Identity server domain
-     */
-    'server' => 'idp.scigap.org',
-
-    /**
-     * Identity server web services endpoint
-     */
-    'service-url' => 'https://idp.scigap.org:7443/services/',
-
-    /**
-     * Gateway domain name
-     */
-    'gateway-id' => 'default',
-
-    /**
-     * Path to the server certificate file
-     */
-    'cafile-path' => app_path() . '/resources/security/idp_scigap_org.pem',
-
-    /**
-     * Enable HTTPS server verification
-     */
-    'verify-peer' => true,
-
-    /**
-     * Allow self signed server certificates
-     */
-    'allow-self-signed' => false
-);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 752c05d..63a87db 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -80,7 +80,7 @@ class AccountController extends BaseController {
                 	
                     Utilities::store_id_in_session($username);
                     Utilities::print_success_message('Login successful! You will be redirected to your home page shortly.');
-                	Session::put("gateway_id", Config::get('wsis::gateway-id'));
+                	Session::put("gateway_id", Config::get('pga_config.wsis')['gateway-id']);
                 	//TODO::If this option is not safe, have to find a better method to send credentials to identity server on every connection.
                 	Session::put("password", $_POST["password"]);
                 	

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/filters.php
----------------------------------------------------------------------
diff --git a/app/filters.php b/app/filters.php
index 93b988b..33f98d2 100755
--- a/app/filters.php
+++ b/app/filters.php
@@ -13,11 +13,9 @@
 
 App::before(function($request)
 {
-	$airavataClient = Utilities::get_airavata_client();
-	if( ! is_object( $airavataClient))
+    $apiVersion = Airavata::getApiVersion();
+	if(empty($apiVersion))
 		return View::make("server-down");
-	else
-		Session::put("airavataClient", $airavataClient);
 });
 
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index b2bf9e1..5775991 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -3,10 +3,9 @@
 use Airavata\Model\Workspace\Gateway;
 
 public function addGateway( $input){
-	$airavataClient = Session::get("airavataClient");
 	$gateway = new Gateway();
 	$gateway->domain = $input["domainName"];
 	$gateway->gatewayName = $input["gatewayName"];
 	$gateway->emailAddress = $input["admin-email"];
-	return $airavataClient->addGateway( $gateway);
+	return Airavata::addGateway( $gateway);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/AiravataClientFactory.php
----------------------------------------------------------------------
diff --git a/app/libraries/AiravataClientFactory.php b/app/libraries/AiravataClientFactory.php
index c55a359..efd01a9 100755
--- a/app/libraries/AiravataClientFactory.php
+++ b/app/libraries/AiravataClientFactory.php
@@ -2,29 +2,6 @@
 
 namespace Airavata\Client;
 
-$GLOBALS['THRIFT_ROOT'] = 'Thrift/';
-//require_once $GLOBALS['THRIFT_ROOT'] . 'Thrift.php';
-/*
-require_once $GLOBALS['THRIFT_ROOT'] . 'Transport/TTransport.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Transport/TSocket.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Protocol/TProtocol.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Protocol/TBinaryProtocol.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Exception/TException.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Exception/TTransportException.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Type/TType.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Type/TMessageType.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'Factory/TStringFuncFactory.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'StringFunc/TStringFunc.php';
-require_once $GLOBALS['THRIFT_ROOT'] . 'StringFunc/Core.php';
-
-$GLOBALS['AIRAVATA_ROOT'] = 'Airavata/';
-require_once $GLOBALS['AIRAVATA_ROOT'] . 'API/Airavata.php';
-*/
-
-use Thrift\Protocol\TBinaryProtocol;
-use Thrift\Transport\TSocket;
-use Airavata\API\AiravataClient;
-
 class AiravataClientFactory
 {
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/AppUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AppUtilities.php b/app/libraries/AppUtilities.php
index 2f9b32e..e485a36 100644
--- a/app/libraries/AppUtilities.php
+++ b/app/libraries/AppUtilities.php
@@ -1,29 +1,20 @@
 <?php
 
 //Airavata classes - loaded from app/libraries/Airavata
-use Airavata\API\AiravataClient;
-
 use Airavata\Model\AppCatalog\AppInterface\DataType;
 use Airavata\Model\AppCatalog\AppInterface\InputDataObjectType;
 use Airavata\Model\AppCatalog\AppInterface\OutputDataObjectType;
 use Airavata\Model\AppCatalog\AppInterface\ApplicationInterfaceDescription;
-
-use Airavata\Model\Workspace\Project;
-
 use Airavata\Model\AppCatalog\AppDeployment\ApplicationModule;
 use Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType;
 use Airavata\Model\AppCatalog\AppDeployment\ApplicationDeploymentDescription;
 use Airavata\Model\AppCatalog\AppDeployment\SetEnvPaths;
 
-//use Airavata\Model\AppCatalog\ComputeResource
-
 
 class AppUtilities{
 
 	public static function create_or_update_appModule( $inputs, $update = false){
 
-		$airavataclient = Session::get("airavataClient");
-
 		$appModule = new ApplicationModule( array(
 												"appModuleName" => $inputs["appModuleName"],
 												"appModuleVersion" => $inputs["appModuleVersion"],
@@ -31,25 +22,21 @@ class AppUtilities{
 										));
 		
 		if( $update)
-			return $airavataclient->updateApplicationModule( $inputs["appModuleId"], $appModule);
+			return Airavata::updateApplicationModule( $inputs["appModuleId"], $appModule);
 		else
-			return $airavataclient->registerApplicationModule( Session::get("gateway_id"), $appModule);
+			return Airavata::registerApplicationModule( Session::get("gateway_id"), $appModule);
 	}
 
 	public static function deleteAppModule( $appModuleId){
 
-		$airavataclient = Session::get("airavataClient");
-
-		return $airavataclient->deleteApplicationModule( $appModuleId);
+		return Airavata::deleteApplicationModule( $appModuleId);
 	}
 
 	public static function getAppInterfaceData(){
 
-		$airavataclient = Session::get("airavataClient");
-
 		$dataType = new DataType();
 		$modules = AppUtilities::getAllModules();
-		$appInterfaces = $airavataclient->getAllApplicationInterfaces( Session::get("gateway_id"));
+		$appInterfaces = Airavata::getAllApplicationInterfaces( Session::get("gateway_id"));
 
 
 		$InputDataObjectType = new InputDataObjectType();
@@ -62,8 +49,7 @@ class AppUtilities{
 	}
 
 	public static function create_or_update_appInterface( $appInterfaceValues, $update = false){
-		
-		$airavataclient = Session::get("airavataClient");
+
 		//var_dump( $appInterfaceValues); exit;
 		$appInterface = new ApplicationInterfaceDescription( array(
 																"applicationName" => $appInterfaceValues["applicationName"],
@@ -112,28 +98,23 @@ class AppUtilities{
 		//var_dump( $appInterface); exit;
 
 		if( $update)
-			$airavataclient->updateApplicationInterface( $appInterfaceValues["app-interface-id"], $appInterface);
+            Airavata::updateApplicationInterface( $appInterfaceValues["app-interface-id"], $appInterface);
 		else
-			$airavataclient->getApplicationInterface($airavataclient->registerApplicationInterface( Session::get("gateway_id"), $appInterface) );
+            Airavata::getApplicationInterface(Airavata::registerApplicationInterface( Session::get("gateway_id"), $appInterface) );
 
 		//print_r( "App interface has been created.");
 	}
 
 	public static function deleteAppInterface( $appInterfaceId){
-
-		$airavataclient = Session::get("airavataClient");
-
-		return $airavataclient->deleteApplicationInterface( $appInterfaceId);
+		return Airavata::deleteApplicationInterface( $appInterfaceId);
 	}
 
 
 	public static function getAppDeploymentData(){
 
-		$airavataclient = Session::get("airavataClient");
-
-		$appDeployments = $airavataclient->getAllApplicationDeployments( Session::get("gateway_id"));
+		$appDeployments = Airavata::getAllApplicationDeployments( Session::get("gateway_id"));
 		//var_dump( $appDeployments); exit;
-		$computeResources = $airavataclient->getAllComputeResourceNames();
+		$computeResources = Airavata::getAllComputeResourceNames();
 		$modules = AppUtilities::getAllModules();
 		$apt = new ApplicationParallelismType();
 
@@ -149,8 +130,6 @@ class AppUtilities{
 
 		$appDeploymentValues = $inputs;
 
-		$airavataclient = Session::get("airavataClient");
-
 		if( isset( $appDeploymentValues["moduleLoadCmds"]))
 			$appDeploymentValues["moduleLoadCmds"] = array_unique( array_filter( $appDeploymentValues["moduleLoadCmds"]));
 
@@ -207,9 +186,9 @@ class AppUtilities{
 		//var_dump( $appDeploymentValues); exit;
 		$appDeployment = new ApplicationDeploymentDescription(  $appDeploymentValues);
 		if( $update)
-			$airavataclient->updateApplicationDeployment( $inputs["app-deployment-id"], $appDeployment);
+            Airavata::updateApplicationDeployment( $inputs["app-deployment-id"], $appDeployment);
 		else
-			$appDeploymentId = $airavataclient->registerApplicationDeployment( Session::get("gateway_id"), $appDeployment);
+			$appDeploymentId = Airavata::registerApplicationDeployment( Session::get("gateway_id"), $appDeployment);
 
 		return;
 
@@ -217,14 +196,10 @@ class AppUtilities{
 
 	public static function deleteAppDeployment( $appDeploymentId )
 	{
-
-		$airavataclient = Session::get("airavataClient");
-
-		return $airavataclient->deleteApplicationDeployment( $appDeploymentId);
+		return Airavata::deleteApplicationDeployment( $appDeploymentId);
 	}
 
 	public static function getAllModules(){
-		$airavataclient = Session::get("airavataClient");
-		return $airavataclient->getAllAppModules( Session::get("gateway_id"));
+		return Airavata::getAllAppModules( Session::get("gateway_id"));
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 98fa54e..92e06f3 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -2,12 +2,8 @@
 
 
 //Airavata classes - loaded from app/libraries/Airavata
-use Airavata\API\AiravataClient;
-
 //Compute Resource classes
-
 use Airavata\Model\AppCatalog\ComputeResource\FileSystems;
-use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionInterface;
 use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionProtocol;
 use Airavata\Model\AppCatalog\ComputeResource\SecurityProtocol;
 use Airavata\Model\AppCatalog\ComputeResource\ResourceJobManager;
@@ -25,9 +21,7 @@ use Airavata\Model\AppCatalog\ComputeResource\LOCALDataMovement;
 use Airavata\Model\AppCatalog\ComputeResource\UnicoreDataMovement;
 use Airavata\Model\AppCatalog\ComputeResource\MonitorMode;
 
-
 //Gateway Classes
-
 use Airavata\Model\AppCatalog\GatewayProfile\GatewayResourceProfile;
 use Airavata\Model\AppCatalog\GatewayProfile\ComputeResourcePreference;
 
@@ -46,14 +40,13 @@ class CRUtilities{
  */
 public static function register_or_update_compute_resource( $computeDescription, $update = false)
 {
-    $airavataclient = Session::get("airavataClient");
     if( $update)
     {
         $computeResourceId = $computeDescription->computeResourceId;
 
-        if( $airavataclient->updateComputeResource( $computeResourceId, $computeDescription) )
+        if( Airavata::updateComputeResource( $computeResourceId, $computeDescription) )
         {
-            $computeResource = $airavataclient->getComputeResource( $computeResourceId);
+            $computeResource = Airavata::getComputeResource( $computeResourceId);
             return $computeResource;
         }
         else
@@ -67,10 +60,10 @@ public static function register_or_update_compute_resource( $computeDescription,
             $computeDescription["fileSystems"][$fileSystem] = "";
         */
         $cd = new ComputeResourceDescription( $computeDescription);
-        $computeResourceId = $airavataclient->registerComputeResource( $cd);
+        $computeResourceId = Airavata::registerComputeResource( $cd);
     }
 
-    $computeResource = $airavataclient->getComputeResource( $computeResourceId);
+    $computeResource = Airavata::getComputeResource( $computeResourceId);
     return $computeResource;
 
 }
@@ -111,8 +104,7 @@ public static function createQueueObject( $queue){
 
 public static function deleteQueue( $computeResourceId, $queueName)
 {
-    $airavataclient = Session::get("airavataClient");
-    $airavataclient->deleteBatchQueue( $computeResourceId, $queueName);
+    Airavata::deleteBatchQueue( $computeResourceId, $queueName);
 }
 
 
@@ -122,7 +114,6 @@ public static function deleteQueue( $computeResourceId, $queueName)
 
 public static function create_or_update_JSIObject( $inputs, $update = false){
 
-    $airavataclient = Session::get("airavataClient");
     $computeResource = Utilities::get_compute_resource(  $inputs["crId"]);
 
 
@@ -151,13 +142,13 @@ public static function create_or_update_JSIObject( $inputs, $update = false){
 
         if( $update) //update Local JSP
         {
-            $jsiObject = $airavataclient->getLocalJobSubmission( $jsiId);
-            $localSub = $airavataclient->updateResourceJobManager(  $jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
+            $jsiObject = Airavata::getLocalJobSubmission( $jsiId);
+            $localSub = Airavata::updateResourceJobManager(  $jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
             //$localSub = $airavataclient->updateLocalSubmissionDetails( $jsiId, $localJobSubmission);
         }
         else        // create Local JSP
         {
-            $localSub = $airavataclient->addLocalSubmissionDetails( $computeResource->computeResourceId, 0, $localJobSubmission);
+            $localSub = Airavata::addLocalSubmissionDetails( $computeResource->computeResourceId, 0, $localJobSubmission);
             return $localSub;
         }
         
@@ -182,26 +173,26 @@ public static function create_or_update_JSIObject( $inputs, $update = false){
         //var_dump( $sshJobSubmission); exit;
         if( $update) //update Local JSP
         {
-            $jsiObject = $airavataclient->getSSHJobSubmission( $jsiId);
+            $jsiObject = Airavata::getSSHJobSubmission( $jsiId);
 
             //first update resource job manager
             $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
-            $airavataclient->updateResourceJobManager(  $rmjId, $resourceManager);
-            $jsiObject = $airavataclient->getSSHJobSubmission( $jsiId);
+            Airavata::updateResourceJobManager(  $rmjId, $resourceManager);
+            $jsiObject = Airavata::getSSHJobSubmission( $jsiId);
 
             $jsiObject->securityProtocol = intval( $inputs["securityProtocol"] );
             $jsiObject->alternativeSSHHostName = $inputs["alternativeSSHHostName"];
             $jsiObject->sshPort = intval( $inputs["sshPort"] );
             $jsiObject->monitorMode = intval( $inputs["monitorMode"] );
-            $jsiObject->resourceJobManager = $airavataclient->getresourceJobManager( $rmjId);
+            $jsiObject->resourceJobManager = Airavata::getresourceJobManager( $rmjId);
             //var_dump( $jsiObject); exit;
             //add updated resource job manager to ssh job submission object.
             //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
-            $localSub = $airavataclient->updateSSHJobSubmissionDetails( $jsiId, $jsiObject);
+            $localSub = Airavata::updateSSHJobSubmissionDetails( $jsiId, $jsiObject);
         }
         else
         {
-            $sshSub = $airavataclient->addSSHJobSubmissionDetails( $computeResource->computeResourceId, 0, $sshJobSubmission);
+            $sshSub = Airavata::addSSHJobSubmissionDetails( $computeResource->computeResourceId, 0, $sshJobSubmission);
         }
         return;        
     }
@@ -215,15 +206,15 @@ public static function create_or_update_JSIObject( $inputs, $update = false){
                                                         );
         if( $update)
         {
-            $jsiObject = $airavataclient->getUnicoreJobSubmission( $jsiId);
+            $jsiObject = Airavata::getUnicoreJobSubmission( $jsiId);
             $jsiObject->securityProtocol = intval( $inputs["securityProtocol"] );
             $jsiObject->unicoreEndPointURL = $inputs["unicoreEndPointURL"];
 
-            $unicoreSub = $airavataclient->updateUnicoreJobSubmissionDetails( $jsiId, $jsiObject);
+            $unicoreSub = Airavata::updateUnicoreJobSubmissionDetails( $jsiId, $jsiObject);
         }
         else
         {
-            $unicoreSub = $airavataclient->addUNICOREJobSubmissionDetails( $computeResource->computeResourceId, 0, $unicoreJobSubmission);
+            $unicoreSub = Airavata::addUNICOREJobSubmissionDetails( $computeResource->computeResourceId, 0, $unicoreJobSubmission);
         }
     }
     else /* Globus does not work currently */
@@ -236,13 +227,12 @@ public static function create_or_update_JSIObject( $inputs, $update = false){
  * Creating Data Movement Interface Object.
 */
 public static function create_or_update_DMIObject( $inputs, $update = false){
-    $airavataclient = Session::get("airavataClient");
 
     $computeResource = Utilities::get_compute_resource(  $inputs["crId"] );
     if( $inputs["dataMovementProtocol"] == DataMovementProtocol::LOCAL) /* LOCAL */
     {
         $localDataMovement = new LOCALDataMovement();
-        $localdmp = $airavataclient->addLocalDataMovementDetails( $computeResource->computeResourceId, 0, $localDataMovement);
+        $localdmp = Airavata::addLocalDataMovementDetails( $computeResource->computeResourceId, 0, $localDataMovement);
         
         if( $localdmp)
             print_r( "The Local Data Movement has been added. Edit UI for the Local Data Movement Interface is yet to be made.
@@ -260,9 +250,9 @@ public static function create_or_update_DMIObject( $inputs, $update = false){
                                             );
 
         if( $update)
-            $scpdmp = $airavataclient->updateSCPDataMovementDetails( $inputs["dmiId"], $scpDataMovement);
+            $scpdmp = Airavata::updateSCPDataMovementDetails( $inputs["dmiId"], $scpDataMovement);
         else
-            $scpdmp = $airavataclient->addSCPDataMovementDetails( $computeResource->computeResourceId, 0, $scpDataMovement);   
+            $scpdmp = Airavata::addSCPDataMovementDetails( $computeResource->computeResourceId, 0, $scpDataMovement);
    }
     else if( $inputs["dataMovementProtocol"] == DataMovementProtocol::GridFTP) /* GridFTP */
     {
@@ -271,9 +261,9 @@ public static function create_or_update_DMIObject( $inputs, $update = false){
                 "gridFTPEndPoints" => $inputs["gridFTPEndPoints"]
             ));
         if( $update)
-            $gridftpdmp = $airavataclient->updateGridFTPDataMovementDetails( $inputs["dmiId"], $gridFTPDataMovement);
+            $gridftpdmp = Airavata::updateGridFTPDataMovementDetails( $inputs["dmiId"], $gridFTPDataMovement);
         else
-            $gridftpdmp = $airavataclient->addGridFTPDataMovementDetails( $computeResource->computeResourceId, 0, $gridFTPDataMovement);
+            $gridftpdmp = Airavata::addGridFTPDataMovementDetails( $computeResource->computeResourceId, 0, $gridFTPDataMovement);
     }
     else if( $inputs["dataMovementProtocol"] == DataMovementProtocol::UNICORE_STORAGE_SERVICE) /* Unicore Storage Service */
     {
@@ -284,9 +274,9 @@ public static function create_or_update_DMIObject( $inputs, $update = false){
                                                             )
                                                         );
         if( $update)
-            $unicoredmp = $airavataclient->updateUnicoreDataMovementDetails( $inputs["dmiId"], $unicoreDataMovement);
+            $unicoredmp = Airavata::updateUnicoreDataMovementDetails( $inputs["dmiId"], $unicoreDataMovement);
         else
-            $unicoredmp = $airavataclient->addUnicoreDataMovementDetails( $computeResource->computeResourceId, 0, $unicoreDataMovement);
+            $unicoredmp = Airavata::addUnicoreDataMovementDetails( $computeResource->computeResourceId, 0, $unicoreDataMovement);
     }
     else /* other data movement protocols */
     {
@@ -295,8 +285,7 @@ public static function create_or_update_DMIObject( $inputs, $update = false){
 }
 
 public static function getAllCRObjects( $onlyName = false){
-    $airavataclient = Session::get("airavataClient");
-    $crNames = $airavataclient->getAllComputeResourceNames();
+    $crNames = Airavata::getAllComputeResourceNames();
     if( $onlyName)
         return $crNames;
     else
@@ -304,7 +293,7 @@ public static function getAllCRObjects( $onlyName = false){
         $crObjects = array();
         foreach( $crNames as $id => $crName)
         {
-            $crObjects[] = $airavataclient->getComputeResource( $id);
+            $crObjects[] = Airavata::getComputeResource( $id);
         }
         return $crObjects;
     }
@@ -312,8 +301,7 @@ public static function getAllCRObjects( $onlyName = false){
 }
 
 public static function getBrowseCRData(){
-    $airavataclient = Session::get("airavataClient");
-	$appDeployments = $airavataclient->getAllApplicationDeployments( Session::get("gateway_id"));
+	$appDeployments = Airavata::getAllApplicationDeployments( Session::get("gateway_id"));
 
     return array( 'crObjects' => CRUtilities::getAllCRObjects(true),
     			  'appDeployments' => $appDeployments 
@@ -322,30 +310,28 @@ public static function getBrowseCRData(){
 
 public static function getJobSubmissionDetails( $jobSubmissionInterfaceId, $jsp){
     //jsp = job submission protocol type
-    $airavataclient = Session::get("airavataClient");
     if( $jsp == JobSubmissionProtocol::LOCAL)
-        return $airavataclient->getLocalJobSubmission( $jobSubmissionInterfaceId);
+        return Airavata::getLocalJobSubmission( $jobSubmissionInterfaceId);
     else if( $jsp == JobSubmissionProtocol::SSH)
-        return $airavataclient->getSSHJobSubmission( $jobSubmissionInterfaceId);
+        return Airavata::getSSHJobSubmission( $jobSubmissionInterfaceId);
     else if( $jsp == JobSubmissionProtocol::UNICORE)
-        return $airavataclient->getUnicoreJobSubmission( $jobSubmissionInterfaceId);
+        return Airavata::getUnicoreJobSubmission( $jobSubmissionInterfaceId);
     else if( $jsp == JobSubmissionProtocol::CLOUD)
-        return $airavataclient->getCloudJobSubmission( $jobSubmissionInterfaceId);
+        return Airavata::getCloudJobSubmission( $jobSubmissionInterfaceId);
 
     //globus get function not present ??	
 }
 
 public static function getDataMovementDetails( $dataMovementInterfaceId, $dmi){
     //jsp = job submission protocol type
-    $airavataclient = Session::get("airavataClient");
     if( $dmi == DataMovementProtocol::LOCAL)
-        return $airavataclient->getLocalDataMovement( $dataMovementInterfaceId);
+        return Airavata::getLocalDataMovement( $dataMovementInterfaceId);
     else if( $dmi == DataMovementProtocol::SCP)
-        return $airavataclient->getSCPDataMovement( $dataMovementInterfaceId);
+        return Airavata::getSCPDataMovement( $dataMovementInterfaceId);
     else if( $dmi == DataMovementProtocol::GridFTP)
-        return $airavataclient->getGridFTPDataMovement( $dataMovementInterfaceId);
+        return Airavata::getGridFTPDataMovement( $dataMovementInterfaceId);
     else if( $dmi == DataMovementProtocol::UNICORE_STORAGE_SERVICE)
-        return $airavataclient->getUnicoreDataMovement( $dataMovementInterfaceId);
+        return Airavata::getUnicoreDataMovement( $dataMovementInterfaceId);
     /*
     else if( $dmi == JobSubmissionProtocol::CLOUD)
         return $airavataclient->getCloudJobSubmission( $dataMovementInterfaceId);
@@ -355,26 +341,24 @@ public static function getDataMovementDetails( $dataMovementInterfaceId, $dmi){
 }
 
 public static function deleteActions( $inputs){
-    $airavataclient = Session::get("airavataClient");
     if( isset( $inputs["jsiId"]) )
-        if( $airavataclient->deleteJobSubmissionInterface( $inputs["crId"], $inputs["jsiId"]) )
+        if( Airavata::deleteJobSubmissionInterface( $inputs["crId"], $inputs["jsiId"]) )
             return 1;
         else
             return 0;
     else if( isset( $inputs["dmiId"]) )
-        if( $airavataclient->deleteDataMovementInterface( $inputs["crId"], $inputs["dmiId"]) )
+        if( Airavata::deleteDataMovementInterface( $inputs["crId"], $inputs["dmiId"]) )
             return 1;
         else 
             return 0;
     elseif( isset( $inputs["del-crId"]))
-    	if( $airavataclient->deleteComputeResource( $inputs["del-crId"] ) )
+    	if( Airavata::deleteComputeResource( $inputs["del-crId"] ) )
     		return 1;
     	else
     		return 0;
 }
 
 public static function create_or_update_gateway_profile( $inputs, $update = false){
-    $airavataclient = Session::get("airavataClient");
 
     $computeResourcePreferences = array();
     if( isset( $input["crPreferences"]) )
@@ -393,23 +377,22 @@ public static function create_or_update_gateway_profile( $inputs, $update = fals
                                                         "gatewayDescription" => $inputs["gatewayDescription"]
                                                         )
                                                 );
-        $gatewayProfileId = $airavataclient->updateGatewayResourceProfile( $inputs["edit-gpId"], $gatewayProfile);
+        $gatewayProfileId = Airavata::updateGatewayResourceProfile( $inputs["edit-gpId"], $gatewayProfile);
     }
     else
-        $gatewayProfileId = $airavataclient->registerGatewayResourceProfile( $gatewayProfile);
+        $gatewayProfileId = Airavata::registerGatewayResourceProfile( $gatewayProfile);
 }
 
 public static function getAllGatewayProfilesData(){
-    $airavataclient = Session::get("airavataClient");
 
     if( Session::has("scigap_admin") )
-        $gateways = $airavataclient->getAllGateways();
+        $gateways = Airavata::getAllGateways();
     else
     {
-        $gateways[0] = $airavataclient->getGateway( Config::get('wsis::gateway-id'));
+        $gateways[0] = Airavata::getGateway( Config::get('wsis::gateway-id'));
     }
 
-    $gatewayProfiles = $airavataclient->getAllGatewayComputeResources();
+    $gatewayProfiles = Airavata::getAllGatewayComputeResources();
     //$gatewayProfileIds = array("GatewayTest3_57726e98-313f-4e7c-87a5-18e69928afb5", "GatewayTest4_4fd9fb28-4ced-4149-bdbd-1f276077dad8");
     foreach( $gateways as $key => $gw)
     {
@@ -421,7 +404,7 @@ public static function getAllGatewayProfilesData(){
             {
                 foreach( (array)$gp->computeResourcePreferences as $i => $crp)
                 {
-                    $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = $airavataclient->getComputeResource( $crp->computeResourceId);
+                    $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = Airavata::getComputeResource( $crp->computeResourceId);
                 }
                 $gateways[$key]->profile = $gatewayProfiles[$index];
             }
@@ -433,25 +416,19 @@ public static function getAllGatewayProfilesData(){
 }
 
 public static function add_or_update_CRP( $inputs){
-    $airavataclient = Session::get("airavataClient");
-
     $computeResourcePreferences = new computeResourcePreference( $inputs);
 
     //var_dump( $inputs); exit;
-    return $airavataclient->addGatewayComputeResourcePreference( $inputs["gatewayId"], $inputs["computeResourceId"], $computeResourcePreferences);
+    return Airavata::addGatewayComputeResourcePreference( $inputs["gatewayId"], $inputs["computeResourceId"], $computeResourcePreferences);
 
 }
 
 public static function deleteGP( $gpId){
-    $airavataclient = Session::get("airavataClient");
-
-    return $airavataclient->deleteGatewayResourceProfile( $gpId);
+    return Airavata::deleteGatewayResourceProfile( $gpId);
 }
 
 public static function deleteCR( $inputs){
-    $airavataclient = Session::get("airavataClient");
-
-    return $airavataclient->deleteGatewayComputeResourcePreference( $inputs["gpId"], $inputs["rem-crId"]);
+    return Airavata::deleteGatewayComputeResourcePreference( $inputs["gpId"], $inputs["rem-crId"]);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/ExpUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExpUtilities.php b/app/libraries/ExpUtilities.php
index 40e5d36..ae5ab7f 100644
--- a/app/libraries/ExpUtilities.php
+++ b/app/libraries/ExpUtilities.php
@@ -1,15 +1,6 @@
 <?php
 
-//Thrift classes - loaded from Vendor/Thrift
-use Thrift\Transport\TTransport;
-use Thrift\Exception\TException;
-use Thrift\Exception\TTransportException;
-use Thrift\Factory\TStringFuncFactory;
-use Thrift\Protocol\TBinaryProtocol;
-use Thrift\Transport\TSocket;
-
 //Airavata classes - loaded from app/libraries/Airavata
-use Airavata\API\AiravataClient;
 use Airavata\API\Error\InvalidRequestException;
 use Airavata\API\Error\AiravataClientException;
 use Airavata\API\Error\AiravataSystemException;
@@ -22,8 +13,6 @@ use Airavata\Model\Workspace\Experiment\Experiment;
 use Airavata\Model\Workspace\Experiment\ExperimentState;
 use Airavata\Model\AppCatalog\AppInterface\DataType;
 use Airavata\Model\Workspace\Experiment\JobState;
-use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionInterface;
-use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionProtocol;
 
 class ExpUtilities{
 
@@ -33,7 +22,6 @@ class ExpUtilities{
  */
 public static function launch_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
     //global $tokenFilePath;
     try
     {
@@ -151,12 +139,11 @@ public static function list_input_files($experiment)
  */
 public static function get_application_inputs($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $inputs = null;
 
     try
     {
-        $inputs = $airavataclient->getApplicationInputs($id);
+        $inputs = Airavata::getApplicationInputs($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -188,12 +175,11 @@ public static function get_application_inputs($id)
  */
 public static function get_application_outputs($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $outputs = null;
 
     try
     {
-        $outputs = $airavataclient->getApplicationOutputs($id);
+        $outputs = Airavata::getApplicationOutputs($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -225,11 +211,9 @@ public static function get_application_outputs($id)
  */
 public static function get_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
-        return $airavataclient->getExperiment($expId);
+        return Airavata::getExperiment($expId);
     }
     catch (InvalidRequestException $ire)
     {
@@ -575,11 +559,9 @@ public static function file_upload_successful()
  */
 public static function update_experiment($expId, $updatedExperiment)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
-        $airavataclient->updateExperiment($expId, $updatedExperiment);
+        Airavata::updateExperiment($expId, $updatedExperiment);
 
         /*
         Utilities::print_success_message("<p>Experiment updated!</p>" .
@@ -621,14 +603,12 @@ public static function update_experiment($expId, $updatedExperiment)
  */
 public static function clone_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
         //create new experiment to receive the clone
-        $experiment = $airavataclient->getExperiment($expId);
+        $experiment = Airavata::getExperiment($expId);
 
-        $cloneId = $airavataclient->cloneExperiment($expId, 'Clone of ' . $experiment->name);
+        $cloneId = Airavata::cloneExperiment($expId, 'Clone of ' . $experiment->name);
 
         Utilities::print_success_message("<p>Experiment cloned!</p>" .
             '<p>You will be redirected to the edit page shortly, or you can
@@ -674,11 +654,9 @@ public static function clone_experiment($expId)
  */
 public static function cancel_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
-        $airavataclient->terminateExperiment($expId);
+        Airavata::terminateExperiment($expId);
 
         Utilities::print_success_message("Experiment canceled!");
     }
@@ -727,8 +705,6 @@ public static function cancel_experiment($expId)
  */
 public static function create_experiment()
 {
-    $airavataclient = Session::get("airavataClient");
-
     $experiment = Utilities::assemble_experiment();
     //var_dump($experiment); exit;
     $expId = null;
@@ -737,7 +713,7 @@ public static function create_experiment()
     {
         if($experiment)
         {
-            $expId = $airavataclient->createExperiment( Session::get("gateway_id"), $experiment);
+            $expId = Airavata::createExperiment( Session::get("gateway_id"), $experiment);
         }
 
         if ($expId)
@@ -805,8 +781,6 @@ public static function list_output_files($experiment, $expStatus)
 }
 public static function get_experiment_values( $experiment, $project, $forSearch = false)
 {
-    $airavataclient = Session::get("airavataClient");
-    //var_dump( $experiment); exit;
     $expVal = array();
     $expVal["experimentStatusString"] = "";
     $expVal["experimentTimeOfStateChange"] = "";
@@ -821,7 +795,7 @@ public static function get_experiment_values( $experiment, $project, $forSearch
         $expVal["experimentTimeOfStateChange"] = date('Y-m-d H:i:s', $experimentStatus->timeOfStateChange/1000); // divide by 1000 since timeOfStateChange is in ms
         $expVal["experimentCreationTime"] = date('Y-m-d H:i:s', $experiment->creationTime/1000); // divide by 1000 since creationTime is in ms
     }
-    $jobStatus = $airavataclient->getJobStatuses($experiment->experimentID);
+    $jobStatus = Airavata::getJobStatuses($experiment->experimentID);
 
     if ($jobStatus)
     {
@@ -884,7 +858,6 @@ public static function get_experiment_values( $experiment, $project, $forSearch
  */
 public static function get_expsearch_results( $inputs)
 {
-    $airavataclient = Session::get("airavataClient");
     $experiments = array();
 
     try
@@ -892,16 +865,16 @@ public static function get_expsearch_results( $inputs)
         switch ( $inputs["search-key"])
         {
             case 'experiment-name':
-                $experiments = $airavataclient->searchExperimentsByName(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByName(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'experiment-description':
-                $experiments = $airavataclient->searchExperimentsByDesc(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByDesc(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'application':
-                $experiments = $airavataclient->searchExperimentsByApplication(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByApplication(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'creation-time':
-                $experiments = $airavataclient->searchExperimentsByCreationTime(Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000, strtotime( $inputs["to-date"])*1000 );
+                $experiments = Airavata::searchExperimentsByCreationTime(Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000, strtotime( $inputs["to-date"])*1000 );
                 break;
             case '':
         }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/IdUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/IdUtilities.php b/app/libraries/IdUtilities.php
new file mode 100755
index 0000000..9db7450
--- /dev/null
+++ b/app/libraries/IdUtilities.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * Interface for ID management
+ */
+
+interface IdUtilities
+{
+    /**
+     * Connect to the user database.
+     * @return mixed|void
+     */
+    public function connect();
+
+    /**
+     * Return true if the given username exists in the database.
+     * @param $username
+     * @return bool
+     */
+    public function username_exists($username);
+
+    /**
+     * Authenticate user given username and password.
+     * @param $username
+     * @param $password
+     * @return int|mixed
+     */
+    public function authenticate($username, $password);
+
+    /**
+     * Create new user
+     *
+     * @param $username
+     * @param $password
+     * @param $first_name
+     * @param $last_name
+     * @param $email
+     * @param $organization
+     * @param $address
+     * @param $country
+     * @param $telephone
+     * @param $mobile
+     * @param $im
+     * @param $url
+     * @return mixed
+     */
+    public function add_user($username, $password, $first_name, $last_name, $email, $organization,
+            $address, $country,$telephone, $mobile, $im, $url);
+
+    /**
+     * Function to remove an existing user
+     *
+     * @param $username
+     * @return void
+     */
+    public function remove_user($username);
+
+    /**
+     * Get the user profile
+     * @param $username
+     * @return mixed|void
+     */
+    public function get_user_profile($username);
+
+    /**
+     * Update the user profile
+     *
+     * @param $username
+     * @param $first_name
+     * @param $last_name
+     * @param $email
+     * @param $organization
+     * @param $address
+     * @param $country
+     * @param $telephone
+     * @param $mobile
+     * @param $im
+     * @param $url
+     * @return mixed
+     */
+    public function update_user_profile($username, $first_name, $last_name, $email, $organization, $address,
+        $country, $telephone, $mobile, $im, $url);
+
+    /**
+     * Function to update user password
+     *
+     * @param $username
+     * @param $current_password
+     * @param $new_password
+     * @return mixed
+     */
+    public function change_password($username, $current_password, $new_password);
+
+    /**
+     * Function to check whether a user has permission for a particular permission string(api method).
+     *
+     * @param $username
+     * @param $permission_string
+     * @return bool
+     */
+    public function checkPermissionForUser($username, $permission_string);
+
+    /**
+     * Function to get all the permissions that a particular user has.
+     *
+     * @param $username
+     * @return mixed
+     */
+    public function getUserPermissions($username);
+
+    /**
+     * Function to get the entire list of roles in the application
+     *
+     * @return mixed
+     */
+    public function getRoleNames();
+    
+    /**
+     * Function to check whether a role is existing 
+     *
+     * @param string $roleName 
+     * @return IsExistingRoleResponse
+     */
+    public function isExistingRole( $roleName);
+
+    /**
+     * Function to add new role by providing the role name.
+     * 
+     * @param string $roleName
+     */
+    public function addRole($roleName);
+
+    /**
+     * Function to get the role list of a user
+     *
+     * @param $username
+     * @return mixed
+     */
+    public function getRoleListOfUser($username);
+    /**
+     * Function to update role list of user 
+     *
+     * @param UpdateRoleListOfUser $parameters
+     * @return void
+     */
+    public function updateRoleListOfUser( $username, $roles);
+
+    /**
+     * Function to get the user list of a particular role
+     *
+     * @param $role
+     * @return mixed
+     */
+    public function getUserListOfRole($role);
+
+    /**
+     * Function to add a role to a user
+     *
+     * @param $username
+     * @param $role
+     * @return void
+     */
+    public function addUserToRole($username, $role);
+
+    /**
+     * Function to role from user
+     *
+     * @param $username
+     * @param $role
+     * @return void
+     */
+    public function removeUserFromRole($username, $role);
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/Utilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/Utilities.php b/app/libraries/Utilities.php
index b3ccf64..923e1d2 100644
--- a/app/libraries/Utilities.php
+++ b/app/libraries/Utilities.php
@@ -1,15 +1,6 @@
 <?php
 
-//Thrift classes - loaded from Vendor/Thrift
-use Thrift\Transport\TTransport;
-use Thrift\Exception\TException;
-use Thrift\Exception\TTransportException;
-use Thrift\Factory\TStringFuncFactory;
-use Thrift\Protocol\TBinaryProtocol;
-use Thrift\Transport\TSocket;
-
 //Airavata classes - loaded from app/libraries/Airavata
-use Airavata\API\AiravataClient;
 use Airavata\API\Error\InvalidRequestException;
 use Airavata\API\Error\AiravataClientException;
 use Airavata\API\Error\AiravataSystemException;
@@ -23,8 +14,6 @@ use Airavata\Model\Workspace\Experiment\ExperimentState;
 use Airavata\Model\AppCatalog\AppInterface\DataType;
 use Airavata\Model\Workspace\Project;
 use Airavata\Model\Workspace\Experiment\JobState;
-use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionInterface;
-use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionProtocol;
 
 
 
@@ -207,9 +196,6 @@ public static function connect_to_id_store()
         case 'XML':
             $idStore = new XmlIdUtilities(); // XML user database
             break;
-        case 'USER_API':
-            $idStore = new UserAPIUtilities(); // Airavata UserAPI
-            break;
     }
 
     try
@@ -224,40 +210,6 @@ public static function connect_to_id_store()
     }
 }
 
-/**
- * Return an Airavata client
- * @return AiravataClient
- */
-public static function get_airavata_client()
-{
-    try
-    {
-        $app_config = Utilities::read_config();
-        $transport = new TSocket( $app_config["airavata-server"], $app_config["airavata-port"]);
-        $transport->setRecvTimeout( $app_config["airavata-timeout"]);
-        $transport->setSendTimeout( $app_config["airavata-timeout"]);
-
-        $protocol = new TBinaryProtocol($transport);
-        $transport->open();
-
-        $client = new AiravataClient($protocol);
-
-        if( is_object( $client))
-            return $client;
-        else
-            return Redirect::to("airavata/down");
-    }
-    catch (Exception $e)
-    {
-        /*Utilities::print_error_message('<p>There was a problem connecting to Airavata.
-            Please try again later or submit a bug report using the link in the Help menu.</p>' .
-            '<p>' . $e->getMessage() . '</p>');
-        */
-        
-    }
-}
-
-
 
 /**
  * Launch the experiment with the given ID
@@ -265,7 +217,6 @@ public static function get_airavata_client()
  */
 public static function launch_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
     //global $tokenFilePath;
     try
     {
@@ -286,7 +237,7 @@ public static function launch_experiment($expId)
 
         $app_config = Utilities::read_config();
         $hardCodedToken = $app_config['credential-store-token'];
-        $airavataclient->launchExperiment($expId, $hardCodedToken);
+        Airavata::launchExperiment($expId, $hardCodedToken);
 
         /*
         Utilities::print_success_message('Experiment launched!');
@@ -335,12 +286,11 @@ public static function launch_experiment($expId)
  */
 public static function get_all_user_projects($gatewayId, $username)
 {
-    $airavataclient = Session::get("airavataClient");
     $userProjects = null;
 
     try
     {
-        $userProjects = $airavataclient->getAllUserProjects($gatewayId, $username);
+        $userProjects = Airavata::getAllUserProjects($gatewayId, $username);
         //var_dump( $userProjects); exit;
     }
     catch (InvalidRequestException $ire)
@@ -380,12 +330,11 @@ public static function get_all_user_projects($gatewayId, $username)
  */
 public static function get_all_applications()
 {
-    $airavataclient = Session::get("airavataClient");
     $applications = null;
 
     try
     {
-        $applications = $airavataclient->getAllApplicationInterfaceNames( Session::get("gateway_id"));
+        $applications = Airavata::getAllApplicationInterfaceNames( Session::get("gateway_id"));
     }
     catch (InvalidRequestException $ire)
     {
@@ -426,12 +375,11 @@ public static function get_all_applications()
  */
 public static function get_application_interface($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $applicationInterface = null;
 
     try
     {
-        $applicationInterface = $airavataclient->getApplicationInterface($id);
+        $applicationInterface = Airavata::getApplicationInterface($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -463,12 +411,11 @@ public static function get_application_interface($id)
  */
 public static function get_available_app_interface_compute_resources($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $computeResources = null;
 
     try
     {
-        $computeResources = $airavataclient->getAvailableAppInterfaceComputeResources($id);
+        $computeResources = Airavata::getAvailableAppInterfaceComputeResources($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -500,12 +447,11 @@ public static function get_available_app_interface_compute_resources($id)
  */
 public static function get_compute_resource($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $computeResource = null;
 
     try
     {
-        $computeResource = $airavataclient->getComputeResource($id);
+        $computeResource = Airavata::getComputeResource($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -585,12 +531,11 @@ public static function list_input_files($experiment)
  */
 public static function get_application_inputs($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $inputs = null;
 
     try
     {
-        $inputs = $airavataclient->getApplicationInputs($id);
+        $inputs = Airavata::getApplicationInputs($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -622,12 +567,11 @@ public static function get_application_inputs($id)
  */
 public static function get_application_outputs($id)
 {
-    $airavataclient = Session::get("airavataClient");
     $outputs = null;
 
     try
     {
-        $outputs = $airavataclient->getApplicationOutputs($id);
+        $outputs = Airavata::getApplicationOutputs($id);
     }
     catch (InvalidRequestException $ire)
     {
@@ -659,11 +603,10 @@ public static function get_application_outputs($id)
  */
 public static function get_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
 
     try
     {
-        return $airavataclient->getExperiment($expId);
+        return Airavata::getExperiment($expId);
     }
     catch (InvalidRequestException $ire)
     {
@@ -711,11 +654,10 @@ public static function get_experiment($expId)
  */
 public static function get_project($projectId)
 {
-    $airavataclient = Session::get("airavataClient");
 
     try
     {
-        return $airavataclient->getProject($projectId);
+        return Airavata::getProject($projectId);
     }
     catch (InvalidRequestException $ire)
     {
@@ -760,10 +702,7 @@ public static function assemble_experiment()
     $userConfigData = new UserConfigurationData();
     $userConfigData->computationalResourceScheduling = $scheduling;
     if( isset( $_POST["userDN"]) )
-    {
-        $userConfigData->generateCert = 1;
         $userConfigData->userDN = $_POST["userDN"];
-    }
 
     $applicationInputs = Utilities::get_application_inputs($_POST['application']);
     $experimentInputs = Utilities::process_inputs($applicationInputs, $experimentInputs);
@@ -1050,11 +989,9 @@ public static function file_upload_successful()
  */
 public static function update_experiment($expId, $updatedExperiment)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
-        $airavataclient->updateExperiment($expId, $updatedExperiment);
+        Airavata::updateExperiment($expId, $updatedExperiment);
 
         /*
         Utilities::print_success_message("<p>Experiment updated!</p>" .
@@ -1096,12 +1033,10 @@ public static function update_experiment($expId, $updatedExperiment)
  */
 public static function clone_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
-
     try
     {
         //create new experiment to receive the clone
-        $experiment = $airavataclient->getExperiment($expId);
+        $experiment = Airavata::getExperiment($expId);
 
         $cloneId = $airavataclient->cloneExperiment($expId, 'Clone of ' . $experiment->name);
 
@@ -1149,14 +1084,13 @@ public static function clone_experiment($expId)
  */
 public static function cancel_experiment($expId)
 {
-    $airavataclient = Session::get("airavataClient");
     $app_config = Utilities::read_config();
 
 
 
     try
     {
-        $airavataclient->terminateExperiment($expId, $app_config["credential-store-token"]);
+        Airavata::terminateExperiment($expId, $app_config["credential-store-token"]);
 
         Utilities::print_success_message("Experiment canceled!");
     }
@@ -1268,7 +1202,27 @@ public static function create_application_select($id = null, $editable = true)
  */
 public static function create_compute_resources_select($applicationId, $resourceHostId)
 {
-    return Utilities::get_available_app_interface_compute_resources($applicationId);
+    $computeResources = Utilities::get_available_app_interface_compute_resources($applicationId);
+    
+    if( count( $computeResources) > 0)
+    {
+    	echo '<select class="form-control" name="compute-resource" id="compute-resource">';
+	    foreach ($computeResources as $id => $name)
+	    {
+	        $selected = ($resourceHostId == $id)? ' selected' : '';
+
+	        echo '<option value="' . $id . '"' . $selected . '>' .
+	                $name . '</option>';
+
+	    }
+
+    	echo '</select>';
+    }
+    else
+    {
+    	echo "<h4>No Compute Resources exist at the moment.";
+    }
+
 }
 
 
@@ -1385,12 +1339,14 @@ public static function create_nav_bar()
 	        'Project' => array
 	        (
 	            array('label' => 'Create', 'url' => URL::to('/') . '/project/create', "nav-active" => "project"),
-	            array('label' => 'Search', 'url' => URL::to('/') . '/project/search', "nav-active"=> "project")
+	            array('label' => 'Search', 'url' => URL::to('/') . '/project/search', "nav-active"=> "project"),
+                array('label' => 'Browse', 'url' => URL::to('/') . '/project/browse', "nav-active" => "project")
 	        ),
 	        'Experiment' => array
 	        (
 	            array('label' => 'Create', 'url' => URL::to('/') . '/experiment/create', "nav-active" => "experiment"),
-	            array('label' => 'Search', 'url' => URL::to('/') . '/experiment/search', "nav-active" => "experiment")
+	            array('label' => 'Search', 'url' => URL::to('/') . '/experiment/search', "nav-active" => "experiment"),
+                array('label' => 'Browse', 'url' => URL::to('/') . '/experiment/browse', "nav-active" => "experiment")
 	        )
 	    );
 
@@ -1573,9 +1529,6 @@ public static function write_new_token($tokenId)
 
 public static function create_project()
 {
-    
-    $airavataclient = Session::get("airavataClient");
-    
     $project = new Project();
     $project->owner = Session::get('username');
     $project->name = $_POST['project-name'];
@@ -1586,7 +1539,7 @@ public static function create_project()
 
     try
     {
-        $projectId = $airavataclient->createProject( Session::get("gateway_id"), $project);
+        $projectId = Airavata::createProject( Session::get("gateway_id"), $project);
 
         if ($projectId)
         {
@@ -1622,13 +1575,12 @@ public static function create_project()
  */
 public static function get_experiments_in_project($projectId)
 {
-    $airavataclient = Session::get("airavataClient");
 
     $experiments = array();
 
     try
     {
-        $experiments = $airavataclient->getAllExperimentsInProject($projectId);
+        $experiments = Airavata::getAllExperimentsInProject($projectId);
     }
     catch (InvalidRequestException $ire)
     {
@@ -1652,7 +1604,6 @@ public static function get_experiments_in_project($projectId)
 
 public static function update_project($projectId, $projectDetails)
 {
-    $airavataclient = Session::get("airavataClient");
 
     $updatedProject = new Project();
     $updatedProject->owner = $projectDetails["owner"];
@@ -1661,7 +1612,7 @@ public static function update_project($projectId, $projectDetails)
 
     try
     {
-        $airavataclient->updateProject($projectId, $updatedProject);
+        Airavata::updateProject($projectId, $updatedProject);
 
         //Utilities::print_success_message('Project updated! Click <a href="project_summary.php?projId=' . $projectId . '">here</a> to view the project summary.');
     }
@@ -1690,7 +1641,6 @@ public static function update_project($projectId, $projectDetails)
  */
 public static function create_experiment()
 {
-    $airavataclient = Session::get("airavataClient");
 
     $experiment = Utilities::assemble_experiment();
     $expId = null;
@@ -1699,7 +1649,7 @@ public static function create_experiment()
     {
         if($experiment)
         {
-            $expId = $airavataclient->createExperiment( Session::get("gateway_id"), $experiment);
+            $expId = Airavata::createExperiment( Session::get("gateway_id"), $experiment);
         }
 
         if ($expId)
@@ -1770,7 +1720,6 @@ public static function list_output_files($experiment, $expStatus)
 
 public static function get_experiment_values( $experiment, $project, $forSearch = false)
 {
-    $airavataclient = Session::get("airavataClient");
     //var_dump( $experiment); exit;
     $expVal = array();
     $expVal["experimentStatusString"] = "";
@@ -1786,7 +1735,7 @@ public static function get_experiment_values( $experiment, $project, $forSearch
         $expVal["experimentTimeOfStateChange"] = date('Y-m-d H:i:s', $experimentStatus->timeOfStateChange/1000); // divide by 1000 since timeOfStateChange is in ms
         $expVal["experimentCreationTime"] = date('Y-m-d H:i:s', $experiment->creationTime/1000); // divide by 1000 since creationTime is in ms
     }
-    $jobStatus = $airavataclient->getJobStatuses($experiment->experimentID);
+    $jobStatus = Airavata::getJobStatuses($experiment->experimentID);
 
     if ($jobStatus)
     {
@@ -1842,9 +1791,98 @@ public static function get_experiment_values( $experiment, $project, $forSearch
 
 }
 
+    public static function get_all_user_projects_with_pagination($limit, $offset)
+    {
+
+        $projects = array();
+
+        try
+        {
+            $projects = Airavata::getAllUserProjectsWithPagination( Session::get("gateway_id"),
+                Session::get("username"), $limit, $offset);
+        }
+        catch (InvalidRequestException $ire)
+        {
+            Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
+        }
+        catch (AiravataClientException $ace)
+        {
+            Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
+        }
+        catch (AiravataSystemException $ase)
+        {
+            if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR
+            {
+                Utilities::print_info_message('<p>You have not created any projects yet, so no results will be returned!</p>
+                                <p>Click <a href="create_project.php">here</a> to create a new project.</p>');
+            }
+            else
+            {
+                Utilities::print_error_message('There was a problem with Airavata. Please try again later, or report a bug using the link in the Help menu.');
+                //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage());
+            }
+        }
+        catch (TTransportException $tte)
+        {
+            Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage());
+        }
+
+        return $projects;
+    }
+
+
+
+    public static function get_projsearch_results_with_pagination( $searchKey, $searchValue, $limit, $offset)
+    {
+
+        $projects = array();
+
+        try
+        {
+            switch ( $searchKey)
+            {
+                case 'project-name':
+                    $projects = Airavata::searchProjectsByProjectNameWithPagination( Session::get("gateway_id"),
+                        Session::get("username"), $searchValue, $limit, $offset);
+                    break;
+                case 'project-description':
+                    $projects = $airavataclient->searchProjectsByProjectDescWithPagination( Session::get("gateway_id"),
+                        Session::get("username"), $searchValue, $limit, $offset);
+                    break;
+            }
+        }
+        catch (InvalidRequestException $ire)
+        {
+            Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
+        }
+        catch (AiravataClientException $ace)
+        {
+            Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
+        }
+        catch (AiravataSystemException $ase)
+        {
+            if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR
+            {
+                Utilities::print_info_message('<p>You have not created any projects yet, so no results will be returned!</p>
+                                <p>Click <a href="create_project.php">here</a> to create a new project.</p>');
+            }
+            else
+            {
+                Utilities::print_error_message('There was a problem with Airavata. Please try again later, or report a bug using the link in the Help menu.');
+                //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage());
+            }
+        }
+        catch (TTransportException $tte)
+        {
+            Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage());
+        }
+
+        return $projects;
+    }
+
+
 public static function get_projsearch_results( $searchKey, $searchValue)
 {
-    $airavataclient = Session::get("airavataClient");;
 
     $projects = array();
 
@@ -1853,7 +1891,7 @@ public static function get_projsearch_results( $searchKey, $searchValue)
         switch ( $searchKey)
         {
             case 'project-name':
-                $projects = $airavataclient->searchProjectsByProjectName( Session::get("gateway_id"), Session::get("username"), $searchValue);
+                $projects = Airavata::searchProjectsByProjectName( Session::get("gateway_id"), Session::get("username"), $searchValue);
                 break;
             case 'project-description':
                 $projects = $airavataclient->searchProjectsByProjectDesc( Session::get("gateway_id"), Session::get("username"), $searchValue);
@@ -1915,13 +1953,87 @@ public static function create_options($values, $labels, $disabled)
     }
 }
 
-/**
+    /**
+     * Get results of the user's search of experiments with pagination
+     * @return array|null
+     */
+    public static function get_expsearch_results_with_pagination( $inputs, $limit, $offset)
+    {
+        $experiments = array();
+
+        try
+        {
+            switch ( $inputs["search-key"])
+            {
+                case 'experiment-name':
+                    $experiments = Airavata::searchExperimentsByNameWithPagination(
+                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
+                    break;
+                case 'experiment-description':
+                    $experiments = Airavata::searchExperimentsByDescWithPagination(
+                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
+                    break;
+                case 'application':
+                    $experiments = Airavata::searchExperimentsByApplicationWithPagination(
+                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
+                    break;
+                case 'creation-time':
+                    $experiments = Airavata::searchExperimentsByCreationTimeWithPagination(
+                        Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000,
+                        strtotime( $inputs["to-date"])*1000 , $limit, $offset);
+                    break;
+                case '':
+            }
+        }
+        catch (InvalidRequestException $ire)
+        {
+            Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
+        }
+        catch (AiravataClientException $ace)
+        {
+            Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
+        }
+        catch (AiravataSystemException $ase)
+        {
+            if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR
+            {
+                Utilities::print_info_message('<p>You have not created any experiments yet, so no results will be returned!</p>
+                                <p>Click <a href="create_experiment.php">here</a> to create an experiment, or
+                                <a href="create_project.php">here</a> to create a new project.</p>');
+            }
+            else
+            {
+                Utilities::print_error_message('There was a problem with Airavata. Please try again later or report a bug using the link in the Help menu.');
+                //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage());
+            }
+        }
+        catch (TTransportException $tte)
+        {
+            Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage());
+        }
+
+        //get values of all experiments
+        $expContainer = array();
+        $expNum = 0;
+        foreach( $experiments as $experiment)
+        {
+            $expValue = Utilities::get_experiment_values( $experiment, Utilities::get_project($experiment->projectID), true );
+            $expContainer[$expNum]['experiment'] = $experiment;
+            if( $expValue["experimentStatusString"] == "FAILED")
+                $expValue["editable"] = false;
+            $expContainer[$expNum]['expValue'] = $expValue;
+            $expNum++;
+        }
+
+        return $expContainer;
+    }
+
+    /**
  * Get results of the user's search of experiments
  * @return array|null
  */
 public static function get_expsearch_results( $inputs)
 {
-    $airavataclient = Session::get("airavataClient");
     $experiments = array();
 
     try
@@ -1929,16 +2041,16 @@ public static function get_expsearch_results( $inputs)
         switch ( $inputs["search-key"])
         {
             case 'experiment-name':
-                $experiments = $airavataclient->searchExperimentsByName(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByName(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'experiment-description':
-                $experiments = $airavataclient->searchExperimentsByDesc(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByDesc(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'application':
-                $experiments = $airavataclient->searchExperimentsByApplication(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
+                $experiments = Airavata::searchExperimentsByApplication(Session::get('gateway_id'), Session::get('username'), $inputs["search-value"]);
                 break;
             case 'creation-time':
-                $experiments = $airavataclient->searchExperimentsByCreationTime(Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000, strtotime( $inputs["to-date"])*1000 );
+                $experiments = Airavata::searchExperimentsByCreationTime(Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000, strtotime( $inputs["to-date"])*1000 );
                 break;
             case '':
         }
@@ -1986,6 +2098,64 @@ public static function get_expsearch_results( $inputs)
     return $expContainer;
 }
 
+    /**
+     * Get results of the user's all experiments with pagination.
+     * Results are ordered creation time DESC
+     * @return array|null
+     */
+    public static function get_all_user_experiments_with_pagination($limit, $offset)
+    {
+        $experiments = array();
+
+        try
+        {
+            $experiments = Airavata::getAllUserExperimentsWithPagination(
+                Session::get('gateway_id'), Session::get('username'), $limit, $offset
+            );
+        }
+        catch (InvalidRequestException $ire)
+        {
+            Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
+        }
+        catch (AiravataClientException $ace)
+        {
+            Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
+        }
+        catch (AiravataSystemException $ase)
+        {
+            if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR
+            {
+                Utilities::print_info_message('<p>You have not created any experiments yet, so no results will be returned!</p>
+                                <p>Click <a href="create_experiment.php">here</a> to create an experiment, or
+                                <a href="create_project.php">here</a> to create a new project.</p>');
+            }
+            else
+            {
+                Utilities::print_error_message('There was a problem with Airavata. Please try again later or report a bug using the link in the Help menu.');
+                //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage());
+            }
+        }
+        catch (TTransportException $tte)
+        {
+            Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage());
+        }
+
+        //get values of all experiments
+        $expContainer = array();
+        $expNum = 0;
+        foreach( $experiments as $experiment)
+        {
+            $expValue = Utilities::get_experiment_values( $experiment, Utilities::get_project($experiment->projectID), true );
+            $expContainer[$expNum]['experiment'] = $experiment;
+            if( $expValue["experimentStatusString"] == "FAILED")
+                $expValue["editable"] = false;
+            $expContainer[$expNum]['expValue'] = $expValue;
+            $expNum++;
+        }
+
+        return $expContainer;
+    }
+
 public static function getExpStates(){
     return ExperimentState::$__names;
 }
@@ -2026,11 +2196,7 @@ public static function apply_changes_to_experiment($experiment, $input)
 
     $userConfigDataUpdated->computationalResourceScheduling = $schedulingUpdated;
     if( isset( $input["userDN"]) )
-    {
-        $userConfigDataUpdated->generateCert = 1;
         $userConfigDataUpdated->userDN = $input["userDN"];
-    }
-
 
     $experiment->userConfigurationData = $userConfigDataUpdated;
 
@@ -2084,20 +2250,11 @@ public static function read_config( $fileName = null){
 }
 
 public static function get_job_details( $experimentId){
-    $airavataclient = Session::get("airavataClient");
-    return $airavataclient->getJobDetails( $experimentId);
+    return Airavata::getJobDetails( $experimentId);
 }
 
 public static function get_transfer_details( $experimentId){
-    $airavataclient = Session::get("airavataClient");
-    return $airavataclient->getDataTransferDetails( $experimentId);
-}
-
-public static function getQueueDatafromResourceId( $crId){
-    $airavataclient = Session::get("airavataClient");
-    $resourceObject = $airavataclient->getComputeResource( $crId);
-
-    return $resourceObject->batchQueues;
+    return Airavata::getDataTransferDetails( $experimentId);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/WSISUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/WSISUtilities.php b/app/libraries/WSISUtilities.php
new file mode 100755
index 0000000..29804d2
--- /dev/null
+++ b/app/libraries/WSISUtilities.php
@@ -0,0 +1,318 @@
+<?php
+
+/**
+ * Utilities for ID management with a WSO2 IS 4.6.0
+ */
+
+class WSISUtilities implements IdUtilities{
+
+    /**
+     * Return true if the given username exists in the identity server.
+     * @param $username
+     * @return bool
+     */
+    public function username_exists($username) {
+        try{
+            //$this->wsis_client = new WSISClient( $username);
+            return WSIS::username_exists($username);
+        } catch (Exception $ex) {
+            print_r( $ex);
+            throw new Exception("Unable to check whether username exists", 0, NULL);
+        }
+        
+    }
+
+    /**
+     * authenticate a given user
+     * @param $username
+     * @param $password
+     * @return boolean
+     */
+    public function authenticate($username, $password) {
+        try{
+            return WSIS::authenticate($username, $password);
+        } catch (Exception $ex) {
+            var_dump( $ex);
+            throw new Exception("Unable to authenticate user", 0, NULL);
+        }        
+    }
+
+    /**
+     * Add a new user to the identity server.
+     * @param $username
+     * @param $password
+     * @return void
+     */
+    public function add_user($username, $password, $first_name, $last_name, $email, $organization,
+            $address, $country,$telephone, $mobile, $im, $url) {
+        try{
+            WSIS::addUser($username, $password, $first_name . " " . $last_name);
+        } catch (Exception $ex) {
+            var_dump($ex);
+            throw new Exception("Unable to add new user", 0, NULL);
+        }        
+    }
+
+    /**
+     * Get the user profile
+     * @param $username
+     * @return mixed|void
+     */
+    public function get_user_profile($username)
+    {
+        // TODO: Implement get_user_profile() method.
+    }
+
+    /**
+     * Update the user profile
+     *
+     * @param $username
+     * @param $first_name
+     * @param $last_name
+     * @param $email
+     * @param $organization
+     * @param $address
+     * @param $country
+     * @param $telephone
+     * @param $mobile
+     * @param $im
+     * @param $url
+     * @return mixed
+     */
+    public function update_user_profile($username, $first_name, $last_name, $email, $organization, $address,
+                                        $country, $telephone, $mobile, $im, $url)
+    {
+        // TODO: Implement update_user_profile() method.
+    }
+
+    /**
+     * Function to update user password
+     *
+     * @param $username
+     * @param $current_password
+     * @param $new_password
+     * @return mixed
+     */
+    public function change_password($username, $current_password, $new_password)
+    {
+        // TODO: Implement change_password() method.
+    }
+
+    /**
+     * Function to remove an existing user
+     *
+     * @param $username
+     * @return void
+     */
+    public function remove_user($username)
+    {
+        // TODO: Implement remove_user() method.
+    }
+
+    /**
+     * Function to check whether a user has permission for a particular permission string(api method).
+     *
+     * @param $username
+     * @param $permission_string
+     * @return bool
+     */
+    public function checkPermissionForUser($username, $permission_string)
+    {
+        // TODO: Implement checkPermissionForUser() method.
+    }
+
+    /**
+     * Function to get all the permissions that a particular user has.
+     *
+     * @param $username
+     * @return mixed
+     */
+    public function getUserPermissions($username)
+    {
+        // TODO: Implement getUserPermissions() method.
+    }
+
+    /**
+     * Function to check whether a role is existing 
+     *
+     * @param string $roleName 
+     * @return IsExistingRoleResponse
+     */
+    public function isExistingRole( $roleName){
+        try{
+            return WSIS::is_existing_role( $roleName);
+        } catch (Exception $ex) {
+            var_dump($ex);
+            throw new Exception("Unable to check if role exists.", 0, $ex);
+        }    
+    }
+
+    /**
+     * Function to add new role by providing the role name.
+     * 
+     * @param string $roleName
+     */
+    public function addRole($roleName){
+        try{
+            return WSIS::add_role( $roleName);
+        } catch (Exception $ex) {
+            var_dump( $ex);
+            throw new Exception("Unable to add role.", 0, $ex);
+        }        
+    }
+
+    /**
+     * Function to delete existing role
+     * 
+     * @param string $roleName
+     * @return void
+     * @throws Exception
+     */
+    public function deleteRole($roleName) {
+        try {
+            WSIS::delete_role($roleName);
+        } catch (Exception $ex) {
+            throw new Exception("Unable to delete role", 0, $ex);
+        }
+    }
+
+    /**
+     * Function to get the entire list of roles in the application
+     *
+     * @return mixed
+     */
+    public function getRoleNames()
+    {
+        try{
+            WSIS::get_all_roles();
+        } catch (Exception $ex) {
+            var_dump($ex);
+            throw new Exception("Unable to get roles.", 0, NULL);
+        }        
+    }
+
+    /**
+     * Function to get the role list of a user
+     *
+     * @param $username
+     * @return mixed
+     */
+    public function getRoleListOfUser($username)
+    {
+        try{
+            return WSIS::get_user_roles( $username);
+        } catch (Exception $ex) {
+            var_dump($ex);
+            throw new Exception("Unable to get roles.", 0, NULL);
+        }  
+    }
+
+    /**
+     * Function to get the user list of a particular role
+     *
+     * @param $role
+     * @return mixed
+     */
+    public function getUserListOfRole($role)
+    {
+        try{
+            return WSIS::get_userlist_of_role( $role);
+        } catch (Exception $ex) {
+            var_dump( $ex); exit;
+            throw new Exception("Unable to get users.", 0, NULL);
+        }
+    }
+
+    /**
+     * Function to add a role to a user
+     *
+     * @param $username
+     * @param $role
+     * @return void
+     */
+    public function addUserToRole($username, $role)
+    {
+        // TODO: Implement addUserToRole() method.
+    }
+
+    /**
+     * Function to role from user
+     *
+     * @param $username
+     * @param $role
+     * @return void
+     */
+
+    /**
+     * Function to update role list of user 
+     *
+     * @param UpdateRoleListOfUser $parameters
+     * @return void
+     */
+    public function updateRoleListOfUser($username, $roles)
+    {
+        try{
+            return WSIS::update_user_roles( $username, $roles);
+        } catch (Exception $ex) {
+            var_dump($ex); exit;
+            throw new Exception("Unable to update User roles.", 0, NULL);
+        }  
+    }
+    public function removeUserFromRole($username, $role)
+    {
+        // TODO: Implement removeUserFromRole() method.
+    }
+
+    /**
+     * Function to list users
+     *
+     * @param void
+     * @return void
+     */
+    public function listUsers(){
+        try {
+            return WSIS::list_users();
+        } catch (Exception $ex) {
+    
+            throw new Exception( "Unable to list users", 0, $ex);
+        }
+    }
+
+    /**
+     * Function to get the tenant id
+     *
+     * @param GetTenantId $parameters
+     * @return GetTenantIdResponse
+     */
+    public function getTenantId(){
+        try {
+            return WSIS::get_tenant_id();
+        } catch (Exception $ex) {
+            var_dump( $ex->debug_message); 
+            throw new Exception("Unable to get the Tenant Id.", 0, $ex);
+        }
+    }
+    /**
+    * Function create a new Tenant
+    *
+    * @param Tenant $parameters
+    * @return void
+    */
+    public function createTenant( $inputs){
+        try {
+            return WSIS::create_tenant( $inputs);
+        } catch (Exception $ex) {
+            var_dump( $ex); 
+            //throw new Exception("Unable to create Tenant.", 0, $ex);
+        }
+    }
+
+    /**
+     * Connect to the user database.
+     * @return mixed|void
+     */
+    public function connect()
+    {
+        // TODO: Implement connect() method.
+    }
+}

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

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3ca02155/app/libraries/Wsis/Stubs/AuthenticationAdmin.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/AuthenticationAdmin.php b/app/libraries/Wsis/Stubs/AuthenticationAdmin.php
new file mode 100755
index 0000000..3c1ef1b
--- /dev/null
+++ b/app/libraries/Wsis/Stubs/AuthenticationAdmin.php
@@ -0,0 +1,55 @@
+<?php
+namespace Wsis\Stubs;
+
+use Wsis\Stubs\AuthenticationAdminStub;
+
+/**
+ * AuthenticationAdmin class
+ * 
+ * This class provide an easy to use interface for
+ * WSO2 IS 5.0.0 TenantMgtAdmin service.
+ */
+class AuthenticationAdmin {
+    /**
+     * @var AuthenticationAdminStub $serviceStub
+     * @access private
+     */
+    private $serviceStub;
+
+    public function __construct($server_url, $options) {
+        $this->serviceStub = new AuthenticationAdminStub(
+                $server_url . "AuthenticationAdmin?wsdl", $options
+        );
+    }
+    
+    /**
+     * Function to get the soap client
+     * 
+     * @return SoapClient
+     */
+    public function getSoapClient(){
+        return $this->serviceStub;
+    }
+
+    /**
+     * Method to login the user
+     * @param $username
+     * @param $password
+     * @param $tenantDomain
+     * @return true/false
+     */
+    public function login($username, $password, $tenantDomain){
+        $parameters = new login();
+        $parameters->username = $username. "@" . $tenantDomain;
+        $parameters->password = $password;
+        return $this->serviceStub->login($parameters);
+    }
+
+    /**
+     * Method to logout the current user
+     */
+    public function logout(){
+        $parameters = new logout();
+        $this->serviceStub->logout($parameters);
+    }
+}


Mime
View raw message