Skip to content
Snippets Groups Projects
Commit 0687d174 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

fix upload

parent 03999653
No related branches found
No related tags found
No related merge requests found
...@@ -131,8 +131,12 @@ public class HaaSClient { ...@@ -131,8 +131,12 @@ public class HaaSClient {
for (Path file : files) { for (Path file : files) {
System.out.println("Uploading file: " + file.getFileName()); System.out.println("Uploading file: " + file.getFileName());
scpClient.upload(file, fileTransfer.getSharedBasepath() + "/" + file.getFileName()); String destFile = fileTransfer.getSharedBasepath() + "/" ;
System.out.println("File uploaded."); boolean result = scpClient.upload(file, destFile);
System.out.println(result?"File uploaded.":"File not uploaded");
if(!result) {
throw new HaaSClientException("Uploading of " + file + " to " + destFile + " failed");
}
} }
} }
getFileTransfer().endFileTransfer(job.getId(), fileTransfer, getSessionID()); getFileTransfer().endFileTransfer(job.getId(), fileTransfer, getSessionID());
......
...@@ -4,6 +4,7 @@ import java.io.IOException; ...@@ -4,6 +4,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Collections;
import javax.xml.rpc.ServiceException; import javax.xml.rpc.ServiceException;
...@@ -16,8 +17,8 @@ public class TestHaaSJavaClientWithSPIM { ...@@ -16,8 +17,8 @@ public class TestHaaSJavaClientWithSPIM {
HaaSClient client = new HaaSClient(2l, 9600, 6l, "DD-17-31"); HaaSClient client = new HaaSClient(2l, 9600, 6l, "DD-17-31");
Path baseDir = Paths.get("/home/koz01/Work/vyzkumnik/fiji/work/aaa"); Path baseDir = Paths.get("/home/koz01/Work/vyzkumnik/fiji/work/aaa");
long jobId = 36;// client.start(Collections.emptyList(), "TestOutRedirect", long jobId = client.start(getAllFiles(baseDir.resolve("spim-data")), "TestOutRedirect",
// Collections.emptyList()); Collections.emptyList());
Path workDir = baseDir.resolve("" + jobId); Path workDir = baseDir.resolve("" + jobId);
if (!Files.isDirectory(workDir)) { if (!Files.isDirectory(workDir)) {
Files.createDirectories(workDir); Files.createDirectories(workDir);
...@@ -47,6 +48,17 @@ public class TestHaaSJavaClientWithSPIM { ...@@ -47,6 +48,17 @@ public class TestHaaSJavaClientWithSPIM {
&& info.getState() != JobState.Finished); && info.getState() != JobState.Finished);
} }
private static Iterable<Path> getAllFiles(Path resolve) {
return () -> {
try {
return Files.newDirectoryStream(resolve).iterator();
} catch (IOException e) {
throw new RuntimeException(e);
}
};
}
private static void addOffsetFilesForTask(Long taskId, SynchronizableFiles files) { private static void addOffsetFilesForTask(Long taskId, SynchronizableFiles files) {
files.addFile(taskId, SynchronizableFileType.ProgressFile, 0); files.addFile(taskId, SynchronizableFileType.ProgressFile, 0);
files.addFile(taskId, SynchronizableFileType.StandardErrorFile, 0); files.addFile(taskId, SynchronizableFileType.StandardErrorFile, 0);
......
...@@ -34,7 +34,9 @@ public class ScpClient implements Closeable { ...@@ -34,7 +34,9 @@ public class ScpClient implements Closeable {
public ScpClient(String hostName, String userName, String keyFile, String pass) throws JSchException { public ScpClient(String hostName, String userName, String keyFile, String pass) throws JSchException {
Identity id = IdentityFile.newInstance(keyFile, null, jsch); Identity id = IdentityFile.newInstance(keyFile, null, jsch);
try { try {
id.setPassphrase(pass.getBytes("UTF-8")); if(pass != null) {
id.setPassphrase(pass.getBytes("UTF-8"));
}
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment