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

refactoring

parent 8f0a34c0
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package cz.it4i.fiji.haas_java_client;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.rmi.RemoteException;
import java.util.Arrays;
......@@ -130,7 +131,7 @@ public class HaaSClient {
for (Path file : files) {
System.out.println("Uploading file: " + file.getFileName());
scpClient.upload(file, fileTransfer.getSharedBasepath() + "//" + file.getFileName());
scpClient.upload(file, fileTransfer.getSharedBasepath() + "/" + file.getFileName());
System.out.println("File uploaded.");
}
}
......@@ -184,12 +185,18 @@ public class HaaSClient {
try (ScpClient scpClient = getScpClient(ft)) {
for (String fileName : getFileTransfer().listChangedFilesForJob(jobId, getSessionID())) {
fileName = fileName.replaceAll("/", "");
fileName = fileName.replaceFirst("/", "");
Path rFile = workDirectory.resolve(fileName);
scpClient.download(ft.getSharedBasepath() + "//" + fileName, rFile);
if(!Files.exists(rFile.getParent())) {
Files.createDirectories(rFile.getParent());
}
String fileToDownload = ft.getSharedBasepath() + "/" + fileName;
scpClient.download(fileToDownload, rFile);
}
}
getFileTransfer().endFileTransfer(jobId, ft, getSessionID());
} catch (IOException | JSchException | ServiceException e) {
throw new HaaSClientException(e);
}
......
......@@ -7,7 +7,6 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
......@@ -18,17 +17,6 @@ import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
public class ScpClient implements Closeable {
public static void main(String[] args) throws JSchException, IOException {
try (ScpClient scpClient = new ScpClient("salomon.it4i.cz", "koz01", "/home/koz01/.ssh/it4i_rsa",
"nejlepsivyzkum")) {
boolean u = scpClient.upload(Paths.get("/home/koz01/aaa/vecmath.jar"), "/home/koz01/");
boolean d = scpClient.download("/home/koz01/proof", Paths.get("/home/koz01/aaa/proof"));
System.out.println(u);
System.out.println(d);
}
}
private String hostName;
private String username;
private JSch jsch = new JSch();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment