This is an automated email from the ASF dual-hosted git repository.
yasith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/master by this push:
new e4cee4e5dd Fix buildDestinationFilePath for different output storage
resources (#578)
e4cee4e5dd is described below
commit e4cee4e5dddec2c2d01149c4a4020634456767ca
Author: Lahiru Jayathilake <[email protected]>
AuthorDate: Fri Nov 21 13:28:50 2025 -0500
Fix buildDestinationFilePath for different output storage resources (#578)
* Making experiment data path relative when the destination and source
storage are different.
* Fix buildDestinationFilePath for different output storage resources
* spotless apply
---
.../helix/impl/task/staging/ArchiveTask.java | 4 +-
.../helix/impl/task/staging/DataStagingTask.java | 49 ++++++++++++++--------
.../impl/task/staging/OutputDataStagingTask.java | 6 +--
3 files changed, 37 insertions(+), 22 deletions(-)
diff --git
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
index 46ed806e6f..ad764b305e 100644
---
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
+++
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
@@ -68,10 +68,10 @@ public class ArchiveTask extends DataStagingTask {
tarDirPath = sourceURI.getPath();
}
- String inputPath = getTaskContext()
+ String outputStorageRoot = getTaskContext()
.getOutputGatewayStorageResourcePreference()
.getFileSystemRootLocation();
- destFilePath = buildDestinationFilePath(inputPath,
archiveFileName);
+ destFilePath = buildDestinationFilePath(outputStorageRoot,
archiveFileName);
tarCreationAbsPath = tarDirPath + File.separator +
archiveFileName;
} catch (URISyntaxException e) {
diff --git
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
index dacc55808a..623cfa0d9c 100644
---
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
+++
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
@@ -197,26 +197,41 @@ public abstract class DataStagingTask extends
AiravataTask {
return localDataPath;
}
- protected String buildDestinationFilePath(String inputPath, String
fileName) {
+ /**
+ * Builds the destination file path for data staging tasks.
+ * The method constructs the path as: targetStorageRoot +
experimentDataDir + fileName
+ * If experimentDataDir is given as an absolute path (starts with '/'),
the leading
+ * separator is stripped to make it relative to targetStorageRoot.
+ * If experimentDataDir is null or empty falls back to processId-based
path.
+ *
+ * @param targetStorageRoot The file system root location of the target
storage resource
+ * @param fileName The name of the file to be staged
+ * @return The complete destination file path
+ */
+ protected String buildDestinationFilePath(String targetStorageRoot, String
fileName) {
+ String targetRoot = targetStorageRoot.trim();
+ if (!targetRoot.endsWith(File.separator)) {
+ targetRoot += File.separator;
+ }
- inputPath = (inputPath.endsWith(File.separator) ? inputPath :
inputPath + File.separator);
String experimentDataDir = getProcessModel().getExperimentDataDir();
- String filePath;
- // TODO : This logic is extremely dangerous. This was implemented
expecting the input and output storage are
- // same.
- if (experimentDataDir != null && !experimentDataDir.isEmpty()) {
- if (!experimentDataDir.endsWith(File.separator)) {
- experimentDataDir += File.separator;
- }
- if (experimentDataDir.startsWith(File.separator)) {
- filePath = experimentDataDir + fileName;
- } else {
- filePath = inputPath + experimentDataDir + fileName;
- }
- } else {
- filePath = inputPath + getProcessId() + File.separator + fileName;
+
+ if (experimentDataDir == null || experimentDataDir.trim().isEmpty()) {
+ return targetRoot + getProcessId() + File.separator + fileName;
+ }
+
+ String normalizedDir = experimentDataDir.trim();
+ if (normalizedDir.startsWith(File.separator)) {
+ normalizedDir = normalizedDir.substring(1);
+ logger.debug(
+ "Stripped the leading separator from experimentDataDir to
make it relative: {}", normalizedDir);
}
- return filePath;
+
+ if (!normalizedDir.endsWith(File.separator)) {
+ normalizedDir += File.separator;
+ }
+
+ return targetRoot + normalizedDir + fileName;
}
protected String escapeSpecialCharacters(String inputString) {
diff --git
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
index 3aab8d3fa6..8a80da1f4b 100644
---
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
+++
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
@@ -92,9 +92,9 @@ public class OutputDataStagingTask extends DataStagingTask {
if (dataStagingTaskModel.getDestination().startsWith("dummy"))
{
StoragePreference outputStoragePref =
getTaskContext().getOutputGatewayStorageResourcePreference();
- String inputPath =
outputStoragePref.getFileSystemRootLocation();
- String destFilePath = buildDestinationFilePath(inputPath,
sourceFileName);
- logger.info("Output storage path for task id " +
getTaskId() + " is " + destFilePath);
+ String outputStorageRoot =
outputStoragePref.getFileSystemRootLocation();
+ String destFilePath =
buildDestinationFilePath(outputStorageRoot, sourceFileName);
+ logger.info("Output storage path for task id {} is {}",
getTaskId(), destFilePath);
destinationURI = new URI(
"file",
outputStoragePref.getLoginUserName(),