diff --git a/redaction-service-v1/pom.xml b/redaction-service-v1/pom.xml
index 5b3aaadd..5d5846b2 100644
--- a/redaction-service-v1/pom.xml
+++ b/redaction-service-v1/pom.xml
@@ -32,7 +32,7 @@
com.iqser.red
platform-commons-dependency
- 1.11.0
+ 1.15.0
import
pom
diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/storage/RedactionStorageService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/storage/RedactionStorageService.java
index 4ac59e31..21d4562a 100644
--- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/storage/RedactionStorageService.java
+++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/storage/RedactionStorageService.java
@@ -1,5 +1,6 @@
package com.iqser.red.service.redaction.v1.server.storage;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -41,7 +42,10 @@ public class RedactionStorageService {
@SneakyThrows
public void storeObject(String dossierId, String fileId, FileType fileType, Object any) {
- storageService.storeObject(StorageIdUtils.getStorageId(dossierId, fileId, fileType), objectMapper.writeValueAsBytes(any));
+ try (var baos = new ByteArrayOutputStream()){
+ objectMapper.writeValue(baos, any);
+ storageService.storeObject(StorageIdUtils.getStorageId(dossierId, fileId, fileType), baos);
+ }
}
diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/java/com/iqser/red/service/redaction/v1/server/FileSystemBackedStorageService.java b/redaction-service-v1/redaction-service-server-v1/src/test/java/com/iqser/red/service/redaction/v1/server/FileSystemBackedStorageService.java
index 2bea7b75..c08a9a11 100644
--- a/redaction-service-v1/redaction-service-server-v1/src/test/java/com/iqser/red/service/redaction/v1/server/FileSystemBackedStorageService.java
+++ b/redaction-service-v1/redaction-service-server-v1/src/test/java/com/iqser/red/service/redaction/v1/server/FileSystemBackedStorageService.java
@@ -7,18 +7,20 @@ import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.InputStreamResource;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.util.HashMap;
-import java.util.Map;
+import java.io.InputStream;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.zip.GZIPOutputStream;
-public class FileSystemBackedStorageService extends S3StorageService {
+public class FileSystemBackedStorageService implements StorageService{
private final Map dataMap = new HashMap<>();
public FileSystemBackedStorageService() {
- super(null, null);
}
@SneakyThrows
@@ -33,20 +35,73 @@ public class FileSystemBackedStorageService extends S3StorageService {
}
+ @Override
+ public void deleteObject(String objectId) {
+ dataMap.remove(objectId);
+ }
+
+ @Override
+ public boolean objectExists(String objectId) {
+ return dataMap.containsKey(objectId);
+ }
+
+ @Override
+ public void init() {
+
+ }
+
+ public List listPaths(){
+ return new ArrayList<>(dataMap.keySet());
+ }
+
+
+ public List listFilePaths(){
+ return dataMap.values().stream().map(File::getAbsolutePath).collect(Collectors.toList());
+ }
+
+
@SneakyThrows
@Override
public void storeObject(String objectId, byte[] data) {
- File tempFile = File.createTempFile("test", ".tmp");
+ File tempFile = File.createTempFile("storage", objectId.replace("/","-"));
- IOUtils.write(data, new FileOutputStream(tempFile));
+ try(var fileOutputStream = new FileOutputStream(tempFile)) {
+ IOUtils.write(data, fileOutputStream);
+ }
dataMap.put(objectId, tempFile);
}
+ @Override
+ @SneakyThrows
+ public void storeObject(String objectId, InputStream stream) {
+ File tempFile = File.createTempFile("test", ".tmp");
+
+ try(var fileOutputStream = new FileOutputStream(tempFile)) {
+ IOUtils.copy(stream, fileOutputStream);
+ }
+
+ dataMap.put(objectId, tempFile);
+ }
+
+
+ @Override
+ @SneakyThrows
+ public void storeObject(String objectId, ByteArrayOutputStream stream) {
+
+ File tempFile = File.createTempFile("test", ".tmp");
+ try(var fileOutputStream = new FileOutputStream(tempFile)){
+ stream.writeTo(fileOutputStream);
+ }
+
+ dataMap.put(objectId, tempFile);
+ }
+
+
public void clearStorage() {
this.dataMap.forEach((k, v) -> {
v.delete();
});
this.dataMap.clear();
}
-}
+}
\ No newline at end of file