Repository: airavata
Updated Branches:
  refs/heads/airavata-0.15-release-branch 567657b85 -> c3039e136


avoid modifying output param if the value has a url pattern

Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c3039e13
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c3039e13
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c3039e13

Branch: refs/heads/airavata-0.15-release-branch
Commit: c3039e136d9f2d24f67be5c3a19883d3588d1f1b
Parents: 567657b
Author: msmemon <[email protected]>
Authored: Tue Jul 14 20:15:17 2015 +0200
Committer: msmemon <[email protected]>
Committed: Tue Jul 14 20:15:17 2015 +0200

----------------------------------------------------------------------
 .../airavata/gfac/core/cpi/BetterGfacImpl.java  | 35 ++++++++++++++------
 1 file changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c3039e13/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
index d6f68be..8d30bb5 100644
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
+++ 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
@@ -71,12 +71,16 @@ import org.xml.sax.SAXException;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPathExpressionException;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * This is the GFac CPI class for external usage, this simply have a single 
method to submit a job to
@@ -367,18 +371,21 @@ public class BetterGfacImpl implements GFac {
         for (OutputDataObjectType objectType : taskOutputs) {
             if (objectType.getType() == DataType.URI && objectType.getValue() 
!= null) {
                 String filePath = objectType.getValue();
+                boolean isUrl = isURL(filePath);
+ 
                 // if output is not in working folder
-                if (objectType.getLocation() != null && 
!objectType.getLocation().isEmpty()) {
-                    if (objectType.getLocation().startsWith(File.separator)) {
-                        filePath = objectType.getLocation() + File.separator + 
filePath;
-                    } else {
-                        filePath = jobExecutionContext.getOutputDir() + 
File.separator + objectType.getLocation() + File.separator + filePath;
-                    }
-                } else {
-                    filePath = jobExecutionContext.getOutputDir() + 
File.separator + filePath;
+                if(!isUrl) {
+                       if (objectType.getLocation() != null && 
!objectType.getLocation().isEmpty()) {
+                           if 
(objectType.getLocation().startsWith(File.separator)) {
+                               filePath = objectType.getLocation() + 
File.separator + filePath;
+                           } else {
+                               filePath = jobExecutionContext.getOutputDir() + 
File.separator + objectType.getLocation() + File.separator + filePath;
+                           }
+                       } else {
+                           filePath = jobExecutionContext.getOutputDir() + 
File.separator + filePath;
+                       }
+                       objectType.setValue(filePath);
                 }
-                objectType.setValue(filePath);
-
             }
             if (objectType.getType() == DataType.STDOUT) {
                        String stdout = objectType.getValue();
@@ -409,6 +416,14 @@ public class BetterGfacImpl implements GFac {
         return jobExecutionContext;
     }
 
+    private boolean isURL(String path) {
+           String pattern =  
"^(https?|ftp|file|gsiftp|rns)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
+           Pattern p = Pattern.compile(pattern);
+               Matcher m = p.matcher(path);
+               return m.matches();
+    }
+
+    
     private void setUpWorkingLocation(JobExecutionContext jobExecutionContext, 
ApplicationInterfaceDescription applicationInterface, String scratchLocation) {
         /**
          * Scratch location

Reply via email to