DSL-Json test

This commit is contained in:
deiflaender 2022-05-11 09:42:57 +02:00
parent d2807e0ff1
commit cc2d02162d

View File

@ -42,6 +42,7 @@ public class RedactionStorageService {
@SneakyThrows
public void storeObject(String dossierId, String fileId, FileType fileType, Object any) {
var baos = new ByteArrayOutputStream();
dslJson.newWriter();
dslJson.serialize(any, baos);
storageService.storeObject(StorageIdUtils.getStorageId(dossierId, fileId, fileType), baos.toByteArray());
}
@ -64,6 +65,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(ImportedRedactions.class, inputStreamResource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Could not imported redactions", e);
@ -82,6 +84,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(RedactionLog.class, inputStreamResource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Could not convert RedactionLog", e);
@ -100,6 +103,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(Text.class, inputStreamResource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Could not convert Text", e);
@ -117,6 +121,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(NerEntities.class, inputStreamResource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Could not convert NER Entities", e);
@ -128,6 +133,7 @@ public class RedactionStorageService {
try {
var sectionGrid = storageService.getObject(StorageIdUtils.getStorageId(dossierId, fileId, FileType.SECTION_GRID));
dslJson.newReader();
return dslJson.deserialize(SectionGrid.class, sectionGrid.getInputStream());
} catch (StorageObjectDoesNotExist e) {
throw new NotFoundException("Section Grid is not available.");