From 3ca02155c67493ff295638e5fc2a2d74a0f0d4cb Mon Sep 17 00:00:00 2001 From: Supun Nakandala Date: Sat, 9 May 2015 13:54:23 +0530 Subject: [PATCH 1/4] wrapping Airavata and WSIS code as laravel library component and service providers --- 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 +- .../{id_utilities.php => IdUtilities.php} | 0 app/libraries/Utilities.php | 391 ++- .../{wsis_utilities.php => WSISUtilities.php} | 2 - .../libraries}/Wsis/Facades/Wsis.php | 2 +- .../Wsis/Stubs/AuthenticationAdmin.php | 55 + .../Wsis/Stubs/AuthenticationAdminStub.php | 1016 +++++++ .../libraries}/Wsis/Stubs/TenantManager.php | 4 +- .../Wsis/Stubs/TenantMgtAdminStub.php | 2 +- .../Wsis/Stubs/UserStoreManager.php | 4 +- .../Wsis/Stubs/UserStoreManagerStub.php | 2 +- .../Airavata => app/libraries}/Wsis/Wsis.php | 4 +- .../libraries}/Wsis/WsisServiceProvider.php | 20 +- ...ml_id_utilities.php => XmlIdUtilities.php} | 2 - app/libraries/utilities.php | 2337 ----------------- workbench/airavata/wsis/.gitignore | 4 - workbench/airavata/wsis/.travis.yml | 13 - workbench/airavata/wsis/composer.json | 20 - workbench/airavata/wsis/phpunit.xml | 18 - workbench/airavata/wsis/src/config/config.php | 52 - workbench/airavata/wsis/tests/.gitkeep | 0 29 files changed, 1446 insertions(+), 2817 deletions(-) delete mode 100644 app/config/packages/airavata/wsis/config.php rename app/libraries/{id_utilities.php => IdUtilities.php} (100%) rename app/libraries/{wsis_utilities.php => WSISUtilities.php} (99%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Facades/Wsis.php (88%) create mode 100755 app/libraries/Wsis/Stubs/AuthenticationAdmin.php create mode 100644 app/libraries/Wsis/Stubs/AuthenticationAdminStub.php rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Stubs/TenantManager.php (98%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Stubs/TenantMgtAdminStub.php (99%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Stubs/UserStoreManager.php (98%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Stubs/UserStoreManagerStub.php (99%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/Wsis.php (99%) rename {workbench/airavata/wsis/src/Airavata => app/libraries}/Wsis/WsisServiceProvider.php (62%) rename app/libraries/{xml_id_utilities.php => XmlIdUtilities.php} (99%) delete mode 100644 app/libraries/utilities.php delete mode 100755 workbench/airavata/wsis/.gitignore delete mode 100755 workbench/airavata/wsis/.travis.yml delete mode 100755 workbench/airavata/wsis/composer.json delete mode 100755 workbench/airavata/wsis/phpunit.xml delete mode 100644 workbench/airavata/wsis/src/config/config.php delete mode 100755 workbench/airavata/wsis/tests/.gitkeep diff --git a/app/config/app.php b/app/config/app.php index 1b4c90f53..93d1421bb 100755 --- a/app/config/app.php +++ b/app/config/app.php @@ -121,7 +121,8 @@ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider', - 'Airavata\Wsis\WsisServiceProvider', + 'Wsis\WsisServiceProvider', + 'Airavata\AiravataServiceProvider', ), /* @@ -188,7 +189,8 @@ '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', ), ); diff --git a/app/config/packages/airavata/wsis/config.php b/app/config/packages/airavata/wsis/config.php deleted file mode 100644 index 9041036b0..000000000 --- a/app/config/packages/airavata/wsis/config.php +++ /dev/null @@ -1,52 +0,0 @@ - '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 diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 752c05de8..63a87db2e 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -80,7 +80,7 @@ public function loginSubmit(){ 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"]); diff --git a/app/filters.php b/app/filters.php index 93b988b01..33f98d2d2 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); }); diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php index b2bf9e175..5775991ad 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 diff --git a/app/libraries/AiravataClientFactory.php b/app/libraries/AiravataClientFactory.php index c55a359d8..efd01a99d 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 { diff --git a/app/libraries/AppUtilities.php b/app/libraries/AppUtilities.php index 2f9b32e93..e485a368f 100644 --- a/app/libraries/AppUtilities.php +++ b/app/libraries/AppUtilities.php @@ -1,29 +1,20 @@ $inputs["appModuleName"], "appModuleVersion" => $inputs["appModuleVersion"], @@ -31,25 +22,21 @@ public static function create_or_update_appModule( $inputs, $update = false){ )); 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 @@ public static function getAppInterfaceData(){ } 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 @@ public static function create_or_update_appInterface( $appInterfaceValues, $upda //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 @@ public static function create_or_update_appDeployment( $inputs, $update = false) $appDeploymentValues = $inputs; - $airavataclient = Session::get("airavataClient"); - if( isset( $appDeploymentValues["moduleLoadCmds"])) $appDeploymentValues["moduleLoadCmds"] = array_unique( array_filter( $appDeploymentValues["moduleLoadCmds"])); @@ -207,9 +186,9 @@ public static function create_or_update_appDeployment( $inputs, $update = false) //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 @@ public static function create_or_update_appDeployment( $inputs, $update = false) 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 diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php index 98fa54e23..92e06f3d7 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\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"]); } } diff --git a/app/libraries/ExpUtilities.php b/app/libraries/ExpUtilities.php index 40e5d361a..ae5ab7fc8 100644 --- a/app/libraries/ExpUtilities.php +++ b/app/libraries/ExpUtilities.php @@ -1,15 +1,6 @@ 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("

Experiment updated!

" . @@ -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("

Experiment cloned!

" . '

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 '': } diff --git a/app/libraries/id_utilities.php b/app/libraries/IdUtilities.php similarity index 100% rename from app/libraries/id_utilities.php rename to app/libraries/IdUtilities.php diff --git a/app/libraries/Utilities.php b/app/libraries/Utilities.php index b3ccf64fd..923e1d26a 100644 --- a/app/libraries/Utilities.php +++ b/app/libraries/Utilities.php @@ -1,15 +1,6 @@ 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('

There was a problem connecting to Airavata. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

' . $e->getMessage() . '

'); - */ - - } -} - - /** * 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("

Experiment updated!

" . @@ -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 ''; + } + else + { + echo "

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 here 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!

' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('

You have not created any projects yet, so no results will be returned!

+

Click here to create a new project.

'); + } + 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!

' . $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!

' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('

You have not created any projects yet, so no results will be returned!

+

Click here to create a new project.

'); + } + 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!

' . $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!

' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('

You have not created any experiments yet, so no results will be returned!

+

Click here to create an experiment, or + here to create a new project.

'); + } + 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!

' . $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!

' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('

You have not created any experiments yet, so no results will be returned!

+

Click here to create an experiment, or + here to create a new project.

'); + } + 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!

' . $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); } } diff --git a/app/libraries/wsis_utilities.php b/app/libraries/WSISUtilities.php similarity index 99% rename from app/libraries/wsis_utilities.php rename to app/libraries/WSISUtilities.php index 530fa52d8..29804d23f 100755 --- a/app/libraries/wsis_utilities.php +++ b/app/libraries/WSISUtilities.php @@ -1,7 +1,5 @@ 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); + } +} diff --git a/app/libraries/Wsis/Stubs/AuthenticationAdminStub.php b/app/libraries/Wsis/Stubs/AuthenticationAdminStub.php new file mode 100644 index 000000000..00a1f0240 --- /dev/null +++ b/app/libraries/Wsis/Stubs/AuthenticationAdminStub.php @@ -0,0 +1,1016 @@ + 'TransactionConfiguration', + 'AbstractPolicyOperator' => 'AbstractPolicyOperator', + 'PolicyComponent' => 'PolicyComponent', + 'All' => 'All', + 'Policy' => 'Policy', + 'Enum' => 'Enum', + 'ThreadFactory' => 'ThreadFactory', + 'XmlSchemaObject' => 'XmlSchemaObject', + 'XmlSchemaAnnotated' => 'XmlSchemaAnnotated', + 'XmlSchemaAnnotation' => 'XmlSchemaAnnotation', + 'XmlSchemaObjectCollection' => 'XmlSchemaObjectCollection', + 'XmlSchemaParticle' => 'XmlSchemaParticle', + 'XmlSchemaElement' => 'XmlSchemaElement', + 'XmlSchemaDerivationMethod' => 'XmlSchemaDerivationMethod', + 'XmlSchemaForm' => 'XmlSchemaForm', + 'XmlSchemaType' => 'XmlSchemaType', + 'XmlSchemaDatatype' => 'XmlSchemaDatatype', + 'TargetResolver' => 'TargetResolver', + 'LifecycleManager' => 'LifecycleManager', + 'SOAPEnvelope' => 'SOAPEnvelope', + 'SOAPBody' => 'SOAPBody', + 'SOAPFault' => 'SOAPFault', + 'SOAPFaultCode' => 'SOAPFaultCode', + 'SOAPFaultDetail' => 'SOAPFaultDetail', + 'SOAPFaultNode' => 'SOAPFaultNode', + 'SOAPFaultReason' => 'SOAPFaultReason', + 'SOAPFaultText' => 'SOAPFaultText', + 'SOAPFaultRole' => 'SOAPFaultRole', + 'SOAPHeader' => 'SOAPHeader', + 'SOAPVersion' => 'SOAPVersion', + 'Attachments' => 'Attachments', + 'IncomingAttachmentStreams' => 'IncomingAttachmentStreams', + 'IncomingAttachmentInputStream' => 'IncomingAttachmentInputStream', + 'AuthenticationException' => 'AuthenticationException', + 'TransportListener' => 'TransportListener', + 'TransportSender' => 'TransportSender', + 'Attr' => 'Attr', + 'Element' => 'Element', + 'TypeInfo' => 'TypeInfo', + 'Options' => 'Options', + 'Set' => 'Set', + 'Map' => 'Map', + 'Iterator' => 'Iterator', + 'LinkedList' => 'LinkedList', + 'LinkedHashMap' => 'LinkedHashMap', + 'InputStream' => 'InputStream', + 'NodeManager' => 'NodeManager', + 'AxisMessage' => 'AxisMessage', + 'AxisOperation' => 'AxisOperation', + 'AxisService' => 'AxisService', + 'AxisServiceGroup' => 'AxisServiceGroup', + 'TransportInDescription' => 'TransportInDescription', + 'Flow' => 'Flow', + 'HandlerDescription' => 'HandlerDescription', + 'ParameterInclude' => 'ParameterInclude', + 'PhaseRule' => 'PhaseRule', + 'TransportOutDescription' => 'TransportOutDescription', + 'OMNamespace' => 'OMNamespace', + 'loginWithRememberMeCookie' => 'loginWithRememberMeCookie', + 'loginWithRememberMeCookieResponse' => 'loginWithRememberMeCookieResponse', + 'AuthenticationAdminAuthenticationException' => 'AuthenticationAdminAuthenticationException', + 'logout' => 'logout', + 'login' => 'login', + 'loginResponse' => 'loginResponse', + 'loginWithRememberMeOption' => 'loginWithRememberMeOption', + 'loginWithRememberMeOptionResponse' => 'loginWithRememberMeOptionResponse', + 'getAuthenticatorName' => 'getAuthenticatorName', + 'getAuthenticatorNameResponse' => 'getAuthenticatorNameResponse', + 'authenticateWithRememberMe' => 'authenticateWithRememberMe', + 'authenticateWithRememberMeResponse' => 'authenticateWithRememberMeResponse', + 'isDisabled' => 'isDisabled', + 'isDisabledResponse' => 'isDisabledResponse', + 'getPriority' => 'getPriority', + 'getPriorityResponse' => 'getPriorityResponse', + 'MessageContext' => 'MessageContext', + 'ConfigurationContext' => 'ConfigurationContext', + 'OperationContext' => 'OperationContext', + 'ServiceContext' => 'ServiceContext', + 'ServiceGroupContext' => 'ServiceGroupContext', + 'SessionContext' => 'SessionContext', + 'PhasesInfo' => 'PhasesInfo', + 'ExcludeInfo' => 'ExcludeInfo', + 'URL' => 'URL', + 'EndpointReference' => 'EndpointReference', + 'RelatesTo' => 'RelatesTo', + 'SecretResolver' => 'SecretResolver', + 'AxisConfiguration' => 'AxisConfiguration', + 'ListenerManager' => 'ListenerManager', + 'AxisConfigurator' => 'AxisConfigurator', + 'ObjectSupplier' => 'ObjectSupplier', + 'ServiceLifeCycle' => 'ServiceLifeCycle', + 'MessageReceiver' => 'MessageReceiver', + 'Phase' => 'Phase', + 'Handler' => 'Handler', + 'StateManager' => 'StateManager', + 'RememberMeData' => 'RememberMeData', + 'ClusteringAgent' => 'ClusteringAgent', + 'TypeTable' => 'TypeTable', + ); + + public function AuthenticationAdminStub($wsdl = "AuthenticationAdmin.xml", $options = array()) { + foreach(self::$classmap as $key => $value) { + if(!isset($options['classmap'][$key])) { + $options['classmap'][$key] = $value; + } + } + parent::__construct($wsdl, $options); + } + + /** + * + * + * @param logout $parameters + * @return void + */ + public function logout(logout $parameters) { + return $this->__soapCall('logout', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param loginWithRememberMeCookie $parameters + * @return loginWithRememberMeCookieResponse + */ + public function loginWithRememberMeCookie(loginWithRememberMeCookie $parameters) { + return $this->__soapCall('loginWithRememberMeCookie', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param authenticateWithRememberMe $parameters + * @return authenticateWithRememberMeResponse + */ + public function authenticateWithRememberMe(authenticateWithRememberMe $parameters) { + return $this->__soapCall('authenticateWithRememberMe', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param getAuthenticatorName $parameters + * @return getAuthenticatorNameResponse + */ + public function getAuthenticatorName(getAuthenticatorName $parameters) { + return $this->__soapCall('getAuthenticatorName', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param login $parameters + * @return loginResponse + */ + public function login(login $parameters) { + return $this->__soapCall('login', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param loginWithRememberMeOption $parameters + * @return loginWithRememberMeOptionResponse + */ + public function loginWithRememberMeOption(loginWithRememberMeOption $parameters) { + return $this->__soapCall('loginWithRememberMeOption', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param isDisabled $parameters + * @return isDisabledResponse + */ + public function isDisabled(isDisabled $parameters) { + return $this->__soapCall('isDisabled', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } + + /** + * + * + * @param getPriority $parameters + * @return getPriorityResponse + */ + public function getPriority(getPriority $parameters) { + return $this->__soapCall('getPriority', array($parameters), array( + 'uri' => 'http://authentication.services.core.carbon.wso2.org', + 'soapaction' => '' + ) + ); + } +} + +?> diff --git a/workbench/airavata/wsis/src/Airavata/Wsis/Stubs/TenantManager.php b/app/libraries/Wsis/Stubs/TenantManager.php similarity index 98% rename from workbench/airavata/wsis/src/Airavata/Wsis/Stubs/TenantManager.php rename to app/libraries/Wsis/Stubs/TenantManager.php index 90bcd3f2d..26b109b99 100755 --- a/workbench/airavata/wsis/src/Airavata/Wsis/Stubs/TenantManager.php +++ b/app/libraries/Wsis/Stubs/TenantManager.php @@ -1,7 +1,7 @@ package('airavata/wsis'); + $this->package('wsis/wsis'); } /** @@ -33,13 +33,13 @@ public function register() $this->app['wsis'] = $this->app->share(function($app) { return new Wsis( - Config::get('wsis::admin-username'), - Config::get('wsis::admin-password'), - Config::get('wsis::server'), - Config::get('wsis::service-url'), - Config::get('wsis::cafile-path'), - Config::get('wsis::verify-peer'), - Config::get('wsis::allow-selfsigned-cert') + Config::get('pga_config.wsis')['admin-username'], + Config::get('pga_config.wsis')['admin-password'], + Config::get('pga_config.wsis')['server'], + Config::get('pga_config.wsis')['service-url'], + Config::get('pga_config.wsis')['cafile-path'], + Config::get('pga_config.wsis')['verify-peer'], + Config::get('pga_config.wsis')['allow-self-signed-cert'] ); }); @@ -47,7 +47,7 @@ public function register() $this->app->booting(function() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); - $loader->alias('WSIS', 'Airavata\Wsis\Facades\Wsis'); + $loader->alias('WSIS', 'Wsis\Facades\Wsis'); }); } diff --git a/app/libraries/xml_id_utilities.php b/app/libraries/XmlIdUtilities.php similarity index 99% rename from app/libraries/xml_id_utilities.php rename to app/libraries/XmlIdUtilities.php index 0ba976046..5580796ea 100755 --- a/app/libraries/xml_id_utilities.php +++ b/app/libraries/XmlIdUtilities.php @@ -3,8 +3,6 @@ * Utilities for ID management with an XML file */ -//include 'id_utilities.php'; - class XmlIdUtilities implements IdUtilities { const DB_PATH = 'users.xml'; diff --git a/app/libraries/utilities.php b/app/libraries/utilities.php deleted file mode 100644 index 0d428d92a..000000000 --- a/app/libraries/utilities.php +++ /dev/null @@ -1,2337 +0,0 @@ -sshUser = "root"; - $this->hostName = $_SERVER['SERVER_NAME']; - - self::$experimentDataPathAbsolute = base_path() . Constant::EXPERIMENT_DATA_ROOT; - self::$pathConstant = 'file://'.$this->sshUser.'@'.$this->hostName.':' . self::$experimentDataPathAbsolute; - self::$experimentPath = null; -} - -/** - * Print success message - * @param $message - */ -public static function print_success_message($message) -{ - echo '
' . $message . '
'; -} - -/** - * Print warning message - * @param $message - */ -public static function print_warning_message($message) -{ - echo '
' . $message . '
'; -} - -/** - * Print error message - * @param $message - */ -public static function print_error_message($message) -{ - echo '
' . $message . '
'; -} - -/** - * Print info message - * @param $message - */ -public static function print_info_message($message) -{ - echo '
' . $message . '
'; -} - -/** - * Redirect to the given url - * @param $url - */ -public static function redirect($url) -{ - echo ''; -} - -/** - * Return true if the form has been submitted - * @return bool - */ -public static function form_submitted() -{ - return isset($_POST['Submit']); -} - -/** - * Compare the submitted credentials with those stored in the database - * @param $username - * @param $password - * @return bool - */ -public static function id_matches_db($username, $password) -{ - $idStore = new WSISUtilities(); - - try - { - $idStore->connect(); - } - catch (Exception $e) - { - Utilities::print_error_message('

Error connecting to ID store. - Please try again later or report a bug using the link in the Help menu

' . - '

' . $e->getMessage() . '

'); - } - //checking user roles. - //var_dump( $idStore->updateRoleListOfUser( $username, array( "new"=>array("admin"), "deleted"=>array() ) ) ); - //var_dump($idStore->getRoleListOfUser( $username) ); exit; - //var_dump( $idStore->authenticate($username, $password)); exit; - if($idStore->authenticate($username, $password)) - { - //checking if user is an Admin and saving in Session. - $app_config = Utilities::read_config(); - - if( in_array( $app_config["admin-role"], (array)$idStore->getRoleListOfUser( $username))) - { - Session::put("admin", true); - } - return true; - }else{ - return false; - } -} - - -/** - * Store username in session variables - * @param $username - */ -public static function store_id_in_session($username) -{ - Session::put('username', $username ); - Session::put('loggedin', true); -} - -/** - * Return true if the username stored in the session - * @return bool - */ -public static function id_in_session() -{ - if( Session::has("username") && Session::has('loggedin') ) - return true; - else - return false; -} - -/** - * Verify if the user is already logged in. If not, redirect to the home page. - */ -public static function verify_login() -{ - if (Utilities::id_in_session()) - { - return true; - } - else - { - Utilities::print_error_message('User is not logged in!'); - return false; - } -} - -/** - * Connect to the ID store - */ -public static function connect_to_id_store() -{ - global $idStore; - $app_config = Utilities::read_config(); - - switch ($app_config["user-store"]) - { - case 'WSO2': - $idStore = new WSISUtilities(); // WS02 Identity Server - break; - case 'XML': - $idStore = new XmlIdUtilities(); // XML user database - break; - } - - try - { - $idStore->connect(); - } - catch (Exception $e) - { - Utilities::print_error_message('

Error connecting to ID store. - Please try again later or report a bug using the link in the Help menu

' . - '

' . $e->getMessage() . '

'); - } -} - -/** - * 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('

There was a problem connecting to Airavata. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

' . $e->getMessage() . '

'); - */ - - } -} - - - -/** - * Launch the experiment with the given ID - * @param $expId - */ -public static function launch_experiment($expId) -{ - $airavataclient = Session::get("airavataClient"); - //global $tokenFilePath; - try - { - /* temporarily using hard-coded token - open_tokens_file($tokenFilePath); - - $communityToken = $tokenFile->tokenId; - - - $token = isset($_SESSION['tokenId'])? $_SESSION['tokenId'] : $communityToken; - - $airavataclient->launchExperiment($expId, $token); - - $tokenString = isset($_SESSION['tokenId'])? 'personal' : 'community'; - - Utilities::print_success_message('Experiment launched using ' . $tokenString . ' allocation!'); - */ - - $app_config = Utilities::read_config(); - $hardCodedToken = $app_config['credential-store-token']; - $airavataclient->launchExperiment($expId, $hardCodedToken); - - /* - Utilities::print_success_message('Experiment launched!'); - Utilities::print_success_message("

Experiment launched!

" . - '

You will be redirected to the summary page shortly, or you can - go directly to the experiment summary page.

'); - redirect('experiment_summary.php?expId=' . $expId); - */ - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem launching the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (ExperimentNotFoundException $enf) - { - Utilities::print_error_message('

There was a problem launching the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

ExperimentNotFoundException: ' . $enf->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem launching the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem launching the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - catch (Exception $e) - { - Utilities::print_error_message('

There was a problem launching the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Exception: ' . $e->getMessage() . '

'); - } -} - -/** - * Get all projects owned by the given user - * @param $username - * @return null - */ -public static function get_all_user_projects($gatewayId, $username) -{ - $airavataclient = Session::get("airavataClient"); - $userProjects = null; - - try - { - $userProjects = $airavataclient->getAllUserProjects($gatewayId, $username); - //var_dump( $userProjects); exit; - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting the user\'s projects. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage(). '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting the user\'s projects. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage(). '

'); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_warning_message('

You must create a project before you can create an experiment. - Click here to create a project.

'); - } - else - { - Utilities::print_error_message('

There was a problem getting the user\'s projects. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - } - - return $userProjects; -} - - -/** - * Get all available applications - * @return null - */ -public static function get_all_applications() -{ - $airavataclient = Session::get("airavataClient"); - $applications = null; - - try - { - $applications = $airavataclient->getAllApplicationInterfaceNames( Session::get("gateway_id")); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting all applications. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting all applications. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_warning_message('

You must create an application module, interface and deployment space before you can create an experiment. - Click here to create an application.

'); - /* - Utilities::print_error_message('

There was a problem getting all applications. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - */ - } - - if( count( $applications) == 0) - Utilities::print_warning_message('

You must create an application module, interface and deployment space before you can create an experiment. - Click here to create an application.

'); - - - return $applications; -} - - -/** - * Get the interface for the application with the given ID - * @param $id - * @return null - */ -public static function get_application_interface($id) -{ - $airavataclient = Session::get("airavataClient"); - $applicationInterface = null; - - try - { - $applicationInterface = $airavataclient->getApplicationInterface($id); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting the application interface. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage(). '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting the application interface. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting the application interface. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - } - - return $applicationInterface; -} - - -/** - * Get a list of compute resources available for the given application ID - * @param $id - * @return null - */ -public static function get_available_app_interface_compute_resources($id) -{ - $airavataclient = Session::get("airavataClient"); - $computeResources = null; - - try - { - $computeResources = $airavataclient->getAvailableAppInterfaceComputeResources($id); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting compute resources. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting compute resources. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting compute resources. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - } - - return $computeResources; -} - - -/** - * Get the ComputeResourceDescription with the given ID - * @param $id - * @return null - */ -public static function get_compute_resource($id) -{ - $airavataclient = Session::get("airavataClient"); - $computeResource = null; - - try - { - $computeResource = $airavataclient->getComputeResource($id); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting the compute resource. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting the compute resource. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting the compute resource. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - } - - return $computeResource; -} - - -/** - * List the experiment's input files - * @param $experiment - */ -public static function list_input_files($experiment) -{ - $applicationInputs = Utilities::get_application_inputs($experiment->applicationId); - - $experimentInputs = $experiment->experimentInputs; - - - //showing experiment inputs in the order defined by the admins. - $order = array(); - foreach ($experimentInputs as $index => $input) - { - $order[$index] = $input->inputOrder; - } - array_multisort($order, SORT_ASC, $experimentInputs); - - foreach ($experimentInputs as $input) - { - $matchingAppInput = null; - - foreach($applicationInputs as $applicationInput) - { - if ($input->name == $applicationInput->name) - { - $matchingAppInput = $applicationInput; - } - } - //var_dump($matchingAppInput); - - if ($matchingAppInput->type == DataType::URI) - { - $explode = explode('/', $input->value); - echo '

' . - $explode[sizeof($explode)-1] . ' -

'; - } - elseif ($matchingAppInput->type == DataType::STRING) - { - echo '

' . $input->name . ': ' . $input->value . '

'; - } - } -} - - -/** - * Get a list of the inputs for the application with the given ID - * @param $id - * @return null - */ -public static function get_application_inputs($id) -{ - $airavataclient = Session::get("airavataClient"); - $inputs = null; - - try - { - $inputs = $airavataclient->getApplicationInputs($id); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting application inputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting application inputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting application inputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - } - - return $inputs; -} - - -/** - * Get a list of the outputs for the application with the given ID - * @param $id - * @return null - */ -public static function get_application_outputs($id) -{ - $airavataclient = Session::get("airavataClient"); - $outputs = null; - - try - { - $outputs = $airavataclient->getApplicationOutputs($id); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting application outputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting application outputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata Client Exception: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting application outputs. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Airavata System Exception: ' . $ase->getMessage() . '

'); - } - - return $outputs; -} - - -/** - * Get the experiment with the given ID - * @param $expId - * @return null - */ -public static function get_experiment($expId) -{ - $airavataclient = Session::get("airavataClient"); - - try - { - return $airavataclient->getExperiment($expId); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (ExperimentNotFoundException $enf) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

ExperimentNotFoundException: ' . $enf->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - catch (TTransportException $tte) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

TTransportException: ' . $tte->getMessage() . '

'); - } - catch (Exception $e) - { - Utilities::print_error_message('

There was a problem getting the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Exception: ' . $e->getMessage() . '

'); - } - -} - -/** - * Get the project with the given ID - * @param $projectId - * @return null - */ -public static function get_project($projectId) -{ - $airavataclient = Session::get("airavataClient"); - - try - { - return $airavataclient->getProject($projectId); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem getting the project. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem getting the project. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem getting the project. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException!

' . $ase->getMessage() . '

'); - } - -} - - -/** - * Create and configure a new Experiment - * @return Experiment - */ -public static function assemble_experiment() -{ - $utility = new Utilities(); - $experimentInputs = array(); - $app_config = Utilities::read_config(); - - $scheduling = new ComputationalResourceScheduling(); - $scheduling->totalCPUCount = $_POST['cpu-count']; - $scheduling->nodeCount = $_POST['node-count']; - $scheduling->queueName = $_POST['queue-name']; - $scheduling->wallTimeLimit = $_POST['wall-time']; - $scheduling->totalPhysicalMemory = $_POST['total-physical-memory']; - $scheduling->resourceHostId = $_POST['compute-resource']; - - $userConfigData = new UserConfigurationData(); - $userConfigData->computationalResourceScheduling = $scheduling; - if( isset( $_POST["userDN"]) ) - $userConfigData->userDN = $_POST["userDN"]; - - $applicationInputs = Utilities::get_application_inputs($_POST['application']); - $experimentInputs = Utilities::process_inputs($applicationInputs, $experimentInputs); - - if( Utilities::$experimentPath == null){ - Utilities::create_experiment_folder_path(); - } - - $advHandling = new AdvancedOutputDataHandling(); - - $advHandling->outputDataDir = str_replace( base_path() . Constant::EXPERIMENT_DATA_ROOT, Utilities::$pathConstant , Utilities::$experimentPath); - $userConfigData->advanceOutputDataHandling = $advHandling; - - //TODO: replace constructor with a call to airvata to get a prepopulated experiment template - $experiment = new Experiment(); - - // required - $experiment->projectID = $_POST['project']; - $experiment->userName = Session::get( 'username'); - $experiment->name = $_POST['experiment-name']; - - // optional - $experiment->description = $_POST['experiment-description']; - $experiment->applicationId = $_POST['application']; - $experiment->userConfigurationData = $userConfigData; - $experiment->experimentInputs = $experimentInputs; - if( isset( $_POST["enableEmailNotification"])) - { - $experiment->enableEmailNotification = intval( $_POST["enableEmailNotification"] ); - $experiment->emailAddresses = array_unique( array_filter( $_POST["emailAddresses"], "trim") ); - } - - // adding default experiment outputs for now till prepoulated experiment template is not implemented. - $experiment->experimentOutputs = Utilities::get_application_outputs( $_POST["application"]); - - if ($experimentInputs) - { - return $experiment; - } -} - -/** - * @param $applicationInputs - * @param $experimentInputs - * @internal param $environmentPath - * @return array - */ -public static function process_inputs($applicationInputs, $experimentInputs) -{ - $utility = new Utilities(); - $experimentAssemblySuccessful = true; - $newExperimentInputs = array(); - - //var_dump($_FILES); - - if (sizeof($_FILES) > 0) - { - if (Utilities::file_upload_successful()) - { - // construct unique path - Utilities::create_experiment_folder_path(); - } - else - { - $experimentAssemblySuccessful = false; - } - } - - //sending application inputs in the order defined by the admins. - $order = array(); - foreach ($applicationInputs as $index => $input) - { - $order[$index] = $input->inputOrder; - } - array_multisort($order, SORT_ASC, $applicationInputs); - - foreach ($applicationInputs as $applicationInput) - { - $experimentInput = new InputDataObjectType(); - $experimentInput = $applicationInput; - //$experimentInput->name = $applicationInput->name; - //$experimentInput->metaData = $applicationInput->metaData; - - - //$experimentInput->type = $applicationInput->type; - //$experimentInput->type = DataType::STRING; - - - if(($applicationInput->type == DataType::STRING) || - ($applicationInput->type == DataType::INTEGER) || - ($applicationInput->type == DataType::FLOAT)) - { - if (isset($_POST[$applicationInput->name]) && (trim($_POST[$applicationInput->name]) != '')) - { - $experimentInput->value = $_POST[$applicationInput->name]; - $experimentInput->type = $applicationInput->type; - - } - else // use previous value - { - $index = -1; - for ($i = 0; $i < sizeof($experimentInputs); $i++) - { - if ($experimentInputs[$i]->name == $applicationInput->name) - { - $index = $i; - } - } - - if ($index >= 0) - { - $experimentInput->value = $experimentInputs[$index]->value; - $experimentInput->type = $applicationInput->type; - } - } - } - elseif ($applicationInput->type == DataType::URI) - { - //var_dump($_FILES[$applicationInput->name]->name); - if ($_FILES[$applicationInput->name]['name']) - { - $file = $_FILES[$applicationInput->name]; - - - // - // move file to experiment data directory - // - $filePath = Utilities::$experimentPath . $file['name']; - - // check if file already exists - if (is_file($filePath)) - { - unlink($filePath); - - Utilities::print_warning_message('Uploaded file already exists! Overwriting...'); - } - - $moveFile = move_uploaded_file($file['tmp_name'], $filePath); - - if ($moveFile) - { - Utilities::print_success_message('Upload: ' . $file['name'] . '
' . - 'Type: ' . $file['type'] . '
' . - 'Size: ' . ($file['size']/1024) . ' kB');//
' . - //'Stored in: ' . $experimentPath . $file['name']); - } - else - { - Utilities::print_error_message('

Error moving uploaded file ' . $file['name'] . '! - Please try again later or report a bug using the link in the Help menu.

'); - $experimentAssemblySuccessful = false; - } - - $experimentInput->value = str_replace(base_path() . Constant::EXPERIMENT_DATA_ROOT, Utilities::$pathConstant , $filePath); - $experimentInput->type = $applicationInput->type; - - } - else - { - $index = -1; - for ($i = 0; $i < sizeof($experimentInputs); $i++) - { - if ($experimentInputs[$i]->name == $applicationInput->name) - { - $index = $i; - } - } - - if ($index >= 0) - { - $experimentInput->value = $experimentInputs[$index]->value; - $experimentInput->type = $applicationInput->type; - } - } - - } - else - { - Utilities::print_error_message('I cannot accept this input type yet!'); - } - - - - - - - - //$experimentInputs[] = $experimentInput; - /* - $index = -1; - for ($i = 0; $i < sizeof($experimentInputs); $i++) - { - if ($experimentInputs[$i]->key == $experimentInput->key) - { - $index = $i; - } - } - - if ($index >= 0) - { - unset($experimentInputs[$index]); - } - */ - //$experimentInputs[] = $experimentInput; - - - - - - $newExperimentInputs[] = $experimentInput; - - - } - - if ($experimentAssemblySuccessful) - { - return $newExperimentInputs; - } - else - { - return false; - } - -} - - -public static function create_experiment_folder_path() -{ - do - { - Utilities::$experimentPath = base_path() . Constant::EXPERIMENT_DATA_ROOT . str_replace(' ', '', Session::get('username') ) . md5(rand() * time()) . '/'; - } - while (is_dir( Utilities::$experimentPath)); // if dir already exists, try again - // create upload directory - if (!mkdir( Utilities::$experimentPath)) - { - Utilities::print_error_message('

Error creating upload directory! - Please try again later or report a bug using the link in the Help menu.

'); - $experimentAssemblySuccessful = false; - } -} - -/** - * Check the uploaded files for errors - */ -public static function file_upload_successful() -{ - $uploadSuccessful = true; - - foreach ($_FILES as $file) - { - //var_dump($file); - if($file['name']) - { - if ($file['error'] > 0) - { - $uploadSuccessful = false; - Utilities::print_error_message('

Error uploading file ' . $file['name'] . ' ! - Please try again later or report a bug using the link in the Help menu.'); - }/* - elseif ($file['type'] != 'text/plain') - { - $uploadSuccessful = false; - Utilities::print_error_message('Uploaded file ' . $file['name'] . ' type not supported!'); - } - elseif (($file['size'] / 1024) > 20) - { - $uploadSuccessful = false; - Utilities::print_error_message('Uploaded file ' . $file['name'] . ' must be smaller than 10 MB!'); - }*/ - } - - - } - - return $uploadSuccessful; -} - - -/** - * Update the experiment with the given ID - * @param $expId - * @param $updatedExperiment - */ -public static function update_experiment($expId, $updatedExperiment) -{ - $airavataclient = Session::get("airavataClient"); - - try - { - $airavataclient->updateExperiment($expId, $updatedExperiment); - - /* - Utilities::print_success_message("

Experiment updated!

" . - '

Click - here to visit the experiment summary page.

'); - */ - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem updating the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (ExperimentNotFoundException $enf) - { - Utilities::print_error_message('

There was a problem updating the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

ExperimentNotFoundException: ' . $enf->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem updating the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem updating the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - -} - - -/** - * Clone the experiment with the given ID - * @param $expId - */ -public static function clone_experiment($expId) -{ - $airavataclient = Session::get("airavataClient"); - - try - { - //create new experiment to receive the clone - $experiment = $airavataclient->getExperiment($expId); - - $cloneId = $airavataclient->cloneExperiment($expId, 'Clone of ' . $experiment->name); - - Utilities::print_success_message("

Experiment cloned!

" . - '

You will be redirected to the edit page shortly, or you can - go directly to the edit experiment page.

'); - //redirect('edit_experiment.php?expId=' . $cloneId); - return $cloneId; - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem cloning the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (ExperimentNotFoundException $enf) - { - Utilities::print_error_message('

There was a problem cloning the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

ExperimentNotFoundException: ' . $enf->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem cloning the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem cloning the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - catch (TTransportException $tte) - { - Utilities::print_error_message('

There was a problem cloning the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

TTransportException: ' . $tte->getMessage() . '

'); - } -} - -/** - * Cancel the experiment with the given ID - * @param $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"]); - - Utilities::print_success_message("Experiment canceled!"); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

InvalidRequestException: ' . $ire->getMessage() . '

'); - } - catch (ExperimentNotFoundException $enf) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

ExperimentNotFoundException: ' . $enf->getMessage() . '

'); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataClientException: ' . $ace->getMessage() . '

'); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

AiravataSystemException: ' . $ase->getMessage() . '

'); - } - catch (TTransportException $tte) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

TTransportException: ' . $tte->getMessage() . '

'); - } - catch (Exception $e) - { - Utilities::print_error_message('

There was a problem canceling the experiment. - Please try again later or submit a bug report using the link in the Help menu.

' . - '

Exception: ' . $e->getMessage() . '

'); - } -} - - -/** - * Create a select input and populate it with project options from the database - */ -public static function create_project_select($projectId = null, $editable = true) -{ - $editable? $disabled = '' : $disabled = 'disabled'; - $userProjects = Utilities::get_all_user_projects( Session::get("gateway_id"), Session::get('username') ); - - echo ''; - if( sizeof($userProjects) == 0 ) - { - Utilities::print_warning_message('

You must create a project before you can create an experiment. - Click here to create a project.

'); - } -} - - -/** - * Create a select input and populate it with applications options - * @param null $id - * @param bool $editable - */ -public static function create_application_select($id = null, $editable = true) -{ - $disabled = $editable? '' : 'disabled'; - - $applicationIds = Utilities::get_all_applications(); - - echo ''; -} - - -/** - * Create a select input and populate it with compute resources - * available for the given application ID - * @param $applicationId - * @param $resourceHostId - */ -public static function create_compute_resources_select($applicationId, $resourceHostId) -{ - $computeResources = Utilities::get_available_app_interface_compute_resources($applicationId); - - if( count( $computeResources) > 0) - { - echo ''; - } - else - { - echo "

No Compute Resources exist at the moment."; - } - -} - - -/** - * Create form inputs to accept the inputs to the given application - * @param $id - * @param $isRequired - * @internal param $required - */ -public static function create_inputs($id, $isRequired) -{ - $inputs = Utilities::get_application_inputs($id); - - $required = $isRequired? ' required' : ''; - - //var_dump( $inputs); echo "
after sort
"; - //arranging inputs in ascending order. - foreach ($inputs as $index => $input) - { - $order[$index] = $input->inputOrder; - } - array_multisort($order, SORT_ASC, $inputs); - //var_dump( $inputs); exit; - foreach ($inputs as $input) - { - switch ($input->type) - { - case DataType::STRING: - echo '
- - -
'; - break; - case DataType::INTEGER: - echo '
- - -
'; - break; - case DataType::FLOAT: - echo '
- - -
'; - break; - case DataType::URI: - echo '
- - -

' . $input->userFriendlyDescription . '

-
'; - break; - default: - Utilities::print_error_message('Input data type not supported! - Please file a bug report using the link in the Help menu.'); - break; - } - } -} - - -/** - * Create navigation bar - * Used for all pages - */ -public static function create_nav_bar() -{ - $menus = array(); -/* - if( Session::has('loggedin')) - { - $menus = array - ( - 'Project' => array - ( - array('label' => 'Create Project', 'url' => URL::to('/') . '/project/create'), - array('label' => 'Search Projects', 'url' => URL::to('/') . '/project/search') - ), - 'Experiment' => array - ( - array('label' => 'Create Experiment', 'url' => URL::to('/') . '/experiment/create'), - array('label' => 'Search Experiments', 'url' => URL::to('/') . '/experiment/search') - ), - 'Compute Resource' => array - ( - array('label' => 'Register', 'url' => URL::to('/') . '/cr/create'), - array('label' => 'Browse', 'url' => URL::to('/') . '/cr/browse') - ), - 'App Catalog' => array - ( - array('label' => 'Module', 'url' => URL::to('/') . '/app/module'), - array('label' => 'Interface', 'url' => URL::to('/') . '/app/interface'), - array('label' => 'Deployment', 'url' => URL::to('/') . '/app/deployment') - ), - 'Help' => array - ( - array('label' => 'Report Issue', 'url' => '#'), - array('label' => 'Request Feature', 'url' => '#') - ) - ); - } -*/ - if( Session::has('loggedin')) - { - $menus = array - ( - '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' => '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' => 'Browse', 'url' => URL::to('/') . '/experiment/browse', "nav-active" => "experiment") - ) - ); - - if( Session::has("admin")) - { - $menus['Compute Resource'] = array - ( - array('label' => 'Register', 'url' => URL::to('/') . '/cr/create', "nav-active" => "compute-resource"), - array('label' => 'Browse', 'url' => URL::to('/') . '/cr/browse', "nav-active" => "compute-resource") - ); - $menus['App Catalog'] = array - ( - array('label' => 'Module', 'url' => URL::to('/') . '/app/module', "nav-active" => "app-catalog"), - array('label' => 'Interface', 'url' => URL::to('/') . '/app/interface', "nav-active" => "app-catalog"), - array('label' => 'Deployment', 'url' => URL::to('/') . '/app/deployment', "nav-active" => "app-catalog") - ); - /* - $menus['Gateway Profile'] = array - ( - - array('label' => 'Register', 'url' => URL::to('/') . '/gp/create', "nav-active" => "gateway-profile"), - array('label' => 'Browse', 'url' => URL::to('/') . '/gp/browse', "nav-active" => "gateway-profile") - ); - */ - - } - - $menus['Help'] = array - ( - array('label' => 'Report Issue', 'url' => '#', "nav-active", ""), - array('label' => 'Request Feature', 'url' => '#', "nav-active", "") - ); - } - - $selfExplode = explode('/', $_SERVER['PHP_SELF']); - - - - // nav bar and left-aligned content - - echo ''; -} - -/** -* Add attributes to the HTTP header. -*/ -public static function create_http_header() -{ - header( 'Cache-Control: no-store, no-cache, must-revalidate' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); -} - -/** - * Open the XML file containing the community token - * @param $tokenFilePath - * @throws Exception - */ -public static function open_tokens_file($tokenFilePath) -{ - if (file_exists( $tokenFilePath )) - { - $tokenFile = simplexml_load_file( $tokenFilePath ); - } - else - { - throw new Exception('Error: Cannot connect to tokens database!'); - } - - - if (!$tokenFile) - { - throw new Exception('Error: Cannot open tokens database!'); - } -} - - -/** - * Write the new token to the XML file - * @param $tokenId - */ -public static function write_new_token($tokenId) -{ // write new tokenId to tokens file - $tokenFile->tokenId = $tokenId; - - //Format XML to save indented tree rather than one line - $dom = new DOMDocument('1.0'); - $dom->preserveWhiteSpace = false; - $dom->formatOutput = true; - $dom->loadXML( $tokenFile->asXML()); - $dom->save( $tokenFilePath ); -} - - -//moved from create project view. - -public static function create_project() -{ - - $airavataclient = Session::get("airavataClient"); - - $project = new Project(); - $project->owner = Session::get('username'); - $project->name = $_POST['project-name']; - $project->description = $_POST['project-description']; - - - $projectId = null; - - try - { - $projectId = $airavataclient->createProject( Session::get("gateway_id"), $project); - - if ($projectId) - { - Utilities::print_success_message("

Project {$_POST['project-name']} created!

" . - '

You will be redirected to the summary page shortly, or you can - go directly to the project summary page.

'); - } - else - { - Utilities::print_error_message("Error creating project {$_POST['project-name']}!"); - } - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('AiravataSystemException!

' . $ase->getMessage()); - } - - return $projectId; -} - -/** - * Get experiments in project - * @param $projectId - * @return array|null - */ -public static function get_experiments_in_project($projectId) -{ - $airavataclient = Session::get("airavataClient"); - - $experiments = array(); - - try - { - $experiments = $airavataclient->getAllExperimentsInProject($projectId); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('AiravataSystemException!

' . $ase->getMessage()); - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $tte->getMessage()); - } - - return $experiments; -} - -public static function update_project($projectId, $projectDetails) -{ - $airavataclient = Session::get("airavataClient"); - - $updatedProject = new Project(); - $updatedProject->owner = $projectDetails["owner"]; - $updatedProject->name = $projectDetails["name"]; - $updatedProject->description = $projectDetails["description"]; - - try - { - $airavataclient->updateProject($projectId, $updatedProject); - - //Utilities::print_success_message('Project updated! Click here to view the project summary.'); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (ProjectNotFoundException $pnfe) - { - Utilities::print_error_message('ProjectNotFoundException!

' . $pnfe->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('AiravataSystemException!

' . $ase->getMessage()); - } -} - - -/** - * Create a new experiment from the values submitted in the form - * @return null - */ -public static function create_experiment() -{ - $airavataclient = Session::get("airavataClient"); - - $experiment = Utilities::assemble_experiment(); - $expId = null; - - try - { - if($experiment) - { - $expId = $airavataclient->createExperiment( Session::get("gateway_id"), $experiment); - } - - if ($expId) - { - /* - Utilities::print_success_message("Experiment {$_POST['experiment-name']} created!" . - ' Go to experiment summary page'); - */ - } - else - { - Utilities::print_error_message("Error creating experiment {$_POST['experiment-name']}!"); - } - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - Utilities::print_error_message('AiravataSystemException!

' . $ase->getMessage()); - } - - return $expId; -} - -/* - * Required in Experiment Sumamry page. - * -*/ - -public static function list_output_files($experiment, $expStatus) -{ - - $expStatusVal = array_search($expStatus, ExperimentState::$__names); - - if($expStatusVal == ExperimentState::COMPLETED ) - { - $utility = new Utilities(); - $experimentOutputs = $experiment->experimentOutputs; - - foreach ((array)$experimentOutputs as $output) - { - if ($output->type == DataType::URI || $output->type == DataType::STDOUT || $output->type == DataType::STDERR ) - { - $explode = explode('/', $output->value); - //echo '

' . $output->key . ': ' . $output->value . '

'; - $outputPath = str_replace(Utilities::$experimentDataPathAbsolute, Constant::EXPERIMENT_DATA_ROOT, $output->value); - $outputPathArray = explode("/", $outputPath); - - echo '

' . $output->name . ' : ' . 'value) . '">' . - $outputPathArray[ sizeof( $outputPathArray) - 1] . '

'; - } - elseif ($output->type == DataType::STRING) - { - echo '

' . $output->value . '

'; - } - } - } - else - echo "Experiment hasn't completed. Experiment Status is : " . $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"] = ""; - $expVal["experimentCreationTime"] = ""; - - if( $experiment->experimentStatus != null) - { - $experimentStatus = $experiment->experimentStatus; - $experimentState = $experimentStatus->experimentState; - $experimentStatusString = ExperimentState::$__names[$experimentState]; - $expVal["experimentStatusString"] = $experimentStatusString; - $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); - - if ($jobStatus) - { - $jobName = array_keys($jobStatus); - $jobState = JobState::$__names[$jobStatus[$jobName[0]]->jobState]; - } - else - { - $jobState = null; - } - - $expVal["jobState"] = $jobState; - - if(! $forSearch) - { - $userConfigData = $experiment->userConfigurationData; - $scheduling = $userConfigData->computationalResourceScheduling; - $expVal['scheduling'] = $scheduling; - $expVal["computeResource"] = Utilities::get_compute_resource($scheduling->resourceHostId); - } - $expVal["applicationInterface"] = Utilities::get_application_interface($experiment->applicationId); - - - switch ($experimentStatusString) - { - case 'CREATED': - case 'VALIDATED': - case 'SCHEDULED': - case 'CANCELED': - case 'FAILED': - $expVal["editable"] = true; - break; - default: - $expVal["editable"] = false; - break; - } - - switch ($experimentStatusString) - { - case 'CREATED': - case 'VALIDATED': - case 'SCHEDULED': - case 'LAUNCHED': - case 'EXECUTING': - $expVal["cancelable"] = true; - break; - default: - $expVal["cancelable"] = false; - break; - } - - return $expVal; - -} - - public static function get_all_user_projects_with_pagination($limit, $offset) - { - $airavataclient = Session::get("airavataClient");; - - $projects = array(); - - try - { - $projects = $airavataclient->getAllUserProjectsWithPagination( Session::get("gateway_id"), - Session::get("username"), $limit, $offset); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any projects yet, so no results will be returned!

-

Click here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $tte->getMessage()); - } - - return $projects; - } - - - - public static function get_projsearch_results_with_pagination( $searchKey, $searchValue, $limit, $offset) - { - $airavataclient = Session::get("airavataClient"); - - $projects = array(); - - try - { - switch ( $searchKey) - { - case 'project-name': - $projects = $airavataclient->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!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any projects yet, so no results will be returned!

-

Click here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $tte->getMessage()); - } - - return $projects; - } - - -public static function get_projsearch_results( $searchKey, $searchValue) -{ - $airavataclient = Session::get("airavataClient");; - - $projects = array(); - - try - { - switch ( $searchKey) - { - case 'project-name': - $projects = $airavataclient->searchProjectsByProjectName( Session::get("gateway_id"), Session::get("username"), $searchValue); - break; - case 'project-description': - $projects = $airavataclient->searchProjectsByProjectDesc( Session::get("gateway_id"), Session::get("username"), $searchValue); - break; - } - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any projects yet, so no results will be returned!

-

Click here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $tte->getMessage()); - } - - return $projects; -} - - -/** - * Create options for the search key select input - * @param $values - * @param $labels - * @param $disabled - */ -public static function create_options($values, $labels, $disabled) -{ - for ($i = 0; $i < sizeof($values); $i++) - { - $selected = ''; - - // if option was previously selected, mark it as selected - if (isset($_POST['search-key'])) - { - if ($values[$i] == $_POST['search-key']) - { - $selected = 'selected'; - } - } - - echo ''; - } -} - - /** - * 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) - { - $airavataclient = Session::get("airavataClient"); - $experiments = array(); - - try - { - switch ( $inputs["search-key"]) - { - case 'experiment-name': - $experiments = $airavataclient->searchExperimentsByNameWithPagination( - Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); - break; - case 'experiment-description': - $experiments = $airavataclient->searchExperimentsByDescWithPagination( - Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); - break; - case 'application': - $experiments = $airavataclient->searchExperimentsByApplicationWithPagination( - Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); - break; - case 'creation-time': - $experiments = $airavataclient->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!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any experiments yet, so no results will be returned!

-

Click here to create an experiment, or - here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $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 - { - switch ( $inputs["search-key"]) - { - case 'experiment-name': - $experiments = $airavataclient->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"]); - break; - case 'application': - $experiments = $airavataclient->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 ); - break; - case '': - } - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any experiments yet, so no results will be returned!

-

Click here to create an experiment, or - here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $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 all experiments with pagination. - * Results are ordered creation time DESC - * @return array|null - */ - public static function get_all_user_experiments_with_pagination($limit, $offset) - { - $airavataclient = Session::get("airavataClient"); - $experiments = array(); - - try - { - $experiments = $airavataclient->getAllUserExperimentsWithPagination( - Session::get('gateway_id'), Session::get('username'), $limit, $offset - ); - } - catch (InvalidRequestException $ire) - { - Utilities::print_error_message('InvalidRequestException!

' . $ire->getMessage()); - } - catch (AiravataClientException $ace) - { - Utilities::print_error_message('AiravataClientException!

' . $ace->getMessage()); - } - catch (AiravataSystemException $ase) - { - if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR - { - Utilities::print_info_message('

You have not created any experiments yet, so no results will be returned!

-

Click here to create an experiment, or - here to create a new project.

'); - } - 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!

' . $ase->airavataErrorType . ': ' . $ase->getMessage()); - } - } - catch (TTransportException $tte) - { - Utilities::print_error_message('TTransportException!

' . $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; -} - - -public static function apply_changes_to_experiment($experiment, $input) -{ - $experiment->name = $input['experiment-name']; - $experiment->description = rtrim($input['experiment-description']); - $experiment->projectID = $input['project']; - //$experiment->applicationId = $_POST['application']; - - $userConfigDataUpdated = $experiment->userConfigurationData; - $schedulingUpdated = $userConfigDataUpdated->computationalResourceScheduling; - - $schedulingUpdated->resourceHostId = $input['compute-resource']; - $schedulingUpdated->nodeCount = $input['node-count']; - $schedulingUpdated->queueName = $_POST['queue-name']; - $schedulingUpdated->totalCPUCount = $input['cpu-count']; - //$schedulingUpdated->numberOfThreads = $input['threads']; - $schedulingUpdated->wallTimeLimit = $input['wall-time']; - //$schedulingUpdated->totalPhysicalMemory = $input['memory']; - - /* - switch ($_POST['compute-resource']) - { - case 'trestles.sdsc.edu': - $schedulingUpdated->ComputationalProjectAccount = 'sds128'; - break; - case 'stampede.tacc.xsede.org': - case 'lonestar.tacc.utexas.edu': - $schedulingUpdated->ComputationalProjectAccount = 'TG-STA110014S'; - break; - default: - $schedulingUpdated->ComputationalProjectAccount = 'admin'; - } - */ - - $userConfigDataUpdated->computationalResourceScheduling = $schedulingUpdated; - if( isset( $input["userDN"]) ) - $userConfigDataUpdated->userDN = $input["userDN"]; - - $experiment->userConfigurationData = $userConfigDataUpdated; - - $applicationInputs = Utilities::get_application_inputs($experiment->applicationId); - - $experimentInputs = $experiment->experimentInputs; // get current inputs - //var_dump($experimentInputs); - $experimentInputs = Utilities::process_inputs($applicationInputs, $experimentInputs); // get new inputs - //var_dump($experimentInputs); - - if ($experimentInputs) - { - $experiment->experimentInputs = $experimentInputs; - //var_dump($experiment); - return $experiment; - } -} - -public static function read_config( $fileName = null){ - $wsis_config = null; - - if( $fileName == null) - $fileName = "app_config.ini"; - try { - if (file_exists( app_path() . "/config/" . $fileName ) ) { - - try - { - $wsis_config = parse_ini_file( app_path() . "/config/" . $fileName ); - } - - catch( \Exception $e) - { - print_r( $e); exit; - } - } - else - { - throw new Exception("Error: Cannot open file!"); - } - - if (!$wsis_config) - { - throw new Exception('Error: Unable to read the file!'); - } - }catch (Exception $e) { - throw new Exception('Unable to instantiate the client. Try editing the file.', 0, NULL); - } - return $wsis_config; - -} - -public static function get_job_details( $experimentId){ - $airavataclient = Session::get("airavataClient"); - return $airavataclient->getJobDetails( $experimentId); -} - -public static function get_transfer_details( $experimentId){ - $airavataclient = Session::get("airavataClient"); - return $airavataclient->getDataTransferDetails( $experimentId); -} - -} - -?> diff --git a/workbench/airavata/wsis/.gitignore b/workbench/airavata/wsis/.gitignore deleted file mode 100755 index 582640226..000000000 --- a/workbench/airavata/wsis/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/vendor -composer.phar -composer.lock -.DS_Store diff --git a/workbench/airavata/wsis/.travis.yml b/workbench/airavata/wsis/.travis.yml deleted file mode 100755 index f60bbe00a..000000000 --- a/workbench/airavata/wsis/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/workbench/airavata/wsis/composer.json b/workbench/airavata/wsis/composer.json deleted file mode 100755 index 2af236e8b..000000000 --- a/workbench/airavata/wsis/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "airavata/wsis", - "description": "", - "authors": [ - { - "name": "Apache Airavata", - "email": "dev@airavata.apache.org" - } - ], - "require": { - "php": ">=5.4.0", - "illuminate/support": "4.2.*" - }, - "autoload": { - "psr-0": { - "Airavata\\Wsis": "src/" - } - }, - "minimum-stability": "stable" -} diff --git a/workbench/airavata/wsis/phpunit.xml b/workbench/airavata/wsis/phpunit.xml deleted file mode 100755 index 3347b75b7..000000000 --- a/workbench/airavata/wsis/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - diff --git a/workbench/airavata/wsis/src/config/config.php b/workbench/airavata/wsis/src/config/config.php deleted file mode 100644 index 69f61cf7c..000000000 --- a/workbench/airavata/wsis/src/config/config.php +++ /dev/null @@ -1,52 +0,0 @@ - 'admin', - - /** - * Gateway user role - */ - 'gateway-admin' => 'Internal/everyone', - - /** - * Tenant admin's username - */ - 'admin-username' => 'admin-username', - - /** - * Tenant admin's password - */ - 'admin-password' => 'admin-password', - - /** - * 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 diff --git a/workbench/airavata/wsis/tests/.gitkeep b/workbench/airavata/wsis/tests/.gitkeep deleted file mode 100755 index e69de29bb..000000000 From e1a1024f372bf485ccaa7e68efd00cb3bd33f44b Mon Sep 17 00:00:00 2001 From: Supun Nakandala Date: Sat, 9 May 2015 14:15:37 +0530 Subject: [PATCH 2/4] Adding missing files --- .../Airavata/AiravataServiceProvider.php | 80 +++++++++++++++++++ app/libraries/Airavata/Facades/Airavata.php | 16 ++++ 2 files changed, 96 insertions(+) create mode 100755 app/libraries/Airavata/AiravataServiceProvider.php create mode 100755 app/libraries/Airavata/Facades/Airavata.php diff --git a/app/libraries/Airavata/AiravataServiceProvider.php b/app/libraries/Airavata/AiravataServiceProvider.php new file mode 100755 index 000000000..2ff4db142 --- /dev/null +++ b/app/libraries/Airavata/AiravataServiceProvider.php @@ -0,0 +1,80 @@ +package('airavata/airavata'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + //registering service provider + $this->app['airavata'] = $this->app->share(function($app) + { + try{ + $transport = new TSocket( + Config::get('pga_config.airavata')['airavata-server'], + Config::get('pga_config.airavata')['airavata-port'] + ); + $transport->setRecvTimeout( Config::get('pga_config.airavata')['airavata-timeout']); + $transport->setSendTimeout( Config::get('pga_config.airavata')['airavata-timeout']); + + $protocol = new TBinaryProtocol($transport); + $transport->open(); + + $client = new AiravataClient($protocol); + + }catch (\Exception $ex){ + var_dump($ex); + exit; + } + + if( is_object( $client)) + return $client; + else + return Redirect::to("airavata/down"); + }); + + //registering alis + $this->app->booting(function() + { + $loader = \Illuminate\Foundation\AliasLoader::getInstance(); + $loader->alias('Airavata', 'Airavata\Facades\Airavata'); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('airavata'); + } + +} diff --git a/app/libraries/Airavata/Facades/Airavata.php b/app/libraries/Airavata/Facades/Airavata.php new file mode 100755 index 000000000..1446c2c3a --- /dev/null +++ b/app/libraries/Airavata/Facades/Airavata.php @@ -0,0 +1,16 @@ + Date: Sat, 9 May 2015 14:17:17 +0530 Subject: [PATCH 3/4] Adding missing files --- app/config/pga_config.php | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 app/config/pga_config.php diff --git a/app/config/pga_config.php b/app/config/pga_config.php new file mode 100644 index 000000000..146b236f3 --- /dev/null +++ b/app/config/pga_config.php @@ -0,0 +1,85 @@ + [ + + /** + * 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-cert' => false + ], + + + /** + * ***************************************************************** + * These are Airavata Related Configurations + * ***************************************************************** + */ + 'airavata' => [ + /** + * Airavata API server location + */ + 'airavata-server' => 'gw111.iu.xsede.org', + + /** + * Airavata API server port + */ + 'airavata-port' => '9930', + + /** + * Airavata API server thrift communication timeout + */ + 'airavata-timeout' => '1000000' + ] + +); \ No newline at end of file From c1174e1e7716c8fa1d11406bb77edfa7c6791857 Mon Sep 17 00:00:00 2001 From: Supun Nakandala Date: Sat, 9 May 2015 14:27:15 +0530 Subject: [PATCH 4/4] Correcting the wrong API method invocation in Wsis.php --- app/libraries/Wsis/Wsis.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php index ede9774b6..2588012e1 100755 --- a/app/libraries/Wsis/Wsis.php +++ b/app/libraries/Wsis/Wsis.php @@ -2,8 +2,8 @@ namespace Wsis; -use Illuminate\Support\Facades\Config; use Wsis\Stubs\UserStoreManager; +use Wsis\Stubs\TenantManager; class Wsis { @@ -13,6 +13,12 @@ class Wsis { */ private $userStoreManager; + /** + * @var + * @access private + */ + private $tenantManager; + /** * @var string * @access private @@ -63,6 +69,7 @@ public function __construct($admin_username, $admin_password = null, $server, try { $this->userStoreManager = new UserStoreManager($service_url, $parameters); + $this->tenantManager = new TenantManager($service_url, $parameters); } catch (Exception $ex) { print_r( $ex); exit; throw new Exception("Unable to instantiate client", 0, $ex); @@ -265,16 +272,26 @@ public function get_tenant_id(){ /** * Function create a new Tenant - * - * @param Tenant $parameters - * @return void + * @param $active + * @param $adminUsername + * @param $adminPassword + * @param $email + * @param $firstName + * @param $lastName + * @param $tenantDomain + * @throws Exception */ - public function create_tenant( $inputs){ + public function create_tenant($active, $adminUsername, $adminPassword, $email, + $firstName, $lastName, $tenantDomain){ try { - return $this->userStoreManager->createTenant( $inputs); + return $this->tenantManager->addTenant($active, $adminUsername, $adminPassword, $email, + $firstName, $lastName, $tenantDomain); } catch (Exception $ex) { - var_dump( $ex); - throw new Exception("Unable to create Tenant.", 0, $ex); + /** + * Fixme - There is an issue in the Remote IS which throws an exception when called this method + * But the tenant creation works. Therefore ignores the exception for the moment. + */ + //throw new Exception("Unable to create Tenant.", 0, $ex); } } } \ No newline at end of file