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/30 23:26:43 UTC

airavata-php-gateway git commit: checking input is of type uri

Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop e410f776e -> 770cf3059


checking input is of type uri


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

Branch: refs/heads/develop
Commit: 770cf3059d3d40c466b8b1bc99466ad8ad739a99
Parents: e410f77
Author: scnakandala <su...@gmail.com>
Authored: Wed Mar 30 17:26:39 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Wed Mar 30 17:26:39 2016 -0400

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


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/770cf305/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index ae5a94e..359f8ff 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -77,19 +77,24 @@ class ExperimentUtilities
             $matchingAppInput = null;
 
             if ($input->type == DataType::URI) {
-                $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;
-                    }
-                }
                 $dataRoot = Config::get("pga_config.airavata")["experiment-data-absolute-path"];
                 if(!ExperimentUtilities::endsWith($dataRoot, "/"))
                     $dataRoot = $dataRoot . "/";
-                $filePath = str_replace($dataRoot, "", parse_url($currentInputPath, PHP_URL_PATH));
-                echo '<p>' . $input->name . ':&nbsp;<a target="_blank" href="' . URL::to("/") . '/download/?path=' . $filePath . '">' . basename($filePath) . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+                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){
+                            $currentInputPath = $rp->filePath;
+                            break;
+                        }
+                    }
+                    $filePath = str_replace($dataRoot, "", parse_url($currentInputPath, PHP_URL_PATH));
+                }else{
+                    $filePath = str_replace($dataRoot, "", parse_url($input->value, PHP_URL_PATH));
+                }
+                echo '<p>' . $input->name . ':&nbsp;<a target="_blank" href="' . URL::to("/") . '/download/?path='
+                    . $filePath . '">' . basename($filePath) . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
             } elseif ($input->type == DataType::STRING || $input->type == DataType::INTEGER
                 || $input->type == DataType::FLOAT) {
                 echo '<p>' . $input->name . ':&nbsp;' . $input->value . '</p>';
@@ -726,19 +731,26 @@ class ExperimentUtilities
         foreach ((array)$outputs as $output) {
             if ($output->type == DataType::URI || $output->type == DataType::STDOUT || $output->type == DataType::STDERR) {
                 if(!empty($output->value) && filter_var($output->value, FILTER_VALIDATE_URL)){
-                    $dataProductModel = Airavata::getDataProduct(Session::get('authz-token'), $output->value);
-                    $currentInputPath = "";
-                    foreach ($dataProductModel->replicaLocations as $rp) {
-                        if ($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE) {
-                            $currentInputPath = $rp->filePath;
-                            break;
-                        }
-                    }
                     $dataRoot = Config::get("pga_config.airavata")["experiment-data-absolute-path"];
-                    if (!ExperimentUtilities::endsWith($dataRoot, "/"))
+                    if(!ExperimentUtilities::endsWith($dataRoot, "/"))
                         $dataRoot = $dataRoot . "/";
-                    $filePath = str_replace($dataRoot, "", parse_url($currentInputPath, PHP_URL_PATH));
-                    echo '<p><a target="_blank" href="' . URL::to("/") . '/download/?path=' . urlencode($filePath) . '">' . basename($filePath) . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+                    if(strpos($output->value, "airavata-dp") == 0){
+                        $dataProductModel = Airavata::getDataProduct(Session::get('authz-token'), $output->value);
+                        $currentOutputPath = "";
+                        foreach ($dataProductModel->replicaLocations as $rp) {
+                            if($rp->replicaLocationCategory == ReplicaLocationCategory::GATEWAY_DATA_STORE){
+                                $currentOutputPath = $rp->filePath;
+                                break;
+                            }
+                        }
+                        $filePath = str_replace($dataRoot, "", parse_url($currentOutputPath, PHP_URL_PATH));
+                    }else{
+                        $filePath = str_replace($dataRoot, "", parse_url($output->value, PHP_URL_PATH));
+                    }
+                    echo '<p>' . $output->name . ':&nbsp;<a target="_blank" href="' . URL::to("/")
+                        . '/download/?path=' . urlencode($filePath) . '">' . basename($filePath)
+                        . ' <span class="glyphicon glyphicon-new-window"></span></a></p>';
+
                 }
             } elseif ($output->type == DataType::STRING) {
                 echo '<p>' . $output->value . '</p>';