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 2022/06/17 18:09:34 UTC
[airavata] branch develop updated: Handling special characters in output staging
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 1a00507107 Handling special characters in output staging
1a00507107 is described below
commit 1a005071079e76063f02b4686ae2d7b7ead06c13
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Thu Jun 9 13:18:38 2022 -0400
Handling special characters in output staging
---
.../helix/impl/task/staging/DataStagingTask.java | 17 ++++++++++++++++-
.../helix/impl/task/staging/OutputDataStagingTask.java | 11 +++++++----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
index 89f2dfff84..d220ca0c57 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
@@ -151,12 +151,27 @@ public abstract class DataStagingTask extends AiravataTask {
return filePath;
}
+ protected String escapeSpecialCharacters(String inputString){
+ final String[] metaCharacters = {"\\","^","$","{","}","[","]","(",")","?","&","%"};
+
+ for (String metaCharacter : metaCharacters) {
+ if (inputString.contains(metaCharacter)) {
+ inputString = inputString.replace(metaCharacter, "\\" + metaCharacter);
+ }
+ }
+ return inputString;
+ }
+
public void naiveTransfer(AgentAdaptor srcAdaptor, String sourceFile, AgentAdaptor destAdaptor, String destFile,
String tempFile) throws TaskOnFailException {
+
+ sourceFile = escapeSpecialCharacters(sourceFile);
+ destFile = escapeSpecialCharacters(destFile);
+
logger.info("Using naive transfer to transfer " + sourceFile + " to " + destFile);
try {
try {
- logger.info("Downloading file " + sourceFile + " to loacl temp file " + tempFile);
+ logger.info("Downloading file " + sourceFile + " to local temp file " + tempFile);
srcAdaptor.downloadFile(sourceFile, tempFile);
} catch (AgentException e) {
throw new TaskOnFailException("Failed downloading file " + sourceFile + " to the local path " +
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
index e9ec4d3d68..ba06618f98 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
@@ -171,9 +171,11 @@ public class OutputDataStagingTask extends DataStagingTask {
}
if (!destinationURIs.isEmpty()) {
if (processOutput.getType() == DataType.URI) {
- saveExperimentOutput(processOutput.getName(), destinationURIs.get(0).toString());
+ saveExperimentOutput(processOutput.getName(), escapeSpecialCharacters(destinationURIs.get(0).toString()));
} else if (processOutput.getType() == DataType.URI_COLLECTION) {
- saveExperimentOutputCollection(processOutput.getName(), destinationURIs.stream().map(URI::toString).collect(Collectors.toList()));
+ saveExperimentOutputCollection(processOutput.getName(), destinationURIs.stream()
+ .map(URI::toString)
+ .map(this::escapeSpecialCharacters).collect(Collectors.toList()));
}
}
return onSuccess("Output data staging task " + getTaskId() + " successfully completed");
@@ -181,9 +183,10 @@ public class OutputDataStagingTask extends DataStagingTask {
} else {
// Uploading output file to the storage resource
assert processOutput != null;
- boolean transferred = transferFileToStorage(sourceURI.getPath(), destinationURI.getPath(), sourceFileName, adaptor, storageResourceAdaptor);
+ boolean transferred = transferFileToStorage(sourceURI.getPath(), destinationURI.getPath(),
+ sourceFileName, adaptor, storageResourceAdaptor);
if (transferred) {
- saveExperimentOutput(processOutput.getName(), destinationURI.toString());
+ saveExperimentOutput(processOutput.getName(), escapeSpecialCharacters(destinationURI.toString()));
} else {
logger.warn("File " + sourceFileName + " did not transfer");
}