You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2020/10/13 22:23:48 UTC

[airavata] branch develop updated: Replacing special characters when creating stdout and stderr files

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/develop by this push:
     new a31babb  Replacing special characters when creating stdout and stderr files
a31babb is described below

commit a31babb27080cef0c7a47ec0082d592d1c058e23
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue Oct 13 18:23:33 2020 -0400

    Replacing special characters when creating stdout and stderr files
---
 .../main/java/org/apache/airavata/helix/impl/task/TaskContext.java   | 5 +++--
 .../src/main/java/org/apache/airavata/helix/core/util/TaskUtil.java  | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
index 7e32c00..b506d46 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
@@ -21,6 +21,7 @@ package org.apache.airavata.helix.impl.task;
 
 import org.apache.airavata.common.utils.AiravataUtils;
 import org.apache.airavata.common.utils.ThriftUtils;
+import org.apache.airavata.helix.core.util.TaskUtil;
 import org.apache.airavata.messaging.core.Publisher;
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
 import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
@@ -847,7 +848,7 @@ public class TaskContext {
                     if (outputDataObjectType.getType().equals(DataType.STDOUT)) {
                         if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                             String stdOut = (ctx.getWorkingDir().endsWith(File.separator) ? ctx.getWorkingDir() : ctx.getWorkingDir() + File.separator)
-                                    + ctx.getApplicationInterfaceDescription().getApplicationName() + ".stdout";
+                                    + TaskUtil.replaceSpecialCharacters(ctx.getApplicationInterfaceDescription().getApplicationName(), "_") + ".stdout";
                             outputDataObjectType.setValue(stdOut);
                             ctx.setStdoutLocation(stdOut);
                         } else {
@@ -857,7 +858,7 @@ public class TaskContext {
                     if (outputDataObjectType.getType().equals(DataType.STDERR)) {
                         if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                             String stderrLocation = (ctx.getWorkingDir().endsWith(File.separator) ? ctx.getWorkingDir() : ctx.getWorkingDir() + File.separator)
-                                    + ctx.getApplicationInterfaceDescription().getApplicationName() + ".stderr";
+                                    + TaskUtil.replaceSpecialCharacters(ctx.getApplicationInterfaceDescription().getApplicationName(), "_") + ".stderr";
                             outputDataObjectType.setValue(stderrLocation);
                             ctx.setStderrLocation(stderrLocation);
                         } else {
diff --git a/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/util/TaskUtil.java b/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/util/TaskUtil.java
index 539a75d..5de46a7 100644
--- a/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/util/TaskUtil.java
+++ b/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/util/TaskUtil.java
@@ -139,4 +139,8 @@ public class TaskUtil {
             }
         }
     }
+
+    public static String replaceSpecialCharacters(String originalTxt, String replaceTxt) {
+        return originalTxt.replaceAll("[^a-zA-Z0-9_-]", replaceTxt);
+    }
 }