airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [28/50] [abbrv] airavata-php-gateway git commit: fixing bug
Date Thu, 07 Jul 2016 19:27:32 GMT
fixing bug


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

Branch: refs/heads/master
Commit: 2fd10b0b687c3d37d6232bfb8f582226369616cd
Parents: 6e844a1
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Tue Jun 28 12:48:31 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Tue Jun 28 12:48:31 2016 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 9 +++++++--
 app/routes.php                        | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2fd10b0b/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index d9b64b5..4760181 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -120,7 +120,7 @@ class ExperimentUtilities
 
             if ($input->type == DataType::URI) {
                 $dataRoot = Config::get("pga_config.airavata")["experiment-data-absolute-path"];
-                if(!$dataRoot.endswith("/"))
+                if(!ExperimentUtilities::endsWith($dataRoot, "/"))
                     $dataRoot = $dataRoot . "/";
                 $filePath = str_replace($dataRoot, "", parse_url($input->value, PHP_URL_PATH));
                 echo '<p>' . $input->name . ':&nbsp;<a target="_blank" href="'
. URL::to("/")
@@ -143,7 +143,7 @@ class ExperimentUtilities
         foreach ((array)$outputs as $output) {
             if ($output->type == DataType::URI || $output->type == DataType::STDOUT
|| $output->type == DataType::STDERR) {
                 $dataRoot = Config::get("pga_config.airavata")["experiment-data-absolute-path"];
-                if(!$dataRoot.endswith("/"))
+                if(!ExperimentUtilities::endsWith($dataRoot, "/"))
                     $dataRoot = $dataRoot . "/";
                 $filePath = str_replace($dataRoot, "", parse_url($output->value, PHP_URL_PATH));
                 echo '<p>' . $output->name . ':&nbsp;<a target="_blank" href="'
. URL::to("/")
@@ -157,6 +157,11 @@ class ExperimentUtilities
         }
     }
 
+    private  static function endsWith($haystack, $needle) {
+        // search forward starting from end minus needle length characters
+        return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 &&
strpos($haystack, $needle, $temp) !== false);
+    }
+
     /**
      * Get the experiment with the given ID
      * @param $expId

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/2fd10b0b/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index ba37f40..437f812 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -115,7 +115,7 @@ Route::get("download", function(){
         $id = Input::get("id");
 
         $dataRoot = Config::get("pga_config.airavata")["experiment-data-absolute-path"];
-        if(!$dataRoot.endswith("/"))
+        if(!((($temp = strlen($dataRoot) - strlen("/")) >= 0 && strpos($dataRoot,
"/", $temp) !== false)))
             $dataRoot = $dataRoot . "/";
 
         $dataProductModel = Airavata::getDataProduct(Session::get('authz-token'), $id);


Mime
View raw message