Repository: airavata-php-gateway Updated Branches: refs/heads/develop 1a02de62b -> cc4ba94fe
fixing experiment clone issue Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/cc4ba94f Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/cc4ba94f Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/cc4ba94f Branch: refs/heads/develop Commit: cc4ba94fe2c891a0ea38f0976e6ce34595279294 Parents: 1a02de6 Author: scnakandala <[email protected]> Authored: Wed Mar 23 17:12:48 2016 -0400 Committer: scnakandala <[email protected]> Committed: Wed Mar 23 17:12:48 2016 -0400 ---------------------------------------------------------------------- app/libraries/ExperimentUtilities.php | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cc4ba94f/app/libraries/ExperimentUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php index fd33150..74b1309 100644 --- a/app/libraries/ExperimentUtilities.php +++ b/app/libraries/ExperimentUtilities.php @@ -307,7 +307,7 @@ class ExperimentUtilities $dataProductModel->gatewayId = Config::get("pga_config.airavata")["gateway-id"]; $dataProductModel->ownerName = Session::get("username"); $dataProductModel->productName = basename($filePath); - $logicalPath = str_replace(Config::get("pga_config.airavata")["experiment-data-absolute-path"],"", $filePath); + $logicalPath = str_replace(Config::get("pga_config.airavata")["experiment-data-absolute-path"] . "/" . Session::get('username'), "", $filePath); $dataProductModel->logicalPath = $logicalPath; $dataProductModel->dataProductType = DataProductType::FILE; @@ -432,12 +432,39 @@ class ExperimentUtilities if ($experimentInput->type == DataType::URI) { $currentInputPath = $experimentInput->value; $hostPathConstant = 'file://' . $hostName . ':'; + $dataProductModel = Airavata::getDataProduct($experimentInput->value); + $currentInputPath = ""; + foreach ($dataProductModel->replicaLocations as $rp) { + if($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE){ + $currentInputPath = $rp->filePath; + break; + } + } $currentInputPath = str_replace($hostPathConstant, '', $currentInputPath); $parts = explode('/', rtrim($currentInputPath, '/')); $fileName = array_pop($parts); $newInputPath = ExperimentUtilities::$experimentPath . $fileName; copy($currentInputPath, $newInputPath); - $experimentInput->value = $hostPathConstant . $newInputPath; + + $dataProductModel = new DataProductModel(); + $dataProductModel->gatewayId = Config::get("pga_config.airavata")["gateway-id"]; + $dataProductModel->ownerName = Session::get("username"); + $dataProductModel->productName = basename($newInputPath); + $logicalPath = str_replace(Config::get("pga_config.airavata")["experiment-data-absolute-path"] . "/" . Session::get('username'), "", $newInputPath); + $dataProductModel->logicalPath = $logicalPath; + $dataProductModel->dataProductType = DataProductType::FILE; + + $dataReplicationModel = new DataReplicaLocationModel(); + $dataReplicationModel->storageResourceId = Config::get("pga_config.airavata")["gateway-data-store-resource-id"]; + $dataReplicationModel->replicaName = basename($newInputPath) . "-gateway-datastore-copy"; + $dataReplicationModel->replicaLocationCategory = ReplicaLocationCategory::GATEWAY_DATA_STORE; + $dataReplicationModel->replicaPersistentType = ReplicaPersistentType::TRANSIENT; + $hostName = $_SERVER['SERVER_NAME']; + $dataReplicationModel->filePath = "file://" . $hostName . $newInputPath; + + $dataProductModel->replicaLocations[] = $dataReplicationModel; + $uri = Airavata::registerDataProduct(Session::get('authz-token'), $dataProductModel); + $experimentInput->value = $uri; } } $experiment->userConfigurationData->experimentDataDir = ExperimentUtilities::$relativeExperimentDataDir; @@ -468,6 +495,7 @@ class ExperimentUtilities /** * Cancel the experiment with the given ID + * Cancel the experiment with the given ID * @param $expId */ public static function cancel_experiment($expId)
