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/07/07 19:27:38 UTC
[34/50] [abbrv] airavata-php-gateway git commit: optional file upload
testing
optional file upload testing
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/ae6d78bb
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/ae6d78bb
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/ae6d78bb
Branch: refs/heads/master
Commit: ae6d78bb41d696b148e84f5c25ad3354b1226c54
Parents: c7798cc
Author: scnakandala <su...@gmail.com>
Authored: Tue Jul 5 17:33:50 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Tue Jul 5 17:33:50 2016 -0400
----------------------------------------------------------------------
app/libraries/Airavata/API/Airavata.php | 42 +++++-----
.../Airavata/Model/Application/Io/Types.php | 10 ++-
app/libraries/ExperimentUtilities.php | 87 ++++++++++++++++++--
app/views/experiment/create-complete.blade.php | 11 +++
app/views/partials/experiment-inputs.blade.php | 2 +-
5 files changed, 121 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ae6d78bb/app/libraries/Airavata/API/Airavata.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php
index 690b75b..cebfb90 100644
--- a/app/libraries/Airavata/API/Airavata.php
+++ b/app/libraries/Airavata/API/Airavata.php
@@ -508,27 +508,27 @@ interface AiravataIf {
*/
public function getUserProjects(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $limit, $offset);
/**
- * *
- * * Search User Projects
- * * Search and get all Projects for user by project description or/and project name with pagination.
- * * Results will be ordered based on creation time DESC.
- * *
- * * @param gatewayId
- * * The unique identifier of the gateway making the request.
- * *
- * * @param userName
- * * The identifier of the user.
- * *
- * * @param filters
- * * Map of multiple filter criteria. Currenlt search filters includes Project Name and Project Description
- * *
- * * @param limit
- * * The amount results to be fetched.
- * *
- * * @param offset
- * * The starting point of the results to be fetched.
- * *
- * *
+ *
+ * Search User Projects
+ * Search and get all Projects for user by project description or/and project name with pagination.
+ * Results will be ordered based on creation time DESC.
+ *
+ * @param gatewayId
+ * The unique identifier of the gateway making the request.
+ *
+ * @param userName
+ * The identifier of the user.
+ *
+ * @param filters
+ * Map of multiple filter criteria. Currenlt search filters includes Project Name and Project Description
+ *
+ * @param limit
+ * The amount results to be fetched.
+ *
+ * @param offset
+ * The starting point of the results to be fetched.
+ *
+ *
*
* @param \Airavata\Model\Security\AuthzToken $authzToken
* @param string $gatewayId
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ae6d78bb/app/libraries/Airavata/Model/Application/Io/Types.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Model/Application/Io/Types.php b/app/libraries/Airavata/Model/Application/Io/Types.php
index b2890c1..fae8964 100644
--- a/app/libraries/Airavata/Model/Application/Io/Types.php
+++ b/app/libraries/Airavata/Model/Application/Io/Types.php
@@ -26,15 +26,17 @@ final class DataType {
const INTEGER = 1;
const FLOAT = 2;
const URI = 3;
- const STDOUT = 4;
- const STDERR = 5;
+ const URI_COLLECTION = 4;
+ const STDOUT = 5;
+ const STDERR = 6;
static public $__names = array(
0 => 'STRING',
1 => 'INTEGER',
2 => 'FLOAT',
3 => 'URI',
- 4 => 'STDOUT',
- 5 => 'STDERR',
+ 4 => 'URI_COLLECTION',
+ 5 => 'STDOUT',
+ 6 => 'STDERR',
);
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ae6d78bb/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 1b7cf1a..fdb191c 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -20,6 +20,7 @@ use Airavata\Model\Data\Replica\DataProductType;
use Airavata\Model\Data\Replica\DataReplicaLocationModel;
use Airavata\Model\Data\Replica\ReplicaLocationCategory;
use Airavata\Model\Data\Replica\ReplicaPersistentType;
+use Airavata\Model\Application\Io\InputDataObjectType;
class ExperimentUtilities
{
@@ -78,22 +79,46 @@ class ExperimentUtilities
$matchingAppInput = null;
if ($input->type == DataType::URI) {
- if(strpos($input->value, "airavata-dp") === 0){
+ if (strpos($input->value, "airavata-dp") === 0) {
$dataProductModel = Airavata::getDataProduct(Session::get('authz-token'), $input->value);
$currentInputPath = "";
foreach ($dataProductModel->replicaLocations as $rp) {
- if($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE){
+ if ($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE) {
$currentInputPath = $rp->filePath;
break;
}
}
$fileName = basename($currentInputPath);
- }else{
+ } else {
$fileName = basename($input->value);
}
echo '<p>' . $input->name . ': <a target="_blank" href="' . URL::to("/") . '/download/?id='
- . $input->value . '">' . $fileName . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+ . $input->value . '">' . $fileName . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+
+ }else if($input->type == DataType::URI_COLLECTION) {
+ $uriList = $input->value;
+ $uriList = preg_split('/,/', $uriList);
+
+ foreach($uriList as $uri){
+ if (strpos($uri, "airavata-dp") === 0) {
+ $dataProductModel = Airavata::getDataProduct(Session::get('authz-token'), $input->value);
+ $currentInputPath = "";
+ foreach ($dataProductModel->replicaLocations as $rp) {
+ if ($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE) {
+ $currentInputPath = $rp->filePath;
+ break;
+ }
+ }
+ $fileName = basename($currentInputPath);
+ } else {
+ $fileName = basename($input->value);
+ }
+
+ echo '<p>' . $input->name . ': <a target="_blank" href="' . URL::to("/") . '/download/?id='
+ . $input->value . '">' . $fileName . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+
+ }
} elseif ($input->type == DataType::STRING || $input->type == DataType::INTEGER
|| $input->type == DataType::FLOAT) {
@@ -405,6 +430,52 @@ class ExperimentUtilities
$newExperimentInputs[] = $experimentInput;
}
+ if($_FILES['optInputFiles']){
+ $uriList = "";
+ foreach($_FILES['optInputFiles'] as $file){
+ $filePath = ExperimentUtilities::$experimentPath . $file['name'];
+
+ // 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_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;
+ }
+
+ $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, -1);
+ $optInput = new InputDataObjectType();
+ $optInput->name = "Optional-File-Input-List";
+ $optInput->type = DataType::URI_COLLECTION;
+ $optInput->value = $uriList;
+ $newExperimentInputs[] = $optInput;
+ }
+
if ($experimentAssemblySuccessful) {
return $newExperimentInputs;
} else {
@@ -444,7 +515,7 @@ class ExperimentUtilities
foreach ($_FILES as $file) {
//var_dump($file);
- if ($file['name']) {
+ if (!is_array($file) and $file['name']) {
if ($file['error'] > 0) {
$uploadSuccessful = false;
CommonUtilities::print_error_message('<p>Error uploading file ' . $file['name'] . ' !
@@ -682,6 +753,12 @@ class ExperimentUtilities
break;
}
}
+
+ echo '<div>
+ <label>Optional Input Files</label>
+ <input type="file" id="optInputFiles" name="optInputFiles[]" multiple onchange="javascript:updateList()" >
+ <div id="optFileList"></div>
+ </div>';
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ae6d78bb/app/views/experiment/create-complete.blade.php
----------------------------------------------------------------------
diff --git a/app/views/experiment/create-complete.blade.php b/app/views/experiment/create-complete.blade.php
index 022661f..0771a71 100644
--- a/app/views/experiment/create-complete.blade.php
+++ b/app/views/experiment/create-complete.blade.php
@@ -152,5 +152,16 @@
readBlob(startByte, endByte, fileId);
});
});
+
+ updateList = function() {
+ var input = document.getElementById('optInputFiles');
+ var output = document.getElementById('optFileList');
+
+ output.innerHTML = '<ul>';
+ for (var i = 0; i < input.files.length; ++i) {
+ output.innerHTML += '<li>' + input.files.item(i).name + '</li>';
+ }
+ output.innerHTML += '</ul>';
+ }
</script>
@stop
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ae6d78bb/app/views/partials/experiment-inputs.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/experiment-inputs.blade.php b/app/views/partials/experiment-inputs.blade.php
index 5e83587..f6e2557 100644
--- a/app/views/partials/experiment-inputs.blade.php
+++ b/app/views/partials/experiment-inputs.blade.php
@@ -28,7 +28,7 @@
<div class="panel panel-default">
<div class="panel-heading">Application configuration</div>
<div class="panel-body">
- <label>Application input</label>
+ <label>Application Inputs</label>
<div class="well">
@if( $expInputs["clonedExp"] || $expInputs["savedExp"])