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

feat: some changes

parent f1b7b6f3
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ import java.nio.file.DirectoryStream; ...@@ -5,7 +5,6 @@ import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
...@@ -23,10 +22,6 @@ public class Synchronization { ...@@ -23,10 +22,6 @@ public class Synchronization {
private Supplier<HaaSFileTransfer> fileTransferSupplier; private Supplier<HaaSFileTransfer> fileTransferSupplier;
private Supplier<Iterable<String>> changedFilesSupplier;
private Map<String,String> propertiesHolder;
private Path workingDirectory; private Path workingDirectory;
private Queue<Path> toUpload = new LinkedBlockingQueue<>(); private Queue<Path> toUpload = new LinkedBlockingQueue<>();
...@@ -78,7 +73,7 @@ public class Synchronization { ...@@ -78,7 +73,7 @@ public class Synchronization {
} }
private UploadingFile createUploadingFile(Path p) { private UploadingFile createUploadingFile(Path p) {
// TODO Auto-generated method stub
return null; return null;
} }
} }
package cz.it4i.fiji.haas.data_transfer;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import cz.it4i.fiji.haas_java_client.HaaSClient.UploadingFile;
public class UploadingFileImpl implements UploadingFile{
private final Path path;
public UploadingFileImpl(Path path) {
this.path = path;
}
@Override
public InputStream getInputStream() throws IOException {
return Files.newInputStream(path);
}
@Override
public String getName() {
return path.getFileName().toString();
}
@Override
public long getLength() throws IOException {
return Files.size(path);
}
@Override
public long getLastTime() {
// TODO Auto-generated method stub
return 0;
}
}
...@@ -103,11 +103,11 @@ public class HaaSClient { ...@@ -103,11 +103,11 @@ public class HaaSClient {
} }
public interface UploadingFile { public interface UploadingFile {
InputStream getInputStream(); InputStream getInputStream() throws IOException;
String getName(); String getName();
long getLength(); long getLength() throws IOException;
long getLastTime(); long getLastTime();
} }
......
...@@ -41,8 +41,13 @@ class HaaSFileTransferImp implements HaaSFileTransfer { ...@@ -41,8 +41,13 @@ class HaaSFileTransferImp implements HaaSFileTransfer {
@Override @Override
public void upload(Iterable<UploadingFile> files) { public void upload(Iterable<UploadingFile> files) {
List<Long> totalSizes = StreamSupport.stream(files.spliterator(), false).map(f -> f.getLength()) List<Long> totalSizes = StreamSupport.stream(files.spliterator(), false).map(f -> {
.collect(Collectors.toList()); try {
return f.getLength();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}).collect(Collectors.toList());
long totalSize = totalSizes.stream().mapToLong(l -> l.longValue()).sum(); long totalSize = totalSizes.stream().mapToLong(l -> l.longValue()).sum();
TransferFileProgressForHaaSClient progress = new TransferFileProgressForHaaSClient(totalSize, notifier); TransferFileProgressForHaaSClient progress = new TransferFileProgressForHaaSClient(totalSize, notifier);
int index = 0; int index = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment