You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/05 00:15:49 UTC

[09/10] airavata-php-gateway git commit: Cleaning and restructuring PGA

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2fbd9289/app/libraries/AppUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AppUtilities.php b/app/libraries/AppUtilities.php
index e485a36..5ceb44a 100644
--- a/app/libraries/AppUtilities.php
+++ b/app/libraries/AppUtilities.php
@@ -1,205 +1,327 @@
 <?php
 
 //Airavata classes - loaded from app/libraries/Airavata
-use Airavata\Model\AppCatalog\AppInterface\DataType;
-use Airavata\Model\AppCatalog\AppInterface\InputDataObjectType;
-use Airavata\Model\AppCatalog\AppInterface\OutputDataObjectType;
-use Airavata\Model\AppCatalog\AppInterface\ApplicationInterfaceDescription;
+use Airavata\Model\AppCatalog\AppDeployment\ApplicationDeploymentDescription;
 use Airavata\Model\AppCatalog\AppDeployment\ApplicationModule;
 use Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType;
-use Airavata\Model\AppCatalog\AppDeployment\ApplicationDeploymentDescription;
 use Airavata\Model\AppCatalog\AppDeployment\SetEnvPaths;
+use Airavata\Model\AppCatalog\AppInterface\ApplicationInterfaceDescription;
+use Airavata\Model\AppCatalog\AppInterface\DataType;
+use Airavata\Model\AppCatalog\AppInterface\InputDataObjectType;
+use Airavata\Model\AppCatalog\AppInterface\OutputDataObjectType;
+
+
+class AppUtilities
+{
+
+    public static function create_or_update_appModule($inputs, $update = false)
+    {
+
+        $appModule = new ApplicationModule(array(
+            "appModuleName" => $inputs["appModuleName"],
+            "appModuleVersion" => $inputs["appModuleVersion"],
+            "appModuleDescription" => $inputs["appModuleDescription"]
+        ));
+
+        if ($update)
+            return Airavata::updateApplicationModule($inputs["appModuleId"], $appModule);
+        else
+            return Airavata::registerApplicationModule(Session::get("gateway_id"), $appModule);
+    }
+
+    public static function deleteAppModule($appModuleId)
+    {
+
+        return Airavata::deleteApplicationModule($appModuleId);
+    }
+
+    public static function getAppInterfaceData()
+    {
+
+        $dataType = new DataType();
+        $modules = AppUtilities::getAllModules();
+        $appInterfaces = Airavata::getAllApplicationInterfaces(Session::get("gateway_id"));
+
+
+        $InputDataObjectType = new InputDataObjectType();
+
+        return array(
+            "appInterfaces" => $appInterfaces,
+            "dataTypes" => $dataType::$__names,
+            "modules" => $modules
+        );
+    }
+
+    public static function create_or_update_appInterface($appInterfaceValues, $update = false)
+    {
+
+        //var_dump( $appInterfaceValues); exit;
+        $appInterface = new ApplicationInterfaceDescription(array(
+            "applicationName" => $appInterfaceValues["applicationName"],
+            "applicationDescription" => $appInterfaceValues["applicationDescription"],
+            "applicationModules" => $appInterfaceValues["applicationModules"]
+        ));
+
+        if (isset($appInterfaceValues["inputName"])) {
+            foreach ($appInterfaceValues["inputName"] as $index => $name) {
+                $inputDataObjectType = new InputDataObjectType(array(
+                    "name" => $name,
+                    "value" => $appInterfaceValues["inputValue"][$index],
+                    "type" => $appInterfaceValues["inputType"][$index],
+                    "applicationArgument" => $appInterfaceValues["applicationArgumentInput"][$index],
+                    "standardInput" => $appInterfaceValues["standardInput"][$index],
+                    "userFriendlyDescription" => $appInterfaceValues["userFriendlyDescription"][$index],
+                    "metaData" => $appInterfaceValues["metaData"][$index],
+                    "inputOrder" => intval($appInterfaceValues["inputOrder"][$index]),
+                    "dataStaged" => intval($appInterfaceValues["dataStaged"][$index]),
+                    "isRequired" => $appInterfaceValues["isRequiredInput"][$index],
+                    "requiredToAddedToCommandLine" => $appInterfaceValues["requiredToAddedToCommandLineInput"][$index]
+                ));
+                $appInterface->applicationInputs[] = $inputDataObjectType;
+            }
+        }
+
+        if (isset($appInterfaceValues["outputName"])) {
+            foreach ($appInterfaceValues["outputName"] as $index => $name) {
+                $outputDataObjectType = new OutputDataObjectType(array(
+                    "name" => $name,
+                    "value" => $appInterfaceValues["outputValue"][$index],
+                    "type" => $appInterfaceValues["outputType"][$index],
+                    "applicationArgument" => $appInterfaceValues["applicationArgumentOutput"][$index],
+                    "dataMovement" => intval($appInterfaceValues["dataMovement"][$index]),
+                    "location" => $appInterfaceValues["location"][$index],
+                    "isRequired" => $appInterfaceValues["isRequiredOutput"][$index],
+                    "requiredToAddedToCommandLine" => $appInterfaceValues["requiredToAddedToCommandLineOutput"][$index],
+                    "searchQuery" => $appInterfaceValues["searchQuery"][$index]
+                ));
+                $appInterface->applicationOutputs[] = $outputDataObjectType;
+            }
+        }
+
+        //var_dump( $appInterface); exit;
+
+        if ($update)
+            Airavata::updateApplicationInterface($appInterfaceValues["app-interface-id"], $appInterface);
+        else
+            Airavata::getApplicationInterface(Airavata::registerApplicationInterface(Session::get("gateway_id"), $appInterface));
+
+        //print_r( "App interface has been created.");
+    }
+
+    public static function deleteAppInterface($appInterfaceId)
+    {
+        return Airavata::deleteApplicationInterface($appInterfaceId);
+    }
+
+
+    public static function getAppDeploymentData()
+    {
+
+        $appDeployments = Airavata::getAllApplicationDeployments(Session::get("gateway_id"));
+        //var_dump( $appDeployments); exit;
+        $computeResources = Airavata::getAllComputeResourceNames();
+        $modules = AppUtilities::getAllModules();
+        $apt = new ApplicationParallelismType();
+
+        return array(
+            "appDeployments" => $appDeployments,
+            "applicationParallelismTypes" => $apt::$__names,
+            "computeResources" => $computeResources,
+            "modules" => $modules
+        );
+    }
+
+    public static function create_or_update_appDeployment($inputs, $update = false)
+    {
+
+        $appDeploymentValues = $inputs;
+
+        if (isset($appDeploymentValues["moduleLoadCmds"]))
+            $appDeploymentValues["moduleLoadCmds"] = array_unique(array_filter($appDeploymentValues["moduleLoadCmds"]));
+
+        if (isset($appDeploymentValues["libraryPrependPathName"])) {
+            $libPrependPathNames = array_unique(array_filter($appDeploymentValues["libraryPrependPathName"], "trim"));
+
+            foreach ($libPrependPathNames as $index => $prependName) {
+                $envPath = new SetEnvPaths(array(
+                    "name" => $prependName,
+                    "value" => $appDeploymentValues["libraryPrependPathValue"][$index]
+                ));
+                $appDeploymentValues["libPrependPaths"][] = $envPath;
+            }
+        }
+
+        if (isset($appDeploymentValues["libraryAppendPathName"])) {
+            $libAppendPathNames = array_unique(array_filter($appDeploymentValues["libraryAppendPathName"], "trim"));
+            foreach ($libAppendPathNames as $index => $appendName) {
+                $envPath = new SetEnvPaths(array(
+                    "name" => $appendName,
+                    "value" => $appDeploymentValues["libraryAppendPathValue"][$index]
+                ));
+                $appDeploymentValues["libAppendPaths"][] = $envPath;
+            }
+        }
+
+        if (isset($appDeploymentValues["environmentName"])) {
+            $environmentNames = array_unique(array_filter($appDeploymentValues["environmentName"], "trim"));
+            foreach ($environmentNames as $index => $envName) {
+                $envPath = new SetEnvPaths(array(
+                    "name" => $envName,
+                    "value" => $appDeploymentValues["environmentValue"][$index]
+                ));
+                $appDeploymentValues["setEnvironment"][] = $envPath;
+            }
+        }
+
+        if (isset($appDeploymentValues["preJobCommand"])) {
+            $appDeploymentValues["preJobCommands"] = array_unique(array_filter($appDeploymentValues["preJobCommand"], "trim"));
+        }
+
+        if (isset($appDeploymentValues["postJobCommand"])) {
+            $appDeploymentValues["postJobCommands"] = array_unique(array_filter($appDeploymentValues["postJobCommand"], "trim"));
+        }
+
+        //var_dump( $appDeploymentValues); exit;
+        $appDeployment = new ApplicationDeploymentDescription($appDeploymentValues);
+        if ($update)
+            Airavata::updateApplicationDeployment($inputs["app-deployment-id"], $appDeployment);
+        else
+            $appDeploymentId = Airavata::registerApplicationDeployment(Session::get("gateway_id"), $appDeployment);
+
+        return;
+
+    }
+
+    public static function deleteAppDeployment($appDeploymentId)
+    {
+        return Airavata::deleteApplicationDeployment($appDeploymentId);
+    }
+
+    public static function getAllModules()
+    {
+        return Airavata::getAllAppModules(Session::get("gateway_id"));
+    }
+
+    /**
+     * Get all available applications
+     * @return null
+     */
+    public static function get_all_applications()
+    {
+        $applications = null;
+
+        try {
+            $applications = Airavata::getAllApplicationInterfaceNames(Session::get("gateway_id"));
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting all applications.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting all applications.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_warning_message('<p>You must create an application module, interface and deployment space before you can create an experiment.
+                Click <a href="' . URL::to('/') . '/app/module">here</a> to create an application.</p>');
+            /*
+            Utilities::print_error_message('<p>There was a problem getting all applications.
+                Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+                */
+        }
+
+        if (count($applications) == 0)
+            CommonUtilities::print_warning_message('<p>You must create an application module, interface and deployment space before you can create an experiment.
+                Click <a href="' . URL::to('/') . '/app/module">here</a> to create an application.</p>');
+
+
+        return $applications;
+    }
+
+    /**
+     * Get the interface for the application with the given ID
+     * @param $id
+     * @return null
+     */
+    public static function get_application_interface($id)
+    {
+        $applicationInterface = null;
+
+        try {
+            $applicationInterface = Airavata::getApplicationInterface($id);
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the application interface.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the application interface.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the application interface.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+        }
+
+        return $applicationInterface;
+    }
+
+    /**
+     * Get a list of the inputs for the application with the given ID
+     * @param $id
+     * @return null
+     */
+    public static function get_application_inputs($id)
+    {
+        $inputs = null;
+
+        try {
+            $inputs = Airavata::getApplicationInputs($id);
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application inputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application inputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application inputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+        }
+
+        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)
+    {
+        $outputs = null;
+
+        try {
+            $outputs = Airavata::getApplicationOutputs($id);
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application outputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application outputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('<p>There was a problem getting application outputs.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+        }
+
+        return $outputs;
+    }
 
 
-class AppUtilities{
-
-	public static function create_or_update_appModule( $inputs, $update = false){
-
-		$appModule = new ApplicationModule( array(
-												"appModuleName" => $inputs["appModuleName"],
-												"appModuleVersion" => $inputs["appModuleVersion"],
-												"appModuleDescription" => $inputs["appModuleDescription"]
-										));
-		
-		if( $update)
-			return Airavata::updateApplicationModule( $inputs["appModuleId"], $appModule);
-		else
-			return Airavata::registerApplicationModule( Session::get("gateway_id"), $appModule);
-	}
-
-	public static function deleteAppModule( $appModuleId){
-
-		return Airavata::deleteApplicationModule( $appModuleId);
-	}
-
-	public static function getAppInterfaceData(){
-
-		$dataType = new DataType();
-		$modules = AppUtilities::getAllModules();
-		$appInterfaces = Airavata::getAllApplicationInterfaces( Session::get("gateway_id"));
-
-
-		$InputDataObjectType = new InputDataObjectType();
-
-		return array(
-						"appInterfaces" 	=> $appInterfaces,
-						"dataTypes" 		=> $dataType::$__names,
-						"modules"   		=> $modules
-						);
-	}
-
-	public static function create_or_update_appInterface( $appInterfaceValues, $update = false){
-
-		//var_dump( $appInterfaceValues); exit;
-		$appInterface = new ApplicationInterfaceDescription( array(
-																"applicationName" => $appInterfaceValues["applicationName"],
-																"applicationDescription" => $appInterfaceValues["applicationDescription"],
-																"applicationModules" => $appInterfaceValues["applicationModules"]
-															) ); 
-
-		if( isset( $appInterfaceValues["inputName"]))
-		{
-			foreach ($appInterfaceValues["inputName"] as $index => $name) {
-				$inputDataObjectType = new InputDataObjectType( array(
-																	"name" => $name,
-																	"value" => $appInterfaceValues["inputValue"][ $index],
-																	"type" => $appInterfaceValues["inputType"][ $index],
-																	"applicationArgument" => $appInterfaceValues["applicationArgumentInput"][$index],
-																	"standardInput" => $appInterfaceValues["standardInput"][ $index],
-																	"userFriendlyDescription" => $appInterfaceValues["userFriendlyDescription"][ $index],
-																	"metaData" => $appInterfaceValues["metaData"][ $index],
-																	"inputOrder" => intval( $appInterfaceValues["inputOrder"][ $index]),
-																	"dataStaged" => intval( $appInterfaceValues["dataStaged"][ $index]),
-																	"isRequired" => $appInterfaceValues["isRequiredInput"][ $index],
-																	"requiredToAddedToCommandLine" => $appInterfaceValues["requiredToAddedToCommandLineInput"][$index]
-																) );
-				$appInterface->applicationInputs[] = $inputDataObjectType;
-			}
-		}
-
-		if( isset( $appInterfaceValues["outputName"]))
-		{
-			foreach ( $appInterfaceValues["outputName"] as $index => $name) {
-				$outputDataObjectType = new OutputDataObjectType( array(
-																	"name" => $name,
-																	"value" => $appInterfaceValues["outputValue"][ $index],
-																	"type" => $appInterfaceValues["outputType"][ $index],
-																	"applicationArgument" => $appInterfaceValues["applicationArgumentOutput"][$index],
-																	"dataMovement" => intval( $appInterfaceValues["dataMovement"][ $index]),
-																	"location" => $appInterfaceValues["location"][ $index],
-																	"isRequired" => $appInterfaceValues["isRequiredOutput"][ $index],
-																	"requiredToAddedToCommandLine" => $appInterfaceValues["requiredToAddedToCommandLineOutput"][$index],
-																	"searchQuery" => $appInterfaceValues["searchQuery"][$index]
-																));
-				$appInterface->applicationOutputs[] = $outputDataObjectType;
-			}
-		}
-
-		//var_dump( $appInterface); exit;
-
-		if( $update)
-            Airavata::updateApplicationInterface( $appInterfaceValues["app-interface-id"], $appInterface);
-		else
-            Airavata::getApplicationInterface(Airavata::registerApplicationInterface( Session::get("gateway_id"), $appInterface) );
-
-		//print_r( "App interface has been created.");
-	}
-
-	public static function deleteAppInterface( $appInterfaceId){
-		return Airavata::deleteApplicationInterface( $appInterfaceId);
-	}
-
-
-	public static function getAppDeploymentData(){
-
-		$appDeployments = Airavata::getAllApplicationDeployments( Session::get("gateway_id"));
-		//var_dump( $appDeployments); exit;
-		$computeResources = Airavata::getAllComputeResourceNames();
-		$modules = AppUtilities::getAllModules();
-		$apt = new ApplicationParallelismType();
-
-		return array( 
-						"appDeployments" 			  => $appDeployments,
-						"applicationParallelismTypes" => $apt::$__names,
-						"computeResources"            => $computeResources,
-						"modules"			          => $modules
-					);
-	}
-
-	public static function create_or_update_appDeployment( $inputs, $update = false){
-
-		$appDeploymentValues = $inputs;
-
-		if( isset( $appDeploymentValues["moduleLoadCmds"]))
-			$appDeploymentValues["moduleLoadCmds"] = array_unique( array_filter( $appDeploymentValues["moduleLoadCmds"]));
-
-		if( isset( $appDeploymentValues["libraryPrependPathName"] )) 
-		{	
-			$libPrependPathNames = array_unique( array_filter( $appDeploymentValues["libraryPrependPathName"],"trim" ));
-		
-			foreach( $libPrependPathNames as $index => $prependName)
-			{
-				$envPath = new SetEnvPaths(array(
-												"name" => $prependName,
-												"value" => $appDeploymentValues["libraryPrependPathValue"][ $index]
-											));
-				$appDeploymentValues["libPrependPaths"][] = $envPath;
-			}
-		}
-
-		if( isset( $appDeploymentValues["libraryAppendPathName"] )) 
-		{
-			$libAppendPathNames = array_unique( array_filter( $appDeploymentValues["libraryAppendPathName"],"trim" ));
-			foreach( $libAppendPathNames as $index => $appendName)
-			{
-				$envPath = new SetEnvPaths(array(
-												"name" => $appendName,
-												"value" => $appDeploymentValues["libraryAppendPathValue"][ $index]
-											));
-				$appDeploymentValues["libAppendPaths"][] = $envPath;
-			}
-		}
-
-		if( isset( $appDeploymentValues["environmentName"] )) 
-		{
-			$environmentNames = array_unique( array_filter( $appDeploymentValues["environmentName"], "trim"));
-			foreach( $environmentNames as $index => $envName)
-			{
-				$envPath = new SetEnvPaths(array(
-												"name" => $envName,
-												"value" => $appDeploymentValues["environmentValue"][$index]
-											));
-				$appDeploymentValues["setEnvironment"][] = $envPath;
-			}
-		}
-		
-		if( isset( $appDeploymentValues["preJobCommand"] )) 
-		{
-			$appDeploymentValues["preJobCommands"] = array_unique( array_filter( $appDeploymentValues["preJobCommand"], "trim"));
-		}
-
-		if( isset( $appDeploymentValues["postJobCommand"] )) 
-		{
-			$appDeploymentValues["postJobCommands"] = array_unique( array_filter( $appDeploymentValues["postJobCommand"], "trim"));
-		}
-
-		//var_dump( $appDeploymentValues); exit;
-		$appDeployment = new ApplicationDeploymentDescription(  $appDeploymentValues);
-		if( $update)
-            Airavata::updateApplicationDeployment( $inputs["app-deployment-id"], $appDeployment);
-		else
-			$appDeploymentId = Airavata::registerApplicationDeployment( Session::get("gateway_id"), $appDeployment);
-
-		return;
-
-	}
-
-	public static function deleteAppDeployment( $appDeploymentId )
-	{
-		return Airavata::deleteApplicationDeployment( $appDeploymentId);
-	}
-
-	public static function getAllModules(){
-		return Airavata::getAllAppModules( Session::get("gateway_id"));
-	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2fbd9289/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 308bcdb..688c1de 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -3,433 +3,481 @@
 
 //Airavata classes - loaded from app/libraries/Airavata
 //Compute Resource classes
+use Airavata\Model\AppCatalog\ComputeResource\BatchQueue;
+use Airavata\Model\AppCatalog\ComputeResource\ComputeResourceDescription;
+use Airavata\Model\AppCatalog\ComputeResource\DataMovementProtocol;
 use Airavata\Model\AppCatalog\ComputeResource\FileSystems;
+use Airavata\Model\AppCatalog\ComputeResource\GridFTPDataMovement;
+use Airavata\Model\AppCatalog\ComputeResource\JobManagerCommand;
 use Airavata\Model\AppCatalog\ComputeResource\JobSubmissionProtocol;
-use Airavata\Model\AppCatalog\ComputeResource\SecurityProtocol;
+use Airavata\Model\AppCatalog\ComputeResource\LOCALDataMovement;
+use Airavata\Model\AppCatalog\ComputeResource\LOCALSubmission;
+use Airavata\Model\AppCatalog\ComputeResource\MonitorMode;
 use Airavata\Model\AppCatalog\ComputeResource\ResourceJobManager;
 use Airavata\Model\AppCatalog\ComputeResource\ResourceJobManagerType;
-use Airavata\Model\AppCatalog\ComputeResource\JobManagerCommand;
-use Airavata\Model\AppCatalog\ComputeResource\DataMovementProtocol;
-use Airavata\Model\AppCatalog\ComputeResource\ComputeResourceDescription;
-use Airavata\Model\AppCatalog\ComputeResource\SSHJobSubmission;
-use Airavata\Model\AppCatalog\ComputeResource\LOCALSubmission;
-use Airavata\Model\AppCatalog\ComputeResource\UnicoreJobSubmission;
-use Airavata\Model\AppCatalog\ComputeResource\BatchQueue;
 use Airavata\Model\AppCatalog\ComputeResource\SCPDataMovement;
-use Airavata\Model\AppCatalog\ComputeResource\GridFTPDataMovement;
-use Airavata\Model\AppCatalog\ComputeResource\LOCALDataMovement;
+use Airavata\Model\AppCatalog\ComputeResource\SecurityProtocol;
+use Airavata\Model\AppCatalog\ComputeResource\SSHJobSubmission;
 use Airavata\Model\AppCatalog\ComputeResource\UnicoreDataMovement;
-use Airavata\Model\AppCatalog\ComputeResource\MonitorMode;
-
-//Gateway Classes
-use Airavata\Model\AppCatalog\GatewayProfile\GatewayResourceProfile;
+use Airavata\Model\AppCatalog\ComputeResource\UnicoreJobSubmission;
 use Airavata\Model\AppCatalog\GatewayProfile\ComputeResourcePreference;
+use Airavata\Model\AppCatalog\GatewayProfile\GatewayResourceProfile;
 
+//Gateway Classes
 
 
-
-class CRUtilities{
-/**
- * Basic utility functions
- */
+class CRUtilities
+{
+    /**
+     * Basic utility functions
+     */
 
 //define('ROOT_DIR', __DIR__);
 
-/**
- * Define configuration constants
- */
-public static function register_or_update_compute_resource( $computeDescription, $update = false)
-{
-    if( $update)
+    /**
+     * Define configuration constants
+     */
+    public static function register_or_update_compute_resource($computeDescription, $update = false)
     {
-        $computeResourceId = $computeDescription->computeResourceId;
-
-        if( Airavata::updateComputeResource( $computeResourceId, $computeDescription) )
-        {
-            $computeResource = Airavata::getComputeResource( $computeResourceId);
-            return $computeResource;
+        if ($update) {
+            $computeResourceId = $computeDescription->computeResourceId;
+
+            if (Airavata::updateComputeResource($computeResourceId, $computeDescription)) {
+                $computeResource = Airavata::getComputeResource($computeResourceId);
+                return $computeResource;
+            } else
+                print_r("Something went wrong while updating!");
+            exit;
+        } else {
+            /*
+            $fileSystems = new FileSystems();
+            foreach( $fileSystems as $fileSystem)
+                $computeDescription["fileSystems"][$fileSystem] = "";
+            */
+            $cd = new ComputeResourceDescription($computeDescription);
+            $computeResourceId = Airavata::registerComputeResource($cd);
         }
-        else
-            print_r( "Something went wrong while updating!"); exit;
+
+        $computeResource = Airavata::getComputeResource($computeResourceId);
+        return $computeResource;
+
     }
-    else
+
+    /*
+     * Getting data for Compute resource inputs
+    */
+
+    public static function getEditCRData()
     {
-        /*
-        $fileSystems = new FileSystems();
-        foreach( $fileSystems as $fileSystem)
-            $computeDescription["fileSystems"][$fileSystem] = "";
-        */
-        $cd = new ComputeResourceDescription( $computeDescription);
-        $computeResourceId = Airavata::registerComputeResource( $cd);
+        $files = new FileSystems();
+        $jsp = new JobSubmissionProtocol();
+        $rjmt = new ResourceJobManagerType();
+        $sp = new SecurityProtocol();
+        $dmp = new DataMovementProtocol();
+        $jmc = new JobManagerCommand();
+        $mm = new MonitorMode();
+        return array(
+            "fileSystemsObject" => $files,
+            "fileSystems" => $files::$__names,
+            "jobSubmissionProtocolsObject" => $jsp,
+            "jobSubmissionProtocols" => $jsp::$__names,
+            "resourceJobManagerTypesObject" => $rjmt,
+            "resourceJobManagerTypes" => $rjmt::$__names,
+            "securityProtocolsObject" => $sp,
+            "securityProtocols" => $sp::$__names,
+            "dataMovementProtocolsObject" => $dmp,
+            "dataMovementProtocols" => $dmp::$__names,
+            "jobManagerCommands" => $jmc::$__names,
+            "monitorModes" => $mm::$__names
+        );
     }
 
-    $computeResource = Airavata::getComputeResource( $computeResourceId);
-    return $computeResource;
 
-}
+    public static function createQueueObject($queue)
+    {
+        $queueObject = new BatchQueue($queue);
+        return $queueObject;
+    }
 
-/*
- * Getting data for Compute resource inputs 
-*/
-
-public static function getEditCRData(){
-    $files = new FileSystems();
-    $jsp = new JobSubmissionProtocol();
-    $rjmt = new ResourceJobManagerType();
-    $sp = new SecurityProtocol();
-    $dmp = new DataMovementProtocol();
-    $jmc = new JobManagerCommand();
-    $mm = new MonitorMode();
-    return array(
-                    "fileSystemsObject" => $files,
-                    "fileSystems" => $files::$__names,
-                    "jobSubmissionProtocolsObject" => $jsp,
-                    "jobSubmissionProtocols" => $jsp::$__names,
-                    "resourceJobManagerTypesObject" => $rjmt,
-                    "resourceJobManagerTypes" => $rjmt::$__names,
-                    "securityProtocolsObject" => $sp,
-                    "securityProtocols" => $sp::$__names,
-                    "dataMovementProtocolsObject" => $dmp,
-                    "dataMovementProtocols" => $dmp::$__names,
-                    "jobManagerCommands" => $jmc::$__names,
-                    "monitorModes" => $mm::$__names
-                );
-}
+    public static function deleteQueue($computeResourceId, $queueName)
+    {
+        Airavata::deleteBatchQueue($computeResourceId, $queueName);
+    }
 
 
-public static function createQueueObject( $queue){
-    $queueObject = new BatchQueue( $queue); 
-    return $queueObject;
-}
+    /*
+     * Creating Job Submission Interface.
+    */
 
-public static function deleteQueue( $computeResourceId, $queueName)
-{
-    Airavata::deleteBatchQueue( $computeResourceId, $queueName);
-}
+    public static function create_or_update_JSIObject($inputs, $update = false)
+    {
 
+        $computeResource = CRUtilities::get_compute_resource($inputs["crId"]);
 
-/*
- * Creating Job Submission Interface.
-*/
 
-public static function create_or_update_JSIObject( $inputs, $update = false){
+        $jsiId = null;
+        if (isset($inputs["jsiId"]))
+            $jsiId = $inputs["jsiId"];
 
-    $computeResource = Utilities::get_compute_resource(  $inputs["crId"]);
+        if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::LOCAL) {
 
+            //print_r( $jsiObject->resourceJobManager->resourceJobManagerId);
+            $resourceManager = new ResourceJobManager(array(
+                "resourceJobManagerType" => $inputs["resourceJobManagerType"],
+                "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
+                "jobManagerBinPath" => $inputs["jobManagerBinPath"],
+                "jobManagerCommands" => $inputs["jobManagerCommands"]
+            ));
 
-    $jsiId = null;
-    if( isset( $inputs["jsiId"]))
-        $jsiId = $inputs["jsiId"];
+            //$rmId = $jsiObject->resourceJobManager->resourceJobManagerId;
+            //$rm = $airavataclient->updateResourceJobManager($rmId, $resourceManager);
+            //print_r( $rm); exit;
+            $localJobSubmission = new LOCALSubmission(array(
+                    "resourceJobManager" => $resourceManager
+                )
+            );
 
-    if( $inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::LOCAL)
-    {
+            if ($update) //update Local JSP
+            {
+                $jsiObject = Airavata::getLocalJobSubmission($jsiId);
+                $localSub = Airavata::updateResourceJobManager($jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
+                //$localSub = $airavataclient->updateLocalSubmissionDetails( $jsiId, $localJobSubmission);
+            } else // create Local JSP
+            {
+                $localSub = Airavata::addLocalSubmissionDetails($computeResource->computeResourceId, 0, $localJobSubmission);
+                return $localSub;
+            }
 
-        //print_r( $jsiObject->resourceJobManager->resourceJobManagerId);
-        $resourceManager = new ResourceJobManager(array( 
-                                                    "resourceJobManagerType" => $inputs["resourceJobManagerType"],
-                                                    "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
-                                                    "jobManagerBinPath"      => $inputs["jobManagerBinPath"],
-                                                    "jobManagerCommands"     => $inputs["jobManagerCommands"]
-                                                    ));
-
-        //$rmId = $jsiObject->resourceJobManager->resourceJobManagerId;
-        //$rm = $airavataclient->updateResourceJobManager($rmId, $resourceManager);
-        //print_r( $rm); exit;
-        $localJobSubmission = new LOCALSubmission(  array(
-                                                            "resourceJobManager" => $resourceManager
-                                                        )
-                                                    );
-
-        if( $update) //update Local JSP
-        {
-            $jsiObject = Airavata::getLocalJobSubmission( $jsiId);
-            $localSub = Airavata::updateResourceJobManager(  $jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
-            //$localSub = $airavataclient->updateLocalSubmissionDetails( $jsiId, $localJobSubmission);
-        }
-        else        // create Local JSP
-        {
-            $localSub = Airavata::addLocalSubmissionDetails( $computeResource->computeResourceId, 0, $localJobSubmission);
-            return $localSub;
+        } else if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::SSH) /* SSH */ {
+            $resourceManager = new ResourceJobManager(array(
+                "resourceJobManagerType" => $inputs["resourceJobManagerType"],
+                "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
+                "jobManagerBinPath" => $inputs["jobManagerBinPath"],
+                "jobManagerCommands" => $inputs["jobManagerCommands"]
+            ));
+            $sshJobSubmission = new SSHJobSubmission(array
+                (
+                    "securityProtocol" => intval($inputs["securityProtocol"]),
+                    "resourceJobManager" => $resourceManager,
+                    "alternativeSSHHostName" => $inputs["alternativeSSHHostName"],
+                    "sshPort" => intval($inputs["sshPort"]),
+                    "monitorMode" => intval($inputs["monitorMode"])
+                )
+            );
+            //var_dump( $sshJobSubmission); exit;
+            if ($update) //update Local JSP
+            {
+                $jsiObject = Airavata::getSSHJobSubmission($jsiId);
+
+                //first update resource job manager
+                $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
+                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 = Airavata::getresourceJobManager($rmjId);
+                //var_dump( $jsiObject); exit;
+                //add updated resource job manager to ssh job submission object.
+                //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
+                $localSub = Airavata::updateSSHJobSubmissionDetails($jsiId, $jsiObject);
+            } else {
+                $sshSub = Airavata::addSSHJobSubmissionDetails($computeResource->computeResourceId, 0, $sshJobSubmission);
+            }
+            return;
+        } else if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::UNICORE) {
+            $unicoreJobSubmission = new UnicoreJobSubmission(array
+                (
+                    "securityProtocol" => intval($inputs["securityProtocol"]),
+                    "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]
+                )
+            );
+            if ($update) {
+                $jsiObject = Airavata::getUnicoreJobSubmission($jsiId);
+                $jsiObject->securityProtocol = intval($inputs["securityProtocol"]);
+                $jsiObject->unicoreEndPointURL = $inputs["unicoreEndPointURL"];
+
+                $unicoreSub = Airavata::updateUnicoreJobSubmissionDetails($jsiId, $jsiObject);
+            } else {
+                $unicoreSub = Airavata::addUNICOREJobSubmissionDetails($computeResource->computeResourceId, 0, $unicoreJobSubmission);
+            }
+        } else /* Globus does not work currently */ {
+            print_r("Whoops! We haven't coded for this Job Submission Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
         }
-        
     }
-    else if( $inputs["jobSubmissionProtocol"] ==  JobSubmissionProtocol::SSH) /* SSH */
+
+    /*
+     * Creating Data Movement Interface Object.
+    */
+    public static function create_or_update_DMIObject($inputs, $update = false)
     {
-        $resourceManager = new ResourceJobManager(array( 
-                                                    "resourceJobManagerType" => $inputs["resourceJobManagerType"],
-                                                    "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
-                                                    "jobManagerBinPath"      => $inputs["jobManagerBinPath"],
-                                                    "jobManagerCommands"     => $inputs["jobManagerCommands"]
-                                                    ));
-        $sshJobSubmission = new SSHJobSubmission( array
-                                                    (
-                                                        "securityProtocol" => intval( $inputs["securityProtocol"]),
-                                                        "resourceJobManager" => $resourceManager,
-                                                        "alternativeSSHHostName" => $inputs["alternativeSSHHostName"],
-                                                        "sshPort" => intval( $inputs["sshPort"] ),
-                                                        "monitorMode" => intval( $inputs["monitorMode"] )
-                                                    )
-                                                );
-        //var_dump( $sshJobSubmission); exit;
-        if( $update) //update Local JSP
-        {
-            $jsiObject = Airavata::getSSHJobSubmission( $jsiId);
-
-            //first update resource job manager
-            $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
-            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 = Airavata::getresourceJobManager( $rmjId);
-            //var_dump( $jsiObject); exit;
-            //add updated resource job manager to ssh job submission object.
-            //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
-            $localSub = Airavata::updateSSHJobSubmissionDetails( $jsiId, $jsiObject);
-        }
-        else
-        {
-            $sshSub = Airavata::addSSHJobSubmissionDetails( $computeResource->computeResourceId, 0, $sshJobSubmission);
+
+        $computeResource = CRUtilities::get_compute_resource($inputs["crId"]);
+        if ($inputs["dataMovementProtocol"] == DataMovementProtocol::LOCAL) /* LOCAL */ {
+            $localDataMovement = new 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.
+                Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
+        } else if ($inputs["dataMovementProtocol"] == DataMovementProtocol::SCP) /* SCP */ {
+            //var_dump( $inputs); exit;
+            $scpDataMovement = new SCPDataMovement(array(
+                    "securityProtocol" => intval($inputs["securityProtocol"]),
+                    "alternativeSCPHostName" => $inputs["alternativeSSHHostName"],
+                    "sshPort" => intval($inputs["sshPort"])
+                )
+
+            );
+
+            if ($update)
+                $scpdmp = Airavata::updateSCPDataMovementDetails($inputs["dmiId"], $scpDataMovement);
+            else
+                $scpdmp = Airavata::addSCPDataMovementDetails($computeResource->computeResourceId, 0, $scpDataMovement);
+        } else if ($inputs["dataMovementProtocol"] == DataMovementProtocol::GridFTP) /* GridFTP */ {
+            $gridFTPDataMovement = new GridFTPDataMovement(array(
+                "securityProtocol" => $inputs["securityProtocol"],
+                "gridFTPEndPoints" => $inputs["gridFTPEndPoints"]
+            ));
+            if ($update)
+                $gridftpdmp = Airavata::updateGridFTPDataMovementDetails($inputs["dmiId"], $gridFTPDataMovement);
+            else
+                $gridftpdmp = Airavata::addGridFTPDataMovementDetails($computeResource->computeResourceId, 0, $gridFTPDataMovement);
+        } else if ($inputs["dataMovementProtocol"] == DataMovementProtocol::UNICORE_STORAGE_SERVICE) /* Unicore Storage Service */ {
+            $unicoreDataMovement = new UnicoreDataMovement(array
+                (
+                    "securityProtocol" => intval($inputs["securityProtocol"]),
+                    "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]
+                )
+            );
+            if ($update)
+                $unicoredmp = Airavata::updateUnicoreDataMovementDetails($inputs["dmiId"], $unicoreDataMovement);
+            else
+                $unicoredmp = Airavata::addUnicoreDataMovementDetails($computeResource->computeResourceId, 0, $unicoreDataMovement);
+        } else /* other data movement protocols */ {
+            print_r("Whoops! We haven't coded for this Data Movement Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
         }
-        return;        
     }
-    else if( $inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::UNICORE)
+
+    public static function getAllCRObjects($onlyName = false)
     {
-        $unicoreJobSubmission  = new UnicoreJobSubmission( array
-                                                            (
-                                                                "securityProtocol" => intval( $inputs["securityProtocol"]),
-                                                                "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]
-                                                            )
-                                                        );
-        if( $update)
-        {
-            $jsiObject = Airavata::getUnicoreJobSubmission( $jsiId);
-            $jsiObject->securityProtocol = intval( $inputs["securityProtocol"] );
-            $jsiObject->unicoreEndPointURL = $inputs["unicoreEndPointURL"];
-
-            $unicoreSub = Airavata::updateUnicoreJobSubmissionDetails( $jsiId, $jsiObject);
-        }
-        else
-        {
-            $unicoreSub = Airavata::addUNICOREJobSubmissionDetails( $computeResource->computeResourceId, 0, $unicoreJobSubmission);
+        $crNames = Airavata::getAllComputeResourceNames();
+        if ($onlyName)
+            return $crNames;
+        else {
+            $crObjects = array();
+            foreach ($crNames as $id => $crName) {
+                $crObjects[] = Airavata::getComputeResource($id);
+            }
+            return $crObjects;
         }
-    }
-    else /* Globus does not work currently */
-    {
-        print_r( "Whoops! We haven't coded for this Job Submission Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
-    }
-}
 
-/*
- * Creating Data Movement Interface Object.
-*/
-public static function create_or_update_DMIObject( $inputs, $update = false){
+    }
 
-    $computeResource = Utilities::get_compute_resource(  $inputs["crId"] );
-    if( $inputs["dataMovementProtocol"] == DataMovementProtocol::LOCAL) /* LOCAL */
+    public static function getBrowseCRData()
     {
-        $localDataMovement = new 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.
-                Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
+        $appDeployments = Airavata::getAllApplicationDeployments(Session::get("gateway_id"));
+
+        return array('crObjects' => CRUtilities::getAllCRObjects(true),
+            'appDeployments' => $appDeployments
+        );
     }
-    else if( $inputs["dataMovementProtocol"] == DataMovementProtocol::SCP) /* SCP */
-    {
-        //var_dump( $inputs); exit;
-        $scpDataMovement = new SCPDataMovement( array(
-                                                "securityProtocol" => intval( $inputs["securityProtocol"] ),
-                                                "alternativeSCPHostName" => $inputs["alternativeSSHHostName"],
-                                                "sshPort" => intval( $inputs["sshPort"] )
-                                                )
-
-                                            );
-
-        if( $update)
-            $scpdmp = Airavata::updateSCPDataMovementDetails( $inputs["dmiId"], $scpDataMovement);
-        else
-            $scpdmp = Airavata::addSCPDataMovementDetails( $computeResource->computeResourceId, 0, $scpDataMovement);
-   }
-    else if( $inputs["dataMovementProtocol"] == DataMovementProtocol::GridFTP) /* GridFTP */
+
+    public static function getJobSubmissionDetails($jobSubmissionInterfaceId, $jsp)
     {
-        $gridFTPDataMovement = new GridFTPDataMovement( array(
-                "securityProtocol" => $inputs["securityProtocol"],
-                "gridFTPEndPoints" => $inputs["gridFTPEndPoints"]
-            ));
-        if( $update)
-            $gridftpdmp = Airavata::updateGridFTPDataMovementDetails( $inputs["dmiId"], $gridFTPDataMovement);
-        else
-            $gridftpdmp = Airavata::addGridFTPDataMovementDetails( $computeResource->computeResourceId, 0, $gridFTPDataMovement);
+        //jsp = job submission protocol type
+        if ($jsp == JobSubmissionProtocol::LOCAL)
+            return Airavata::getLocalJobSubmission($jobSubmissionInterfaceId);
+        else if ($jsp == JobSubmissionProtocol::SSH)
+            return Airavata::getSSHJobSubmission($jobSubmissionInterfaceId);
+        else if ($jsp == JobSubmissionProtocol::UNICORE)
+            return Airavata::getUnicoreJobSubmission($jobSubmissionInterfaceId);
+        else if ($jsp == JobSubmissionProtocol::CLOUD)
+            return Airavata::getCloudJobSubmission($jobSubmissionInterfaceId);
+
+        //globus get function not present ??
     }
-    else if( $inputs["dataMovementProtocol"] == DataMovementProtocol::UNICORE_STORAGE_SERVICE) /* Unicore Storage Service */
+
+    public static function getDataMovementDetails($dataMovementInterfaceId, $dmi)
     {
-        $unicoreDataMovement  = new UnicoreDataMovement( array
-                                                            (
-                                                                "securityProtocol" => intval( $inputs["securityProtocol"]),
-                                                                "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]
-                                                            )
-                                                        );
-        if( $update)
-            $unicoredmp = Airavata::updateUnicoreDataMovementDetails( $inputs["dmiId"], $unicoreDataMovement);
-        else
-            $unicoredmp = Airavata::addUnicoreDataMovementDetails( $computeResource->computeResourceId, 0, $unicoreDataMovement);
+        //jsp = job submission protocol type
+        if ($dmi == DataMovementProtocol::LOCAL)
+            return Airavata::getLocalDataMovement($dataMovementInterfaceId);
+        else if ($dmi == DataMovementProtocol::SCP)
+            return Airavata::getSCPDataMovement($dataMovementInterfaceId);
+        else if ($dmi == DataMovementProtocol::GridFTP)
+            return Airavata::getGridFTPDataMovement($dataMovementInterfaceId);
+        else if ($dmi == DataMovementProtocol::UNICORE_STORAGE_SERVICE)
+            return Airavata::getUnicoreDataMovement($dataMovementInterfaceId);
+        /*
+        else if( $dmi == JobSubmissionProtocol::CLOUD)
+            return $airavataclient->getCloudJobSubmission( $dataMovementInterfaceId);
+        */
+
+        //globus get function not present ??
     }
-    else /* other data movement protocols */
+
+    public static function deleteActions($inputs)
     {
-        print_r( "Whoops! We haven't coded for this Data Movement Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
+        if (isset($inputs["jsiId"]))
+            if (Airavata::deleteJobSubmissionInterface($inputs["crId"], $inputs["jsiId"]))
+                return 1;
+            else
+                return 0;
+        else if (isset($inputs["dmiId"]))
+            if (Airavata::deleteDataMovementInterface($inputs["crId"], $inputs["dmiId"]))
+                return 1;
+            else
+                return 0;
+        elseif (isset($inputs["del-crId"]))
+            if (Airavata::deleteComputeResource($inputs["del-crId"]))
+                return 1;
+            else
+                return 0;
     }
-}
 
-public static function getAllCRObjects( $onlyName = false){
-    $crNames = Airavata::getAllComputeResourceNames();
-    if( $onlyName)
-        return $crNames;
-    else
+    public static function create_or_update_gateway_profile($inputs, $update = false)
     {
-        $crObjects = array();
-        foreach( $crNames as $id => $crName)
-        {
-            $crObjects[] = Airavata::getComputeResource( $id);
-        }
-        return $crObjects;
-    }
 
-}
+        $computeResourcePreferences = array();
+        if (isset($input["crPreferences"]))
+            $computeResourcePreferences = $input["crPreferences"];
+
+        $gatewayProfile = new GatewayResourceProfile(array(
+                "gatewayName" => $inputs["gatewayName"],
+                "gatewayDescription" => $inputs["gatewayDescription"],
+                "computeResourcePreferences" => $computeResourcePreferences
+            )
+        );
+
+        if ($update) {
+            $gatewayProfile = new GatewayResourceProfile(array(
+                    "gatewayName" => $inputs["gatewayName"],
+                    "gatewayDescription" => $inputs["gatewayDescription"]
+                )
+            );
+            $gatewayProfileId = Airavata::updateGatewayResourceProfile($inputs["edit-gpId"], $gatewayProfile);
+        } else
+            $gatewayProfileId = Airavata::registerGatewayResourceProfile($gatewayProfile);
+    }
 
-public static function getBrowseCRData(){
-	$appDeployments = Airavata::getAllApplicationDeployments( Session::get("gateway_id"));
+    public static function getAllGatewayProfilesData()
+    {
 
-    return array( 'crObjects' => CRUtilities::getAllCRObjects(true),
-    			  'appDeployments' => $appDeployments 
-    			);
-}
+        if (Session::has("scigap_admin"))
+            $gateways = Airavata::getAllGateways();
+        else {
+            $gateways[0] = Airavata::getGateway(Session::get("gateway_id"));
+        }
 
-public static function getJobSubmissionDetails( $jobSubmissionInterfaceId, $jsp){
-    //jsp = job submission protocol type
-    if( $jsp == JobSubmissionProtocol::LOCAL)
-        return Airavata::getLocalJobSubmission( $jobSubmissionInterfaceId);
-    else if( $jsp == JobSubmissionProtocol::SSH)
-        return Airavata::getSSHJobSubmission( $jobSubmissionInterfaceId);
-    else if( $jsp == JobSubmissionProtocol::UNICORE)
-        return Airavata::getUnicoreJobSubmission( $jobSubmissionInterfaceId);
-    else if( $jsp == JobSubmissionProtocol::CLOUD)
-        return Airavata::getCloudJobSubmission( $jobSubmissionInterfaceId);
-
-    //globus get function not present ??	
-}
+        $gatewayProfiles = Airavata::getAllGatewayComputeResources();
+        //$gatewayProfileIds = array("GatewayTest3_57726e98-313f-4e7c-87a5-18e69928afb5", "GatewayTest4_4fd9fb28-4ced-4149-bdbd-1f276077dad8");
+        foreach ($gateways as $key => $gw) {
+            $gateways[$key]->profile = array();
+            foreach ((array)$gatewayProfiles as $index => $gp) {
+
+                if ($gw->gatewayId == $gp->gatewayID) {
+                    foreach ((array)$gp->computeResourcePreferences as $i => $crp) {
+                        $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = Airavata::getComputeResource($crp->computeResourceId);
+                    }
+                    $gateways[$key]->profile = $gatewayProfiles[$index];
+                }
+            }
+        }
+        //var_dump( $gatewayProfiles[0]->computeResourcePreferences[0]->crDetails); exit;
 
-public static function getDataMovementDetails( $dataMovementInterfaceId, $dmi){
-    //jsp = job submission protocol type
-    if( $dmi == DataMovementProtocol::LOCAL)
-        return Airavata::getLocalDataMovement( $dataMovementInterfaceId);
-    else if( $dmi == DataMovementProtocol::SCP)
-        return Airavata::getSCPDataMovement( $dataMovementInterfaceId);
-    else if( $dmi == DataMovementProtocol::GridFTP)
-        return Airavata::getGridFTPDataMovement( $dataMovementInterfaceId);
-    else if( $dmi == DataMovementProtocol::UNICORE_STORAGE_SERVICE)
-        return Airavata::getUnicoreDataMovement( $dataMovementInterfaceId);
-    /*
-    else if( $dmi == JobSubmissionProtocol::CLOUD)
-        return $airavataclient->getCloudJobSubmission( $dataMovementInterfaceId);
-    */
+        return $gateways;
+    }
 
-    //globus get function not present ??
-}
+    public static function add_or_update_CRP($inputs)
+    {
+        $computeResourcePreferences = new computeResourcePreference($inputs);
 
-public static function deleteActions( $inputs){
-    if( isset( $inputs["jsiId"]) )
-        if( Airavata::deleteJobSubmissionInterface( $inputs["crId"], $inputs["jsiId"]) )
-            return 1;
-        else
-            return 0;
-    else if( isset( $inputs["dmiId"]) )
-        if( Airavata::deleteDataMovementInterface( $inputs["crId"], $inputs["dmiId"]) )
-            return 1;
-        else 
-            return 0;
-    elseif( isset( $inputs["del-crId"]))
-    	if( Airavata::deleteComputeResource( $inputs["del-crId"] ) )
-    		return 1;
-    	else
-    		return 0;
-}
+        //var_dump( $inputs); exit;
+        return Airavata::addGatewayComputeResourcePreference($inputs["gatewayId"], $inputs["computeResourceId"], $computeResourcePreferences);
 
-public static function create_or_update_gateway_profile( $inputs, $update = false){
-
-    $computeResourcePreferences = array();
-    if( isset( $input["crPreferences"]) )
-        $computeResourcePreferences = $input["crPreferences"];
-
-    $gatewayProfile = new GatewayResourceProfile( array(
-                                                        "gatewayName" => $inputs["gatewayName"],
-                                                        "gatewayDescription" => $inputs["gatewayDescription"],
-                                                        "computeResourcePreferences" =>  $computeResourcePreferences
-                                                        )
-                                                );
-
-    if( $update){
-        $gatewayProfile = new GatewayResourceProfile( array(
-                                                        "gatewayName" => $inputs["gatewayName"],
-                                                        "gatewayDescription" => $inputs["gatewayDescription"]
-                                                        )
-                                                );
-        $gatewayProfileId = Airavata::updateGatewayResourceProfile( $inputs["edit-gpId"], $gatewayProfile);
     }
-    else
-        $gatewayProfileId = Airavata::registerGatewayResourceProfile( $gatewayProfile);
-}
 
-public static function getAllGatewayProfilesData(){
-
-    if( Session::has("scigap_admin") )
-        $gateways = Airavata::getAllGateways();
-    else
+    public static function deleteGP($gpId)
     {
-        $gateways[0] = Airavata::getGateway( Session::get("gateway_id") );
+        return Airavata::deleteGatewayResourceProfile($gpId);
     }
 
-    $gatewayProfiles = Airavata::getAllGatewayComputeResources();
-    //$gatewayProfileIds = array("GatewayTest3_57726e98-313f-4e7c-87a5-18e69928afb5", "GatewayTest4_4fd9fb28-4ced-4149-bdbd-1f276077dad8");
-    foreach( $gateways as $key => $gw)
+    public static function deleteCR($inputs)
     {
-        $gateways[$key]->profile = array();
-        foreach( (array)$gatewayProfiles as $index => $gp)
-        {
+        return Airavata::deleteGatewayComputeResourcePreference($inputs["gpId"], $inputs["rem-crId"]);
+    }
 
-            if( $gw->gatewayId == $gp->gatewayID)
-            {
-                foreach( (array)$gp->computeResourcePreferences as $i => $crp)
-                {
-                    $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = Airavata::getComputeResource( $crp->computeResourceId);
-                }
-                $gateways[$key]->profile = $gatewayProfiles[$index];
-            }
+    /**
+     * Get the ComputeResourceDescription with the given ID
+     * @param $id
+     * @return null
+     */
+    public static function get_compute_resource($id)
+    {
+        $computeResource = null;
+
+        try {
+            $computeResource = Airavata::getComputeResource($id);
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the compute resource.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the compute resource.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('<p>There was a problem getting the compute resource.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
         }
+
+        return $computeResource;
     }
-    //var_dump( $gatewayProfiles[0]->computeResourcePreferences[0]->crDetails); exit;
-    
-    return $gateways;
-}
 
-public static function add_or_update_CRP( $inputs){
-    $computeResourcePreferences = new computeResourcePreference( $inputs);
 
-    //var_dump( $inputs); exit;
-    return Airavata::addGatewayComputeResourcePreference( $inputs["gatewayId"], $inputs["computeResourceId"], $computeResourcePreferences);
+    /**
+     * 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)
+    {
+        return CRUtilities::get_available_app_interface_compute_resources($applicationId);
+    }
 
-}
+    /**
+     * 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)
+    {
+        $computeResources = null;
+
+        try {
+            $computeResources = Airavata::getAvailableAppInterfaceComputeResources($id);
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('<p>There was a problem getting compute resources.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>There was a problem getting compute resources.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('<p>There was a problem getting compute resources.
+            Please try again later or submit a bug report using the link in the Help menu.</p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+        }
 
-public static function deleteGP( $gpId){
-    return Airavata::deleteGatewayResourceProfile( $gpId);
-}
+        return $computeResources;
+    }
 
-public static function deleteCR( $inputs){
-    return Airavata::deleteGatewayComputeResourcePreference( $inputs["gpId"], $inputs["rem-crId"]);
 }
 
-}
 ?>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2fbd9289/app/libraries/CommonUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php
new file mode 100644
index 0000000..7b7ee09
--- /dev/null
+++ b/app/libraries/CommonUtilities.php
@@ -0,0 +1,246 @@
+<?php
+
+class CommonUtilities
+{
+
+    /**
+     * Print success message
+     * @param $message
+     */
+    public static function print_success_message($message)
+    {
+        echo '<div class="alert alert-success">' . $message . '</div>';
+    }
+
+    /**
+     * Print warning message
+     * @param $message
+     */
+    public static function print_warning_message($message)
+    {
+        echo '<div class="alert alert-warning">' . $message . '</div>';
+    }
+
+    /**
+     * Print error message
+     * @param $message
+     */
+    public static function print_error_message($message)
+    {
+        echo '<div class="alert alert-danger">' . $message . '</div>';
+    }
+
+    /**
+     * Print info message
+     * @param $message
+     */
+    public static function print_info_message($message)
+    {
+        echo '<div class="alert alert-info">' . $message . '</div>';
+    }
+
+    /**
+     * Redirect to the given url
+     * @param $url
+     */
+    public static function redirect($url)
+    {
+        echo '<meta http-equiv="Refresh" content="0; URL=' . $url . '">';
+    }
+
+    /**
+     * Return true if the form has been submitted
+     * @return bool
+     */
+    public static function form_submitted()
+    {
+        return isset($_POST['Submit']);
+    }
+
+    /**
+     * 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 (CommonUtilities::id_in_session()) {
+            return true;
+        } else {
+            CommonUtilities::print_error_message('User is not logged in!');
+            return false;
+        }
+    }
+
+    /**
+     * 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', '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['Help'] = array
+            (
+                array('label' => 'Report Issue', 'url' => '#', "nav-active", ""),
+                array('label' => 'Request Feature', 'url' => '#', "nav-active", "")
+            );
+        }
+
+        echo '<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
+            <div class="container-fluid">
+                <!-- Brand and toggle get grouped for better mobile display -->
+                <div class="navbar-header">
+                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+                       <span class="sr-only">Toggle navigation</span>
+                       <span class="icon-bar"></span>
+                       <span class="icon-bar"></span>
+                       <span class="icon-bar"></span>
+                    </button>
+                    <a class="navbar-brand" href="' . URL::to('home') . '" title="PHP Gateway with Airavata">PGA</a>
+                </div>
+
+                <!-- Collect the nav links, forms, and other content for toggling -->
+                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+                    <ul class="nav navbar-nav">';
+
+
+        foreach ($menus as $label => $options) {
+            Session::has('loggedin') ? $disabled = '' : $disabled = ' class="disabled"';
+
+            $active = "";
+            if (Session::has("nav-active") && isset($options[0]['nav-active'])) {
+                if ($options[0]['nav-active'] == Session::get("nav-active"))
+                    $active = " active ";
+            }
+            echo '<li class="dropdown ' . $active . '">
+                <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $label . '<span class="caret"></span></a>
+                <ul class="dropdown-menu" role="menu">';
+
+            if (Session::has('loggedin')) {
+                foreach ($options as $option) {
+                    $id = strtolower(str_replace(' ', '-', $option['label']));
+
+                    echo '<li' . $disabled . '><a href="' . $option['url'] . '" id=' . $id . '>' . $option['label'] . '</a></li>';
+                }
+            }
+
+            echo '</ul>
+        </li>';
+        }
+
+
+        echo '</ul>
+
+        <ul class="nav navbar-nav navbar-right">';
+
+        // right-aligned content
+
+        if (Session::has('loggedin')) {
+            $active = "";
+            if (Session::has("nav-active")) {
+                if ("user-console" == Session::get("nav-active"))
+                    $active = " active ";
+            }
+            if (Session::has("admin"))
+                echo '<li><a href="' . URL::to("/") . '/admin/dashboard"><span class="glyphicon glyphicon-user"></span> Dashboard</a></li>';
+            else
+                echo '<li><a href="' . URL::to("/") . '/user/profile"><span class="glyphicon glyphicon-user"></span> Profile</a></li>';
+
+            echo '<li class="dropdown ' . $active . '">
+
+                <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . Session::get("username") . ' <span class="caret"></span></a>';
+            echo '<ul class="dropdown-menu" role="menu">';
+
+            echo '<li><a href="' . URL::to('/') . '/logout"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>';
+            echo '</ul></li></ul>';
+        } else {
+            echo '<li><a href="' . URL::to('/') . '/create"><span class="glyphicon glyphicon-user"></span> Create account</a></li>';
+            echo '<li><a href="' . URL::to('/') . '/login"><span class="glyphicon glyphicon-log-in"></span> Log in</a></li>';
+            echo '</ul>';
+
+        }
+
+        echo '</div></div></nav>';
+    }
+
+    /**
+     * 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!');
+        }
+    }
+}
+