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 2016/03/23 17:33:20 UTC
airavata-php-gateway git commit: refactoring the URI input setting
logic
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop 36d251ed8 -> 72a1cb7ed
refactoring the URI input setting logic
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/72a1cb7e
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/72a1cb7e
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/72a1cb7e
Branch: refs/heads/develop
Commit: 72a1cb7edce63c9c4d8db2b042f902740042f051
Parents: 36d251e
Author: scnakandala <su...@gmail.com>
Authored: Wed Mar 23 12:33:17 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Wed Mar 23 12:33:17 2016 -0400
----------------------------------------------------------------------
app/libraries/ExperimentUtilities.php | 87 +++++++++---------------------
1 file changed, 26 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/72a1cb7e/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index b3c4b8c..ea46ae8 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -229,8 +229,6 @@ class ExperimentUtilities
$experimentAssemblySuccessful = true;
$newExperimentInputs = array();
- //var_dump($_FILES);
-
if (sizeof($_FILES) > 0) {
if (ExperimentUtilities::file_upload_successful()) {
// construct unique path
@@ -248,21 +246,12 @@ class ExperimentUtilities
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;
+ $experimentInput = $applicationInput;
if (($applicationInput->type == DataType::STRING) ||
($applicationInput->type == DataType::INTEGER) ||
- ($applicationInput->type == DataType::FLOAT) ||
- ($applicationInput->type == DataType::URI && !empty($applicationInput->metaData)
- && json_decode($applicationInput->metaData)->location=="remote")
+ ($applicationInput->type == DataType::FLOAT)
) {
if (isset($_POST[$applicationInput->name]) && (trim($_POST[$applicationInput->name]) != '')) {
$experimentInput->value = $_POST[$applicationInput->name];
@@ -283,64 +272,40 @@ class ExperimentUtilities
}
}
} 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
- //
- if(!empty($applicationInput->value)){
- $filePath = ExperimentUtilities::$experimentPath . $applicationInput->value;
- }else{
- $filePath = ExperimentUtilities::$experimentPath . $file['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...');
- }
-
- $moveFile = move_uploaded_file($file['tmp_name'], $filePath);
-
- if ($moveFile) {
- CommonUtilities::print_success_message('Upload: ' . $file['name'] . '<br>' .
- 'Type: ' . $file['type'] . '<br>' .
- 'Size: ' . ($file['size'] / 1024) . ' kB');
- //<br>' .
- //'Stored in: ' . $experimentPath . $file['name']);
- } else {
- 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;
- }
- $hostName = $_SERVER['SERVER_NAME'];
- $experimentInput->value = 'file://' . $hostName . ':' . $filePath;
- $experimentInput->type = $applicationInput->type;
+ CommonUtilities::print_warning_message('Uploaded file already exists! Overwriting...');
+ }
- } else {
- $index = -1;
- for ($i = 0; $i < sizeof($experimentInputs); $i++) {
- if ($experimentInputs[$i]->name == $applicationInput->name) {
- $index = $i;
- }
- }
+ $moveFile = move_uploaded_file($file['tmp_name'], $filePath);
- if ($index >= 0) {
- $experimentInput->value = $experimentInputs[$index]->value;
- $experimentInput->type = $applicationInput->type;
- }
+ 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;
}
+ $hostName = $_SERVER['SERVER_NAME'];
+ $experimentInput->value = 'file://' . $hostName . ':' . $filePath;
+ $experimentInput->type = $applicationInput->type;
+
} else {
CommonUtilities::print_error_message('I cannot accept this input type yet!');
}
-
$newExperimentInputs[] = $experimentInput;
-
}
if ($experimentAssemblySuccessful) {