airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [35/40] airavata-php-gateway git commit: fixing cloning issue
Date Fri, 25 Mar 2016 20:49:20 GMT
fixing cloning 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/be798e60
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/be798e60
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/be798e60

Branch: refs/heads/master
Commit: be798e60d127a6c406c455c93fb2061f75df08c4
Parents: c17be85
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Fri Mar 25 14:01:05 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Fri Mar 25 14:01:05 2016 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 74 +++++++++++++++---------------
 1 file changed, 38 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/be798e60/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 9bb91c1..9ba0028 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -283,50 +283,52 @@ class ExperimentUtilities
                     }
                 }
             } elseif ($applicationInput->type == DataType::URI) {
-                $file = $_FILES[$applicationInput->name];
-
-                //
-                // move file to experiment data directory
-                //
-                if(!empty($applicationInput->value)){
-                    $filePath = ExperimentUtilities::$experimentPath . $applicationInput->value;
-                }else{
-                    $filePath = ExperimentUtilities::$experimentPath . $file['name'];
-                }
+                if ($_FILES[$applicationInput->name]['name']) {
+                    $file = $_FILES[$applicationInput->name];
+
+                    //
+                    // move file to experiment data directory
+                    //
+                    if (!empty($applicationInput->value)) {
+                        $filePath = ExperimentUtilities::$experimentPath . $applicationInput->value;
+                    } else {
+                        $filePath = ExperimentUtilities::$experimentPath . $file['name'];
+                    }
 
-                // 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($file['tmp_name'], $filePath);
+                    $moveFile = move_uploaded_file($file['tmp_name'], $filePath);
 
-                if (!$moveFile) {
-                    CommonUtilities::print_error_message('<p>Error moving uploaded
file ' . $file['name'] . '!
+                    if (!$moveFile) {
+                        CommonUtilities::print_error_message('<p>Error moving uploaded
file ' . $file['name'] . '!
                         Please try again later or report a bug using the link in the Help
menu.</p>');
-                    $experimentAssemblySuccessful = false;
-                }
+                        $experimentAssemblySuccessful = false;
+                    }
 
-                $experimentInput->type = $applicationInput->type;
+                    $experimentInput->type = $applicationInput->type;
                     $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->gatewayId = Config::get("pga_config.airavata")["gateway-id"];
+                    $dataProductModel->ownerName = Session::get("username");
+                    $dataProductModel->productName = basename($filePath);
+                    $dataProductModel->dataProductType = DataProductType::FILE;
 
-                $dataProductModel->replicaLocations[] = $dataReplicationModel;
-                $uri = Airavata::registerDataProduct(Session::get('authz-token'), $dataProductModel);
-                $experimentInput->value = $uri;
+                    $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);
+                    $experimentInput->value = $uri;
+                }
             } else {
                 CommonUtilities::print_error_message('I cannot accept this input type yet!');
             }


Mime
View raw message