Supporting cascading wildcards
diff --git a/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/SSHJAgentAdaptor.java b/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/SSHJAgentAdaptor.java
index 05ce146..8cf0b9d 100644
--- a/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/SSHJAgentAdaptor.java
+++ b/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/SSHJAgentAdaptor.java
@@ -344,12 +344,25 @@
@Override
public List<String> getFileNameFromExtension(String fileName, String parentPath) throws AgentException {
- try (SFTPClient sftpClient = sshjClient.newSFTPClientWrapper()) {
+ /*try (SFTPClient sftpClient = sshjClient.newSFTPClientWrapper()) {
List<RemoteResourceInfo> ls = sftpClient.ls(parentPath, resource -> isMatch(resource.getName(), fileName));
return ls.stream().map(RemoteResourceInfo::getPath).collect(Collectors.toList());
} catch (Exception e) {
throw new AgentException(e);
+ }*/
+ if (fileName.endsWith("*")) {
+ throw new AgentException("Wildcards that ends with * does not support for security reasons. Specify an extension");
}
+
+ CommandOutput commandOutput = executeCommand("ls " + fileName, parentPath); // This has a risk of returning folders also
+ String[] filesTmp = commandOutput.getStdOut().split("\n");
+ List<String> files = new ArrayList<>();
+ for (String f: filesTmp) {
+ if (!f.isEmpty()) {
+ files.add(f);
+ }
+ }
+ return files;
}
@Override
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 af43cef..a5d9d74 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
@@ -137,11 +137,11 @@
logger.warn("Ignoring file transfer as filename is empty or null");
continue;
}
- sourceFileName = new File(subFilePath).getName();
+ sourceFileName = subFilePath;
if (destParentPath.endsWith(File.separator)) {
- destinationURI = new URI(destParentPath + sourceFileName);
+ destinationURI = new URI(destParentPath + subFilePath);
} else {
- destinationURI = new URI(destParentPath + File.separator + sourceFileName);
+ destinationURI = new URI(destParentPath + File.separator + subFilePath);
}
URI newSourceURI = new URI((sourceParentPath.endsWith(File.separator) ?