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/09 17:18:50 UTC
[airavata] branch output-staging-wildcard-fix created (now fc269fd878)
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a change to branch output-staging-wildcard-fix
in repository https://gitbox.apache.org/repos/asf/airavata.git
at fc269fd878 Handling special characters in output staging
This branch includes the following new commits:
new fc269fd878 Handling special characters in output staging
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[airavata] 01/01: Handling special characters in output staging
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch output-staging-wildcard-fix
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit fc269fd87892cdbf867ccc9f7c8e9c1f77e3b56c
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");
}