fixing bug in experiment cloning

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

Branch: refs/heads/master
Commit: f10b730ac53df6007cedc142c053139d86cf5d8b
Parents: 6838d6a
Author: scnakandala <[email protected]>
Authored: Wed Jul 6 14:36:20 2016 -0400
Committer: scnakandala <[email protected]>
Committed: Wed Jul 6 14:36:20 2016 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 67 +++++++++++++++---------------
 1 file changed, 33 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f10b730a/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php 
b/app/libraries/ExperimentUtilities.php
index 1cacbf6..20d634c 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -328,9 +328,7 @@ class ExperimentUtilities
         $experimentAssemblySuccessful = true;
         $newExperimentInputs = array();
 
-        if (ExperimentUtilities::$experimentPath == null) {
-            ExperimentUtilities::create_experiment_folder_path($projectId, 
$experimentName);
-        }
+        ExperimentUtilities::create_experiment_folder_path($projectId, 
$experimentName);
 //        if (sizeof($_FILES) > 0) {
 //            if (ExperimentUtilities::file_upload_successful()) {
 //                // construct unique path
@@ -441,41 +439,44 @@ class ExperimentUtilities
         if($_FILES['optInputFiles']){
             $uriList = "";
             for($i=0; $i < count($_FILES['optInputFiles']['name']); $i++){
-                $filePath = ExperimentUtilities::$experimentPath . 
$_FILES['optInputFiles']['name'][$i];
+                if(!empty($_FILES['optInputFiles']['name'][$i])){
+                    $filePath = ExperimentUtilities::$experimentPath . 
$_FILES['optInputFiles']['name'][$i];
 
-                // check if file already exists
-                if (is_file($filePath)) {
-                    unlink($filePath);
+                    // check if file already exists
+                    if (is_file($filePath)) {
+                        unlink($filePath);
 
-                    CommonUtilities::print_warning_message('Uploaded file 
already exists! Overwriting...');
-                }
+                        CommonUtilities::print_warning_message('Uploaded file 
already exists! Overwriting...');
+                    }
 
-                $moveFile = 
move_uploaded_file($_FILES['optInputFiles']['tmp_name'][$i], $filePath);
+                    $moveFile = 
move_uploaded_file($_FILES['optInputFiles']['tmp_name'][$i], $filePath);
 
-                if (!$moveFile) {
-                    CommonUtilities::print_error_message('<p>Error moving 
uploaded file ' . $_FILES['optInputFiles']['name'][$i] . '!
+                    if (!$moveFile) {
+                        CommonUtilities::print_error_message('<p>Error moving 
uploaded file ' . $_FILES['optInputFiles']['name'][$i] . '!
                         Please try again later or report a bug using the link 
in the Help menu.</p>');
-                    $experimentAssemblySuccessful = false;
-                }
+                        $experimentAssemblySuccessful = false;
+                    }
 
-                $dataProductModel = new DataProductModel();
-                $dataProductModel->gatewayId = 
Config::get("pga_config.airavata")["gateway-id"];
-                $dataProductModel->ownerName = Session::get("username");
-                $dataProductModel->productName = basename($filePath);
-                $dataProductModel->dataProductType = DataProductType::FILE;
-
-                $dataReplicationModel = new DataReplicaLocationModel();
-                $dataReplicationModel->storageResourceId = 
Config::get("pga_config.airavata")["gateway-data-store-resource-id"];
-                $dataReplicationModel->replicaName = basename($filePath) . " 
gateway data store copy";
-                $dataReplicationModel->replicaLocationCategory = 
ReplicaLocationCategory::GATEWAY_DATA_STORE;
-                $dataReplicationModel->replicaPersistentType = 
ReplicaPersistentType::TRANSIENT;
-                $hostName = $_SERVER['SERVER_NAME'];
-                $dataReplicationModel->filePath = "file://" . $hostName . ":" 
. $filePath;
-
-                $dataProductModel->replicaLocations[] = $dataReplicationModel;
-                $uri = 
Airavata::registerDataProduct(Session::get('authz-token'), $dataProductModel);
-                $uriList = $uriList . $uri . ",";
+                    $dataProductModel = new DataProductModel();
+                    $dataProductModel->gatewayId = 
Config::get("pga_config.airavata")["gateway-id"];
+                    $dataProductModel->ownerName = Session::get("username");
+                    $dataProductModel->productName = basename($filePath);
+                    $dataProductModel->dataProductType = DataProductType::FILE;
+
+                    $dataReplicationModel = new DataReplicaLocationModel();
+                    $dataReplicationModel->storageResourceId = 
Config::get("pga_config.airavata")["gateway-data-store-resource-id"];
+                    $dataReplicationModel->replicaName = basename($filePath) . 
" gateway data store copy";
+                    $dataReplicationModel->replicaLocationCategory = 
ReplicaLocationCategory::GATEWAY_DATA_STORE;
+                    $dataReplicationModel->replicaPersistentType = 
ReplicaPersistentType::TRANSIENT;
+                    $hostName = $_SERVER['SERVER_NAME'];
+                    $dataReplicationModel->filePath = "file://" . $hostName . 
":" . $filePath;
+
+                    $dataProductModel->replicaLocations[] = 
$dataReplicationModel;
+                    $uri = 
Airavata::registerDataProduct(Session::get('authz-token'), $dataProductModel);
+                    $uriList = $uriList . $uri . ",";
+                }
             }
+
             $uriList = substr($uriList,0, strlen($uriList) - 1);
             $optInput = new InputDataObjectType();
             $optInput->name = "Optional-File-Input-List";
@@ -589,9 +590,7 @@ class ExperimentUtilities
             $experiment = Airavata::getExperiment(Session::get('authz-token'), 
$cloneId);
             $experimentInputs = $experiment->experimentInputs;
 
-            if (ExperimentUtilities::$experimentPath == null) {
-                
ExperimentUtilities::create_experiment_folder_path($experiment->projectId, 
$experiment->experimentName);
-            }
+            
ExperimentUtilities::create_experiment_folder_path($experiment->projectId, 
$experiment->experimentName);
 
             $hostName = $_SERVER['SERVER_NAME'];
 

Reply via email to